Index: firmware/App/Modes/ModeGenDialysate.c =================================================================== diff -u -r573a26b2a0273a4983b1de1cbff5bed63e01dce0 -r977f03e20990ed5579160b9b927df1c0f2428101 --- firmware/App/Modes/ModeGenDialysate.c (.../ModeGenDialysate.c) (revision 573a26b2a0273a4983b1de1cbff5bed63e01dce0) +++ firmware/App/Modes/ModeGenDialysate.c (.../ModeGenDialysate.c) (revision 977f03e20990ed5579160b9b927df1c0f2428101) @@ -28,6 +28,7 @@ #include "OperationModes.h" #include "PersistentAlarm.h" #include "Pressure.h" +#include "SpentChamberFill.h" #include "TaskGeneral.h" #include "TDInterface.h" #include "Temperature.h" @@ -87,10 +88,9 @@ static DD_GEND_MODE_STATE_T handleGenDDialysateBypassState( void ); static DD_GEND_MODE_STATE_T handleGenDDialysateDeliveryState( void ); static DD_GEND_MODE_STATE_T handleGenDDialysateDeliveryPauseState( void ); -static DD_GEND_MODE_STATE_T handleGenDDialysateIsolatedUFState( void ); -static F32 getGenDialysateTargetTemperature( void ); +static DD_GEND_MODE_STATE_T handleGenDSpentChamberFillState(void); +static DD_GEND_MODE_STATE_T handleGenDIsolatedUFState( void ); static void checkDialysateTemperature( void ); -static void calculateTargetDialysateTemp( void ); static void publishGenDialysateModeData( void ); /*********************************************************************//** @@ -319,12 +319,16 @@ genDialysateState = handleGenDDialysateDeliveryState(); break; + case DD_GEND_SPENT_CHAMBER_FILL_STATE: + genDialysateState = handleGenDSpentChamberFillState(); + break; + case DD_GEND_DIALYSATE_DELIVERY_PAUSE: genDialysateState = handleGenDDialysateDeliveryPauseState(); break; case DD_GEND_ISOLATED_UF_STATE: - genDialysateState = handleGenDDialysateIsolatedUFState(); + genDialysateState = handleGenDIsolatedUFState(); break; default: @@ -383,7 +387,7 @@ * @details \b Outputs: Adjusted Target temperature * @return none. *************************************************************************/ -static void calculateTargetDialysateTemp( void ) +void calculateTargetDialysateTemp( void ) { // Get the dialysate flow rate from TD F32 dialFlowrate = getTDDialysateFlowrate(); @@ -414,7 +418,7 @@ * @details \b Outputs: none * @return the current state of gen dialysate mode *************************************************************************/ -static DD_GEND_MODE_STATE_T handleGenDDialysateIsolatedUFState( void ) +static DD_GEND_MODE_STATE_T handleGenDIsolatedUFState( void ) { DD_GEND_MODE_STATE_T state = DD_GEND_ISOLATED_UF_STATE; @@ -491,7 +495,37 @@ return state; } +/*********************************************************************//** + * @brief + * The handleGenDSpentChamberFillState function performing spent + * chamber filling/degassing by executing balancing chamber. + * @details \b Inputs: none + * @details \b Outputs: balancing chamber state. + * @return the current state of gen dialysate mode + *************************************************************************/ +static DD_GEND_MODE_STATE_T handleGenDSpentChamberFillState( void ) +{ + DD_GEND_MODE_STATE_T state = DD_GEND_SPENT_CHAMBER_FILL_STATE; + LEVEL_STATE_T spentChamberLevel = getLevelStatus( D46_LEVL ); + + // High level is met + if ( LEVEL_STATE_HIGH == spentChamberLevel ) + { + setModeGenDStateTransition( DD_GEND_DIALYSATE_BYPASS_STATE ); + isDialDeliveryInProgress.data = FALSE; + state = DD_GEND_DIALYSATE_BYPASS_STATE; + } + else + { + //Execute Spent chamber fill + execSpentChamberFillControl(); + } + + return state; + +} + /*********************************************************************//** * @brief * The requestDDGenDialyasteStop function handles an TD request to stop @@ -644,7 +678,7 @@ * @details \b Outputs: none * @return the target dialysate temperature for the treatment. *************************************************************************/ -static F32 getGenDialysateTargetTemperature( void ) +F32 getGenDialysateTargetTemperature( void ) { F32 temp = getF32OverrideValue( &targetHydChamberFluidTemp );