updated even generator
This commit is contained in:
parent
f138950670
commit
f655889e7f
249
bsp_hosted/fsfwconfig/events/translateEvents.cpp
Normal file
249
bsp_hosted/fsfwconfig/events/translateEvents.cpp
Normal file
@ -0,0 +1,249 @@
|
||||
/**
|
||||
* @brief Auto-generated event translation file. Contains 78 translations.
|
||||
* @details
|
||||
* Generated on: 2021-05-14 11:51:26
|
||||
*/
|
||||
#include "translateEvents.h"
|
||||
|
||||
const char *STORE_SEND_WRITE_FAILED_STRING = "STORE_SEND_WRITE_FAILED";
|
||||
const char *STORE_WRITE_FAILED_STRING = "STORE_WRITE_FAILED";
|
||||
const char *STORE_SEND_READ_FAILED_STRING = "STORE_SEND_READ_FAILED";
|
||||
const char *STORE_READ_FAILED_STRING = "STORE_READ_FAILED";
|
||||
const char *UNEXPECTED_MSG_STRING = "UNEXPECTED_MSG";
|
||||
const char *STORING_FAILED_STRING = "STORING_FAILED";
|
||||
const char *TM_DUMP_FAILED_STRING = "TM_DUMP_FAILED";
|
||||
const char *STORE_INIT_FAILED_STRING = "STORE_INIT_FAILED";
|
||||
const char *STORE_INIT_EMPTY_STRING = "STORE_INIT_EMPTY";
|
||||
const char *STORE_CONTENT_CORRUPTED_STRING = "STORE_CONTENT_CORRUPTED";
|
||||
const char *STORE_INITIALIZE_STRING = "STORE_INITIALIZE";
|
||||
const char *INIT_DONE_STRING = "INIT_DONE";
|
||||
const char *DUMP_FINISHED_STRING = "DUMP_FINISHED";
|
||||
const char *DELETION_FINISHED_STRING = "DELETION_FINISHED";
|
||||
const char *DELETION_FAILED_STRING = "DELETION_FAILED";
|
||||
const char *AUTO_CATALOGS_SENDING_FAILED_STRING = "AUTO_CATALOGS_SENDING_FAILED";
|
||||
const char *GET_DATA_FAILED_STRING = "GET_DATA_FAILED";
|
||||
const char *STORE_DATA_FAILED_STRING = "STORE_DATA_FAILED";
|
||||
const char *DEVICE_BUILDING_COMMAND_FAILED_STRING = "DEVICE_BUILDING_COMMAND_FAILED";
|
||||
const char *DEVICE_SENDING_COMMAND_FAILED_STRING = "DEVICE_SENDING_COMMAND_FAILED";
|
||||
const char *DEVICE_REQUESTING_REPLY_FAILED_STRING = "DEVICE_REQUESTING_REPLY_FAILED";
|
||||
const char *DEVICE_READING_REPLY_FAILED_STRING = "DEVICE_READING_REPLY_FAILED";
|
||||
const char *DEVICE_INTERPRETING_REPLY_FAILED_STRING = "DEVICE_INTERPRETING_REPLY_FAILED";
|
||||
const char *DEVICE_MISSED_REPLY_STRING = "DEVICE_MISSED_REPLY";
|
||||
const char *DEVICE_UNKNOWN_REPLY_STRING = "DEVICE_UNKNOWN_REPLY";
|
||||
const char *DEVICE_UNREQUESTED_REPLY_STRING = "DEVICE_UNREQUESTED_REPLY";
|
||||
const char *INVALID_DEVICE_COMMAND_STRING = "INVALID_DEVICE_COMMAND";
|
||||
const char *MONITORING_LIMIT_EXCEEDED_STRING = "MONITORING_LIMIT_EXCEEDED";
|
||||
const char *MONITORING_AMBIGUOUS_STRING = "MONITORING_AMBIGUOUS";
|
||||
const char *FUSE_CURRENT_HIGH_STRING = "FUSE_CURRENT_HIGH";
|
||||
const char *FUSE_WENT_OFF_STRING = "FUSE_WENT_OFF";
|
||||
const char *POWER_ABOVE_HIGH_LIMIT_STRING = "POWER_ABOVE_HIGH_LIMIT";
|
||||
const char *POWER_BELOW_LOW_LIMIT_STRING = "POWER_BELOW_LOW_LIMIT";
|
||||
const char *SWITCH_WENT_OFF_STRING = "SWITCH_WENT_OFF";
|
||||
const char *HEATER_ON_STRING = "HEATER_ON";
|
||||
const char *HEATER_OFF_STRING = "HEATER_OFF";
|
||||
const char *HEATER_TIMEOUT_STRING = "HEATER_TIMEOUT";
|
||||
const char *HEATER_STAYED_ON_STRING = "HEATER_STAYED_ON";
|
||||
const char *HEATER_STAYED_OFF_STRING = "HEATER_STAYED_OFF";
|
||||
const char *TEMP_SENSOR_HIGH_STRING = "TEMP_SENSOR_HIGH";
|
||||
const char *TEMP_SENSOR_LOW_STRING = "TEMP_SENSOR_LOW";
|
||||
const char *TEMP_SENSOR_GRADIENT_STRING = "TEMP_SENSOR_GRADIENT";
|
||||
const char *COMPONENT_TEMP_LOW_STRING = "COMPONENT_TEMP_LOW";
|
||||
const char *COMPONENT_TEMP_HIGH_STRING = "COMPONENT_TEMP_HIGH";
|
||||
const char *COMPONENT_TEMP_OOL_LOW_STRING = "COMPONENT_TEMP_OOL_LOW";
|
||||
const char *COMPONENT_TEMP_OOL_HIGH_STRING = "COMPONENT_TEMP_OOL_HIGH";
|
||||
const char *TEMP_NOT_IN_OP_RANGE_STRING = "TEMP_NOT_IN_OP_RANGE";
|
||||
const char *FDIR_CHANGED_STATE_STRING = "FDIR_CHANGED_STATE";
|
||||
const char *FDIR_STARTS_RECOVERY_STRING = "FDIR_STARTS_RECOVERY";
|
||||
const char *FDIR_TURNS_OFF_DEVICE_STRING = "FDIR_TURNS_OFF_DEVICE";
|
||||
const char *MONITOR_CHANGED_STATE_STRING = "MONITOR_CHANGED_STATE";
|
||||
const char *VALUE_BELOW_LOW_LIMIT_STRING = "VALUE_BELOW_LOW_LIMIT";
|
||||
const char *VALUE_ABOVE_HIGH_LIMIT_STRING = "VALUE_ABOVE_HIGH_LIMIT";
|
||||
const char *VALUE_OUT_OF_RANGE_STRING = "VALUE_OUT_OF_RANGE";
|
||||
const char *SWITCHING_TM_FAILED_STRING = "SWITCHING_TM_FAILED";
|
||||
const char *CHANGING_MODE_STRING = "CHANGING_MODE";
|
||||
const char *MODE_INFO_STRING = "MODE_INFO";
|
||||
const char *FALLBACK_FAILED_STRING = "FALLBACK_FAILED";
|
||||
const char *MODE_TRANSITION_FAILED_STRING = "MODE_TRANSITION_FAILED";
|
||||
const char *CANT_KEEP_MODE_STRING = "CANT_KEEP_MODE";
|
||||
const char *OBJECT_IN_INVALID_MODE_STRING = "OBJECT_IN_INVALID_MODE";
|
||||
const char *FORCING_MODE_STRING = "FORCING_MODE";
|
||||
const char *MODE_CMD_REJECTED_STRING = "MODE_CMD_REJECTED";
|
||||
const char *HEALTH_INFO_STRING = "HEALTH_INFO";
|
||||
const char *CHILD_CHANGED_HEALTH_STRING = "CHILD_CHANGED_HEALTH";
|
||||
const char *CHILD_PROBLEMS_STRING = "CHILD_PROBLEMS";
|
||||
const char *OVERWRITING_HEALTH_STRING = "OVERWRITING_HEALTH";
|
||||
const char *TRYING_RECOVERY_STRING = "TRYING_RECOVERY";
|
||||
const char *RECOVERY_STEP_STRING = "RECOVERY_STEP";
|
||||
const char *RECOVERY_DONE_STRING = "RECOVERY_DONE";
|
||||
const char *RF_AVAILABLE_STRING = "RF_AVAILABLE";
|
||||
const char *RF_LOST_STRING = "RF_LOST";
|
||||
const char *BIT_LOCK_STRING = "BIT_LOCK";
|
||||
const char *BIT_LOCK_LOST_STRING = "BIT_LOCK_LOST";
|
||||
const char *FRAME_PROCESSING_FAILED_STRING = "FRAME_PROCESSING_FAILED";
|
||||
const char *CLOCK_SET_STRING = "CLOCK_SET";
|
||||
const char *CLOCK_SET_FAILURE_STRING = "CLOCK_SET_FAILURE";
|
||||
const char *TEST_STRING = "TEST";
|
||||
|
||||
const char * translateEvents(Event event) {
|
||||
switch( (event & 0xffff) ) {
|
||||
case(2200):
|
||||
return STORE_SEND_WRITE_FAILED_STRING;
|
||||
case(2201):
|
||||
return STORE_WRITE_FAILED_STRING;
|
||||
case(2202):
|
||||
return STORE_SEND_READ_FAILED_STRING;
|
||||
case(2203):
|
||||
return STORE_READ_FAILED_STRING;
|
||||
case(2204):
|
||||
return UNEXPECTED_MSG_STRING;
|
||||
case(2205):
|
||||
return STORING_FAILED_STRING;
|
||||
case(2206):
|
||||
return TM_DUMP_FAILED_STRING;
|
||||
case(2207):
|
||||
return STORE_INIT_FAILED_STRING;
|
||||
case(2208):
|
||||
return STORE_INIT_EMPTY_STRING;
|
||||
case(2209):
|
||||
return STORE_CONTENT_CORRUPTED_STRING;
|
||||
case(2210):
|
||||
return STORE_INITIALIZE_STRING;
|
||||
case(2211):
|
||||
return INIT_DONE_STRING;
|
||||
case(2212):
|
||||
return DUMP_FINISHED_STRING;
|
||||
case(2213):
|
||||
return DELETION_FINISHED_STRING;
|
||||
case(2214):
|
||||
return DELETION_FAILED_STRING;
|
||||
case(2215):
|
||||
return AUTO_CATALOGS_SENDING_FAILED_STRING;
|
||||
case(2600):
|
||||
return GET_DATA_FAILED_STRING;
|
||||
case(2601):
|
||||
return STORE_DATA_FAILED_STRING;
|
||||
case(2800):
|
||||
return DEVICE_BUILDING_COMMAND_FAILED_STRING;
|
||||
case(2801):
|
||||
return DEVICE_SENDING_COMMAND_FAILED_STRING;
|
||||
case(2802):
|
||||
return DEVICE_REQUESTING_REPLY_FAILED_STRING;
|
||||
case(2803):
|
||||
return DEVICE_READING_REPLY_FAILED_STRING;
|
||||
case(2804):
|
||||
return DEVICE_INTERPRETING_REPLY_FAILED_STRING;
|
||||
case(2805):
|
||||
return DEVICE_MISSED_REPLY_STRING;
|
||||
case(2806):
|
||||
return DEVICE_UNKNOWN_REPLY_STRING;
|
||||
case(2807):
|
||||
return DEVICE_UNREQUESTED_REPLY_STRING;
|
||||
case(2808):
|
||||
return INVALID_DEVICE_COMMAND_STRING;
|
||||
case(2809):
|
||||
return MONITORING_LIMIT_EXCEEDED_STRING;
|
||||
case(2810):
|
||||
return MONITORING_AMBIGUOUS_STRING;
|
||||
case(4201):
|
||||
return FUSE_CURRENT_HIGH_STRING;
|
||||
case(4202):
|
||||
return FUSE_WENT_OFF_STRING;
|
||||
case(4204):
|
||||
return POWER_ABOVE_HIGH_LIMIT_STRING;
|
||||
case(4205):
|
||||
return POWER_BELOW_LOW_LIMIT_STRING;
|
||||
case(4300):
|
||||
return SWITCH_WENT_OFF_STRING;
|
||||
case(5000):
|
||||
return HEATER_ON_STRING;
|
||||
case(5001):
|
||||
return HEATER_OFF_STRING;
|
||||
case(5002):
|
||||
return HEATER_TIMEOUT_STRING;
|
||||
case(5003):
|
||||
return HEATER_STAYED_ON_STRING;
|
||||
case(5004):
|
||||
return HEATER_STAYED_OFF_STRING;
|
||||
case(5200):
|
||||
return TEMP_SENSOR_HIGH_STRING;
|
||||
case(5201):
|
||||
return TEMP_SENSOR_LOW_STRING;
|
||||
case(5202):
|
||||
return TEMP_SENSOR_GRADIENT_STRING;
|
||||
case(5901):
|
||||
return COMPONENT_TEMP_LOW_STRING;
|
||||
case(5902):
|
||||
return COMPONENT_TEMP_HIGH_STRING;
|
||||
case(5903):
|
||||
return COMPONENT_TEMP_OOL_LOW_STRING;
|
||||
case(5904):
|
||||
return COMPONENT_TEMP_OOL_HIGH_STRING;
|
||||
case(5905):
|
||||
return TEMP_NOT_IN_OP_RANGE_STRING;
|
||||
case(7101):
|
||||
return FDIR_CHANGED_STATE_STRING;
|
||||
case(7102):
|
||||
return FDIR_STARTS_RECOVERY_STRING;
|
||||
case(7103):
|
||||
return FDIR_TURNS_OFF_DEVICE_STRING;
|
||||
case(7201):
|
||||
return MONITOR_CHANGED_STATE_STRING;
|
||||
case(7202):
|
||||
return VALUE_BELOW_LOW_LIMIT_STRING;
|
||||
case(7203):
|
||||
return VALUE_ABOVE_HIGH_LIMIT_STRING;
|
||||
case(7204):
|
||||
return VALUE_OUT_OF_RANGE_STRING;
|
||||
case(7301):
|
||||
return SWITCHING_TM_FAILED_STRING;
|
||||
case(7400):
|
||||
return CHANGING_MODE_STRING;
|
||||
case(7401):
|
||||
return MODE_INFO_STRING;
|
||||
case(7402):
|
||||
return FALLBACK_FAILED_STRING;
|
||||
case(7403):
|
||||
return MODE_TRANSITION_FAILED_STRING;
|
||||
case(7404):
|
||||
return CANT_KEEP_MODE_STRING;
|
||||
case(7405):
|
||||
return OBJECT_IN_INVALID_MODE_STRING;
|
||||
case(7406):
|
||||
return FORCING_MODE_STRING;
|
||||
case(7407):
|
||||
return MODE_CMD_REJECTED_STRING;
|
||||
case(7506):
|
||||
return HEALTH_INFO_STRING;
|
||||
case(7507):
|
||||
return CHILD_CHANGED_HEALTH_STRING;
|
||||
case(7508):
|
||||
return CHILD_PROBLEMS_STRING;
|
||||
case(7509):
|
||||
return OVERWRITING_HEALTH_STRING;
|
||||
case(7510):
|
||||
return TRYING_RECOVERY_STRING;
|
||||
case(7511):
|
||||
return RECOVERY_STEP_STRING;
|
||||
case(7512):
|
||||
return RECOVERY_DONE_STRING;
|
||||
case(7900):
|
||||
return RF_AVAILABLE_STRING;
|
||||
case(7901):
|
||||
return RF_LOST_STRING;
|
||||
case(7902):
|
||||
return BIT_LOCK_STRING;
|
||||
case(7903):
|
||||
return BIT_LOCK_LOST_STRING;
|
||||
case(7905):
|
||||
return FRAME_PROCESSING_FAILED_STRING;
|
||||
case(8900):
|
||||
return CLOCK_SET_STRING;
|
||||
case(8901):
|
||||
return CLOCK_SET_FAILURE_STRING;
|
||||
case(9700):
|
||||
return TEST_STRING;
|
||||
default:
|
||||
return "UNKNOWN_EVENT";
|
||||
}
|
||||
return 0;
|
||||
}
|
8
bsp_hosted/fsfwconfig/events/translateEvents.h
Normal file
8
bsp_hosted/fsfwconfig/events/translateEvents.h
Normal file
@ -0,0 +1,8 @@
|
||||
#ifndef FSFWCONFIG_EVENTS_TRANSLATEEVENTS_H_
|
||||
#define FSFWCONFIG_EVENTS_TRANSLATEEVENTS_H_
|
||||
|
||||
#include <fsfw/events/Event.h>
|
||||
|
||||
const char * translateEvents(Event event);
|
||||
|
||||
#endif /* FSFWCONFIG_EVENTS_TRANSLATEEVENTS_H_ */
|
16
generators/definitions.py
Normal file
16
generators/definitions.py
Normal file
@ -0,0 +1,16 @@
|
||||
import enum
|
||||
|
||||
|
||||
class BspSelect(enum.Enum):
|
||||
BSP_HOSTED = enum.auto()
|
||||
BSP_LINUX = enum.auto()
|
||||
BSP_STM32_FREERTOS = enum.auto()
|
||||
BSP_STM32_RTEMS = enum.auto()
|
||||
|
||||
|
||||
BspFolderDict = {
|
||||
BspSelect.BSP_HOSTED.value: "bsp_hosted",
|
||||
BspSelect.BSP_LINUX.value: "bsp_linux",
|
||||
BspSelect.BSP_STM32_FREERTOS.value: "bsp_stm32_freertos",
|
||||
BspSelect.BSP_STM32_RTEMS.value: "bsp_stm32_rtems",
|
||||
}
|
92
generators/events/event_parser.py
Normal file
92
generators/events/event_parser.py
Normal file
@ -0,0 +1,92 @@
|
||||
#! /usr/bin/python3
|
||||
"""
|
||||
@file event_parser.py
|
||||
@brief Part of the Mission Information Base Exporter for the SOURCE project by KSat.
|
||||
@details
|
||||
Event 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
|
||||
|
||||
from modgen.events.event_parser import handle_csv_export, handle_cpp_export, SubsystemDefinitionParser, EventParser
|
||||
from modgen.parserbase.file_list_parser import FileListParser
|
||||
from modgen.utility.mib_printer import PrettyPrinter
|
||||
|
||||
from definitions import BspSelect, BspFolderDict
|
||||
from utility.mib_file_management import copy_file, move_file
|
||||
|
||||
# TODO: Ask from user or store in json file?
|
||||
BSP_SELECT = BspSelect.BSP_HOSTED.value
|
||||
BSP_FOLDER = BspFolderDict[BSP_SELECT]
|
||||
DATE_TODAY = datetime.datetime.now()
|
||||
DATE_STRING_FULL = DATE_TODAY.strftime("%Y-%m-%d %H:%M:%S")
|
||||
|
||||
GENERATE_CPP = True
|
||||
GENERATE_CPP_H = True
|
||||
GENERATE_CSV = True
|
||||
COPY_CPP_FILE = True
|
||||
COPY_CPP_H_FILE = True
|
||||
MOVE_CSV_FILE = True
|
||||
|
||||
PARSE_HOST_BSP = True
|
||||
|
||||
CSV_FILENAME = "mib_events.csv"
|
||||
CSV_MOVE_DESTINATION = "../"
|
||||
|
||||
CPP_FILENAME = "translateEvents.cpp"
|
||||
CPP_H_FILENAME = "translateEvents.h"
|
||||
|
||||
CPP_COPY_DESTINATION = f"../../{BSP_FOLDER}/fsfwconfig/events/"
|
||||
|
||||
FILE_SEPARATOR = ";"
|
||||
SUBSYSTEM_DEFINITION_DESTINATIONS = [
|
||||
f"../../{BSP_FOLDER}/fsfwconfig/events/subsystemIdRanges.h",
|
||||
"../../fsfw/events/fwSubsystemIdRanges.h"
|
||||
]
|
||||
HEADER_DEFINITION_DESTINATIONS = ["../../mission/", "../../fsfw/", f"../../{BSP_FOLDER}", "../../test/"]
|
||||
|
||||
|
||||
def main():
|
||||
print("EventParser: Parsing events: ")
|
||||
event_list = parse_events()
|
||||
if GENERATE_CSV:
|
||||
handle_csv_export(file_name=CSV_FILENAME, event_list=event_list, file_separator=FILE_SEPARATOR)
|
||||
if MOVE_CSV_FILE:
|
||||
move_file(file_name=CSV_FILENAME, destination=CSV_MOVE_DESTINATION)
|
||||
if GENERATE_CPP:
|
||||
handle_cpp_export(
|
||||
event_list=event_list, date_string=DATE_STRING_FULL, file_name=CPP_FILENAME,
|
||||
generate_header=GENERATE_CPP_H, header_file_name=CPP_H_FILENAME
|
||||
)
|
||||
if COPY_CPP_FILE:
|
||||
print(f"EventParser: Copying file to {CPP_COPY_DESTINATION}")
|
||||
copy_file(CPP_FILENAME, CPP_COPY_DESTINATION)
|
||||
copy_file(CPP_H_FILENAME, CPP_COPY_DESTINATION)
|
||||
print("")
|
||||
|
||||
|
||||
def parse_events():
|
||||
subsystem_parser = SubsystemDefinitionParser(SUBSYSTEM_DEFINITION_DESTINATIONS)
|
||||
subsystem_table = subsystem_parser.parse_files()
|
||||
print(f"Found {len(subsystem_table)} subsystem definitions.")
|
||||
PrettyPrinter.pprint(subsystem_table)
|
||||
event_header_parser = FileListParser(HEADER_DEFINITION_DESTINATIONS)
|
||||
event_headers = event_header_parser.parse_header_files(
|
||||
True, "Parsing event header file list:\n", True
|
||||
)
|
||||
# PrettyPrinter.pprint(event_headers)
|
||||
# myEventList = parseHeaderFiles(subsystem_table, event_headers)
|
||||
event_parser = EventParser(event_headers, subsystem_table)
|
||||
event_parser.set_moving_window_mode(moving_window_size=7)
|
||||
event_table = event_parser.parse_files()
|
||||
list_items = sorted(event_table.items())
|
||||
print(f"Found {len(list_items)} entries:")
|
||||
PrettyPrinter.pprint(list_items)
|
||||
return list_items
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
@ -1,223 +0,0 @@
|
||||
#! /usr/bin/python3.8
|
||||
"""
|
||||
@file mib_events.py
|
||||
@brief Part of the Mission Information Base Exporter for the SOURCE project by KSat.
|
||||
@details
|
||||
Event 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 re
|
||||
import datetime
|
||||
from parserbase.mib_file_list_parser import FileListParser
|
||||
from parserbase.mib_parser import FileParser
|
||||
from utility.mib_printer import PrettyPrinter
|
||||
from utility.mib_file_management import copy_file, move_file
|
||||
|
||||
DATE_TODAY = datetime.datetime.now()
|
||||
DATE_STRING_FULL = DATE_TODAY.strftime("%Y-%m-%d %H:%M:%S")
|
||||
|
||||
GENERATE_CPP = True
|
||||
GENERATE_CSV = True
|
||||
COPY_CPP_FILE = True
|
||||
MOVE_CSV_FILE = True
|
||||
|
||||
CSV_FILENAME = "mib_events.csv"
|
||||
CSV_MOVE_DESTINATION = "../"
|
||||
|
||||
CPP_FILENAME = "translateEvents.cpp"
|
||||
CPP_COPY_DESTINATION = "../../config/events/"
|
||||
|
||||
FILE_SEPARATOR = ";"
|
||||
SUBSYSTEM_DEFINITION_DESTINATIONS = ["../../config/tmtc/subsystemIdRanges.h",
|
||||
"../../fsfw/events/fwSubsystemIdRanges.h"]
|
||||
HEADER_DEFINITION_DESTINATIONS = ["../../mission/", "../../fsfw/"]
|
||||
|
||||
|
||||
def main():
|
||||
print("EventParser: Parsing events: ")
|
||||
event_list = parse_events()
|
||||
if GENERATE_CSV:
|
||||
handle_csv_export(CSV_FILENAME, event_list)
|
||||
if MOVE_CSV_FILE:
|
||||
move_file(CSV_FILENAME, CSV_MOVE_DESTINATION)
|
||||
if GENERATE_CPP:
|
||||
handle_cpp_export(CPP_FILENAME, event_list)
|
||||
if COPY_CPP_FILE:
|
||||
print("EventParser: Copying file to " + CPP_COPY_DESTINATION)
|
||||
copy_file(CPP_FILENAME, CPP_COPY_DESTINATION)
|
||||
print("")
|
||||
|
||||
|
||||
def parse_events():
|
||||
subsystem_parser = SubsystemDefinitionParser(SUBSYSTEM_DEFINITION_DESTINATIONS)
|
||||
subsystem_table = subsystem_parser.parse_files()
|
||||
print("Found " + str(len(subsystem_table)) + " subsystem definitions.")
|
||||
PrettyPrinter.pprint(subsystem_table)
|
||||
event_header_parser = FileListParser(HEADER_DEFINITION_DESTINATIONS)
|
||||
event_headers = event_header_parser.parse_header_files(
|
||||
True, "Parsing event header file list:\n", True)
|
||||
# g.PP.pprint(event_headers)
|
||||
# myEventList = parseHeaderFiles(subsystem_table, event_headers)
|
||||
event_parser = EventParser(event_headers, subsystem_table)
|
||||
event_table = event_parser.parse_files()
|
||||
list_items = sorted(event_table.items())
|
||||
print("Found " + str(len(list_items)) + " entries:")
|
||||
PrettyPrinter.pprint(list_items)
|
||||
return list_items
|
||||
|
||||
|
||||
class SubsystemDefinitionParser(FileParser):
|
||||
def __init__(self, file_list):
|
||||
super().__init__(file_list)
|
||||
|
||||
def _handle_file_parsing(self, file_name: str, *args, **kwargs):
|
||||
file = open(file_name, "r")
|
||||
for line in file.readlines():
|
||||
match = re.search(r'([A-Z0-9_]*) = ([0-9]{1,2})', line)
|
||||
if match:
|
||||
self.mib_table.update({match.group(1): [match.group(2)]})
|
||||
|
||||
def _post_parsing_operation(self):
|
||||
pass
|
||||
|
||||
|
||||
class EventParser(FileParser):
|
||||
def __init__(self, file_list, interface_list):
|
||||
super().__init__(file_list)
|
||||
self.interfaces = interface_list
|
||||
self.count = 0
|
||||
self.myId = 0
|
||||
self.currentId = 0
|
||||
self.last_lines = ["", "", ""]
|
||||
|
||||
def _handle_file_parsing(self, file_name: str, *args: any, **kwargs):
|
||||
try:
|
||||
file = open(file_name, 'r', encoding='utf-8')
|
||||
all_lines = file.readlines()
|
||||
except UnicodeDecodeError:
|
||||
file = open(file_name, 'r', encoding='cp1252')
|
||||
all_lines = file.readlines()
|
||||
total_count = 0
|
||||
for line in all_lines:
|
||||
self.__handle_line_reading(line, file_name)
|
||||
if self.count > 0:
|
||||
print("File " + file_name + " contained " + str(self.count) + " events.")
|
||||
total_count += self.count
|
||||
self.count = 0
|
||||
|
||||
def _post_parsing_operation(self):
|
||||
pass
|
||||
|
||||
def __handle_line_reading(self, line, file_name):
|
||||
if not self.last_lines[0] == '\n':
|
||||
twolines = self.last_lines[0] + ' ' + line.strip()
|
||||
else:
|
||||
twolines = ''
|
||||
match1 = re.search('SUBSYSTEM_ID[\s]*=[\s]*SUBSYSTEM_ID::([A-Z_0-9]*);', twolines)
|
||||
if match1:
|
||||
self.currentId = self.interfaces[match1.group(1)][0]
|
||||
# print( "Current ID: " + str(currentId) )
|
||||
self.myId = self.return_number_from_string(self.currentId)
|
||||
match = re.search(
|
||||
'(//)?[\t ]*static const(?:expr)? Event[\s]*([A-Z_0-9]*)[\s]*=[\s]*'
|
||||
'MAKE_EVENT\(([0-9]{1,2}),[\s]*SEVERITY::([A-Z]*)\);[\t ]*(//!<)?([^\n]*)', twolines)
|
||||
if match:
|
||||
if match.group(1):
|
||||
self.last_lines[0] = line
|
||||
return
|
||||
description = " "
|
||||
if match.group(6):
|
||||
description = self.clean_up_description(match.group(6))
|
||||
string_to_add = match.group(2)
|
||||
full_id = (self.myId * 100) + self.return_number_from_string(match.group(3))
|
||||
severity = match.group(4)
|
||||
if full_id in self.mib_table:
|
||||
# print("EventParser: Duplicate Event " + hex(full_id) + " from " + file_name +
|
||||
# " was already in " + self.mib_table[full_id][3])
|
||||
pass
|
||||
self.mib_table.update({full_id: (string_to_add, severity, description, file_name)})
|
||||
self.count = self.count + 1
|
||||
self.last_lines[0] = line
|
||||
|
||||
def build_checked_string(self, first_part, second_part):
|
||||
my_str = first_part + self.convert(second_part)
|
||||
if len(my_str) > 16:
|
||||
print("EventParser: Entry: " + my_str + " too long. Will truncate.")
|
||||
my_str = my_str[0:14]
|
||||
# else:
|
||||
# print( "Entry: " + myStr + " is all right.")
|
||||
return my_str
|
||||
|
||||
@staticmethod
|
||||
def return_number_from_string(a_string):
|
||||
if a_string.startswith('0x'):
|
||||
return int(a_string, 16)
|
||||
elif a_string.isdigit():
|
||||
return int(a_string)
|
||||
else:
|
||||
print('EventParser: Illegal number representation: ' + a_string)
|
||||
return 0
|
||||
|
||||
@staticmethod
|
||||
def convert(name):
|
||||
single_strings = name.split('_')
|
||||
new_string = ''
|
||||
for one_string in single_strings:
|
||||
one_string = one_string.lower()
|
||||
one_string = one_string.capitalize()
|
||||
new_string = new_string + one_string
|
||||
return new_string
|
||||
|
||||
@staticmethod
|
||||
def clean_up_description(description):
|
||||
description = description.lstrip('//!<>')
|
||||
description = description.lstrip()
|
||||
if description == '':
|
||||
description = ' '
|
||||
return description
|
||||
|
||||
|
||||
def export_to_file(filename, list_of_entries):
|
||||
print("EventParser: Exporting to file: " + filename)
|
||||
file = open(filename, "w")
|
||||
for entry in list_of_entries:
|
||||
file.write(str(entry[0]) + FILE_SEPARATOR + entry[1][0] + FILE_SEPARATOR + entry[1][1]
|
||||
+ FILE_SEPARATOR + entry[1][2] + FILE_SEPARATOR + entry[1][3] + '\n')
|
||||
file.close()
|
||||
return
|
||||
|
||||
|
||||
def write_translation_file(filename, list_of_entries):
|
||||
outputfile = open(filename, "w")
|
||||
definitions = ""
|
||||
|
||||
function = "const char * translateEvents(Event event){\n\tswitch((event&0xFFFF)){\n"
|
||||
for entry in list_of_entries:
|
||||
definitions += "const char *" + entry[1][0] + "_STRING = \"" + entry[1][0] + "\";\n"
|
||||
function += "\t\tcase " + str(entry[0]) + ":\n\t\t\treturn " + entry[1][0] + "_STRING;\n"
|
||||
function += '\t\tdefault:\n\t\t\treturn "UNKNOWN_EVENT";\n'
|
||||
outputfile.write("/**\n * @brief Auto-generated event translation file. "
|
||||
"Contains " + str(len(list_of_entries)) + " translations.\n"
|
||||
" * Generated on: " + DATE_STRING_FULL +
|
||||
" \n */\n")
|
||||
outputfile.write("#include \"translateEvents.h\"\n\n")
|
||||
outputfile.write(definitions + "\n" + function + "\t}\n\treturn 0;\n}\n")
|
||||
outputfile.close()
|
||||
|
||||
|
||||
def handle_csv_export(file_name: str, list_items: list):
|
||||
"""
|
||||
Generates the CSV in the same directory as the .py file and copes the CSV to another
|
||||
directory if specified.
|
||||
"""
|
||||
export_to_file(file_name, list_items)
|
||||
|
||||
def handle_cpp_export(file_name: str, list_items):
|
||||
print("EventParser: Generating translation cpp file.")
|
||||
write_translation_file(file_name, list_items)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
@ -1,6 +1,7 @@
|
||||
/**
|
||||
* @brief Auto-generated event translation file. Contains 78 translations.
|
||||
* Generated on: 2020-09-30 15:17:26
|
||||
* @details
|
||||
* Generated on: 2021-05-14 11:51:26
|
||||
*/
|
||||
#include "translateEvents.h"
|
||||
|
||||
@ -83,163 +84,163 @@ const char *CLOCK_SET_STRING = "CLOCK_SET";
|
||||
const char *CLOCK_SET_FAILURE_STRING = "CLOCK_SET_FAILURE";
|
||||
const char *TEST_STRING = "TEST";
|
||||
|
||||
const char * translateEvents(Event event){
|
||||
switch((event&0xFFFF)){
|
||||
case 2200:
|
||||
const char * translateEvents(Event event) {
|
||||
switch( (event & 0xffff) ) {
|
||||
case(2200):
|
||||
return STORE_SEND_WRITE_FAILED_STRING;
|
||||
case 2201:
|
||||
case(2201):
|
||||
return STORE_WRITE_FAILED_STRING;
|
||||
case 2202:
|
||||
case(2202):
|
||||
return STORE_SEND_READ_FAILED_STRING;
|
||||
case 2203:
|
||||
case(2203):
|
||||
return STORE_READ_FAILED_STRING;
|
||||
case 2204:
|
||||
case(2204):
|
||||
return UNEXPECTED_MSG_STRING;
|
||||
case 2205:
|
||||
case(2205):
|
||||
return STORING_FAILED_STRING;
|
||||
case 2206:
|
||||
case(2206):
|
||||
return TM_DUMP_FAILED_STRING;
|
||||
case 2207:
|
||||
case(2207):
|
||||
return STORE_INIT_FAILED_STRING;
|
||||
case 2208:
|
||||
case(2208):
|
||||
return STORE_INIT_EMPTY_STRING;
|
||||
case 2209:
|
||||
case(2209):
|
||||
return STORE_CONTENT_CORRUPTED_STRING;
|
||||
case 2210:
|
||||
case(2210):
|
||||
return STORE_INITIALIZE_STRING;
|
||||
case 2211:
|
||||
case(2211):
|
||||
return INIT_DONE_STRING;
|
||||
case 2212:
|
||||
case(2212):
|
||||
return DUMP_FINISHED_STRING;
|
||||
case 2213:
|
||||
case(2213):
|
||||
return DELETION_FINISHED_STRING;
|
||||
case 2214:
|
||||
case(2214):
|
||||
return DELETION_FAILED_STRING;
|
||||
case 2215:
|
||||
case(2215):
|
||||
return AUTO_CATALOGS_SENDING_FAILED_STRING;
|
||||
case 2600:
|
||||
case(2600):
|
||||
return GET_DATA_FAILED_STRING;
|
||||
case 2601:
|
||||
case(2601):
|
||||
return STORE_DATA_FAILED_STRING;
|
||||
case 2800:
|
||||
case(2800):
|
||||
return DEVICE_BUILDING_COMMAND_FAILED_STRING;
|
||||
case 2801:
|
||||
case(2801):
|
||||
return DEVICE_SENDING_COMMAND_FAILED_STRING;
|
||||
case 2802:
|
||||
case(2802):
|
||||
return DEVICE_REQUESTING_REPLY_FAILED_STRING;
|
||||
case 2803:
|
||||
case(2803):
|
||||
return DEVICE_READING_REPLY_FAILED_STRING;
|
||||
case 2804:
|
||||
case(2804):
|
||||
return DEVICE_INTERPRETING_REPLY_FAILED_STRING;
|
||||
case 2805:
|
||||
case(2805):
|
||||
return DEVICE_MISSED_REPLY_STRING;
|
||||
case 2806:
|
||||
case(2806):
|
||||
return DEVICE_UNKNOWN_REPLY_STRING;
|
||||
case 2807:
|
||||
case(2807):
|
||||
return DEVICE_UNREQUESTED_REPLY_STRING;
|
||||
case 2808:
|
||||
case(2808):
|
||||
return INVALID_DEVICE_COMMAND_STRING;
|
||||
case 2809:
|
||||
case(2809):
|
||||
return MONITORING_LIMIT_EXCEEDED_STRING;
|
||||
case 2810:
|
||||
case(2810):
|
||||
return MONITORING_AMBIGUOUS_STRING;
|
||||
case 4201:
|
||||
case(4201):
|
||||
return FUSE_CURRENT_HIGH_STRING;
|
||||
case 4202:
|
||||
case(4202):
|
||||
return FUSE_WENT_OFF_STRING;
|
||||
case 4204:
|
||||
case(4204):
|
||||
return POWER_ABOVE_HIGH_LIMIT_STRING;
|
||||
case 4205:
|
||||
case(4205):
|
||||
return POWER_BELOW_LOW_LIMIT_STRING;
|
||||
case 4300:
|
||||
case(4300):
|
||||
return SWITCH_WENT_OFF_STRING;
|
||||
case 5000:
|
||||
case(5000):
|
||||
return HEATER_ON_STRING;
|
||||
case 5001:
|
||||
case(5001):
|
||||
return HEATER_OFF_STRING;
|
||||
case 5002:
|
||||
case(5002):
|
||||
return HEATER_TIMEOUT_STRING;
|
||||
case 5003:
|
||||
case(5003):
|
||||
return HEATER_STAYED_ON_STRING;
|
||||
case 5004:
|
||||
case(5004):
|
||||
return HEATER_STAYED_OFF_STRING;
|
||||
case 5200:
|
||||
case(5200):
|
||||
return TEMP_SENSOR_HIGH_STRING;
|
||||
case 5201:
|
||||
case(5201):
|
||||
return TEMP_SENSOR_LOW_STRING;
|
||||
case 5202:
|
||||
case(5202):
|
||||
return TEMP_SENSOR_GRADIENT_STRING;
|
||||
case 5901:
|
||||
case(5901):
|
||||
return COMPONENT_TEMP_LOW_STRING;
|
||||
case 5902:
|
||||
case(5902):
|
||||
return COMPONENT_TEMP_HIGH_STRING;
|
||||
case 5903:
|
||||
case(5903):
|
||||
return COMPONENT_TEMP_OOL_LOW_STRING;
|
||||
case 5904:
|
||||
case(5904):
|
||||
return COMPONENT_TEMP_OOL_HIGH_STRING;
|
||||
case 5905:
|
||||
case(5905):
|
||||
return TEMP_NOT_IN_OP_RANGE_STRING;
|
||||
case 7101:
|
||||
case(7101):
|
||||
return FDIR_CHANGED_STATE_STRING;
|
||||
case 7102:
|
||||
case(7102):
|
||||
return FDIR_STARTS_RECOVERY_STRING;
|
||||
case 7103:
|
||||
case(7103):
|
||||
return FDIR_TURNS_OFF_DEVICE_STRING;
|
||||
case 7201:
|
||||
case(7201):
|
||||
return MONITOR_CHANGED_STATE_STRING;
|
||||
case 7202:
|
||||
case(7202):
|
||||
return VALUE_BELOW_LOW_LIMIT_STRING;
|
||||
case 7203:
|
||||
case(7203):
|
||||
return VALUE_ABOVE_HIGH_LIMIT_STRING;
|
||||
case 7204:
|
||||
case(7204):
|
||||
return VALUE_OUT_OF_RANGE_STRING;
|
||||
case 7301:
|
||||
case(7301):
|
||||
return SWITCHING_TM_FAILED_STRING;
|
||||
case 7400:
|
||||
case(7400):
|
||||
return CHANGING_MODE_STRING;
|
||||
case 7401:
|
||||
case(7401):
|
||||
return MODE_INFO_STRING;
|
||||
case 7402:
|
||||
case(7402):
|
||||
return FALLBACK_FAILED_STRING;
|
||||
case 7403:
|
||||
case(7403):
|
||||
return MODE_TRANSITION_FAILED_STRING;
|
||||
case 7404:
|
||||
case(7404):
|
||||
return CANT_KEEP_MODE_STRING;
|
||||
case 7405:
|
||||
case(7405):
|
||||
return OBJECT_IN_INVALID_MODE_STRING;
|
||||
case 7406:
|
||||
case(7406):
|
||||
return FORCING_MODE_STRING;
|
||||
case 7407:
|
||||
case(7407):
|
||||
return MODE_CMD_REJECTED_STRING;
|
||||
case 7506:
|
||||
case(7506):
|
||||
return HEALTH_INFO_STRING;
|
||||
case 7507:
|
||||
case(7507):
|
||||
return CHILD_CHANGED_HEALTH_STRING;
|
||||
case 7508:
|
||||
case(7508):
|
||||
return CHILD_PROBLEMS_STRING;
|
||||
case 7509:
|
||||
case(7509):
|
||||
return OVERWRITING_HEALTH_STRING;
|
||||
case 7510:
|
||||
case(7510):
|
||||
return TRYING_RECOVERY_STRING;
|
||||
case 7511:
|
||||
case(7511):
|
||||
return RECOVERY_STEP_STRING;
|
||||
case 7512:
|
||||
case(7512):
|
||||
return RECOVERY_DONE_STRING;
|
||||
case 7900:
|
||||
case(7900):
|
||||
return RF_AVAILABLE_STRING;
|
||||
case 7901:
|
||||
case(7901):
|
||||
return RF_LOST_STRING;
|
||||
case 7902:
|
||||
case(7902):
|
||||
return BIT_LOCK_STRING;
|
||||
case 7903:
|
||||
case(7903):
|
||||
return BIT_LOCK_LOST_STRING;
|
||||
case 7905:
|
||||
case(7905):
|
||||
return FRAME_PROCESSING_FAILED_STRING;
|
||||
case 8900:
|
||||
case(8900):
|
||||
return CLOCK_SET_STRING;
|
||||
case 8901:
|
||||
case(8901):
|
||||
return CLOCK_SET_FAILURE_STRING;
|
||||
case 9700:
|
||||
case(9700):
|
||||
return TEST_STRING;
|
||||
default:
|
||||
return "UNKNOWN_EVENT";
|
||||
|
8
generators/events/translateEvents.h
Normal file
8
generators/events/translateEvents.h
Normal file
@ -0,0 +1,8 @@
|
||||
#ifndef FSFWCONFIG_EVENTS_TRANSLATEEVENTS_H_
|
||||
#define FSFWCONFIG_EVENTS_TRANSLATEEVENTS_H_
|
||||
|
||||
#include <fsfw/events/Event.h>
|
||||
|
||||
const char * translateEvents(Event event);
|
||||
|
||||
#endif /* FSFWCONFIG_EVENTS_TRANSLATEEVENTS_H_ */
|
@ -1,7 +1,7 @@
|
||||
#! /usr/bin/python3.8
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
@file mib_exporter.py
|
||||
@file mod_exporter.py
|
||||
@brief Mission Information Base Exporter for the SOURCE project by KSat.
|
||||
@details
|
||||
Parses OBSW which is based on FSFW developed by the Institute of Space Systems (IRS) Stuttgart.
|
||||
@ -315,7 +315,7 @@ def handle_external_file_running():
|
||||
TODO: Make this stuff OOP too. Retvals and objects were already refactored
|
||||
"""
|
||||
os.chdir("events")
|
||||
os.system("python mib_events.py")
|
||||
os.system("python event_parser.py")
|
||||
os.chdir("..")
|
||||
print_string = "Exported to file: MIB_Events.csv\r\n"
|
||||
return print_string
|
Reference in New Issue
Block a user