Index: firmware/App/Modes/ModeFill.c =================================================================== diff -u -r62ee40b55ed96eb0de1c0f05455eb986f76c1842 -r80028d3b1eef322950c1a5b74c282df2ba989ff5 --- firmware/App/Modes/ModeFill.c (.../ModeFill.c) (revision 62ee40b55ed96eb0de1c0f05455eb986f76c1842) +++ firmware/App/Modes/ModeFill.c (.../ModeFill.c) (revision 80028d3b1eef322950c1a5b74c282df2ba989ff5) @@ -36,18 +36,21 @@ // ********** private definitions ********** -#define FILL_MIN_RO_FLOW_RATE 0.6 ///< Minimum RO flow rate in fill mode. -#define FILL_MAX_RO_FLOW_RATE 1.0 ///< Maximum RO flow rate in fill mode. -#define FILL_TARGET_RO_FLOW_RATE 0.8 ///< Target RO flow rate in fill mode. -#define FILL_TARGET_RO_PRESSURE_PSI 120 ///< Target RO pressure in fill mode. -#define RO_FLOW_RATE_OUT_OF_RANGE_PERSISTENCE_PERIOD ( 5 * MS_PER_SECOND ) ///< Persistence period for RO flow rate out of range. +#define FILL_MIN_RO_FLOW_RATE 0.6 ///< Minimum RO flow rate in fill mode. +#define FILL_MAX_RO_FLOW_RATE 1.0 ///< Maximum RO flow rate in fill mode. +#define FILL_TARGET_RO_FLOW_RATE 0.8 ///< Target RO flow rate in fill mode. +#define FILL_TARGET_RO_PRESSURE_PSI 120 ///< Target RO pressure in fill mode. +#define RO_FLOW_RATE_OUT_OF_RANGE_PERSISTENCE_PERIOD ( 5 * MS_PER_SECOND ) ///< Persistence period for RO flow rate out of range. -#define DIALYSATE_ACID_CONCENTRATE_RATIO ( 2.35618 / 100 ) ///< Ratio between RO water and acid concentrate. -#define DIALYSATE_BICARB_CONCENTRATE_RATIO ( 4.06812 / 100 ) ///< Ratio between RO water and bicarbonate concentrate. +#define DIALYSATE_ACID_CONCENTRATE_RATIO ( 2.35618 / FRACTION_TO_PERCENT_FACTOR ) ///< Ratio between RO water and acid concentrate. +#define DIALYSATE_BICARB_CONCENTRATE_RATIO ( 4.06812 / FRACTION_TO_PERCENT_FACTOR ) ///< Ratio between RO water and bicarbonate concentrate. +#define DIALYSATE_FILL_TIME_OUT ( 5 * SEC_PER_MIN * MS_PER_SECOND ) ///< Time out period when reservoir is not filled with correct dialysate. + // ********** private data ********** -static DG_FILL_MODE_STATE_T fillState; ///< Currently active fill state. +static DG_FILL_MODE_STATE_T fillState; ///< Currently active fill state. +static U32 dialysateFillStartTime; ///< Current time when starting to fill dialysate. // ********** private function prototypes ********** @@ -82,6 +85,7 @@ void transitionToFillMode( void ) { fillState = DG_FILL_MODE_STATE_START; + dialysateFillStartTime = getMSTimerCount(); // set initial actuator states setValveState( VDR, VALVE_STATE_DRAIN_C_TO_NO ); @@ -90,6 +94,19 @@ /*********************************************************************//** * @brief + * The exitFillMode function prepares to exit fill mode. + * @details Inputs: none + * @details Outputs: requests concentrate pumps off, set valve to no fill + * @return none + *************************************************************************/ +void exitFillMode( void ) +{ + setValveState( VPO, VALVE_STATE_NOFILL_C_TO_NO ); + requestConcentratePumpsOff(); +} + +/*********************************************************************//** + * @brief * The execFillMode function executes the fill mode state machine. * @details Inputs: fillState * @details Outputs: Check water quality, fill mode state machine executed @@ -103,6 +120,12 @@ checkInletPressure(); checkRORejectionRatio(); + // check if run out of time to fill the reservoir + if ( didTimeout( dialysateFillStartTime, DIALYSATE_FILL_TIME_OUT ) ) + { + activateAlarmNoData( ALARM_ID_DG_DIALYSATE_FILL_OUT_OF_TIME ); + } + // execute current Fill state switch ( fillState ) { @@ -255,7 +278,7 @@ setConcentratePumpTargetSpeed( CONCENTRATEPUMPS_CP1, acidCP1PumpFlowRate ); setConcentratePumpTargetSpeed( CONCENTRATEPUMPS_CP2, bicarbCP2PumpFlowRate ); - BOOL const isROPumpFlowRateOutOfRange = ( measuredROFlowRate <= FILL_MIN_RO_FLOW_RATE ) || ( measuredROFlowRate >= FILL_MAX_RO_FLOW_RATE ) ; + BOOL const isROPumpFlowRateOutOfRange = ( measuredROFlowRate <= FILL_MIN_RO_FLOW_RATE ) || ( measuredROFlowRate >= FILL_MAX_RO_FLOW_RATE ); checkPersistentAlarm( PERSISTENT_ALARM_RO_PUMP_FLOW_RATE_OUT_OF_RANGE, isROPumpFlowRateOutOfRange, measuredROFlowRate ); }