Index: firmware/App/Modes/Dialysis.c =================================================================== diff -u -r4dc7ebcdfbc935ca591ecc55412f1763ef6b3eaa -rc65f61087e62766e631f8fe1e07d488ee29147cf --- firmware/App/Modes/Dialysis.c (.../Dialysis.c) (revision 4dc7ebcdfbc935ca591ecc55412f1763ef6b3eaa) +++ firmware/App/Modes/Dialysis.c (.../Dialysis.c) (revision c65f61087e62766e631f8fe1e07d488ee29147cf) @@ -8,7 +8,7 @@ * @file Dialysis.c * * @author (last) Sean Nash -* @date (last) 24-Apr-2023 +* @date (last) 11-Jul-2023 * * @author (original) Sean * @date (original) 15-Jan-2020 @@ -261,8 +261,6 @@ resetReservoirsVariables(); - signalStartDialysisStartOrResume(); - // Set valves for dialysis setValvePosition( VDI, VALVE_POSITION_B_OPEN ); setValvePosition( VDO, VALVE_POSITION_B_OPEN ); @@ -299,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 ); } /*********************************************************************//** @@ -443,6 +445,7 @@ { accept = TRUE; salineBolusStartRequested = TRUE; + signalInitiatePressureStabilization(); } // Send response @@ -483,6 +486,7 @@ { accept = TRUE; salineBolusAbortRequested = TRUE; + signalInitiatePressureStabilization(); } // Send response @@ -719,6 +723,7 @@ if ( priorSubState != currentDialysisState ) { + setCurrentSubState( (U32)currentDialysisState ); SEND_EVENT_WITH_2_U32_DATA( HD_EVENT_SUB_STATE_CHANGE, priorSubState, currentDialysisState ); } // Publish saline bolus data at set interval (whether we are delivering one or not) @@ -791,6 +796,7 @@ if ( priorSubState != currentUFState ) { + setCurrent4thLevelState( (U32)currentUFState ); SEND_EVENT_WITH_2_U32_DATA( HD_EVENT_SUB_STATE_CHANGE, priorSubState, currentUFState ); } @@ -835,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 ); } @@ -915,6 +923,7 @@ if ( SALINE_BOLUS_STATE_IDLE == currentSalineBolusState ) { *dialysisState = DIALYSIS_SALINE_BOLUS_STATE; + setCurrent4thLevelState( (U32)currentSalineBolusState ); } else { @@ -966,6 +975,7 @@ result = UF_PAUSED_STATE; // Go to saline bolus state *dialysisState = DIALYSIS_SALINE_BOLUS_STATE; + setCurrent4thLevelState( (U32)currentSalineBolusState ); } else { @@ -993,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; @@ -1074,6 +1084,8 @@ if ( ( totalSalineVolumeDelivered_mL >= (F32)MAX_SALINE_VOLUME_DELIVERED ) ) { result = SALINE_BOLUS_STATE_MAX_DELIVERED; + setCurrent4thLevelState( (U32)result ); + sendOperationStatusEvent(); } else { @@ -1096,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(); @@ -1111,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(); }