Tools/px4airframes: refactor & remove some unneeded code

This commit is contained in:
Beat Küng 2017-04-11 10:40:14 +02:00
parent 59ea964ea2
commit 62c1a23ea3
3 changed files with 61 additions and 61 deletions

View File

@ -22,6 +22,64 @@ class ParameterGroup(object):
"""
return self.name
def GetImageName(self):
"""
Get parameter group image base name (w/o extension)
"""
if (self.name == "Standard Plane"):
return "Plane"
elif (self.name == "Flying Wing"):
return "FlyingWing"
elif (self.name == "Quadrotor x"):
return "QuadRotorX"
elif (self.name == "Quadrotor +"):
return "QuadRotorPlus"
elif (self.name == "Hexarotor x"):
return "HexaRotorX"
elif (self.name == "Hexarotor +"):
return "HexaRotorPlus"
elif (self.name == "Octorotor +"):
return "OctoRotorPlus"
elif (self.name == "Octorotor x"):
return "OctoRotorX"
elif (self.name == "Octorotor Coaxial"):
return "OctoRotorXCoaxial"
elif (self.name == "Octo Coax Wide"):
return "OctoRotorXCoaxial"
elif (self.name == "Quadrotor Wide"):
return "QuadRotorWide"
elif (self.name == "Quadrotor H"):
return "QuadRotorH"
elif (self.name == "Simulation"):
return "AirframeSimulation"
elif (self.name == "Plane A-Tail"):
return "PlaneATail"
elif (self.name == "VTOL Duo Tailsitter"):
return "VTOLDuoRotorTailSitter"
elif (self.name == "Standard VTOL"):
return "VTOLPlane"
elif (self.name == "VTOL Quad Tailsitter"):
return "VTOLQuadRotorTailSitter"
elif (self.name == "VTOL Tiltrotor"):
return "VTOLTiltRotor"
elif (self.name == "Coaxial Helicopter"):
return "HelicopterCoaxial"
elif (self.name == "Helicopter"):
return "Helicopter"
elif (self.name == "Hexarotor Coaxial"):
return "Y6A"
elif (self.name == "Y6B"):
return "Y6B"
elif (self.name == "Tricopter Y-"):
return "YMinus"
elif (self.name == "Tricopter Y+"):
return "YPlus"
elif (self.name == "Rover"):
return "Rover"
elif (self.name == "Boat"):
return "Boat"
return "AirframeUnknown"
def GetParams(self):
"""
Returns the parsed list of parameters. Every parameter is a Parameter

View File

@ -26,65 +26,10 @@ class XMLOutput():
xml_version.text = "1"
xml_version = ET.SubElement(xml_parameters, "airframe_version_minor")
xml_version.text = "1"
last_param_name = ""
board_specific_param_set = False
for group in groups:
xml_group = ET.SubElement(xml_parameters, "airframe_group")
xml_group.attrib["name"] = group.GetName()
if (group.GetName() == "Standard Plane"):
xml_group.attrib["image"] = "Plane"
elif (group.GetName() == "Flying Wing"):
xml_group.attrib["image"] = "FlyingWing"
elif (group.GetName() == "Quadrotor x"):
xml_group.attrib["image"] = "QuadRotorX"
elif (group.GetName() == "Quadrotor +"):
xml_group.attrib["image"] = "QuadRotorPlus"
elif (group.GetName() == "Hexarotor x"):
xml_group.attrib["image"] = "HexaRotorX"
elif (group.GetName() == "Hexarotor +"):
xml_group.attrib["image"] = "HexaRotorPlus"
elif (group.GetName() == "Octorotor +"):
xml_group.attrib["image"] = "OctoRotorPlus"
elif (group.GetName() == "Octorotor x"):
xml_group.attrib["image"] = "OctoRotorX"
elif (group.GetName() == "Octorotor Coaxial"):
xml_group.attrib["image"] = "OctoRotorXCoaxial"
elif (group.GetName() == "Octo Coax Wide"):
xml_group.attrib["image"] = "OctoRotorXCoaxial"
elif (group.GetName() == "Quadrotor Wide"):
xml_group.attrib["image"] = "QuadRotorWide"
elif (group.GetName() == "Quadrotor H"):
xml_group.attrib["image"] = "QuadRotorH"
elif (group.GetName() == "Simulation"):
xml_group.attrib["image"] = "AirframeSimulation"
elif (group.GetName() == "Plane A-Tail"):
xml_group.attrib["image"] = "PlaneATail"
elif (group.GetName() == "VTOL Duo Tailsitter"):
xml_group.attrib["image"] = "VTOLDuoRotorTailSitter"
elif (group.GetName() == "Standard VTOL"):
xml_group.attrib["image"] = "VTOLPlane"
elif (group.GetName() == "VTOL Quad Tailsitter"):
xml_group.attrib["image"] = "VTOLQuadRotorTailSitter"
elif (group.GetName() == "VTOL Tiltrotor"):
xml_group.attrib["image"] = "VTOLTiltRotor"
elif (group.GetName() == "Coaxial Helicopter"):
xml_group.attrib["image"] = "HelicopterCoaxial"
elif (group.GetName() == "Helicopter"):
xml_group.attrib["image"] = "Helicopter"
elif (group.GetName() == "Hexarotor Coaxial"):
xml_group.attrib["image"] = "Y6A"
elif (group.GetName() == "Y6B"):
xml_group.attrib["image"] = "Y6B"
elif (group.GetName() == "Tricopter Y-"):
xml_group.attrib["image"] = "YMinus"
elif (group.GetName() == "Tricopter Y+"):
xml_group.attrib["image"] = "YPlus"
elif (group.GetName() == "Rover"):
xml_group.attrib["image"] = "Rover"
elif (group.GetName() == "Boat"):
xml_group.attrib["image"] = "Boat"
else:
xml_group.attrib["image"] = "AirframeUnknown"
xml_group.attrib["image"] = group.GetImageName()
for param in group.GetParams():
# check if there is an exclude tag for this airframe
@ -93,13 +38,12 @@ class XMLOutput():
if "CONFIG_ARCH_BOARD_{0}".format(code) == board and param.GetArchValue(code) == "exclude":
excluded = True
if not excluded and ((last_param_name == param.GetName() and not board_specific_param_set) or last_param_name != param.GetName()):
if not excluded:
#print("generating: {0} {1}".format(param.GetName(), excluded))
xml_param = ET.SubElement(xml_group, "airframe")
xml_param.attrib["name"] = param.GetName()
xml_param.attrib["id"] = param.GetId()
xml_param.attrib["maintainer"] = param.GetMaintainer()
last_param_name = param.GetName()
for code in param.GetFieldCodes():
value = param.GetFieldValue(code)
xml_field = ET.SubElement(xml_param, code)
@ -113,8 +57,6 @@ class XMLOutput():
attribstrs = attrib.split(":")
xml_field.attrib[attribstrs[0].strip()] = attribstrs[1].strip()
xml_field.text = valstrs[0]
if last_param_name != param.GetName():
board_specific_param_set = False
indent(xml_parameters)
self.xml_document = ET.ElementTree(xml_parameters)

View File

@ -98,7 +98,7 @@ class MarkdownTablesOutput():
#Close the table.
result += '</tbody></table>\n\n'
self.output = result;
self.output = result
def Save(self, filename):
with codecs.open(filename, 'w', 'utf-8') as f: