Revert "Added ability for board specific meta data generation"

This reverts commit 9ac350a7d1.
This commit is contained in:
Lorenz Meier
2015-04-18 11:38:23 +02:00
parent e097affd7a
commit f8cf495494
4 changed files with 32 additions and 52 deletions

View File

@@ -37,30 +37,20 @@ class Parameter(object):
# Define sorting order of the fields
priority = {
"board": 9,
"code": 10,
"type": 9,
"short_desc": 8,
"long_desc": 7,
"default": 6,
"min": 5,
"max": 4,
"unit": 3,
# all others == 0 (sorted alphabetically)
}
def __init__(self, name, type, default = ""):
def __init__(self):
self.fields = {}
self.name = name
self.type = type
self.default = default
def GetName(self):
return self.name
def GetType(self):
return self.type
def GetDefault(self):
return self.default
def SetField(self, code, value):
"""
Set named field value
@@ -98,7 +88,7 @@ class SourceParser(object):
re_is_a_number = re.compile(r'^-?[0-9\.]')
re_remove_dots = re.compile(r'\.+$')
valid_tags = set(["group", "board", "min", "max", "unit"])
valid_tags = set(["group", "min", "max", "unit"])
# Order of parameter groups
priority = {
@@ -187,12 +177,15 @@ class SourceParser(object):
# Non-empty line outside the comment
m = self.re_parameter_definition.match(line)
if m:
tp, name, defval = m.group(1, 2, 3)
tp, code, defval = m.group(1, 2, 3)
# Remove trailing type specifier from numbers: 0.1f => 0.1
if self.re_is_a_number.match(defval):
defval = self.re_cut_type_specifier.sub('', defval)
param = Parameter(name, tp, defval)
param.SetField("short_desc", name)
param = Parameter()
param.SetField("code", code)
param.SetField("short_desc", code)
param.SetField("type", tp)
param.SetField("default", defval)
# If comment was found before the parameter declaration,
# inject its data into the newly created parameter.
group = "Miscellaneous"
@@ -218,9 +211,11 @@ class SourceParser(object):
# Nasty code dup, but this will all go away soon, so quick and dirty (DonLakeFlyer)
m = self.re_px4_parameter_definition.match(line)
if m:
tp, name = m.group(1, 2)
param = Parameter(name, tp)
param.SetField("short_desc", name)
tp, code = m.group(1, 2)
param = Parameter()
param.SetField("code", code)
param.SetField("short_desc", code)
param.SetField("type", tp)
# If comment was found before the parameter declaration,
# inject its data into the newly created parameter.
group = "Miscellaneous"

View File

@@ -18,36 +18,26 @@ def indent(elem, level=0):
class XMLOutput():
def __init__(self, groups, board):
def __init__(self, groups):
xml_parameters = ET.Element("parameters")
xml_version = ET.SubElement(xml_parameters, "version")
xml_version.text = "3"
last_param_name = ""
board_specific_param_set = False
xml_version.text = "2"
for group in groups:
xml_group = ET.SubElement(xml_parameters, "group")
xml_group.attrib["name"] = group.GetName()
for param in group.GetParams():
if (last_param_name == param.GetName() and not board_specific_param_set) or last_param_name != param.GetName():
xml_param = ET.SubElement(xml_group, "parameter")
xml_param.attrib["name"] = param.GetName()
xml_param.attrib["default"] = param.GetDefault()
xml_param.attrib["type"] = param.GetType()
last_param_name = param.GetName()
for code in param.GetFieldCodes():
value = param.GetFieldValue(code)
if code == "board":
if value == board:
board_specific_param_set = True
xml_field = ET.SubElement(xml_param, code)
xml_field.text = value
else:
xml_group.remove(xml_param)
else:
xml_field = ET.SubElement(xml_param, code)
xml_field.text = value
if last_param_name != param.GetName():
board_specific_param_set = False
xml_param = ET.SubElement(xml_group, "parameter")
for code in param.GetFieldCodes():
value = param.GetFieldValue(code)
if code == "code":
xml_param.attrib["name"] = value
elif code == "default":
xml_param.attrib["default"] = value
elif code == "type":
xml_param.attrib["type"] = value
else:
xml_field = ET.SubElement(xml_param, code)
xml_field.text = value
indent(xml_parameters)
self.xml_document = ET.ElementTree(xml_parameters)