Index: dialin/common/msg_defs.py =================================================================== diff -u -r1935655f59bd37df8cd89f69b6d5ee9b2fdc1233 -r15ac4efc414bb043b7a3d5af0be099389e8a4bd4 --- dialin/common/msg_defs.py (.../msg_defs.py) (revision 1935655f59bd37df8cd89f69b6d5ee9b2fdc1233) +++ dialin/common/msg_defs.py (.../msg_defs.py) (revision 15ac4efc414bb043b7a3d5af0be099389e8a4bd4) @@ -98,7 +98,11 @@ MSG_ID_HD_HEPARIN_DATA = 0x4D # HD Broadcast heparin data MSG_ID_UI_PRE_TREATMENT_UF_REQUEST = 0x4F # UI UF Initialization Request MSG_ID_HD_PRE_TREATMENT_UF_RESPONSE = 0x50 # HD response to user request to adjust the ultrafiltration in pre-treatment + MSG_ID_HD_RINSEBACK_CMD_RESPONSE = 0x53 # HD rinseback request response + MSG_ID_HD_RECIRC_CMD_RESPONSE = 0x55 # HD re-circ request response + MSG_ID_HD_RINSEBACK_PROGRESS = 0x56 # HD broadcast of rinseback progress + MSG_ID_CAN_ERROR_COUNT = 0x999 # test code in support of EMC testing # service/test CAN messages Index: dialin/protocols/CAN.py =================================================================== diff -u -r3338499f8613c3e0156b21c5535109c464cc5438 -r15ac4efc414bb043b7a3d5af0be099389e8a4bd4 --- dialin/protocols/CAN.py (.../CAN.py) (revision 3338499f8613c3e0156b21c5535109c464cc5438) +++ dialin/protocols/CAN.py (.../CAN.py) (revision 15ac4efc414bb043b7a3d5af0be099389e8a4bd4) @@ -473,6 +473,7 @@ DenaliMessage.crc8(self.messages))) if message_valid: + print(complete_dialin_message) # We first check if this is a response to a send request that is pending if dialin_msg_id == self.send_packet_request_id: Index: dialin/ui/hd_simulator.py =================================================================== diff -u -r46af3f4c8b9460406652c8b4193c71c92d63d4a7 -r15ac4efc414bb043b7a3d5af0be099389e8a4bd4 --- dialin/ui/hd_simulator.py (.../hd_simulator.py) (revision 46af3f4c8b9460406652c8b4193c71c92d63d4a7) +++ dialin/ui/hd_simulator.py (.../hd_simulator.py) (revision 15ac4efc414bb043b7a3d5af0be099389e8a4bd4) @@ -102,7 +102,19 @@ HEPARIN_STATE_COMPLETED = 4 # Heparin delivery stopped due to the set stop time before treatment end HEPARIN_STATE_EMPTY = 5 # Heparin Syringe empty + # Rinseback states + RINSEBACK_STOP_INIT_STATE = 0 # Start state (stopped) of the rinseback sub-mode state machine + RINSEBACK_RUN_STATE = 1 # Rinseback running state of the rinseback sub-mode state machine + RINSEBACK_PAUSED_STATE = 2 # Rinseback paused state of the rinseback sub-mode state machine + RINSEBACK_STOP_STATE = 3 # Rinseback stopped (done) state of the rinseback sub-mode state machine + RINSEBACK_RUN_ADDITIONAL_STATE = 4 # Additional rinseback volume (10 mL) state of the rinseback sub-mode state machine + # Recirculate + TREATMENT_RECIRC_RECIRC_STATE = 0 # Re-circulate state of the treatment re-circulate sub-mode state machine + TREATMENT_RECIRC_STOPPED_STATE = 1 # Stopped state of the treatment re-circulate sub-mode state machine + + + class EResponse: Rejected = 0 Accepted = 1 @@ -159,10 +171,11 @@ class HDSimulator(_AbstractSubSystem): NUM_TREATMENT_PARAMETERS = 18 + instanceCount = 0 def __init__(self, can_interface="can0", log_level=None): - super().__init__() + HDSimulator.instanceCount = HDSimulator.instanceCount + 1 self._log_manager = _LogManager(log_level=log_level, log_filepath=self.__class__.__name__ + ".log") self.logger = self._log_manager.logger @@ -1303,23 +1316,27 @@ self.can_interface.send(message, 0) - def cmd_set_treatment_states_data(self, vSubMode, vUFState, vSalineState, vHeparingState): + def cmd_set_treatment_states_data(self, vSubMode, vUFState, vSalineState, vHeparingState, vRinsebackState, vRecirculateState ): """ the Treatment States Data message setter/sender method - | MSG | CAN ID | Box | Type | Ack | Src | Dst | Description | #1:(U32) | #2:(U32) | #3:(U32) | #4:(U32) | - |:----:|:------:|:---:|:------:|:---:|:---:|:---:|:-----------: |:--: |:--: |:--: |:--: | - |0x0F00| 0x040 | 7 | 1 Hz | N | HD | All | Treatment States Data | \ref Data::mSubMode | \ref Data::mUFState | \ref Data::mSalineState | \ref Data::mHeparinState| + | MSG | CAN ID | Box | Type | Ack | Src | Dst | Description | #1:(U32) | #2:(U32) | #3:(U32) | #4:(U32) | #5:(U32) | #6:(U32) | + |:----:|:------:|:---:|:------:|:---:|:---:|:---:|:-----------: |:--: |:--: |:--: |:--: |:--: |:--: | + |0x0F00| 0x040 | 7 | 1 Hz | N | HD | All | Treatment States Data | \ref Data::mSubMode | \ref Data::mUFState | \ref Data::mSalineState | \ref Data::mHeparinState| \ref Data::mRinsebackState | \ref Data::mRecirculateState| :param vSubMode: (int) Sub-Mode :param vUFState: (int) UF State :param vSalineState: (int) Saline Bolus State :param vHeparingState: (int) Saline Bolus State + :param vRinsebackState: (int) Rinseback State + :param vRecirculateState: (int) Recirculate State :return: none """ - payload = integer_to_bytearray(vSubMode) + payload = integer_to_bytearray(vSubMode) payload += integer_to_bytearray(vUFState) payload += integer_to_bytearray(vSalineState) payload += integer_to_bytearray(vHeparingState) + payload += integer_to_bytearray(vRinsebackState) + payload += integer_to_bytearray(vRecirculateState) message = DenaliMessage.build_message(channel_id=DenaliChannels.hd_sync_broadcast_ch_id, message_id=MsgIds.MSG_ID_TREATMENT_STATE.value, @@ -1517,3 +1534,68 @@ payload=payload) self.can_interface.send(message, 0) + + def cmd_send_treatment_adjust_rinseback_response(self, vAccepted, vReason): + """ + the rinseback state change Response message method + | MSG | CAN ID | Box | Type | Ack | Src | Dst | Description | #1:(U32) | #2:(U32) | + |:----:|:------:|:---:|:------:|:---:|:---:|:---:|:-----------: |:--: |:--: | + |0x5300| 0x020 | 6 | Rsp | Y | HD | UI | Rinseback State Change Response | \ref Data::mAccepted | \ref Data::mReason | + + :param vAccepted: (int) boolean accept/reject response + :param vReason : (int) rejection reason + :return: None + """ + + payload = integer_to_bytearray(vAccepted) + payload += integer_to_bytearray(vReason) + + message = DenaliMessage.build_message(channel_id=DenaliChannels.hd_to_ui_ch_id, + message_id=MsgIds.MSG_ID_HD_RINSEBACK_CMD_RESPONSE.value, + payload=payload) + + self.can_interface.send(message, 0) + + def cmd_send_treatment_rinseback_data(self, vTarget, vCurrent, vRate): + """ + the rinseback state change Response message method + | MSG | CAN ID | Box | Type | Ack | Src | Dst | Description | #1:(F32) | #2:(F32) | #2:(U32) | + |:----:|:------:|:---:|:------:|:---:|:---:|:---:|:-----------: |:--: |:--: |:--: | + |0x5600| 0x020 | 6 | 1Hz | N | HD | UI | Rinseback progress data | \ref Data::mTarget | \ref Data::mCurrent | \ref Data::mRate | + + :param vTarget : (float) the target volume in mL + :param vCurrent : (float) the current volume in mL + :param vRate : (uint ) the current flow rate in mL/min + :return: None + """ + + payload = float_to_bytearray(vTarget) + payload += float_to_bytearray(vCurrent) + payload += integer_to_bytearray(vRate) + + message = DenaliMessage.build_message(channel_id=DenaliChannels.hd_to_ui_ch_id, + message_id=MsgIds.MSG_ID_HD_RINSEBACK_PROGRESS.value, + payload=payload) + + self.can_interface.send(message, 0) + + def cmd_send_treatment_adjust_recirculate_response(self, vAccepted, vReason): + """ + the recirculate state change Response message method + | MSG | CAN ID | Box | Type | Ack | Src | Dst | Description | #1:(U32) | #2:(U32) | + |:----:|:------:|:---:|:------:|:---:|:---:|:---:|:-----------: |:--: |:--: | + |0x5500| 0x020 | 6 | Rsp | Y | HD | UI | Recirculate State Change Response | \ref Data::mAccepted | \ref Data::mReason | + + :param vAccepted: (int) boolean accept/reject response + :param vReason : (int) rejection reason + :return: None + """ + + payload = integer_to_bytearray(vAccepted) + payload += integer_to_bytearray(vReason) + + message = DenaliMessage.build_message(channel_id=DenaliChannels.hd_to_ui_ch_id, + message_id=MsgIds.MSG_ID_HD_RECIRC_CMD_RESPONSE.value, + payload=payload) + + self.can_interface.send(message, 0)