mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-31 06:41:36 +08:00
px_generate_params: Sort parameters by name after parsing the xml file.
This commit is contained in:
+15
-29
@@ -45,12 +45,9 @@ struct px4_parameters_t {
|
|||||||
start_name = ""
|
start_name = ""
|
||||||
end_name = ""
|
end_name = ""
|
||||||
|
|
||||||
|
params = []
|
||||||
for group in root:
|
for group in root:
|
||||||
if group.tag == "group" and "no_code_generation" not in group.attrib:
|
if group.tag == "group" and "no_code_generation" not in group.attrib:
|
||||||
section = """
|
|
||||||
/*****************************************************************
|
|
||||||
* %s
|
|
||||||
****************************************************************/""" % group.attrib["name"]
|
|
||||||
for param in group:
|
for param in group:
|
||||||
scope_ = param.find('scope').text
|
scope_ = param.find('scope').text
|
||||||
if not cmake_scope.Has(scope_):
|
if not cmake_scope.Has(scope_):
|
||||||
@@ -58,10 +55,13 @@ for group in root:
|
|||||||
if not start_name:
|
if not start_name:
|
||||||
start_name = param.attrib["name"]
|
start_name = param.attrib["name"]
|
||||||
end_name = param.attrib["name"]
|
end_name = param.attrib["name"]
|
||||||
header += section
|
params.append(param)
|
||||||
section =""
|
|
||||||
header += """
|
params = sorted(params, key=lambda name: name.attrib["name"])
|
||||||
|
for param in params:
|
||||||
|
header += """
|
||||||
const struct param_info_s __param__%s;""" % param.attrib["name"]
|
const struct param_info_s __param__%s;""" % param.attrib["name"]
|
||||||
|
|
||||||
header += """
|
header += """
|
||||||
const unsigned int param_count;
|
const unsigned int param_count;
|
||||||
};
|
};
|
||||||
@@ -83,28 +83,14 @@ __attribute__((used, section("__param")))
|
|||||||
struct px4_parameters_t px4_parameters = {
|
struct px4_parameters_t px4_parameters = {
|
||||||
"""
|
"""
|
||||||
i=0
|
i=0
|
||||||
for group in root:
|
for param in params:
|
||||||
if group.tag == "group" and "no_code_generation" not in group.attrib:
|
val_str = "#error UNKNOWN PARAM TYPE, FIX px_generate_params.py"
|
||||||
section = """
|
if (param.attrib["type"] == "FLOAT"):
|
||||||
/*****************************************************************
|
val_str = ".val.f = "
|
||||||
* %s
|
elif (param.attrib["type"] == "INT32"):
|
||||||
****************************************************************/""" % group.attrib["name"]
|
val_str = ".val.i = "
|
||||||
for param in group:
|
i+=1
|
||||||
scope_ = param.find('scope').text
|
src += """
|
||||||
if not cmake_scope.Has(scope_):
|
|
||||||
continue
|
|
||||||
if not start_name:
|
|
||||||
start_name = param.attrib["name"]
|
|
||||||
end_name = param.attrib["name"]
|
|
||||||
val_str = "#error UNKNOWN PARAM TYPE, FIX px_generate_params.py"
|
|
||||||
if (param.attrib["type"] == "FLOAT"):
|
|
||||||
val_str = ".val.f = "
|
|
||||||
elif (param.attrib["type"] == "INT32"):
|
|
||||||
val_str = ".val.i = "
|
|
||||||
i+=1
|
|
||||||
src += section
|
|
||||||
section =""
|
|
||||||
src += """
|
|
||||||
{
|
{
|
||||||
"%s",
|
"%s",
|
||||||
PARAM_TYPE_%s,
|
PARAM_TYPE_%s,
|
||||||
|
|||||||
Reference in New Issue
Block a user