Index: leahi-common =================================================================== diff -u --- leahi-common (revision 0) +++ leahi-common (revision f6b74a922cea4bd0cc195719e808028e50a5af8c) @@ -0,0 +1 @@ +../leahi-common \ No newline at end of file Index: leahi_dialin/dd/modules/events.py =================================================================== diff -u -rdd92f40a5a5b13449356328cf2526dd948c587ad -rf6b74a922cea4bd0cc195719e808028e50a5af8c --- leahi_dialin/dd/modules/events.py (.../events.py) (revision dd92f40a5a5b13449356328cf2526dd948c587ad) +++ leahi_dialin/dd/modules/events.py (.../events.py) (revision f6b74a922cea4bd0cc195719e808028e50a5af8c) @@ -18,7 +18,7 @@ import struct from logging import Logger from datetime import datetime -from typing import Tuple +from typing import Tuple, Union # Project imports from leahi_dialin.common import dd_enum_repository @@ -76,7 +76,6 @@ # Dictionary of the sub-mode as key and the state enum class as the value self._sub_mode_2_states = { dd_enum_repository.DDFaultStates.DD_FAULT_STATE_START.name: dd_enum_repository.DDFaultNVDataStates, - dd_enum_repository.DDStandbyStates.DD_STANDBY_MODE_STATE_IDLE.name: dd_enum_repository.DDStanDisinfectStates, dd_enum_repository.DDPreGenDialysateStates.DD_PRE_GEN_WET_SELF_TEST.name: dd_enum_repository.DDPreGenWetSelfTestStates } # Dictionary of the state as key and the sub-state enum class as the value @@ -320,25 +319,34 @@ self.event_op_mode_timestamp = timestamp - def _operation_status_match(self, op_mode: int, sub_mode: int=None, state:int=None, sub_state: int=None) -> Tuple[DialinEnum, DialinEnum, DialinEnum, DialinEnum]: + def _operation_status_match(self, op_mode: int, sub_mode: int=None, state:int=None, sub_state: int=None) -> Tuple[DialinEnum, Union[DialinEnum, int], Union[DialinEnum, int], Union[DialinEnum, int]]: """ Convert operation status values to enums. :param op_mode: (Integer) The operation mode value :param sub_mode: (Integer) The operation sub mode value :param state: (Integer) The operation state value :param sub_state: (Integer) The operation sub state value - :return: Returns the DialinEnum for each provied mode/state + :return: Returns the DialinEnum for each provied mode/state, or the original integer value if no enum is found """ - op_mode_enum = dd_enum_repository.TDOpModes(op_mode) + op_mode_enum = dd_enum_repository.DDOpModes(op_mode) sub_mode_enum = None state_enum = None sub_state_enum = None if sub_mode is not None: - sub_mode_enum = self._op_mode_2_sub_mode[op_mode_enum.name](sub_mode) + if op_mode_enum.name not in self._op_mode_2_sub_mode: + sub_mode_enum = sub_mode + else: + sub_mode_enum = self._op_mode_2_sub_mode[op_mode_enum.name](sub_mode) if state is not None: - state_enum = self._sub_mode_2_states[sub_mode_enum.name](state) + if sub_mode_enum.name not in self._sub_mode_2_states: + state_enum = state + else: + state_enum = self._sub_mode_2_states[sub_mode_enum.name](state) if sub_state is not None: - sub_state_enum = self._state_2_sub_states[state_enum.name](sub_state) + if state_enum.name not in self._state_2_sub_states: + sub_state_enum = sub_state + else: + sub_state_enum = self._state_2_sub_states[state_enum.name](sub_state) return op_mode_enum, sub_mode_enum, state_enum, sub_state_enum Index: leahi_dialin/dd/modules/records.py =================================================================== diff -u -rf65ed90f5f8af7672ae59bc5450d1a4f8935d041 -rf6b74a922cea4bd0cc195719e808028e50a5af8c --- leahi_dialin/dd/modules/records.py (.../records.py) (revision f65ed90f5f8af7672ae59bc5450d1a4f8935d041) +++ leahi_dialin/dd/modules/records.py (.../records.py) (revision f6b74a922cea4bd0cc195719e808028e50a5af8c) @@ -47,83 +47,83 @@ if self.can_interface is not None: # Data Request Response messages self.can_interface.register_receiving_publication_function(channel_id = CanChannels.dd_sync_broadcast_ch_id, - message_id = MsgIds.MSG_ID_DD_NVM_SYSTEM_RECORD_RESPONSE.value, + message_id = MsgIds.MSG_ID_UNUSED.value, function = self._handler_system_record_sync) self.can_interface.register_receiving_publication_function(channel_id = CanChannels.dd_sync_broadcast_ch_id, - message_id = MsgIds.MSG_ID_DD_NVM_SERVICE_RECORD_RESPONSE.value, + message_id = MsgIds.MSG_ID_UNUSED.value, function = self._handler_service_record_sync) self.can_interface.register_receiving_publication_function(channel_id = CanChannels.dd_sync_broadcast_ch_id, - message_id = MsgIds.MSG_ID_DD_NVM_CAL_PRESSURE_SENSOR_RESPONSE.value, + message_id = MsgIds.MSG_ID_UNUSED.value, function = self._handler_calibration_record_pres_sensor_sync) self.can_interface.register_receiving_publication_function(channel_id = CanChannels.dd_sync_broadcast_ch_id, - message_id = MsgIds.MSG_ID_DD_NVM_CAL_TEMP_SENSOR_RESPONSE.value, + message_id = MsgIds.MSG_ID_UNUSED.value, function = self._handler_calibration_record_temp_sensor_sync) self.can_interface.register_receiving_publication_function(channel_id = CanChannels.dd_sync_broadcast_ch_id, - message_id = MsgIds.MSG_ID_DD_NVM_CAL_CONC_PUMP_RESPONSE.value, + message_id = MsgIds.MSG_ID_UNUSED.value, function = self._handler_calibration_record_conc_pump_sync) self.can_interface.register_receiving_publication_function(channel_id = CanChannels.dd_sync_broadcast_ch_id, - message_id = MsgIds.MSG_ID_DD_NVM_CAL_D12_PUMP_RESPONSE.value, + message_id = MsgIds.MSG_ID_UNUSED.value, function = self._handler_calibration_record_dial_pump_d12_sync) self.can_interface.register_receiving_publication_function(channel_id = CanChannels.dd_sync_broadcast_ch_id, - message_id = MsgIds.MSG_ID_DD_NVM_CAL_D48_PUMP_RESPONSE.value, + message_id = MsgIds.MSG_ID_UNUSED.value, function = self._handler_calibration_record_dial_pump_d48_sync) self.can_interface.register_receiving_publication_function(channel_id = CanChannels.dd_sync_broadcast_ch_id, - message_id = MsgIds.MSG_ID_DD_NVM_CAL_ACID_CONCENTRATE_RESPONSE.value, + message_id = MsgIds.MSG_ID_UNUSED.value, function = self._handler_calibration_record_acid_conc_sync) self.can_interface.register_receiving_publication_function(channel_id = CanChannels.dd_sync_broadcast_ch_id, - message_id = MsgIds.MSG_ID_DD_NVM_CAL_BICARB_CONCENTRATE_RESPONSE.value, + message_id = MsgIds.MSG_ID_UNUSED.value, function = self._handler_calibration_record_bicarb_conc_sync) self.can_interface.register_receiving_publication_function(channel_id = CanChannels.dd_sync_broadcast_ch_id, - message_id = MsgIds.MSG_ID_DD_NVM_CAL_ACCEL_SENSOR_RESPONSE.value, + message_id = MsgIds.MSG_ID_UNUSED.value, function = self._handler_calibration_record_accelerometer_sync) self.can_interface.register_receiving_publication_function(channel_id = CanChannels.dd_sync_broadcast_ch_id, - message_id = MsgIds.MSG_ID_DD_NVM_CAL_BLOOD_LEAK_SENSOR_RESPONSE.value, + message_id = MsgIds.MSG_ID_UNUSED.value, function = self._handler_calibration_record_blood_leak_sync) self.can_interface.register_receiving_publication_function(channel_id = CanChannels.dd_sync_broadcast_ch_id, - message_id = MsgIds.MSG_ID_DD_NVM_INSTITUTIONAL_RECORD_RESPONSE.value, + message_id = MsgIds.MSG_ID_UNUSED.value, function = self._handler_institutional_record_sync) self.can_interface.register_receiving_publication_function(channel_id = CanChannels.dd_sync_broadcast_ch_id, - message_id = MsgIds.MSG_ID_DD_NVM_USAGE_INFO_RECORD_RESPONSE.value, + message_id = MsgIds.MSG_ID_UNUSED.value, function = self._handler_usage_info_record_sync) # Set Data Response messages self.can_interface.register_receiving_publication_function(channel_id = CanChannels.dd_sync_broadcast_ch_id, - message_id = MsgIds.MSG_ID_DD_NVM_SET_SYSTEM_RECORD_RESPONSE.value, + message_id = MsgIds.MSG_ID_UNUSED.value, function = self._handler_system_rr_sync) self.can_interface.register_receiving_publication_function(channel_id = CanChannels.dd_sync_broadcast_ch_id, - message_id = MsgIds.MSG_ID_DD_NVM_SET_SERVICE_RECORD_RESPONSE.value, + message_id = MsgIds.MSG_ID_UNUSED.value, function = self._handler_service_rr_sync) self.can_interface.register_receiving_publication_function(channel_id = CanChannels.dd_sync_broadcast_ch_id, - message_id = MsgIds.MSG_ID_DD_NVM_SET_CAL_PRESSURE_SENSOR_RESPONSE.value, + message_id = MsgIds.MSG_ID_UNUSED.value, function = self._handler_cal_pressure_rr_sync) self.can_interface.register_receiving_publication_function(channel_id = CanChannels.dd_sync_broadcast_ch_id, - message_id = MsgIds.MSG_ID_DD_NVM_SET_CAL_TEMP_SENSOR_RESPONSE.value, + message_id = MsgIds.MSG_ID_UNUSED.value, function = self._handler_cal_temp_rr_sync) self.can_interface.register_receiving_publication_function(channel_id = CanChannels.dd_sync_broadcast_ch_id, - message_id = MsgIds.MSG_ID_DD_NVM_SET_CAL_CONC_PUMP_RESPONSE.value, + message_id = MsgIds.MSG_ID_UNUSED.value, function = self._handler_cal_conc_pump_rr_sync) self.can_interface.register_receiving_publication_function(channel_id = CanChannels.dd_sync_broadcast_ch_id, - message_id = MsgIds.MSG_ID_DD_NVM_SET_CAL_D12_PUMP_RESPONSE.value, + message_id = MsgIds.MSG_ID_UNUSED.value, function = self._handler_cal_d12_rr_sync) self.can_interface.register_receiving_publication_function(channel_id = CanChannels.dd_sync_broadcast_ch_id, - message_id = MsgIds.MSG_ID_DD_NVM_SET_CAL_D48_PUMP_RESPONSE.value, + message_id = MsgIds.MSG_ID_UNUSED.value, function = self._handler_cal_d48_rr_sync) self.can_interface.register_receiving_publication_function(channel_id = CanChannels.dd_sync_broadcast_ch_id, - message_id = MsgIds.MSG_ID_DD_NVM_SET_CAL_ACID_CONCENTRATE_RESPONSE.value, + message_id = MsgIds.MSG_ID_UNUSED.value, function = self._handler_cal_acid_rr_sync) self.can_interface.register_receiving_publication_function(channel_id = CanChannels.dd_sync_broadcast_ch_id, - message_id = MsgIds.MSG_ID_DD_NVM_SET_CAL_BICARB_CONCENTRATE_RESPONSE.value, + message_id = MsgIds.MSG_ID_UNUSED.value, function = self._handler_cal_bicarb_rr_sync) self.can_interface.register_receiving_publication_function(channel_id = CanChannels.dd_sync_broadcast_ch_id, - message_id = MsgIds.MSG_ID_DD_NVM_SET_CAL_ACCEL_SENSOR_RESPONSE.value, + message_id = MsgIds.MSG_ID_UNUSED.value, function = self._handler_cal_accel_rr_sync) self.can_interface.register_receiving_publication_function(channel_id = CanChannels.dd_sync_broadcast_ch_id, - message_id = MsgIds.MSG_ID_DD_NVM_SET_CAL_BLOOD_LEAK_SENSOR_RESPONSE.value, + message_id = MsgIds.MSG_ID_UNUSED.value, function = self._handler_cal_blood_leak_rr_sync) self.can_interface.register_receiving_publication_function(channel_id = CanChannels.dd_sync_broadcast_ch_id, - message_id = MsgIds.MSG_ID_DD_NVM_SET_INSTITUTIONAL_RECORD_RESPONSE.value, + message_id = MsgIds.MSG_ID_UNUSED.value, function = self._handler_institutional_rr_sync) self.can_interface.register_receiving_publication_function(channel_id = CanChannels.dd_sync_broadcast_ch_id, - message_id = MsgIds.MSG_ID_DD_NVM_SET_USAGE_INFO_RECORD_RESPONSE.value, + message_id = MsgIds.MSG_ID_UNUSED.value, function = self._handler_usage_info_rr_sync) @@ -847,7 +847,7 @@ payload = payload, reset = None, channel_id = CanChannels.dialin_to_dd_ch_id, - msg_id = MsgIds.MSG_ID_DD_SET_OPERATION_MODE_OVERRIDE_REQUEST, + msg_id = MsgIds.MSG_ID_UNUSED, entity_name = 'DD Operation Mode', override_text = f'set to {service_mode.name}', logger = self.logger, @@ -871,7 +871,7 @@ payload = payload, reset = None, channel_id = CanChannels.dialin_to_dd_ch_id, - msg_id = MsgIds.MSG_ID_UI_DD_NVM_GET_RECORD_REQUEST, + msg_id = MsgIds.MSG_ID_UNUSED, entity_name = f'DD System Record request', override_text = '', logger = self.logger, @@ -893,7 +893,7 @@ payload = payload, reset = None, channel_id = CanChannels.dialin_to_dd_ch_id, - msg_id = MsgIds.MSG_ID_UI_DD_NVM_GET_RECORD_REQUEST, + msg_id = MsgIds.MSG_ID_UNUSED, entity_name = f'DD Service Record request', override_text = '', logger = self.logger, @@ -915,7 +915,7 @@ payload = payload, reset = None, channel_id = CanChannels.dialin_to_dd_ch_id, - msg_id = MsgIds.MSG_ID_UI_DD_NVM_GET_RECORD_REQUEST, + msg_id = MsgIds.MSG_ID_UNUSED, entity_name = f'DD Calibration Record request', override_text = '', logger = self.logger, @@ -937,7 +937,7 @@ payload = payload, reset = None, channel_id = CanChannels.dialin_to_dd_ch_id, - msg_id = MsgIds.MSG_ID_UI_DD_NVM_GET_RECORD_REQUEST, + msg_id = MsgIds.MSG_ID_UNUSED, entity_name = f'DD Institutional Record request', override_text = '', logger = self.logger, @@ -959,7 +959,7 @@ payload = payload, reset = None, channel_id = CanChannels.dialin_to_dd_ch_id, - msg_id = MsgIds.MSG_ID_UI_DD_NVM_GET_RECORD_REQUEST, + msg_id = MsgIds.MSG_ID_UNUSED, entity_name = f'DD Usage Information Record request', override_text = '', logger = self.logger, @@ -1000,7 +1000,7 @@ payload = payload, reset = None, channel_id = CanChannels.dialin_to_dd_ch_id, - msg_id = MsgIds.MSG_ID_UI_DD_NVM_SET_SYSTEM_RECORD_REQUEST, + msg_id = MsgIds.MSG_ID_UNUSED, entity_name = f'New DD System Record', override_text = 'being set', logger = self.logger, @@ -1034,7 +1034,7 @@ payload = payload, reset = None, channel_id = CanChannels.dialin_to_dd_ch_id, - msg_id = MsgIds.MSG_ID_UI_DD_NVM_SET_SERVICE_RECORD_REQUEST, + msg_id = MsgIds.MSG_ID_UNUSED, entity_name = f'New DD Service Record', override_text = 'being set', logger = self.logger, @@ -1052,14 +1052,14 @@ @return: 1 if successful, zero otherwise """ msg_id_pairing = { - 'PRES': MsgIds.MSG_ID_UI_DD_NVM_SET_CAL_PRESSURE_SENSOR_REQUEST, - 'TEMP': MsgIds.MSG_ID_UI_DD_NVM_SET_CAL_TEMP_SENSOR_REQUEST, - 'CONC': MsgIds.MSG_ID_UI_DD_NVM_SET_CAL_CONC_PUMP_REQUEST, - 'DIAL': MsgIds.MSG_ID_UI_DD_NVM_SET_CAL_D48_PUMP_REQUEST, - 'ACID': MsgIds.MSG_ID_UI_DD_NVM_SET_CAL_ACID_CONCENTRATE_REQUEST, - 'BICARB': MsgIds.MSG_ID_UI_DD_NVM_SET_CAL_BICARB_CONCENTRATE_REQUEST, - 'ACCEL': MsgIds.MSG_ID_UI_DD_NVM_SET_CAL_ACCEL_SENSOR_REQUEST, - 'BLOOD_LEAK': MsgIds.MSG_ID_UI_DD_NVM_SET_CAL_BLOOD_LEAK_SENSOR_REQUEST, + 'PRES': MsgIds.MSG_ID_UNUSED, + 'TEMP': MsgIds.MSG_ID_UNUSED, + 'CONC': MsgIds.MSG_ID_UNUSED, + 'DIAL': MsgIds.MSG_ID_UNUSED, + 'ACID': MsgIds.MSG_ID_UNUSED, + 'BICARB': MsgIds.MSG_ID_UNUSED, + 'ACCEL': MsgIds.MSG_ID_UNUSED, + 'BLOOD_LEAK': MsgIds.MSG_ID_UNUSED, } # Make a dictionary to store all the send functions for later send send_data = [] @@ -1102,7 +1102,7 @@ kwargs['sensor_enum'] = sensor if sensor == dd_enum_repository.DDDialysatePumpNames.D12_PUMP: - kwargs['msg_id'] = MsgIds.MSG_ID_UI_DD_NVM_SET_CAL_D12_PUMP_REQUEST + kwargs['msg_id'] = MsgIds.MSG_ID_UNUSED else: kwargs['msg_id'] = msg_id_pairing[group] @@ -1289,7 +1289,7 @@ payload = payload, reset = None, channel_id = CanChannels.dialin_to_dd_ch_id, - msg_id = MsgIds.MSG_ID_UI_DD_NVM_SET_INSTITUTIONAL_RECORD_REQUEST, + msg_id = MsgIds.MSG_ID_UNUSED, entity_name = f'DD Institutional Record', override_text = 'being set', logger = self.logger, @@ -1339,7 +1339,7 @@ payload = payload, reset = None, channel_id = CanChannels.dialin_to_dd_ch_id, - msg_id = MsgIds.MSG_ID_UI_DD_NVM_SET_USAGE_INFO_RECORD_REQUEST, + msg_id = MsgIds.MSG_ID_UNUSED, entity_name = f'New DD Usage Information Record', override_text = 'being set', logger = self.logger, @@ -1363,7 +1363,7 @@ else: payload_sensor = byte_to_bytearray(sensor_enum.value) payload_content = b'' - if msg_id == MsgIds.MSG_ID_UI_DD_NVM_SET_CAL_D12_PUMP_REQUEST: + if msg_id == MsgIds.MSG_ID_UNUSED: payload_content += float_to_bytearray(dialysate_pump_target_speed) else: payload_content += float_to_bytearray(fourth_order_coeff) @@ -1373,19 +1373,19 @@ payload_content += float_to_bytearray(offset) payload_content += integer_to_bytearray(calibration_time) payload_content += unsigned_short_to_bytearray(self.crc16(payload_content)) - if msg_id in [MsgIds.MSG_ID_UI_DD_NVM_SET_CAL_D12_PUMP_REQUEST, MsgIds.MSG_ID_UI_DD_NVM_SET_CAL_D48_PUMP_REQUEST]: + if msg_id in [MsgIds.MSG_ID_UNUSED, MsgIds.MSG_ID_UNUSED]: payload = payload_content else: payload = payload_sensor + payload_content sensor_type = '' - if msg_id == MsgIds.MSG_ID_UI_DD_NVM_SET_CAL_PRESSURE_SENSOR_REQUEST: + if msg_id == MsgIds.MSG_ID_UNUSED: sensor_type = 'Pressure Sensor' - elif msg_id == MsgIds.MSG_ID_UI_DD_NVM_SET_CAL_TEMP_SENSOR_REQUEST: + elif msg_id == MsgIds.MSG_ID_UNUSED: sensor_type = 'Temperature Sensor' - elif msg_id == MsgIds.MSG_ID_UI_DD_NVM_SET_CAL_CONC_PUMP_REQUEST: + elif msg_id == MsgIds.MSG_ID_UNUSED: sensor_type = 'Concentrate Pump' - elif msg_id in [MsgIds.MSG_ID_UI_DD_NVM_SET_CAL_D12_PUMP_REQUEST, MsgIds.MSG_ID_UI_DD_NVM_SET_CAL_D48_PUMP_REQUEST]: + elif msg_id in [MsgIds.MSG_ID_UNUSED, MsgIds.MSG_ID_UNUSED]: sensor_type = 'Dialysate Pump' return cmd_generic_override(payload = payload, @@ -1417,9 +1417,9 @@ payload = payload_sensor + payload_content conc_type = '' - if msg_id == MsgIds.MSG_ID_UI_DD_NVM_SET_CAL_ACID_CONCENTRATE_REQUEST: + if msg_id == MsgIds.MSG_ID_UNUSED: conc_type = 'Acid' - elif msg_id == MsgIds.MSG_ID_UI_DD_NVM_SET_CAL_BICARB_CONCENTRATE_REQUEST: + elif msg_id == MsgIds.MSG_ID_UNUSED: conc_type = 'Bicarb' return cmd_generic_override(payload = payload, Index: leahi_dialin/fp/modules/events.py =================================================================== diff -u -rdd92f40a5a5b13449356328cf2526dd948c587ad -rf6b74a922cea4bd0cc195719e808028e50a5af8c --- leahi_dialin/fp/modules/events.py (.../events.py) (revision dd92f40a5a5b13449356328cf2526dd948c587ad) +++ leahi_dialin/fp/modules/events.py (.../events.py) (revision f6b74a922cea4bd0cc195719e808028e50a5af8c) @@ -18,7 +18,7 @@ import struct from logging import Logger from datetime import datetime -from typing import Tuple +from typing import Tuple, Union # Project imports from leahi_dialin.common import dd_enum_repository, fp_enum_repository @@ -71,7 +71,7 @@ fp_enum_repository.FPOpModes.MODE_NLEG.name: fp_enum_repository.FPNotLegalStates} # Dictionary of the sub-mode as key and the state enum class as the value - self._sub_mode_2_states = { fp_enum_repository.FPFaultStates.DD_FAULT_STATE_START.name: fp_enum_repository.FPFaultNVDataStates, + self._sub_mode_2_states = { fp_enum_repository.FPFaultStates.FP_FAULT_STATE_START.name: fp_enum_repository.FPFaultNVDataStates, fp_enum_repository.FPPreGenPermeateStates.FP_PRE_GENP_INLET_PRES_CHECK.name: fp_enum_repository.FPInletPresCheckStates, fp_enum_repository.FPPreGenPermeateStates.FP_PRE_GENP_FILTER_FLUSH.name: fp_enum_repository.FPFilterFlushStates, fp_enum_repository.FPPreGenPermeateStates.FP_PRE_GENP_PERMEATE_FLUSH.name: fp_enum_repository.FPPermeateFlushStates, @@ -323,25 +323,34 @@ self.event_op_mode_timestamp = timestamp - def _operation_status_match(self, op_mode: int, sub_mode: int=None, state:int=None, sub_state: int=None) -> Tuple[DialinEnum, DialinEnum, DialinEnum, DialinEnum]: + def _operation_status_match(self, op_mode: int, sub_mode: int=None, state:int=None, sub_state: int=None) -> Tuple[DialinEnum, Union[DialinEnum, int], Union[DialinEnum, int], Union[DialinEnum, int]]: """ Convert operation status values to enums. :param op_mode: (Integer) The operation mode value :param sub_mode: (Integer) The operation sub mode value :param state: (Integer) The operation state value :param sub_state: (Integer) The operation sub state value - :return: Returns the DialinEnum for each provied mode/state + :return: Returns the DialinEnum for each provied mode/state, or the original integer value if no enum is found """ - op_mode_enum = fp_enum_repository.TDOpModes(op_mode) + op_mode_enum = fp_enum_repository.FPOpModes(op_mode) sub_mode_enum = None state_enum = None sub_state_enum = None if sub_mode is not None: - sub_mode_enum = self._op_mode_2_sub_mode[op_mode_enum.name](sub_mode) + if op_mode_enum.name not in self._op_mode_2_sub_mode: + sub_mode_enum = sub_mode + else: + sub_mode_enum = self._op_mode_2_sub_mode[op_mode_enum.name](sub_mode) if state is not None: - state_enum = self._sub_mode_2_states[sub_mode_enum.name](state) + if sub_mode_enum.name not in self._sub_mode_2_states: + state_enum = state + else: + state_enum = self._sub_mode_2_states[sub_mode_enum.name](state) if sub_state is not None: - sub_state_enum = self._state_2_sub_states[state_enum.name](sub_state) + if state_enum.name not in self._state_2_sub_states: + sub_state_enum = sub_state + else: + sub_state_enum = self._state_2_sub_states[state_enum.name](sub_state) return op_mode_enum, sub_mode_enum, state_enum, sub_state_enum Index: leahi_dialin/td/modules/events.py =================================================================== diff -u -r9fd285180bdddd00e98b3d46da691f90cee2e3dc -rf6b74a922cea4bd0cc195719e808028e50a5af8c --- leahi_dialin/td/modules/events.py (.../events.py) (revision 9fd285180bdddd00e98b3d46da691f90cee2e3dc) +++ leahi_dialin/td/modules/events.py (.../events.py) (revision f6b74a922cea4bd0cc195719e808028e50a5af8c) @@ -18,7 +18,7 @@ import struct from logging import Logger from datetime import datetime -from typing import Tuple +from typing import Tuple, Union # Project imports from leahi_dialin.common import td_enum_repository @@ -80,9 +80,8 @@ td_enum_repository.TDTreatmentStates.TREATMENT_PAUSED_STATE.name:td_enum_repository.TDTreaPausedStates, td_enum_repository.TDTreatmentStates.TREATMENT_RINSEBACK_STATE.name:td_enum_repository.TDTreaRinsebackStates, td_enum_repository.TDTreatmentStates.TREATMENT_RECIRC_STATE.name:td_enum_repository.TDTreaRecircStates, - td_enum_repository.TDTreatmentStates.TREATMENT_SALINE_BOLUS_STATE.name:td_enum_repository.TDTreaBolusStates, - td_enum_repository.TDTreatmentStates.TREATMENT_HEPARIN_STATE.name:td_enum_repository.TDTreaHeparinStates, - td_enum_repository.TDTreatmentStates.TREATMENT_END_STATE.name:td_enum_repository.TDTreaEndStates } + td_enum_repository.TDTreatmentStates.TREATMENT_END_STATE.name:td_enum_repository.TDTreaEndStates, + td_enum_repository.TDTreatmentStates.TREATMENT_SALINE_BOLUS_STATE.name:td_enum_repository.TDTreaBolusStates } # Dictionary of the state as key and the sub state enum class as the value self._state_2_sub_states = {td_enum_repository.TDPreTreaSampleWaterStates.SAMPLE_WATER_STATE.name: td_enum_repository.TDPreTreaSamplWaterUserActionStates, @@ -328,25 +327,34 @@ self.event_op_mode_timestamp = timestamp - def _operation_status_match(self, op_mode: int, sub_mode: int=None, state:int=None, sub_state: int=None) -> Tuple[DialinEnum, DialinEnum, DialinEnum, DialinEnum]: + def _operation_status_match(self, op_mode: int, sub_mode: int=None, state:int=None, sub_state: int=None) -> Tuple[DialinEnum, Union[DialinEnum, int], Union[DialinEnum, int], Union[DialinEnum, int]]: """ Convert operation status values to enums. :param op_mode: (Integer) The operation mode value :param sub_mode: (Integer) The operation sub mode value :param state: (Integer) The operation state value :param sub_state: (Integer) The operation sub state value - :return: Returns the DialinEnum for each provied mode/state + :return: Returns the DialinEnum for each provied mode/state, or the original integer value if no enum is found """ op_mode_enum = td_enum_repository.TDOpModes(op_mode) sub_mode_enum = None state_enum = None sub_state_enum = None if sub_mode is not None: - sub_mode_enum = self._op_mode_2_sub_mode[op_mode_enum.name](sub_mode) + if op_mode_enum.name not in self._op_mode_2_sub_mode: + sub_mode_enum = sub_mode + else: + sub_mode_enum = self._op_mode_2_sub_mode[op_mode_enum.name](sub_mode) if state is not None: - state_enum = self._sub_mode_2_states[sub_mode_enum.name](state) + if sub_mode_enum.name not in self._sub_mode_2_states: + state_enum = state + else: + state_enum = self._sub_mode_2_states[sub_mode_enum.name](state) if sub_state is not None: - sub_state_enum = self._state_2_sub_states[state_enum.name](sub_state) + if state_enum.name not in self._state_2_sub_states: + sub_state_enum = sub_state + else: + sub_state_enum = self._state_2_sub_states[state_enum.name](sub_state) return op_mode_enum, sub_mode_enum, state_enum, sub_state_enum Index: leahi_dialin/td/modules/records.py =================================================================== diff -u -re3c60dd439b2f996b0392951fd4461e8e37b8692 -rf6b74a922cea4bd0cc195719e808028e50a5af8c --- leahi_dialin/td/modules/records.py (.../records.py) (revision e3c60dd439b2f996b0392951fd4461e8e37b8692) +++ leahi_dialin/td/modules/records.py (.../records.py) (revision f6b74a922cea4bd0cc195719e808028e50a5af8c) @@ -46,19 +46,19 @@ if self.can_interface is not None: self.can_interface.register_receiving_publication_function(channel_id = CanChannels.td_sync_broadcast_ch_id, - message_id = MsgIds.MSG_ID_TD_NVM_SYSTEM_RECORD_RESPONSE.value, + message_id = MsgIds.MSG_ID_UNUSED.value, function = self._handler_system_record_sync) self.can_interface.register_receiving_publication_function(channel_id = CanChannels.td_sync_broadcast_ch_id, - message_id = MsgIds.MSG_ID_TD_NVM_SERVICE_RECORD_RESPONSE.value, + message_id = MsgIds.MSG_ID_UNUSED.value, function = self._handler_service_record_sync) self.can_interface.register_receiving_publication_function(channel_id = CanChannels.td_sync_broadcast_ch_id, - message_id = MsgIds.MSG_ID_TD_NVM_CAL_RESPONSE.value, + message_id = MsgIds.MSG_ID_UNUSED.value, function = self._handler_calibration_record_pres_sensor_sync) self.can_interface.register_receiving_publication_function(channel_id = CanChannels.td_sync_broadcast_ch_id, - message_id = MsgIds.MSG_ID_TD_NVM_INSTITUTIONAL_RECORD_RESPONSE.value, + message_id = MsgIds.MSG_ID_UNUSED.value, function = self._handler_institutional_record_sync) self.can_interface.register_receiving_publication_function(channel_id = CanChannels.td_sync_broadcast_ch_id, - message_id = MsgIds.MSG_ID_TD_NVM_USAGE_INFO_RECORD_RESPONSE.value, + message_id = MsgIds.MSG_ID_UNUSED.value, function = self._handler_usage_info_record_sync) self.system_records_timestamp = 0 #: The timestamp of the latest System Records message @@ -246,7 +246,7 @@ payload = payload, reset = None, channel_id = CanChannels.dialin_to_td_ch_id, - msg_id = MsgIds.MSG_ID_UI_TD_NVM_GET_RECORD_REQUEST, + msg_id = MsgIds.MSG_ID_UNUSED, entity_name = f'TD System Record request', override_text = '', logger = self.logger, @@ -268,7 +268,7 @@ payload = payload, reset = None, channel_id = CanChannels.dialin_to_td_ch_id, - msg_id = MsgIds.MSG_ID_UI_TD_NVM_GET_RECORD_REQUEST, + msg_id = MsgIds.MSG_ID_UNUSED, entity_name = f'TD Service Record request', override_text = '', logger = self.logger, @@ -290,7 +290,7 @@ payload = payload, reset = None, channel_id = CanChannels.dialin_to_td_ch_id, - msg_id = MsgIds.MSG_ID_UI_TD_NVM_GET_RECORD_REQUEST, + msg_id = MsgIds.MSG_ID_UNUSED, entity_name = f'TD Calibration Record request', override_text = '', logger = self.logger, @@ -312,7 +312,7 @@ payload = payload, reset = None, channel_id = CanChannels.dialin_to_td_ch_id, - msg_id = MsgIds.MSG_ID_UI_TD_NVM_GET_RECORD_REQUEST, + msg_id = MsgIds.MSG_ID_UNUSED, entity_name = f'TD Institutional Record request', override_text = '', logger = self.logger, @@ -334,7 +334,7 @@ payload = payload, reset = None, channel_id = CanChannels.dialin_to_td_ch_id, - msg_id = MsgIds.MSG_ID_UI_TD_NVM_GET_RECORD_REQUEST, + msg_id = MsgIds.MSG_ID_UNUSED, entity_name = f'TD Usage Information Record request', override_text = '', logger = self.logger, @@ -375,7 +375,7 @@ payload = payload, reset = None, channel_id = CanChannels.dialin_to_td_ch_id, - msg_id = MsgIds.MSG_ID_UI_TD_NVM_SET_SYSTEM_RECORD, + msg_id = MsgIds.MSG_ID_UNUSED, entity_name = f'New TD System Record', override_text = 'being set', logger = self.logger, @@ -409,7 +409,7 @@ payload = payload, reset = None, channel_id = CanChannels.dialin_to_td_ch_id, - msg_id = MsgIds.MSG_ID_TD_NVM_SET_SERVICE_RECORD, + msg_id = MsgIds.MSG_ID_UNUSED, entity_name = f'New TD Service Record', override_text = 'being set', logger = self.logger, @@ -427,9 +427,9 @@ @return: 1 if successful, zero otherwise """ msg_id_pairing = { - 'PRES': MsgIds.MSG_ID_UI_TD_NVM_SET_CAL_PRESSURE_SENSOR, - 'TEMP': MsgIds.MSG_ID_UI_TD_NVM_SET_CAL_TEMP_SENSOR, - 'ACCEL': MsgIds.MSG_ID_UI_TD_NVM_SET_CAL_ACCEL_SENSOR, + 'PRES': MsgIds.MSG_ID_UNUSED, + 'TEMP': MsgIds.MSG_ID_UNUSED, + 'ACCEL': MsgIds.MSG_ID_UNUSED, } send_data = [] checked = [] @@ -580,7 +580,7 @@ payload = payload, reset = None, channel_id = CanChannels.dialin_to_dd_ch_id, - msg_id = MsgIds.MSG_ID_UI_DD_NVM_SET_INSTITUTIONAL_RECORD, + msg_id = MsgIds.MSG_ID_UNUSED, entity_name = f'TD Institutional Record', override_text = 'being set', logger = self.logger, @@ -630,7 +630,7 @@ payload = payload, reset = None, channel_id = CanChannels.dialin_to_td_ch_id, - msg_id = MsgIds.MSG_ID_TD_NVM_SET_USAGE_INFO_RECORD, + msg_id = MsgIds.MSG_ID_UNUSED, entity_name = f'New TD Usage Information Record', override_text = 'being set', logger = self.logger, @@ -651,7 +651,7 @@ calibration_time: int = 0) -> int: payload_sensor = integer_to_bytearray(sensor_enum.value) payload_content = b'' - if msg_id == MsgIds.MSG_ID_UI_DD_NVM_SET_CAL_D12_PUMP: + if msg_id == MsgIds.MSG_ID_UNUSED: payload_content += float_to_bytearray(dialysate_pump_target_speed) payload_content += float_to_bytearray(forth_order_coeff) payload_content += float_to_bytearray(third_order_coeff) @@ -663,13 +663,13 @@ payload = payload_sensor + payload_content sensor_type = '' - if msg_id == MsgIds.TBD: + if msg_id == MsgIds.MSG_ID_UNUSED: sensor_type = 'Pressure Sensor' - elif msg_id == MsgIds.TBD: + elif msg_id == MsgIds.MSG_ID_UNUSED: sensor_type = 'Temperature Sensor' - elif msg_id == MsgIds.TBD: + elif msg_id == MsgIds.MSG_ID_UNUSED: sensor_type = 'Concentrate Pump' - elif msg_id == MsgIds.TBD: + elif msg_id == MsgIds.MSG_ID_UNUSED: sensor_type = 'Dialysate Pump' return cmd_generic_override(payload = payload, @@ -696,9 +696,9 @@ payload += unsigned_short_to_bytearray(self.crc16(payload)) conc_type = '' - if msg_id == MsgIds.TBD: + if msg_id == MsgIds.MSG_ID_UNUSED: conc_type = 'Acid' - elif msg_id == MsgIds.TBD: + elif msg_id == MsgIds.MSG_ID_UNUSED: conc_type = 'Bicarb' return cmd_generic_override(payload = payload,