Index: leahi_dialin/common/msg_ids.py =================================================================== diff -u -r2d1aa1133cbaac4adbf4b6f7b2512f6b9255063f -r3c2bc6419b5796c03a7e4943938055c4ac36c24b --- leahi_dialin/common/msg_ids.py (.../msg_ids.py) (revision 2d1aa1133cbaac4adbf4b6f7b2512f6b9255063f) +++ leahi_dialin/common/msg_ids.py (.../msg_ids.py) (revision 3c2bc6419b5796c03a7e4943938055c4ac36c24b) @@ -203,22 +203,22 @@ MSG_ID_FFU_SIGNAL_DD_UPDATE_AVAILABLE = 0xB4 MSG_ID_TD_UI_CONFIRMATION_REQUEST = 0xB5 MSG_ID_UI_CONFIRMATION_RESULT_RESPONSE = 0xB6 - AVAILABLE_MSG_ID_B7 = 0xB7 + MSG_ID_TD_PRE_TREATMENT_STATE_DATA = 0xB7 MSG_ID_UI_VITALS_ADJUSTMENT_REQUEST = 0xB8 MSG_ID_TD_VITALS_ADJUSTMENT_RESPONSE = 0xB9 - MSG_ID_UI_DD_NVM_GET_RECORD_REQUEST = 0xBA - MSG_ID_DD_NVM_SYSTEM_RECORD_RESPONSE = 0xBB - MSG_ID_UI_DD_NVM_SET_SYSTEM_RECORD_REQUEST = 0xBC - MSG_ID_DD_NVM_SERVICE_RECORD_RESPONSE = 0xBD - MSG_ID_UI_DD_NVM_SET_SERVICE_RECORD_REQUEST = 0xBE - MSG_ID_DD_NVM_INSTITUTIONAL_RECORD_RESPONSE = 0xBF - MSG_ID_UI_DD_NVM_SET_INSTITUTIONAL_RECORD_REQUEST = 0xC0 - MSG_ID_DD_NVM_USAGE_INFO_RECORD_RESPONSE = 0xC1 - MSG_ID_UI_DD_NVM_SET_USAGE_INFO_RECORD_REQUEST = 0xC2 + MSG_ID_UI_ISO_UF_STATE_REQUEST = 0xBA + MSG_ID_TD_ISO_UF_STATE_RESPONSE = 0xBB + MSG_ID_TD_HEMODIAFILTRATION_DATA = 0xBC + MSG_ID_UI_PAUSE_SUB_FLOW_REQUEST = 0xBD + MSG_ID_TD_PAUSE_SUB_FLOW_RESPONSE = 0xBE + MSG_ID_UI_AUTO_SUBSTITUTION_REQUEST = 0xBF + MSG_ID_TD_AUTO_SUBSTITUTION_REPONSE = 0xC0 + MSG_ID_UI_HDF_ADJUSTMENT_REQUEST = 0xC1 + MSG_ID_TD_HDF_ADJUSTMENT_RESPONSE = 0xC2 MSG_ID_DD_NVM_CAL_PRESSURE_SENSOR_RESPONSE = 0xC3 - MSG_ID_UI_DD_NVM_SET_CAL_PRESSURE_SENSOR_REQUEST = 0xC4 - MSG_ID_DD_NVM_CAL_TEMP_SENSOR_RESPONSE = 0xC5 - MSG_ID_UI_DD_NVM_SET_CAL_TEMP_SENSOR_REQUEST = 0xC6 + MSG_ID_TD_DRY_BICARD_DISCONNECT_DATA = 0xC4 + MSG_ID_UI_DRY_BICARD_DISCONNECT_REQUEST = 0xC5 + MSG_ID_TD_DRY_BICARD_DISCONNECT_RESPONSE = 0xC6 MSG_ID_DD_NVM_CAL_CONC_PUMP_RESPONSE = 0xC7 MSG_ID_UI_DD_NVM_SET_CAL_CONC_PUMP_REQUEST = 0xC8 MSG_ID_DD_NVM_CAL_D12_PUMP_RESPONSE = 0xC9 @@ -255,10 +255,10 @@ MSG_ID_DD_NVM_SET_CAL_D48_PUMP_RESPONSE = 0xE8 MSG_ID_DD_NVM_SET_CAL_ACID_CONCENTRATE_RESPONSE = 0xE9 MSG_ID_DD_NVM_SET_CAL_BICARB_CONCENTRATE_RESPONSE = 0xEA - MSG_ID_DD_NVM_SET_CAL_ACCEL_SENSOR_RESPONSE = 0xEB - MSG_ID_DD_NVM_SET_CAL_BLOOD_LEAK_SENSOR_RESPONSE = 0xEC - TBD_ED = 0xED - TBD_EE = 0xEE + MSG_ID_UI_RO_WATER_MODE_REQUEST = 0xEB + MSG_ID_DD_RO_WATER_MODE_RESPONSE = 0xEC + MSG_ID_UI_ADJUST_RO_WATER_MODE_REQUEST = 0xED + MSG_ID_DD_ADJUST_RO_WATER_MODE_RESPONSE = 0xEE TBD_EF = 0xEF MSG_ID_DD_PISTON_PUMP_CONTROL_DATA = 0xF0 @@ -362,7 +362,11 @@ MSG_ID_TD_SYRINGE_PUMP_FORCE_SENSOR_CALIBRATION_REQUEST = 0x8060 MSG_ID_TD_GET_ALARM_PROPERTIES_REQUEST = 0x8061 MSG_ID_TD_ALARM_PROPERTIES_RESPONSE = 0x8062 + MSG_ID_BATTERY_REGISTERS_OVERRIDE_REQUEST = 0x8063 + MSG_ID_TD_BATTERY_PUBLISH_INTERVAL_OVERRIDE_REQUEST = 0x8064 + MSG_ID_TD_AIR_PUMP_RPM_OVERRIDE_REQUEST = 0x8067 + MSG_ID_TD_BATTERY_I2C_STATUS_OVERRIDE_REQUEST = 0x8068 MSG_ID_TD_TRAINING_TEST_OVERRIDE_REQUEST = 0x8999 @@ -374,7 +378,7 @@ MSG_ID_DD_VALVE_SENSED_STATE_OVERRIDE_REQUEST = 0xA005 MSG_ID_DD_PRESSURE_SENSOR_READINGS_OVERRIDE_REQUEST = 0xA006 MSG_ID_DD_PRESSURE_SENSOR_TEMPERATURE_OVERRIDE_REQUEST = 0xA007 - MSG_ID_DD_PRESSURE_SENSOR_READ_COUNTER_OVERRIDE_REQUEST = 0xA008 + MSG_ID_DD_TREATMENT_PARAMS_OVERRIDE_REQUEST = 0xA008 MSG_ID_DD_PRESSURE_SENSOR_ERROR_COUNTER_OVERRIDE_REQUEST = 0xA009 MSG_ID_DD_PRESSURE_SENSOR_PUBLISH_INTERVAL_OVERRIDE_REQUEST = 0xA00A MSG_ID_DD_PRESSURE_SENSOR_FILTER_READINGS_OVERRIDE_REQUEST = 0xA00B @@ -475,7 +479,7 @@ MSG_ID_DD_BICART_LOWER_PRESSURE_OVERRIDE_REQUEST = 0xA06B MSG_ID_DD_FLOATER_LEVEL_OVERRIDE_REQUEST = 0xA06C MSG_ID_DD_SUBSTITUTION_PUMP_START_STOP_OVERRIDE_REQUEST = 0xA06D - MSG_ID_DD_SUBSTITUTION_PUMP_BROADCAST_OVERRIDE_REQUEST = 0xA06E + MSG_ID_DD_SUBSTITUTION_PUMP_PUBLISH_INTERVAL_OVERRIDE_REQUEST = 0xA06E MSG_ID_DD_SUBSTITUTION_PUMP_TARGET_SPEED_OVERRIDE_REQUEST = 0xA06F MSG_ID_DD_CONDUCTIVITY_SENSOR_CAL_REQUEST = 0xA070 MSG_ID_DD_CONDUCTIVITY_SENSOR_CAL_RESPONSE = 0xA071 Index: leahi_dialin/dd/modules/events.py =================================================================== diff -u -r5c1132f5aadff6082afa56588ad1f4a64f828cd9 -r3c2bc6419b5796c03a7e4943938055c4ac36c24b --- leahi_dialin/dd/modules/events.py (.../events.py) (revision 5c1132f5aadff6082afa56588ad1f4a64f828cd9) +++ leahi_dialin/dd/modules/events.py (.../events.py) (revision 3c2bc6419b5796c03a7e4943938055c4ac36c24b) @@ -19,6 +19,7 @@ from logging import Logger from datetime import datetime import time +from typing import Tuple # Project imports from leahi_dialin.common import dd_enum_repository @@ -28,6 +29,7 @@ from leahi_dialin.protocols.CAN import CanMessenger, CanChannels from leahi_dialin.utils.abstract_classes import AbstractSubSystem from leahi_dialin.utils.base import publish +from leahi_dialin.utils.enums import DialinEnum @@ -61,7 +63,7 @@ self.sub_mode = 0 #: The new Operation Sub-Mode value self.event_op_mode_timestamp = 0.0 #: The timestamp of the last Operation Mode change message - # Dictionary of the mode as key and the sub mode states enum class as the value + # Dictionary of the mode as key and the sub mode enum class as the value self._op_mode_2_sub_mode = {dd_enum_repository.DDOpModes.MODE_FAUL.name: dd_enum_repository.DDFaultStates, dd_enum_repository.DDOpModes.MODE_SERV.name: dd_enum_repository.DDServiceStates, dd_enum_repository.DDOpModes.MODE_INIT.name: dd_enum_repository.DDInitStates, @@ -74,6 +76,14 @@ dd_enum_repository.DDOpModes.MODE_ROPS.name: dd_enum_repository.DDROPermeateStates, dd_enum_repository.DDOpModes.MODE_NLEG.name: dd_enum_repository.DDNotLegalStates} + # 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 + self._state_2_sub_states = { } + # Loop through the list of the DD events enums and initial the event dictionary. Each event is a key in the # dictionary and the value is a list. self._event_dictionary = dict() @@ -288,7 +298,8 @@ event_tuple = (current_timestamp, event_enum.name, event_data_1, event_data_2) elif event_enum is dd_enum_repository.DDEventList.DD_EVENT_OPERATION_STATUS: - event_tuple = (current_timestamp, op_mode, sub_mode, sub_state) + op_mode_enum, sub_mode_enum, state_enum, _ = self._operation_status_match(op_mode=op_mode, sub_mode=sub_mode, state=sub_state) + event_tuple = (current_timestamp, op_mode_enum, sub_mode_enum, state_enum) # Update event dictionary self._event_dictionary[event_enum.name].append(event_tuple) @@ -313,3 +324,27 @@ self.process_into_vars(decoder_list = msg_list, message = message) 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]: + """ + 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 + """ + op_mode_enum = dd_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 state is not None: + 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) + + return op_mode_enum, sub_mode_enum, state_enum, sub_state_enum Index: leahi_dialin/fp/modules/events.py =================================================================== diff -u -rcdc6acfe393fcc90595116cf478725e16eba7f28 -r3c2bc6419b5796c03a7e4943938055c4ac36c24b --- leahi_dialin/fp/modules/events.py (.../events.py) (revision cdc6acfe393fcc90595116cf478725e16eba7f28) +++ leahi_dialin/fp/modules/events.py (.../events.py) (revision 3c2bc6419b5796c03a7e4943938055c4ac36c24b) @@ -14,18 +14,21 @@ # ############################################################################ +# Module imports import struct from logging import Logger from datetime import datetime -from time import time +from typing import Tuple +# Project imports from leahi_dialin.common import dd_enum_repository, fp_enum_repository from leahi_dialin.common.generic_defs import DataTypes from leahi_dialin.common.msg_defs import MsgFieldPositions from leahi_dialin.common.msg_ids import MsgIds from leahi_dialin.protocols.CAN import CanMessenger, CanChannels, CanMessenger from leahi_dialin.utils.abstract_classes import AbstractSubSystem from leahi_dialin.utils.base import publish +from leahi_dialin.utils.enums import DialinEnum class FPEvents(AbstractSubSystem): @@ -57,7 +60,7 @@ self.sub_mode = 0 #: The new Operation Sub-Mode value self.event_op_mode_timestamp = 0.0 #: The timestamp of the last Operation Mode change message - # Dictionary of the mode as key and the sub mode states enum class as the value + # Dictionary of the mode as key and the sub mode enum class as the value self._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, @@ -68,6 +71,17 @@ fp_enum_repository.FPOpModes.MODE_DEGP.name: fp_enum_repository.FPGenPermeateDefStates, 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, + 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, + fp_enum_repository.FPPreGenPermeateStates.FP_PRE_GENP_CONCENTRATE_FLUSH.name: fp_enum_repository.FPConcentrateFlushStates, + fp_enum_repository.FPPreGenPDefStates.FP_PRE_GENP_DEF_FLUSH.name: fp_enum_repository.FPDefFlushStates } + + # Dictionary of the state as key and the sub-state enum class as the value + self._state_2_sub_states = { } + # 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. self._event_dictionary = dict() @@ -287,7 +301,8 @@ event_tuple = (current_timestamp, event_enum.name, event_data_1, event_data_2) elif event_enum is fp_enum_repository.FPEventList.FP_EVENT_OPERATION_STATUS: - event_tuple = (current_timestamp, op_mode, sub_mode, sub_state) + op_mode_enum, sub_mode_enum, state_enum, _ = self._operation_status_match(op_mode=op_mode, sub_mode=sub_mode, state=sub_state) + event_tuple = (current_timestamp, op_mode_enum, sub_mode_enum, state_enum) # Update event dictionary self._event_dictionary[event_enum.name].append(event_tuple) @@ -310,3 +325,27 @@ self.process_into_vars(decoder_list = msg_list, message = message) 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]: + """ + 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 + """ + op_mode_enum = fp_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 state is not None: + 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) + + return op_mode_enum, sub_mode_enum, state_enum, sub_state_enum Index: leahi_dialin/td/modules/air_pump.py =================================================================== diff -u -r2d1aa1133cbaac4adbf4b6f7b2512f6b9255063f -r3c2bc6419b5796c03a7e4943938055c4ac36c24b --- leahi_dialin/td/modules/air_pump.py (.../air_pump.py) (revision 2d1aa1133cbaac4adbf4b6f7b2512f6b9255063f) +++ leahi_dialin/td/modules/air_pump.py (.../air_pump.py) (revision 3c2bc6419b5796c03a7e4943938055c4ac36c24b) @@ -16,11 +16,11 @@ # Module imports from logging import Logger - +import time # Project imports from leahi_dialin.common.constants import NO_RESET from leahi_dialin.common.generic_defs import DataTypes -from leahi_dialin.common.msg_defs import MsgIds +from leahi_dialin.common.msg_ids import MsgIds from leahi_dialin.common.override_templates import cmd_generic_broadcast_interval_override, cmd_generic_override from leahi_dialin.common import td_enum_repository from leahi_dialin.protocols.CAN import CanMessenger, CanChannels @@ -32,8 +32,6 @@ class TDAirPump(AbstractSubSystem): """ - TDAirPump - Treatment Delivery (TD) Dialin API sub-class for air pump related commands. """ @@ -64,6 +62,7 @@ td_enum_repository.TDAirPumpAttributes.SCALAR_POWER.name: 0 } } + self.handler_execution_times = [] @publish(["msg_id_td_air_pump_data", "td_air_pump", "td_air_pump_timestamp"]) @@ -74,6 +73,7 @@ @param message: published air pump data message as: air pump state @return: None """ + start = time.perf_counter() sensor_list =[] sensor_list.append((td_enum_repository.TDAirPumpNames.H12_AIR_PUMP.name, td_enum_repository.TDAirPumpAttributes.STATE.name, DataTypes.U32)) sensor_list.append((td_enum_repository.TDAirPumpNames.H12_AIR_PUMP.name, td_enum_repository.TDAirPumpAttributes.DUTY_CYCLE.name, DataTypes.F32)) @@ -87,6 +87,7 @@ decoder_list = sensor_list, message = message) self.td_air_pump_timestamp = timestamp + self.handler_execution_times.append((timestamp, message, time.perf_counter() - start)) def cmd_air_pump_data_broadcast_interval_override(self, ms: int, reset: int = NO_RESET) -> int: Index: leahi_dialin/td/modules/events.py =================================================================== diff -u -rdd92f40a5a5b13449356328cf2526dd948c587ad -r3c2bc6419b5796c03a7e4943938055c4ac36c24b --- leahi_dialin/td/modules/events.py (.../events.py) (revision dd92f40a5a5b13449356328cf2526dd948c587ad) +++ leahi_dialin/td/modules/events.py (.../events.py) (revision 3c2bc6419b5796c03a7e4943938055c4ac36c24b) @@ -18,12 +18,15 @@ import struct from logging import Logger from datetime import datetime +import time from typing import Tuple + # Project imports from leahi_dialin.common import td_enum_repository from leahi_dialin.common.generic_defs import DataTypes -from leahi_dialin.common.msg_defs import MsgIds, MsgFieldPositions +from leahi_dialin.common.msg_defs import MsgFieldPositions +from leahi_dialin.common.msg_ids import MsgIds from leahi_dialin.protocols.CAN import CanMessenger, CanChannels from leahi_dialin.utils.abstract_classes import AbstractSubSystem from leahi_dialin.utils.base import publish @@ -45,11 +48,11 @@ self.logger = logger if self.can_interface is not None: - self.can_interface.register_receiving_publication_function(channel_id = CanChannels.td_sync_broadcast_ch_id, + self.can_interface.register_receiving_publication_function(channel_id = CanChannels.td_to_ui_ch_id, message_id = MsgIds.MSG_ID_TD_EVENT.value, function = self._handler_events_sync) - self.can_interface.register_receiving_publication_function(channel_id = CanChannels.td_sync_broadcast_ch_id, + self.can_interface.register_receiving_publication_function(channel_id = CanChannels.td_to_ui_ch_id, message_id = MsgIds.MSG_ID_TD_OP_MODE_DATA.value, function = self._handler_td_op_mode_sync) @@ -97,6 +100,7 @@ self._event_dictionary = dict() for event in td_enum_repository.TDEventList: self._event_dictionary[td_enum_repository.TDEventList(event).name] = [] + self.handler_execution_times = [] def get_td_nth_event(self, event_id, event_number=0): @@ -166,6 +170,7 @@ @param message: published TD events data message @returns none """ + start = time.perf_counter() event_data_1 = 0 event_data_2 = 0 op_mode = 0 @@ -308,6 +313,7 @@ # Update event dictionary self._event_dictionary[event_enum.name].append(event_tuple) self.events_timestamp = timestamp + self.handler_execution_times.append((timestamp, message, time.perf_counter() - start)) @publish(["msg_id_td_op_mode_data", "event_op_mode_timestamp", "op_mode", "sub_mode"])