Skip to content

Commit

Permalink
Merge pull request #10 from oresat/fix/xtce
Browse files Browse the repository at this point in the history
XTCE Generation Fixes
  • Loading branch information
dmitri-mcguckin authored Jan 2, 2024
2 parents 33f1c5b + 93de182 commit 4585e4a
Showing 1 changed file with 24 additions and 5 deletions.
29 changes: 24 additions & 5 deletions oresat_configs/scripts/gen_xtce.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def write_xtce(config: OreSatConfig, dir_path: str = "."):
)
ref_time = ET.SubElement(para_type, "ReferenceTime")
epoch = ET.SubElement(ref_time, "Epoch")
epoch.text = "1970-01-01T00:00.00.000"
epoch.text = "1970-01-01T00:00:00.000"

para_types = ["unix_time"]
for obj in config.beacon_def:
Expand All @@ -151,6 +151,16 @@ def write_xtce(config: OreSatConfig, dir_path: str = "."):
"oneStringValue": "1",
},
)
unit_set = ET.SubElement(para_type, "UnitSet")
dt_len = DT_LEN[obj.data_type] # Length of the data type
# Integer-type encoding for enums
int_dt_enc = ET.SubElement(
para_type,
"IntegerDataEncoding",
attrib={
"sizeInBits": str(dt_len)
}
)
elif obj.data_type in canopen.objectdictionary.UNSIGNED_TYPES and obj.value_descriptions:
para_type = ET.SubElement(
tm_meta_para,
Expand All @@ -159,6 +169,16 @@ def write_xtce(config: OreSatConfig, dir_path: str = "."):
"name": name,
},
)
unit_set = ET.SubElement(para_type, "UnitSet")
dt_len = DT_LEN[obj.data_type] # Length of the data type
# Integer-type encoding for enums
int_dt_enc = ET.SubElement(
para_type,
"IntegerDataEncoding",
attrib={
"sizeInBits": str(dt_len)
}
)
enum_list = ET.SubElement(para_type, "EnumerationList")
for value, name in obj.value_descriptions.items():
ET.SubElement(
Expand All @@ -175,7 +195,7 @@ def write_xtce(config: OreSatConfig, dir_path: str = "."):
encoding = "unsigned"
else:
signed = True
encoding = "twoComplement"
encoding = "twosComplement"

para_type = ET.SubElement(
tm_meta_para,
Expand Down Expand Up @@ -223,12 +243,11 @@ def write_xtce(config: OreSatConfig, dir_path: str = "."):
"StringParameterType",
attrib={
"name": name,
"baseType": CANOPEN_TO_XTCE_DT[obj.data_type],
},
)
str_para_type = ET.SubElement(
para_type,
"StringParameterType",
"StringDataEncoding",
attrib={
"encoding": "UTF-8",
},
Expand Down Expand Up @@ -271,7 +290,7 @@ def write_xtce(config: OreSatConfig, dir_path: str = "."):
# write
tree = ET.ElementTree(root)
ET.indent(tree, space=" ", level=0)
file_name = f"{config.oresat_id.name.lower()}-xtce.xml"
file_name = f"{config.oresat_id.name.lower()}.xtce"
tree.write(f"{dir_path}/{file_name}", encoding="utf-8", xml_declaration=True)


Expand Down

0 comments on commit 4585e4a

Please sign in to comment.