Index: dialin/hd/calibration_record.py =================================================================== diff -u -r88b4967ce6b9ac816ac21b26326450de4b540887 -r5239867d81fd373c44964081fa9a8a5a93d10ff6 --- dialin/hd/calibration_record.py (.../calibration_record.py) (revision 88b4967ce6b9ac816ac21b26326450de4b540887) +++ dialin/hd/calibration_record.py (.../calibration_record.py) (revision 5239867d81fd373c44964081fa9a8a5a93d10ff6) @@ -469,7 +469,7 @@ hardware_names = ['blood_leak'] group_byte_size = 0 - group_name = 'blood_sensor_sensor' + group_name = 'blood_leak_sensor' hardware_group = OrderedDict({group_name: OrderedDict()}) hardware = OrderedDict() Index: dialin/hd/fans.py =================================================================== diff -u -rc3fa0bd1ad54dddd9f7faee36d806961959f362c -r5239867d81fd373c44964081fa9a8a5a93d10ff6 --- dialin/hd/fans.py (.../fans.py) (revision c3fa0bd1ad54dddd9f7faee36d806961959f362c) +++ dialin/hd/fans.py (.../fans.py) (revision 5239867d81fd373c44964081fa9a8a5a93d10ff6) @@ -163,7 +163,7 @@ # Send message received_message = self.can_interface.send(message) - # If there is no content... + # If there is content... if received_message is not None: self.logger.debug("RPM alarm start time offset set to: " + Index: dialin/hd/hemodialysis_device.py =================================================================== diff -u -r053580d8dbe39bf313d61b002d8d41a189d95c39 -r5239867d81fd373c44964081fa9a8a5a93d10ff6 --- dialin/hd/hemodialysis_device.py (.../hemodialysis_device.py) (revision 053580d8dbe39bf313d61b002d8d41a189d95c39) +++ dialin/hd/hemodialysis_device.py (.../hemodialysis_device.py) (revision 5239867d81fd373c44964081fa9a8a5a93d10ff6) @@ -51,14 +51,18 @@ from ..protocols.CAN import DenaliMessage, DenaliCanMessenger, DenaliChannels from ..utils.base import AbstractSubSystem, publish, LogManager from ..utils.checks import check_broadcast_interval_override_ms -from ..utils.conversions import integer_to_bytearray, unsigned_short_to_bytearray +from ..utils.conversions import integer_to_bytearray, unsigned_short_to_bytearray, bytearray_to_integer, \ + bytearray_to_byte class HD(AbstractSubSystem): """ Hemodialysis Device (HD) Dialin object API. It provides the basic interface to communicate with the HD firmware. """ + # HD debug event max count + _HD_DEBUG_EVENT_LIST_COUNT = 10 + _HD_DEBUG_EVENT_MSG_LEN_INDEX = 5 # HD login password HD_LOGIN_PASSWORD = '123' @@ -106,6 +110,10 @@ self.can_interface.register_receiving_publication_function(channel_id, msg_id, self._handler_hd_op_mode_sync) + self.can_interface.register_receiving_publication_function(channel_id, + MsgIds.MSG_ID_HD_DEBUG_EVENT.value, + self._handler_hd_debug_event_sync) + self.can_interface.register_receiving_publication_function(DenaliChannels.ui_to_hd_ch_id, MsgIds.MSG_ID_HD_UI_VERSION_INFO_RESPONSE.value, self._handler_ui_version_response_sync) @@ -115,10 +123,11 @@ self.hd_operation_sub_mode = 0 self.hd_logged_in = False self.hd_set_logged_in_status(False) - self.hd_no_transmit_msg_list = [0,0,0,0,0,0,0,0] + self.hd_no_transmit_msg_list = [0, 0, 0, 0, 0, 0, 0, 0] self.ui_version = None + self.hd_debug_events = [''] * self._HD_DEBUG_EVENT_LIST_COUNT + self._hd_debug_event_index = 0 - # Create command groups self.accel = HDAccelerometer(self.can_interface, self.logger) self.air_bubbles = HDAirBubbles(self.can_interface, self.logger) @@ -187,6 +196,28 @@ """ return self.ui_version + @publish(["hd_debug_events"]) + def _handler_hd_debug_event_sync(self, message): + + payload = message['message'] + message_length = payload[self._HD_DEBUG_EVENT_MSG_LEN_INDEX] + temp_message = '' + + index = MsgFieldPositions.START_POS_FIELD_1 + + for i in range(0, message_length): + # Loop through the length and get the + char, char_index = bytearray_to_byte(payload, index + i, False) + temp_message += chr(char) + + self._hd_debug_event_index = 0 if self._hd_debug_event_index == self._HD_DEBUG_EVENT_LIST_COUNT - 1 else \ + self._hd_debug_event_index + + self.hd_debug_events.insert(self._hd_debug_event_index, temp_message) + + # Print the latest received message from the debug event to the console + #print(temp_message) + @publish(["hd_logged_in"]) def hd_set_logged_in_status(self, logged_in: bool = False): """ Index: tests/dg_tests.py =================================================================== diff -u -rf5ed119ffe4c4cf520b22221073b1ff9a6f5968a -r5239867d81fd373c44964081fa9a8a5a93d10ff6 --- tests/dg_tests.py (.../dg_tests.py) (revision f5ed119ffe4c4cf520b22221073b1ff9a6f5968a) +++ tests/dg_tests.py (.../dg_tests.py) (revision 5239867d81fd373c44964081fa9a8a5a93d10ff6) @@ -40,6 +40,7 @@ from dialin.dg.pressures import DGPressures from dialin.dg.conductivity_sensors import ConductivitySensorsEnum from dialin.dg.voltages import DGMonitoredVoltages +from dialin.hd.valves import HDValves from time import sleep from datetime import datetime import sys @@ -638,7 +639,8 @@ # test_dg_fans_alarms() while True: - print(get_hd_fans_info()) + # print(get_hd_fans_info()) + print(hd.hd_debug_events) sleep(1) #dg.ro_pump.cmd_ro_pump_measured_flow_rate_override(0.0, reset=1) Index: tests/hd_nvm_scripts.py =================================================================== diff -u -rf5ed119ffe4c4cf520b22221073b1ff9a6f5968a -r5239867d81fd373c44964081fa9a8a5a93d10ff6 --- tests/hd_nvm_scripts.py (.../hd_nvm_scripts.py) (revision f5ed119ffe4c4cf520b22221073b1ff9a6f5968a) +++ tests/hd_nvm_scripts.py (.../hd_nvm_scripts.py) (revision 5239867d81fd373c44964081fa9a8a5a93d10ff6) @@ -54,10 +54,10 @@ # Use cmd_set_hd_calibration_excel_to_fw() set the changes back to firmware # This function requires an address for the excel report. Use the absolute address of your excel report like the # example below - #hd.calibration_record.cmd_set_hd_calibration_excel_to_fw('/home/fw/projects/HD_NV_Records/2022-02-21-HD-Record.xlsx') + hd.calibration_record.cmd_set_hd_calibration_excel_to_fw('/home/fw/projects/HD_NV_Records/2022-05-17-HD-Record.xlsx') # For resetting the calibration record to benign values, use the function below - hd.calibration_record.cmd_reset_hd_calibration_record() + #hd.calibration_record.cmd_reset_hd_calibration_record() if __name__ == "__main__": Index: tests/test_hd_valves.py =================================================================== diff -u -r3a70bfb451b74106348c064c34f19934aadd9119 -r5239867d81fd373c44964081fa9a8a5a93d10ff6 --- tests/test_hd_valves.py (.../test_hd_valves.py) (revision 3a70bfb451b74106348c064c34f19934aadd9119) +++ tests/test_hd_valves.py (.../test_hd_valves.py) (revision 5239867d81fd373c44964081fa9a8a5a93d10ff6) @@ -27,8 +27,13 @@ hd.valves.cmd_hd_valves_broadcast_interval_override(50) sleep(1) - hd.valves.cmd_home_hd_valve(ValvesEnum.VDI.name) + #hd.valves.cmd_home_hd_valve(ValvesEnum.VDI.value) + while True: + print(hd.valves.valves_status, hd.alarms.alarm_top) + sleep(0.05) + + """ # print params every second for a while while True: