Index: leahi_dialin/fp/modules/events.py =================================================================== diff -u -r7d9d004527efeccb91958b440abdff08c2c52648 -re60ad12bcc58d5905d7268bbeaae139d8233e023 --- leahi_dialin/fp/modules/events.py (.../events.py) (revision 7d9d004527efeccb91958b440abdff08c2c52648) +++ leahi_dialin/fp/modules/events.py (.../events.py) (revision e60ad12bcc58d5905d7268bbeaae139d8233e023) @@ -16,7 +16,7 @@ import struct from logging import Logger -from leahi_dialin.common import * +from leahi_dialin.common.fp_defs import fp_enum_repository from leahi_dialin.common.msg_defs import MsgIds, MsgFieldPositions from leahi_dialin.protocols.CAN import DenaliChannels from leahi_dialin.utils.base import AbstractSubSystem, publish @@ -59,24 +59,24 @@ self._fp_event_data_type = dict() # Dictionary of the mode as key and the sub mode states enum class as the value - self._fp_op_mode_2_sub_mode = {FPOpModes.MODE_FAUL.name: FPFaultStates, - FPOpModes.MODE_SERV.name: FPServiceStates, - FPOpModes.MODE_INIT.name: FPPostStates, - FPOpModes.MODE_STAN.name: FPStandbyStates, - FPOpModes.MODE_PRE_GENP.name: FPPreGenPermeateStates, - FPOpModes.MODE_GENP.name: FPGenPermeateStates, - FPOpModes.MODE_DPGP.name: FPPreGenPDefStates, - FPOpModes.MODE_DEGP.name: FPGenPermeateDefStates, - FPOpModes.MODE_NLEG.name: FPNotLegalStates} + self._fp_op_mode_2_sub_mode = {fp_enum_repository.FPOpModes.MODE_FAUL.name: fp_enum_repository.FPFaultStates, + fp_enum_repository.FPOpModes.MODE_SERV.name: fp_enum_repository.FPServiceStates, + fp_enum_repository.FPOpModes.MODE_INIT.name: fp_enum_repository.FPPostStates, + fp_enum_repository.FPOpModes.MODE_STAN.name: fp_enum_repository.FPStandbyStates, + fp_enum_repository.FPOpModes.MODE_PRE_GENP.name: fp_enum_repository.FPPreGenPermeateStates, + fp_enum_repository.FPOpModes.MODE_GENP.name: fp_enum_repository.FPGenPermeateStates, + fp_enum_repository.FPOpModes.MODE_DPGP.name: fp_enum_repository.FPPreGenPDefStates, + fp_enum_repository.FPOpModes.MODE_DEGP.name: fp_enum_repository.FPGenPermeateDefStates, + fp_enum_repository.FPOpModes.MODE_NLEG.name: fp_enum_repository.FPNotLegalStates} # Loop through the list of the FP events enums and initial the event dictionary. Each event is a key in the # dictionary and the value is a list. - for event in FPEventList: - self._fp_event_dictionary[FPEventList(event).name] = [] + for event in fp_enum_repository.FPEventList: + self._fp_event_dictionary[fp_enum_repository.FPEventList(event).name] = [] # Loop through the list of the event data type enum and update the dictionary - for data_type in FPEventDataType: - event_data_type = FPEventDataType(data_type).name + for data_type in fp_enum_repository.FPEventDataTypes: + event_data_type = fp_enum_repository.FPEventDataTypes(data_type).name struct_unpack_type = None # If U32 is in the data type enum (i.e. EVENT_DATA_TYPE_U32), then the key is the enum and the value is @@ -99,14 +99,14 @@ @returns the requested FP event number """ - list_length = len(self._fp_event_dictionary[FPEventList(event_id).name]) + list_length = len(self._fp_event_dictionary[fp_enum_repository.FPEventList(event_id).name]) if list_length == 0: event = [] elif event_number > list_length: - event = self._fp_event_dictionary[FPEventList(event_id).name][list_length - 1] + event = self._fp_event_dictionary[fp_enum_repository.FPEventList(event_id).name][list_length - 1] else: - event = self._fp_event_dictionary[FPEventList(event_id).name][list_length - event_number - 1] + event = self._fp_event_dictionary[fp_enum_repository.FPEventList(event_id).name][list_length - event_number - 1] return event @@ -131,18 +131,18 @@ list_of_events = [] # If there are not enough event lists send all the events that are available - if len(self._fp_event_dictionary[FPEventList(event_id).name]) <= number_of_events: - list_of_events = self._fp_event_dictionary[FPEventList(event_id).name] + if len(self._fp_event_dictionary[fp_enum_repository.FPEventList(event_id).name]) <= number_of_events: + list_of_events = self._fp_event_dictionary[fp_enum_repository.FPEventList(event_id).name] else: # Get the all the events - complete_list = self._fp_event_dictionary[FPEventList(event_id).name] + complete_list = self._fp_event_dictionary[fp_enum_repository.FPEventList(event_id).name] # Since the last are located at the end of the list, iterate backwards for the defined # event messages for i in range(len(complete_list) - 1, len(complete_list) - number_of_events - 1, -1): list_of_events.append(complete_list[i]) if number_of_events == 0: - list_of_events = self._fp_event_dictionary[FPEventList(event_id).name] + list_of_events = self._fp_event_dictionary[fp_enum_repository.FPEventList(event_id).name] return list_of_events @@ -164,11 +164,11 @@ event_id = struct.unpack('i', bytearray( message['message'][MsgFieldPositions.START_POS_FIELD_1:MsgFieldPositions.END_POS_FIELD_1]))[0] - if event_id == FPEventList.FP_EVENT_OPERATION_STATUS.value: + if event_id == fp_enum_repository.FPEventList.FP_EVENT_OPERATION_STATUS.value: # Get the data type event_data_type_1 = struct.unpack('i', bytearray( message['message'][MsgFieldPositions.START_POS_FIELD_2:MsgFieldPositions.END_POS_FIELD_2]))[0] - struct_data_type = self._fp_event_data_type[FPEventDataType(event_data_type_1).name] + struct_data_type = self._fp_event_data_type[fp_enum_repository.FPEventDataType(event_data_type_1).name] op_mode = struct.unpack('