diff --git a/sw/tools/airframe_editor/airframe_editor.py b/sw/tools/airframe_editor/airframe_editor.py
index 074c6e3f12c..8f0098393d7 100755
--- a/sw/tools/airframe_editor/airframe_editor.py
+++ b/sw/tools/airframe_editor/airframe_editor.py
@@ -9,8 +9,12 @@
from os import path, getenv
from lxml import etree
+#lxml.require('1.3.4')
import gui_dialogs
+import airframe_xml
+import paparazzi
+
# if PAPARAZZI_HOME not set, then assume the tree containing this
# file is a reasonable substitute
@@ -36,28 +40,25 @@ def load_airframe_xml(self):
except (IOError, etree.XMLSyntaxError, etree.XMLSyntaxError) as e:
gui_dialogs.error_loading_xml(e.__str__())
raise e
-
- def organize_airframe_xml(self):
- self.airframe = etree.XML(" ")
- child2 = etree.SubElement(self.airframe, "firmwares")
- child2 = etree.SubElement(self.airframe, "modules")
- child2 = etree.SubElement(self.airframe, "gains")
- print(etree.tostring(self.airframe))
+ def update_combo(self,list):
+ self.combo.get_model().clear()
+ for i in list:
+ self.combo.append_text(i)
+ self.combo.set_active(0)
+
def find_firmwares(self, widget):
- list_of_firmwares = glob.glob( path.join( paparazzi_firmwares, "*.makefile") )
- list_of_firmwares.sort()
- self.combo.get_model().clear();
- for firm in list_of_firmwares:
- self.combo.append_text( firm.replace(".makefile","").replace(paparazzi_firmwares, "") )
-
+ list_of_firmwares = paparazzi.get_list_of_firmwares()
+ self.update_combo(list_of_firmwares)
+
def find_modules(self, widget):
- list_of_modules = glob.glob( paparazzi_modules + "*.xml" )
- list_of_modules.sort();
- self.combo.get_model().clear();
- for mod in list_of_modules:
- self.combo.append_text( mod.replace(".xml","").replace(paparazzi_modules, "") )
+ list_of_modules = paparazzi.get_list_of_firmwares()
+ self.update_combo(list_of_modules)
+
+ def find_subsystems(self, widget):
+ list_of_subsystems = paparazzi.get_list_of_subsystems(self.combo.get_active_text())
+ self.update_combo(list_of_subsystems)
def find_module_defines(self, widget):
try:
@@ -204,11 +205,14 @@ def __init__(self):
self.btnFirmwares = gtk.Button("Firmwares")
self.btnFirmwares.connect("clicked", self.find_firmwares)
+ self.btnSubSystem = gtk.Button("SubSystems")
+ self.btnSubSystem.connect("clicked", self.find_subsystems)
+
self.btnModules = gtk.Button("Modules")
self.btnModules.connect("clicked", self.find_modules)
- self.btnModuleDefines = gtk.Button("Define")
- self.btnModuleDefines.connect("clicked", self.find_module_defines)
+ self.btnModuleDefines = gtk.Button("Define")
+ self.btnModuleDefines.connect("clicked", self.find_module_defines)
self.btnAbout = gtk.Button("About")
self.btnAbout.connect("clicked", self.about)
@@ -216,6 +220,7 @@ def __init__(self):
self.toolbar = gtk.HBox()
self.toolbar.pack_start(self.btnRun)
self.toolbar.pack_start(self.btnFirmwares)
+ self.toolbar.pack_start(self.btnSubSystem)
self.toolbar.pack_start(self.btnModules)
self.toolbar.pack_start(self.btnModuleDefines)
self.toolbar.pack_start(self.btnAbout)
@@ -241,6 +246,7 @@ def __init__(self):
self.combo = gtk.combo_box_entry_new_text()
self.combo.append_text("Entry 1")
self.combo.connect("changed", self.combo_changed)
+ self.toolbar.pack_start(self.combo)
self.label1 = gtk.Label("")
@@ -249,7 +255,6 @@ def __init__(self):
self.box1.pack_start(self.label1)
self.box1.pack_start(self.textbox)
- self.box1.pack_start(self.combo)
self.window.add(self.box1)
self.window.show_all()
diff --git a/sw/tools/airframe_editor/airframe_xml.py b/sw/tools/airframe_editor/airframe_xml.py
new file mode 100755
index 00000000000..58cda0f93ba
--- /dev/null
+++ b/sw/tools/airframe_editor/airframe_xml.py
@@ -0,0 +1,37 @@
+#!/usr/bin/env python
+from __future__ import print_function
+
+from optparse import OptionParser
+#import xml.etree.ElementTree as ET
+import lxml.etree as ET
+#print(lxml.etree.LXML_VERSION)
+
+
+import os
+import sys
+import glob
+import re
+
+import paparazzi
+
+def organize_airframe_xml():
+ airframe = ET.fromstring(" ")
+ airframe.append(ET.Comment("+-+-+-+-+-+-+- FIRMWARES -+-+-+-+-+-+-+"))
+ child2 = ET.SubElement(airframe, "firmware")
+ #airframe.append(airframe_xml.getroot().find("firmware"))
+ airframe.append(ET.Comment("+-+-+-+-+-+-+- MODULES -+-+-+-+-+-+-+"))
+ child3 = ET.SubElement(airframe, "modules")
+ airframe.append(ET.Comment("+-+-+-+-+-+-+- ACTUATORS -+-+-+-+-+-+-+"))
+ airframe.append(ET.Comment("+-+-+-+-+-+-+- GAINS -+-+-+-+-+-+-+"))
+ child4 = ET.SubElement(airframe, "gains")
+ airframe.append(ET.Comment("+-+-+-+-+-+-+- MISC -+-+-+-+-+-+-+"))
+ print(ET.tostring(airframe, encoding=None, method="xml", pretty_print=True, with_tail=True,
+standalone=None))
+ ET.ElementTree(airframe).write('test.xml', pretty_print=True)
+
+
+if __name__ == '__main__':
+ print(paparazzi.home_dir)
+ organize_airframe_xml()
+
+ print("test")
diff --git a/sw/tools/airframe_editor/paparazzi.py b/sw/tools/airframe_editor/paparazzi.py
index 38a54755a20..efc92a88a89 100755
--- a/sw/tools/airframe_editor/paparazzi.py
+++ b/sw/tools/airframe_editor/paparazzi.py
@@ -5,15 +5,34 @@
import glob
from os import path, getenv
-# if PAPARAZZI_HOME not set, then assume the tree containing this
+# if home_dir not set, then assume the tree containing this
# file is a reasonable substitute
-paparazzi_home = getenv("PAPARAZZI_HOME", path.normpath(path.join(
+home_dir = getenv("home_dir", path.normpath(path.join(
path.dirname(path.abspath(__file__)),
'../../../')))
# Directories
-paparazzi_firmwares = path.join(paparazzi_home, "conf/firmwares/")
-paparazzi_modules = path.join(paparazzi_home, "conf/modules/")
-paparazzi_airframes = path.join(paparazzi_home, "conf/airframes/")
+firmwares_dir = path.join(home_dir, "conf/firmwares/")
+modules_dir = path.join(home_dir, "conf/modules/")
+airframes_dir = path.join(home_dir, "conf/airframes/")
+
+def get_list_of_files(directory, extension):
+ mylist = glob.glob( path.join( directory, "*" + extension) )
+ mylist.sort()
+ ret = []
+ for it in mylist:
+ ret.append( it.replace(directory,"").replace(extension, "") )
+ return ret
+
+
+def get_list_of_modules():
+ return get_list_of_files( modules_dir, ".xml" )
+
+def get_list_of_firmwares():
+ return get_list_of_files( firmwares_dir, ".makefile" )
+
+def get_list_of_subsystems(firmware):
+ subsys_dir = path.join( firmwares_dir, "subsystems/" + firmware + "/" )
+ return get_list_of_files( subsys_dir, ".makefile" )