Index: firmware/App/Modes/Dialysis.c =================================================================== diff -u -r7dc4bb045389ac95e6658602f2659f6071542361 -rc65f61087e62766e631f8fe1e07d488ee29147cf --- firmware/App/Modes/Dialysis.c (.../Dialysis.c) (revision 7dc4bb045389ac95e6658602f2659f6071542361) +++ firmware/App/Modes/Dialysis.c (.../Dialysis.c) (revision c65f61087e62766e631f8fe1e07d488ee29147cf) @@ -8,7 +8,7 @@ * @file Dialysis.c * * @author (last) Sean Nash -* @date (last) 28-Mar-2023 +* @date (last) 11-Jul-2023 * * @author (original) Sean * @date (original) 15-Jan-2020 @@ -179,6 +179,7 @@ setDialysateFlowRate = 0; setUFVolumeML = 0.0; setUFRate = 0.0; + resetDialOutRateOffset(); salineBolusBroadcastTimerCtr = 0; totalSalineVolumeDelivered_mL = 0.0; @@ -213,8 +214,10 @@ * The resetSalineBolus function initializes the saline bolus variables * at start of treatment or after stopping a bolus (e.g. alarm). Total * saline bolus volume delivered will not be affected by this function. - * @details Inputs: none - * @details Outputs: Dialysis sub-mode module initialized. + * @details Inputs: autoResumeUF + * @details Outputs: salineBolusStartRequested, salineBolusAbortRequested, + * bolusSalineVolumeDelivered_mL, currentSalineBolusState, autoResumeUF, + * currentUFState, currentDialysisState * @return none *************************************************************************/ void resetSalineBolus( void ) @@ -231,6 +234,7 @@ autoResumeUF = FALSE; currentUFState = UF_RUNNING_STATE; } + currentDialysisState = DIALYSIS_UF_STATE; } /*********************************************************************//** @@ -257,8 +261,6 @@ resetReservoirsVariables(); - signalStartDialysisStartOrResume(); - // Set valves for dialysis setValvePosition( VDI, VALVE_POSITION_B_OPEN ); setValvePosition( VDO, VALVE_POSITION_B_OPEN ); @@ -295,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 ); } /*********************************************************************//** @@ -439,6 +445,7 @@ { accept = TRUE; salineBolusStartRequested = TRUE; + signalInitiatePressureStabilization(); } // Send response @@ -479,6 +486,7 @@ { accept = TRUE; salineBolusAbortRequested = TRUE; + signalInitiatePressureStabilization(); } // Send response @@ -715,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) @@ -787,6 +796,7 @@ if ( priorSubState != currentUFState ) { + setCurrent4thLevelState( (U32)currentUFState ); SEND_EVENT_WITH_2_U32_DATA( HD_EVENT_SUB_STATE_CHANGE, priorSubState, currentUFState ); } @@ -831,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 ); } @@ -911,6 +923,7 @@ if ( SALINE_BOLUS_STATE_IDLE == currentSalineBolusState ) { *dialysisState = DIALYSIS_SALINE_BOLUS_STATE; + setCurrent4thLevelState( (U32)currentSalineBolusState ); } else { @@ -962,6 +975,7 @@ result = UF_PAUSED_STATE; // Go to saline bolus state *dialysisState = DIALYSIS_SALINE_BOLUS_STATE; + setCurrent4thLevelState( (U32)currentSalineBolusState ); } else { @@ -989,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; @@ -1070,6 +1084,8 @@ if ( ( totalSalineVolumeDelivered_mL >= (F32)MAX_SALINE_VOLUME_DELIVERED ) ) { result = SALINE_BOLUS_STATE_MAX_DELIVERED; + setCurrent4thLevelState( (U32)result ); + sendOperationStatusEvent(); } else { @@ -1092,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(); @@ -1107,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(); } @@ -1464,17 +1488,8 @@ uFResVolumeInMl = ( resFinalVolume[ inactiveRes ] - resStartVolume[ inactiveRes ] ); measUFVolumeFromPriorReservoirs += uFResVolumeInMl; - // Check UF rate + // Calc UF rate from reservoir weight change uFMeasRate = uFResVolumeInMl / resUFTimeInMin; - if ( fabs( resExpUFRate - uFMeasRate ) > MAX_UF_RATE_ACCURACY_ERROR_ML_MIN ) - { -#ifndef _RELEASE_ - if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_ULTRAFILTRATION_ALARMS ) != SW_CONFIG_ENABLE_VALUE ) -#endif - { - SET_ALARM_WITH_1_F32_DATA( ALARM_ID_HD_UF_RATE_ERROR, uFMeasRate ); - } - } SEND_EVENT_WITH_2_F32_DATA( HD_EVENT_RSRVR_UF_VOLUME_AND_TIME, uFResVolumeInMl, resUFTimeInMin ) SEND_EVENT_WITH_2_F32_DATA( HD_EVENT_RSRVR_UF_RATE, uFMeasRate, resExpUFRate )