Index: dialin/common/msg_defs.py =================================================================== diff -u -r342405f045e63fafeaee5406be24312498950a28 -re41213d8e1c44fa12895f40276432f4a32d2d06f --- dialin/common/msg_defs.py (.../msg_defs.py) (revision 342405f045e63fafeaee5406be24312498950a28) +++ dialin/common/msg_defs.py (.../msg_defs.py) (revision e41213d8e1c44fa12895f40276432f4a32d2d06f) @@ -101,7 +101,8 @@ 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_HD_BLOOD_PRIME_PROGRESS = 0x59 # HD broadcast of blood prime progress + MSG_ID_HD_RECIRCULATE_PROGRESS = 0x5A # HD broadcast of recirculate progress + MSG_ID_HD_BLOOD_PRIME_PROGRESS = 0x59 # HD broadcast of blood prime progress MSG_ID_CAN_ERROR_COUNT = 0x999 # test code in support of EMC testing Index: dialin/ui/hd_simulator.py =================================================================== diff -u -r342405f045e63fafeaee5406be24312498950a28 -re41213d8e1c44fa12895f40276432f4a32d2d06f --- dialin/ui/hd_simulator.py (.../hd_simulator.py) (revision 342405f045e63fafeaee5406be24312498950a28) +++ dialin/ui/hd_simulator.py (.../hd_simulator.py) (revision e41213d8e1c44fa12895f40276432f4a32d2d06f) @@ -76,31 +76,36 @@ class TXStates: + # Sub Mode + TREATMENT_START_STATE = 0 # Start treatment - initialize treatment and go to blood prime state + TREATMENT_BLOOD_PRIME_STATE = 1 # Prime blood-side of dialyzer with gradual ramp for 1 min. while dialyzer is bypassed. No dialysis or UF taking place. No treatment time. + TREATMENT_DIALYSIS_STATE = 2 # Perform dialysis. Deliver Heparin as prescribed. Deliver UF as prescribed. Handle saline boluses as requested + TREATMENT_STOP_STATE = 3 # Treatment stopped. All pumps off. Dializer bypassed + TREATMENT_RINSEBACK_STATE = 4 # Perform rinseback with saline. Dialyzer bypassed. Dialysate recirculating + TREATMENT_RECIRC_STATE = 5 # Recirculate saline and dialysate while patient disconnected. Blood lines open and shunted. Dialyzer is bypassed + TREATMENT_END_STATE = 6 # Dialysis has ended. Blood pump slowed. Dialyzer is bypassed. Dialysate is recirculated. User can rinseback + # Saline states - SALINE_BOLUS_STATE_IDLE = 0 # No saline bolus delivery is in progress - SALINE_BOLUS_STATE_WAIT_FOR_PUMPS_STOP = 1 # Wait for pumps to stop before starting bolus - SALINE_BOLUS_STATE_IN_PROGRESS = 2 # A saline bolus delivery is in progress - SALINE_BOLUS_STATE_MAX_DELIVERED = 3 # Maximum saline bolus volume reached - no more saline bolus deliveries allowed + SALINE_BOLUS_STATE_IDLE = 0 # No saline bolus delivery is in progress + SALINE_BOLUS_STATE_WAIT_FOR_PUMPS_STOP = 1 # Wait for pumps to stop before starting bolus + SALINE_BOLUS_STATE_IN_PROGRESS = 2 # A saline bolus delivery is in progress + SALINE_BOLUS_STATE_MAX_DELIVERED = 3 # Maximum saline bolus volume reached - no more saline bolus deliveries allowed # UF states - UF_START_STATE = 0 # Start state of the ultrafiltration state machine - UF_PAUSED_STATE = 1 # Paused state of the ultrafiltration state machine - UF_RUNNING_STATE = 2 # Running state of the ultrafiltration state machine - UF_OFF_STATE = 3 # Completed/off state of the ultrafiltration state machine - UF_COMPLETED_STATE = 4 # Completed state of ultrafiltration state machine + UF_START_STATE = 0 # Start state of the ultrafiltration state machine + UF_PAUSED_STATE = 1 # Paused state of the ultrafiltration state machine + UF_RUNNING_STATE = 2 # Running state of the ultrafiltration state machine + UF_OFF_STATE = 3 # Completed/off state of the ultrafiltration state machine + UF_COMPLETED_STATE = 4 # Completed state of ultrafiltration state machine - # Sub Mode - # UI only cares about the actual state and _NOT could be any other state - TREATMENT_DIALYSIS_STATE_NOT = 0 - TREATMENT_DIALYSIS_STATE = 1 # Heparin states - HEPARIN_STATE_OFF = 0 # No heparin delivery is in progress - HEPARIN_STATE_PAUSED = 1 # Heparin delivery paused + HEPARIN_STATE_OFF = 0 # No heparin delivery is in progress + HEPARIN_STATE_PAUSED = 1 # Heparin delivery paused HEPARIN_STATE_INITIAL_BOLUS = 2 # Initial heparin bolus delivery in progress - HEPARIN_STATE_DISPENSING = 3 # Gradual heparin dispensing in progress - HEPARIN_STATE_COMPLETED = 4 # Heparin delivery stopped due to the set stop time before treatment end - HEPARIN_STATE_EMPTY = 5 # Heparin Syringe empty + HEPARIN_STATE_DISPENSING = 3 # Gradual heparin dispensing in progress + 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 @@ -113,8 +118,19 @@ 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 + # Blood Prime + BLOOD_PRIME_RAMP_STATE = 0 # Ramp state of the blood prime sub-mode state machine + # Treatment End + TREATMENT_END_WAIT_FOR_RINSEBACK_STATE = 0 # Wait for rinseback state of the treatment end sub-mode state machine + TREATMENT_END_PAUSED_STATE = 1 # Paused state of the treatment end sub-mode state machine + # Treatment Stop + TREATMENT_STOP_RECIRC_STATE = 0 # Dialysate re-circulation state of the treatment stop sub-mode state machine + TREATMENT_STOP_NO_RECIRC_STATE = 1 # No dialysate re-circulation state of the treatment stop sub-mode state machine + + + class EResponse: Rejected = 0 Accepted = 1 @@ -1316,18 +1332,37 @@ self.can_interface.send(message, 0) - def cmd_set_treatment_states_data(self, vSubMode, vUFState, vSalineState, vHeparingState, vRinsebackState, vRecirculateState ): + def cmd_set_treatment_states_data(self, + vSubMode, vUFState, vSalineState, vHeparingState, + vRinsebackState, vRecirculateState, + vBloodPrimeState, vTreatmentEndState, vTreammentStopState): """ 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) | #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| + | MSG | CAN ID | Box | Type | Ack | Src | Dst | Description | + |:----:|:------:|:---:|:------:|:---:|:---:|:---:|:-----------: | + |0x0F00| 0x040 | 7 | 1 Hz | N | HD | All | Treatment States Data | + + | #1:(U32) | #2:(U32) | #3:(U32) | #4:(U32) | + |:--: |:--: |:--: |:--: | + | \ref Data::mSubMode | \ref Data::mUFState | \ref Data::mSalineState | \ref Data::mHeparinState | + |||| + | #5:(U32) | #6:(U32) ||| + |:--: |:--: ||| + | \ref Data::mRinsebackState | \ref Data::mRecirculateState ||| + |||| + | #7:(U32) | #8:(U32) | #9:(U32) || + |:--: |:--: |:--: || + | \ref Data::vBloodPrimeState | \ref Data::mTreatmentEndState | \ref Data::vTreammentStopState || + :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 + :param vBloodPrimeState: (int) Blood Prime State + :param vTreatmentEndState: (int) Treatment End State + :param vTreammentStopState: (int) Treatment Stop State :return: none """ @@ -1337,6 +1372,9 @@ payload += integer_to_bytearray(vHeparingState) payload += integer_to_bytearray(vRinsebackState) payload += integer_to_bytearray(vRecirculateState) + payload += integer_to_bytearray(vBloodPrimeState) + payload += integer_to_bytearray(vTreatmentEndState) + payload += integer_to_bytearray(vTreammentStopState) message = DenaliMessage.build_message(channel_id=DenaliChannels.hd_sync_broadcast_ch_id, message_id=MsgIds.MSG_ID_TREATMENT_STATE.value, @@ -1556,29 +1594,54 @@ self.can_interface.send(message, 0) - def cmd_send_treatment_rinseback_data(self, vTarget, vCurrent, vRate): + def cmd_send_treatment_rinseback_data(self, vTarget, vCurrent, vRate, vTimeoutTotal, vTimeoutCountDown): """ 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 | + | MSG | CAN ID | Box | Type | Ack | Src | Dst | Description | #1:(F32) | #2:(F32) | #3:(U32) | #4:(U32) | #5:(U32) | + |:----:|:------:|:---:|:------:|:---:|:---:|:---:|:-----------: |:--: |:--: |:--: |:--: |:--: | + |0x5600| 0x020 | 6 | 1Hz | N | HD | UI | Rinseback progress data | \ref Data::mTarget | \ref Data::mCurrent | \ref Data::mRate | \ref Data::mTimeoutTotal | \ref Data::mTimeoutCountDown | - :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 + :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 + :param vTimeoutTotal : (uint ) Total Timeout + :param vTimeoutCountDown: (uint ) Current Timeout count down :return: None """ payload = float_to_bytearray(vTarget) payload += float_to_bytearray(vCurrent) payload += integer_to_bytearray(vRate) + payload += integer_to_bytearray(vTimeoutTotal) + payload += integer_to_bytearray(vTimeoutCountDown) 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_recirculate_data(self,vTimeoutTotal, vTimeoutCountDown): + """ + the rinseback state change Response message method + | MSG | CAN ID | Box | Type | Ack | Src | Dst | Description | #1:(U32) | #2:(U32) | + |:----:|:------:|:---:|:------:|:---:|:---:|:---:|:-----------: |:--: |:--: | + |0x5A00| 0x020 | 6 | 1Hz | N | HD | UI | Rinseback progress data | \ref Data::mTimeoutTotal | \ref Data::mTimeoutCountDown | + + :param vTimeoutTotal : (uint ) Total Timeout + :param vTimeoutCountDown: (uint ) Current Timeout count down + :return: None + """ + + payload = integer_to_bytearray(vTimeoutTotal) + payload += integer_to_bytearray(vTimeoutCountDown) + + message = DenaliMessage.build_message(channel_id=DenaliChannels.hd_to_ui_ch_id, + message_id=MsgIds.MSG_ID_HD_RECIRCULATE_PROGRESS.value, + payload=payload) + + self.can_interface.send(message, 0) + def cmd_send_treatment_blood_prime_data(self, vTarget, vCurrent): """ the bloodprime state change Response message method