some minor updates and bugfixes
This commit is contained in:
@ -46,23 +46,23 @@ def write_translation_file(filename: str, list_of_entries, date_string_full: str
|
||||
LOGGER.info("ObjectParser: Writing translation file " + filename)
|
||||
definitions = ""
|
||||
function = (
|
||||
"const char* translateObject(object_id_t object) "
|
||||
"{\n\tswitch( (object & 0xFFFFFFFF) ) {\n"
|
||||
"const char *translateObject(object_id_t object) "
|
||||
"{\n switch ((object & 0xFFFFFFFF)) {\n"
|
||||
)
|
||||
for entry in list_of_entries:
|
||||
# first part of translate file
|
||||
definitions += f'const char *{entry[1][0]}_STRING = "{entry[1][0]}";\n'
|
||||
# second part of translate file. entry[i] contains 32 bit hexadecimal numbers
|
||||
function += f"\tcase {entry[0]}:\n\t\treturn {entry[1][0]}_STRING;\n"
|
||||
function += '\tdefault:\n\t\treturn "UNKNOWN_OBJECT";\n'
|
||||
function += f" case {entry[0]}:\n return {entry[1][0]}_STRING;\n"
|
||||
function += ' default:\n return "UNKNOWN_OBJECT";\n }\n'
|
||||
outputfile.write(
|
||||
f"/**\n * @brief\tAuto-generated object translation file.\n"
|
||||
f"/**\n * @brief Auto-generated object translation file.\n"
|
||||
f" * @details\n"
|
||||
f" * Contains {len(list_of_entries)} translations.\n"
|
||||
f" * Generated on: {date_string_full}\n */\n"
|
||||
)
|
||||
outputfile.write('#include "translateObjects.h"\n\n')
|
||||
outputfile.write(definitions + "\n" + function + "\t}\n\treturn 0;\n}\n")
|
||||
outputfile.write(definitions + "\n" + function + " return 0;\n}\n")
|
||||
outputfile.close()
|
||||
|
||||
|
||||
@ -72,7 +72,7 @@ def write_translation_header_file(filename: str = "translateObjects.h"):
|
||||
f"#ifndef FSFWCONFIG_OBJECTS_TRANSLATEOBJECTS_H_\n"
|
||||
f"#define FSFWCONFIG_OBJECTS_TRANSLATEOBJECTS_H_\n\n"
|
||||
f"#include <fsfw/objectmanager/SystemObjectIF.h>\n\n"
|
||||
f"const char* translateObject(object_id_t object);\n\n"
|
||||
f"const char *translateObject(object_id_t object);\n\n"
|
||||
f"#endif /* FSFWCONFIG_OBJECTS_TRANSLATEOBJECTS_H_ */\n"
|
||||
)
|
||||
|
||||
|
Reference in New Issue
Block a user