mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-25 10:03:34 +08:00
Param parser and XML output: Add support for volatile attribute
This allows to mark parameters as volatile.
This commit is contained in:
@@ -57,6 +57,7 @@ class Parameter(object):
|
|||||||
self.name = name
|
self.name = name
|
||||||
self.type = type
|
self.type = type
|
||||||
self.default = default
|
self.default = default
|
||||||
|
self.volatile = "false"
|
||||||
|
|
||||||
def GetName(self):
|
def GetName(self):
|
||||||
return self.name
|
return self.name
|
||||||
@@ -67,6 +68,9 @@ class Parameter(object):
|
|||||||
def GetDefault(self):
|
def GetDefault(self):
|
||||||
return self.default
|
return self.default
|
||||||
|
|
||||||
|
def GetVolatile(self):
|
||||||
|
return self.volatile
|
||||||
|
|
||||||
def SetField(self, code, value):
|
def SetField(self, code, value):
|
||||||
"""
|
"""
|
||||||
Set named field value
|
Set named field value
|
||||||
@@ -85,6 +89,12 @@ class Parameter(object):
|
|||||||
"""
|
"""
|
||||||
self.bitmask[index] = bit
|
self.bitmask[index] = bit
|
||||||
|
|
||||||
|
def SetVolatile(self):
|
||||||
|
"""
|
||||||
|
Set volatile flag
|
||||||
|
"""
|
||||||
|
self.volatile = "true"
|
||||||
|
|
||||||
def GetFieldCodes(self):
|
def GetFieldCodes(self):
|
||||||
"""
|
"""
|
||||||
Return list of existing field codes in convenient order
|
Return list of existing field codes in convenient order
|
||||||
@@ -282,6 +292,8 @@ class SourceParser(object):
|
|||||||
for tag in tags:
|
for tag in tags:
|
||||||
if tag == "group":
|
if tag == "group":
|
||||||
group = tags[tag]
|
group = tags[tag]
|
||||||
|
elif tag == "volatile":
|
||||||
|
param.SetVolatile()
|
||||||
elif tag not in self.valid_tags:
|
elif tag not in self.valid_tags:
|
||||||
sys.stderr.write("Skipping invalid documentation tag: '%s'\n" % tag)
|
sys.stderr.write("Skipping invalid documentation tag: '%s'\n" % tag)
|
||||||
return False
|
return False
|
||||||
@@ -332,6 +344,9 @@ class SourceParser(object):
|
|||||||
if default != "" and not self.IsNumber(default):
|
if default != "" and not self.IsNumber(default):
|
||||||
sys.stderr.write("Default value not number: {0} {1}\n".format(name, default))
|
sys.stderr.write("Default value not number: {0} {1}\n".format(name, default))
|
||||||
return False
|
return False
|
||||||
|
# if default != "" and "." not in default:
|
||||||
|
# sys.stderr.write("Default value does not contain dot (e.g. 10 needs to be written as 10.0): {0} {1}\n".format(name, default))
|
||||||
|
# return False
|
||||||
if min != "":
|
if min != "":
|
||||||
if not self.IsNumber(min):
|
if not self.IsNumber(min):
|
||||||
sys.stderr.write("Min value not number: {0} {1}\n".format(name, min))
|
sys.stderr.write("Min value not number: {0} {1}\n".format(name, min))
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ class XMLOutput():
|
|||||||
xml_param.attrib["name"] = param.GetName()
|
xml_param.attrib["name"] = param.GetName()
|
||||||
xml_param.attrib["default"] = param.GetDefault()
|
xml_param.attrib["default"] = param.GetDefault()
|
||||||
xml_param.attrib["type"] = param.GetType()
|
xml_param.attrib["type"] = param.GetType()
|
||||||
|
xml_param.attrib["volatile"] = param.GetVolatile()
|
||||||
last_param_name = param.GetName()
|
last_param_name = param.GetName()
|
||||||
for code in param.GetFieldCodes():
|
for code in param.GetFieldCodes():
|
||||||
value = param.GetFieldValue(code)
|
value = param.GetFieldValue(code)
|
||||||
|
|||||||
Reference in New Issue
Block a user