Index: firmware/App/Modes/Dialysis.c =================================================================== diff -u -r833dc8408890ca24e537ccfd7cbc7f47abe19aa4 -rc65f61087e62766e631f8fe1e07d488ee29147cf --- firmware/App/Modes/Dialysis.c (.../Dialysis.c) (revision 833dc8408890ca24e537ccfd7cbc7f47abe19aa4) +++ firmware/App/Modes/Dialysis.c (.../Dialysis.c) (revision c65f61087e62766e631f8fe1e07d488ee29147cf) @@ -7,8 +7,8 @@ * * @file Dialysis.c * -* @author (last) Michael Garthwaite -* @date (last) 15-May-2023 +* @author (last) Sean Nash +* @date (last) 11-Jul-2023 * * @author (original) Sean * @date (original) 15-Jan-2020 @@ -297,6 +297,10 @@ setAlarmUserActionEnabled( ALARM_USER_ACTION_RESUME, TRUE ); setAlarmUserActionEnabled( ALARM_USER_ACTION_RINSEBACK, TRUE ); setAlarmUserActionEnabled( ALARM_USER_ACTION_END_TREATMENT, TRUE ); + + //Set substate for event + setCurrentSubState( (U32)currentDialysisState ); + setCurrent4thLevelState( (U32)currentUFState ); } /*********************************************************************//** @@ -441,6 +445,7 @@ { accept = TRUE; salineBolusStartRequested = TRUE; + signalInitiatePressureStabilization(); } // Send response @@ -481,6 +486,7 @@ { accept = TRUE; salineBolusAbortRequested = TRUE; + signalInitiatePressureStabilization(); } // Send response @@ -790,6 +796,7 @@ if ( priorSubState != currentUFState ) { + setCurrent4thLevelState( (U32)currentUFState ); SEND_EVENT_WITH_2_U32_DATA( HD_EVENT_SUB_STATE_CHANGE, priorSubState, currentUFState ); } @@ -834,8 +841,10 @@ break; } - if ( priorSubState != currentSalineBolusState ) + // MAX DELIVERED transitions different and sends the event on its own. + if ( priorSubState != currentSalineBolusState && currentSalineBolusState != SALINE_BOLUS_STATE_MAX_DELIVERED ) { + setCurrent4thLevelState( (U32)currentSalineBolusState ); SEND_EVENT_WITH_2_U32_DATA( HD_EVENT_SUB_STATE_CHANGE, priorSubState, currentSalineBolusState ); } @@ -914,6 +923,7 @@ if ( SALINE_BOLUS_STATE_IDLE == currentSalineBolusState ) { *dialysisState = DIALYSIS_SALINE_BOLUS_STATE; + setCurrent4thLevelState( (U32)currentSalineBolusState ); } else { @@ -965,6 +975,7 @@ result = UF_PAUSED_STATE; // Go to saline bolus state *dialysisState = DIALYSIS_SALINE_BOLUS_STATE; + setCurrent4thLevelState( (U32)currentSalineBolusState ); } else { @@ -992,9 +1003,9 @@ { salineBolusStartRequested = FALSE; // Cmd all pumps to stop - setBloodPumpTargetFlowRate( 0, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_CLOSED_LOOP ); - setDialInPumpTargetFlowRate( 0, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_CLOSED_LOOP ); - setDialOutPumpTargetRate( 0, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_CLOSED_LOOP ); + setBloodPumpTargetFlowRate( 0, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_OPEN_LOOP ); + setDialInPumpTargetFlowRate( 0, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_OPEN_LOOP ); + setDialOutPumpTargetRate( 0, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_OPEN_LOOP ); stopSyringePump(); // Begin saline bolus result = SALINE_BOLUS_STATE_WAIT_FOR_PUMPS_STOP; @@ -1073,6 +1084,8 @@ if ( ( totalSalineVolumeDelivered_mL >= (F32)MAX_SALINE_VOLUME_DELIVERED ) ) { result = SALINE_BOLUS_STATE_MAX_DELIVERED; + setCurrent4thLevelState( (U32)result ); + sendOperationStatusEvent(); } else { @@ -1095,6 +1108,8 @@ // Hard stop blood and dialysate pumps signalBloodPumpHardStop(); signalDialInPumpHardStop(); + // Tell DG to stop heating dialysate + cmdStopDGTrimmerHeater(); // Send last saline bolus data salineBolusBroadcastTimerCtr = SALINE_BOLUS_DATA_PUB_INTERVAL; publishSalineBolusData(); @@ -1110,7 +1125,13 @@ { autoResumeUF = FALSE; currentUFState = UF_RUNNING_STATE; + //Set substate for event + setCurrentSubState( (U32)DIALYSIS_UF_STATE ); + setCurrent4thLevelState( (U32)currentUFState ); + sendOperationStatusEvent(); + } + signalInitiatePressureStabilization(); // Resume dialysis transitionToDialysis(); }