updated object file generator
All checks were successful
EIVE/eive-obsw/pipeline/head This commit looks good
All checks were successful
EIVE/eive-obsw/pipeline/head This commit looks good
This commit is contained in:
parent
fe0a4844aa
commit
528b3c8610
24
generators/.run/objects.run.xml
Normal file
24
generators/.run/objects.run.xml
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
<component name="ProjectRunConfigurationManager">
|
||||||
|
<configuration default="false" name="objects" type="PythonConfigurationType" factoryName="Python">
|
||||||
|
<module name="generators" />
|
||||||
|
<option name="INTERPRETER_OPTIONS" value="" />
|
||||||
|
<option name="PARENT_ENVS" value="true" />
|
||||||
|
<envs>
|
||||||
|
<env name="PYTHONUNBUFFERED" value="1" />
|
||||||
|
</envs>
|
||||||
|
<option name="SDK_HOME" value="" />
|
||||||
|
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
|
||||||
|
<option name="IS_MODULE_SDK" value="true" />
|
||||||
|
<option name="ADD_CONTENT_ROOTS" value="true" />
|
||||||
|
<option name="ADD_SOURCE_ROOTS" value="true" />
|
||||||
|
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
|
||||||
|
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/fsfwgen.py" />
|
||||||
|
<option name="PARAMETERS" value="objects" />
|
||||||
|
<option name="SHOW_COMMAND_LINE" value="false" />
|
||||||
|
<option name="EMULATE_TERMINAL" value="false" />
|
||||||
|
<option name="MODULE_MODE" value="false" />
|
||||||
|
<option name="REDIRECT_INPUT" value="false" />
|
||||||
|
<option name="INPUT_FILE" value="" />
|
||||||
|
<method v="2" />
|
||||||
|
</configuration>
|
||||||
|
</component>
|
@ -68,8 +68,9 @@
|
|||||||
0x49050001;CSP_COM_IF
|
0x49050001;CSP_COM_IF
|
||||||
0x50000100;CCSDS_PACKET_DISTRIBUTOR
|
0x50000100;CCSDS_PACKET_DISTRIBUTOR
|
||||||
0x50000200;PUS_PACKET_DISTRIBUTOR
|
0x50000200;PUS_PACKET_DISTRIBUTOR
|
||||||
0x50000300;UDP_BRIDGE
|
0x50000300;TMTC_BRIDGE
|
||||||
0x50000400;UDP_POLLING_TASK
|
0x50000400;TMTC_POLLING_TASK
|
||||||
|
0x50000500;FILE_SYSTEM_HANDLER
|
||||||
0x51000500;PUS_SERVICE_6
|
0x51000500;PUS_SERVICE_6
|
||||||
0x53000000;FSFW_OBJECTS_START
|
0x53000000;FSFW_OBJECTS_START
|
||||||
0x53000001;PUS_SERVICE_1_VERIFICATION
|
0x53000001;PUS_SERVICE_1_VERIFICATION
|
||||||
|
|
@ -1,22 +1,18 @@
|
|||||||
#! /usr/bin/env python3
|
"""Part of the Mission Information Base Exporter for the SOURCE project by KSat.
|
||||||
"""
|
|
||||||
@file objects.py
|
|
||||||
@brief Part of the Mission Information Base Exporter for the SOURCE project by KSat.
|
|
||||||
@details
|
|
||||||
Object exporter.
|
Object exporter.
|
||||||
To use MySQLdb, run pip install mysqlclient or install in IDE.
|
|
||||||
On Windows, Build Tools installation might be necessary
|
|
||||||
@data 21.11.2019
|
|
||||||
"""
|
"""
|
||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
from fsfwgen.objects.objects import sql_object_exporter, ObjectDefinitionParser, write_translation_file, \
|
from fsfwgen.core import get_console_logger
|
||||||
|
from fsfwgen.objects.objects import sql_object_exporter, ObjectDefinitionParser, \
|
||||||
|
write_translation_file, \
|
||||||
export_object_file, write_translation_header_file
|
export_object_file, write_translation_header_file
|
||||||
from fsfwgen.utility.printer import PrettyPrinter
|
from fsfwgen.utility.printer import PrettyPrinter
|
||||||
from fsfwgen.utility.file_management import copy_file, move_file
|
from fsfwgen.utility.file_management import copy_file, move_file
|
||||||
|
|
||||||
from definitions import BspType, DATABASE_NAME
|
from definitions import BspType, DATABASE_NAME, OBSW_ROOT_DIR, ROOT_DIR
|
||||||
|
|
||||||
|
LOGGER = get_console_logger()
|
||||||
DATE_TODAY = datetime.datetime.now()
|
DATE_TODAY = datetime.datetime.now()
|
||||||
DATE_STRING_FULL = DATE_TODAY.strftime("%Y-%m-%d %H:%M:%S")
|
DATE_STRING_FULL = DATE_TODAY.strftime("%Y-%m-%d %H:%M:%S")
|
||||||
|
|
||||||
@ -31,23 +27,23 @@ GENERATE_HEADER = True
|
|||||||
BSP_SELECT = BspType.BSP_Q7S
|
BSP_SELECT = BspType.BSP_Q7S
|
||||||
BSP_DIR_NAME = BSP_SELECT.value
|
BSP_DIR_NAME = BSP_SELECT.value
|
||||||
if BSP_SELECT == BspType.BSP_Q7S or BSP_SELECT == BspType.BSP_LINUX_BOARD:
|
if BSP_SELECT == BspType.BSP_Q7S or BSP_SELECT == BspType.BSP_LINUX_BOARD:
|
||||||
FSFW_CONFIG_ROOT = f"../../linux/fsfwconfig"
|
FSFW_CONFIG_ROOT = f"{OBSW_ROOT_DIR}/linux/fsfwconfig"
|
||||||
else:
|
else:
|
||||||
FSFW_CONFIG_ROOT = f"../../{BSP_DIR_NAME}/fsfwconfig"
|
FSFW_CONFIG_ROOT = f"{OBSW_ROOT_DIR}/{BSP_DIR_NAME}/fsfwconfig"
|
||||||
|
|
||||||
EXPORT_TO_SQL = True
|
EXPORT_TO_SQL = True
|
||||||
|
|
||||||
CPP_COPY_DESTINATION = f"{FSFW_CONFIG_ROOT}/objects/"
|
CPP_COPY_DESTINATION = f"{FSFW_CONFIG_ROOT}/objects/"
|
||||||
CSV_MOVE_DESTINATION = "../"
|
CSV_MOVE_DESTINATION = f"{ROOT_DIR}"
|
||||||
CPP_FILENAME = "translateObjects.cpp"
|
CPP_FILENAME = f'{__package__}/translateObjects.cpp'
|
||||||
CPP_H_FILENAME = "translateObjects.h"
|
CPP_H_FILENAME = f'{__package__}/translateObjects.h'
|
||||||
CSV_OBJECT_FILENAME = f"{BSP_SELECT.value}_objects.csv"
|
CSV_OBJECT_FILENAME = f"{BSP_SELECT.value}_objects.csv"
|
||||||
FILE_SEPARATOR = ";"
|
FILE_SEPARATOR = ";"
|
||||||
|
|
||||||
|
|
||||||
OBJECTS_PATH = f"{FSFW_CONFIG_ROOT}/objects/systemObjectList.h"
|
OBJECTS_PATH = f"{FSFW_CONFIG_ROOT}/objects/systemObjectList.h"
|
||||||
FRAMEWORK_OBJECT_PATH = "../../fsfw/objectmanager/frameworkObjects.h"
|
FRAMEWORK_OBJECT_PATH = f'{OBSW_ROOT_DIR}/fsfw/src/fsfw/objectmanager/frameworkObjects.h'
|
||||||
COMMON_OBJECTS_PATH = "../../common/config/commonObjects.h"
|
COMMON_OBJECTS_PATH = f'{OBSW_ROOT_DIR}/common/config/commonObjects.h'
|
||||||
OBJECTS_DEFINITIONS = [OBJECTS_PATH, FRAMEWORK_OBJECT_PATH, COMMON_OBJECTS_PATH]
|
OBJECTS_DEFINITIONS = [OBJECTS_PATH, FRAMEWORK_OBJECT_PATH, COMMON_OBJECTS_PATH]
|
||||||
|
|
||||||
SQL_DELETE_OBJECTS_CMD = """
|
SQL_DELETE_OBJECTS_CMD = """
|
||||||
@ -68,33 +64,33 @@ VALUES(?,?)
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def parse_objects(print_object_list: bool = True):
|
||||||
print("Parsing objects: ")
|
|
||||||
list_items = parse_objects()
|
|
||||||
handle_file_export(list_items)
|
|
||||||
if EXPORT_TO_SQL:
|
|
||||||
print("ObjectParser: Exporting to SQL")
|
|
||||||
sql_object_exporter(
|
|
||||||
object_table=list_items, delete_cmd=SQL_DELETE_OBJECTS_CMD, insert_cmd=SQL_INSERT_INTO_OBJECTS_CMD,
|
|
||||||
create_cmd=SQL_CREATE_OBJECTS_CMD, db_filename=f"../{DATABASE_NAME}"
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def parse_objects():
|
|
||||||
# fetch objects
|
# fetch objects
|
||||||
object_parser = ObjectDefinitionParser(OBJECTS_DEFINITIONS)
|
object_parser = ObjectDefinitionParser(OBJECTS_DEFINITIONS)
|
||||||
subsystem_definitions = object_parser.parse_files()
|
subsystem_definitions = object_parser.parse_files()
|
||||||
# id_subsystem_definitions.update(framework_subsystem_definitions)
|
# id_subsystem_definitions.update(framework_subsystem_definitions)
|
||||||
list_items = sorted(subsystem_definitions.items())
|
list_items = sorted(subsystem_definitions.items())
|
||||||
PrettyPrinter.pprint(list_items)
|
LOGGER.info(f'ObjectParser: Number of objects: {len(list_items)}')
|
||||||
print("ObjectParser: Number of objects: ", len(list_items))
|
|
||||||
return list_items
|
if print_object_list:
|
||||||
|
PrettyPrinter.pprint(list_items)
|
||||||
|
|
||||||
|
handle_file_export(list_items)
|
||||||
|
if EXPORT_TO_SQL:
|
||||||
|
LOGGER.info('ObjectParser: Exporting to SQL')
|
||||||
|
sql_object_exporter(
|
||||||
|
object_table=list_items, delete_cmd=SQL_DELETE_OBJECTS_CMD,
|
||||||
|
insert_cmd=SQL_INSERT_INTO_OBJECTS_CMD,
|
||||||
|
create_cmd=SQL_CREATE_OBJECTS_CMD, db_filename=f"{ROOT_DIR}/{DATABASE_NAME}"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def handle_file_export(list_items):
|
def handle_file_export(list_items):
|
||||||
if GENERATE_CPP:
|
if GENERATE_CPP:
|
||||||
print("ObjectParser: Generating translation C++ file.")
|
LOGGER.info('ObjectParser: Generating translation C++ file')
|
||||||
write_translation_file(filename=CPP_FILENAME, list_of_entries=list_items, date_string_full=DATE_STRING_FULL)
|
write_translation_file(
|
||||||
|
filename=CPP_FILENAME, list_of_entries=list_items, date_string_full=DATE_STRING_FULL
|
||||||
|
)
|
||||||
if COPY_CPP:
|
if COPY_CPP:
|
||||||
print("ObjectParser: Copying object file to " + CPP_COPY_DESTINATION)
|
print("ObjectParser: Copying object file to " + CPP_COPY_DESTINATION)
|
||||||
copy_file(CPP_FILENAME, CPP_COPY_DESTINATION)
|
copy_file(CPP_FILENAME, CPP_COPY_DESTINATION)
|
||||||
@ -103,10 +99,6 @@ def handle_file_export(list_items):
|
|||||||
copy_file(filename=CPP_H_FILENAME, destination=CPP_COPY_DESTINATION)
|
copy_file(filename=CPP_H_FILENAME, destination=CPP_COPY_DESTINATION)
|
||||||
if GENERATE_CSV:
|
if GENERATE_CSV:
|
||||||
print("ObjectParser: Generating text export.")
|
print("ObjectParser: Generating text export.")
|
||||||
export_object_file(filename=CSV_OBJECT_FILENAME, object_list=list_items, file_separator=FILE_SEPARATOR)
|
export_object_file(
|
||||||
if MOVE_CSV:
|
filename=CSV_OBJECT_FILENAME, object_list=list_items, file_separator=FILE_SEPARATOR
|
||||||
move_file(file_name=CSV_OBJECT_FILENAME, destination=CSV_MOVE_DESTINATION)
|
)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
main()
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
/**
|
/**
|
||||||
* @brief Auto-generated object translation file.
|
* @brief Auto-generated object translation file.
|
||||||
* @details
|
* @details
|
||||||
* Contains 102 translations.
|
* Contains 103 translations.
|
||||||
* Generated on: 2021-07-10 16:22:55
|
* Generated on: 2021-08-02 11:48:50
|
||||||
*/
|
*/
|
||||||
#include "translateObjects.h"
|
#include "translateObjects.h"
|
||||||
|
|
||||||
@ -76,8 +76,9 @@ const char *I2C_COM_IF_STRING = "I2C_COM_IF";
|
|||||||
const char *CSP_COM_IF_STRING = "CSP_COM_IF";
|
const char *CSP_COM_IF_STRING = "CSP_COM_IF";
|
||||||
const char *CCSDS_PACKET_DISTRIBUTOR_STRING = "CCSDS_PACKET_DISTRIBUTOR";
|
const char *CCSDS_PACKET_DISTRIBUTOR_STRING = "CCSDS_PACKET_DISTRIBUTOR";
|
||||||
const char *PUS_PACKET_DISTRIBUTOR_STRING = "PUS_PACKET_DISTRIBUTOR";
|
const char *PUS_PACKET_DISTRIBUTOR_STRING = "PUS_PACKET_DISTRIBUTOR";
|
||||||
const char *UDP_BRIDGE_STRING = "UDP_BRIDGE";
|
const char *TMTC_BRIDGE_STRING = "TMTC_BRIDGE";
|
||||||
const char *UDP_POLLING_TASK_STRING = "UDP_POLLING_TASK";
|
const char *TMTC_POLLING_TASK_STRING = "TMTC_POLLING_TASK";
|
||||||
|
const char *FILE_SYSTEM_HANDLER_STRING = "FILE_SYSTEM_HANDLER";
|
||||||
const char *PUS_SERVICE_6_STRING = "PUS_SERVICE_6";
|
const char *PUS_SERVICE_6_STRING = "PUS_SERVICE_6";
|
||||||
const char *FSFW_OBJECTS_START_STRING = "FSFW_OBJECTS_START";
|
const char *FSFW_OBJECTS_START_STRING = "FSFW_OBJECTS_START";
|
||||||
const char *PUS_SERVICE_1_VERIFICATION_STRING = "PUS_SERVICE_1_VERIFICATION";
|
const char *PUS_SERVICE_1_VERIFICATION_STRING = "PUS_SERVICE_1_VERIFICATION";
|
||||||
@ -252,9 +253,11 @@ const char* translateObject(object_id_t object) {
|
|||||||
case 0x50000200:
|
case 0x50000200:
|
||||||
return PUS_PACKET_DISTRIBUTOR_STRING;
|
return PUS_PACKET_DISTRIBUTOR_STRING;
|
||||||
case 0x50000300:
|
case 0x50000300:
|
||||||
return UDP_BRIDGE_STRING;
|
return TMTC_BRIDGE_STRING;
|
||||||
case 0x50000400:
|
case 0x50000400:
|
||||||
return UDP_POLLING_TASK_STRING;
|
return TMTC_POLLING_TASK_STRING;
|
||||||
|
case 0x50000500:
|
||||||
|
return FILE_SYSTEM_HANDLER_STRING;
|
||||||
case 0x51000500:
|
case 0x51000500:
|
||||||
return PUS_SERVICE_6_STRING;
|
return PUS_SERVICE_6_STRING;
|
||||||
case 0x53000000:
|
case 0x53000000:
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
/**
|
/**
|
||||||
* @brief Auto-generated object translation file.
|
* @brief Auto-generated object translation file.
|
||||||
* @details
|
* @details
|
||||||
* Contains 102 translations.
|
* Contains 103 translations.
|
||||||
* Generated on: 2021-07-10 16:22:55
|
* Generated on: 2021-08-02 11:48:50
|
||||||
*/
|
*/
|
||||||
#include "translateObjects.h"
|
#include "translateObjects.h"
|
||||||
|
|
||||||
@ -76,8 +76,9 @@ const char *I2C_COM_IF_STRING = "I2C_COM_IF";
|
|||||||
const char *CSP_COM_IF_STRING = "CSP_COM_IF";
|
const char *CSP_COM_IF_STRING = "CSP_COM_IF";
|
||||||
const char *CCSDS_PACKET_DISTRIBUTOR_STRING = "CCSDS_PACKET_DISTRIBUTOR";
|
const char *CCSDS_PACKET_DISTRIBUTOR_STRING = "CCSDS_PACKET_DISTRIBUTOR";
|
||||||
const char *PUS_PACKET_DISTRIBUTOR_STRING = "PUS_PACKET_DISTRIBUTOR";
|
const char *PUS_PACKET_DISTRIBUTOR_STRING = "PUS_PACKET_DISTRIBUTOR";
|
||||||
const char *UDP_BRIDGE_STRING = "UDP_BRIDGE";
|
const char *TMTC_BRIDGE_STRING = "TMTC_BRIDGE";
|
||||||
const char *UDP_POLLING_TASK_STRING = "UDP_POLLING_TASK";
|
const char *TMTC_POLLING_TASK_STRING = "TMTC_POLLING_TASK";
|
||||||
|
const char *FILE_SYSTEM_HANDLER_STRING = "FILE_SYSTEM_HANDLER";
|
||||||
const char *PUS_SERVICE_6_STRING = "PUS_SERVICE_6";
|
const char *PUS_SERVICE_6_STRING = "PUS_SERVICE_6";
|
||||||
const char *FSFW_OBJECTS_START_STRING = "FSFW_OBJECTS_START";
|
const char *FSFW_OBJECTS_START_STRING = "FSFW_OBJECTS_START";
|
||||||
const char *PUS_SERVICE_1_VERIFICATION_STRING = "PUS_SERVICE_1_VERIFICATION";
|
const char *PUS_SERVICE_1_VERIFICATION_STRING = "PUS_SERVICE_1_VERIFICATION";
|
||||||
@ -252,9 +253,11 @@ const char* translateObject(object_id_t object) {
|
|||||||
case 0x50000200:
|
case 0x50000200:
|
||||||
return PUS_PACKET_DISTRIBUTOR_STRING;
|
return PUS_PACKET_DISTRIBUTOR_STRING;
|
||||||
case 0x50000300:
|
case 0x50000300:
|
||||||
return UDP_BRIDGE_STRING;
|
return TMTC_BRIDGE_STRING;
|
||||||
case 0x50000400:
|
case 0x50000400:
|
||||||
return UDP_POLLING_TASK_STRING;
|
return TMTC_POLLING_TASK_STRING;
|
||||||
|
case 0x50000500:
|
||||||
|
return FILE_SYSTEM_HANDLER_STRING;
|
||||||
case 0x51000500:
|
case 0x51000500:
|
||||||
return PUS_SERVICE_6_STRING;
|
return PUS_SERVICE_6_STRING;
|
||||||
case 0x53000000:
|
case 0x53000000:
|
||||||
|
Loading…
Reference in New Issue
Block a user