Index: firmware/App/Modes/TreatmentStop.c =================================================================== diff -u -r13a064292b5a36a85593f53eabae268ae2bf4bc6 -r8639aa012127798aeb8fd719dd7f93b83275f944 --- firmware/App/Modes/TreatmentStop.c (.../TreatmentStop.c) (revision 13a064292b5a36a85593f53eabae268ae2bf4bc6) +++ firmware/App/Modes/TreatmentStop.c (.../TreatmentStop.c) (revision 8639aa012127798aeb8fd719dd7f93b83275f944) @@ -23,6 +23,7 @@ #include "DialOutFlow.h" #include "ModeTreatment.h" #include "OperationModes.h" +#include "SalineBolus.h" #include "SystemCommMessages.h" #include "TaskGeneral.h" #include "TreatmentStop.h" @@ -58,6 +59,7 @@ static TREATMENT_STOP_STATE_T handleTreatmentStopDialysateRecircState( void ); static TREATMENT_STOP_STATE_T handleTreatmentStopBloodRecircState( void ); static TREATMENT_STOP_STATE_T handleTreatmentStopRecoverBloodDetectState( void ); +static TREATMENT_STOP_STATE_T handleTreatmentStopDeliverSalineBolusState( void ); static void handleTreatmentStopBloodSittingTimer( void ); static void publishTreatmentStopData( void ); @@ -279,6 +281,10 @@ currentTxStopState = handleTreatmentStopRecoverBloodDetectState(); break; + case TREATMENT_STOP_DELIVER_SALINE_BOLUS_STATE: + currentTxStopState = handleTreatmentStopDeliverSalineBolusState(); + break; + default: SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_TREATMENT_STOP_INVALID_STATE, currentTxStopState ); break; @@ -291,6 +297,8 @@ } // Broadcast treatment stop status publishTreatmentStopData(); + // Just pass the blood leak related as 0 since only saline bolus data needs to be published + publishSalineBolusData( 0.0, 0.0, 0 ); } /*********************************************************************//** @@ -317,6 +325,17 @@ result = TREATMENT_STOP_RECOVER_BLOOD_DETECT_STATE; } } + else if ( ( TRUE == isSalineBolusStartRequested() ) || ( getSalineBolusState() != SALINE_BOLUS_STATE_IDLE ) ) + { + // No need for setup function since the saline bolus exec function starts from Idle and sets the actuators + result = TREATMENT_STOP_DELIVER_SALINE_BOLUS_STATE; + + if ( SALINE_BOLUS_STATE_IDLE == (U32)getSalineBolusState() ) + { + // Send the first 4th level state here only when we are in idle + setCurrent4thLevelState( (U32)getSalineBolusState() ); + } + } else { // Both unblocked and not in recirculate both state @@ -383,7 +402,7 @@ handleTreatmentStopBloodSittingTimer(); - result = handleTreatmentStopAlarmsAndSignals(result); + result = handleTreatmentStopAlarmsAndSignals( result ); return result; } @@ -400,7 +419,7 @@ { TREATMENT_STOP_STATE_T result = TREATMENT_STOP_RECIRC_BLOOD_ONLY_STATE; - result = handleTreatmentStopAlarmsAndSignals(result); + result = handleTreatmentStopAlarmsAndSignals( result ); return result; } @@ -449,6 +468,25 @@ /*********************************************************************//** * @brief + * The handleTreatmentStopDeliverSalineBolusState function handles the + * delivery of saline bolus state in treatment stop. + * @details Inputs: none + * @details Outputs: none + * @return next treatment stop state + *************************************************************************/ +static TREATMENT_STOP_STATE_T handleTreatmentStopDeliverSalineBolusState( void ) +{ + TREATMENT_STOP_STATE_T result = TREATMENT_STOP_DELIVER_SALINE_BOLUS_STATE; + + execSalineBolus(); + + result = handleTreatmentStopAlarmsAndSignals( result ); + + return result; +} + +/*********************************************************************//** + * @brief * The handleTreatmentStopBloodSittingTimer function handles the no re-circ * blood timer. It should only be called when Blood is NOT circulating. * Increments and checks for warning and alarm timeouts.