Index: firmware/App/Modes/ModeFill.c =================================================================== diff -u -ra5e4e578efe1af6c82530e73d58b09b2b7ad625c -r8272c6f212023b3f591454c609088be36a6f5980 --- firmware/App/Modes/ModeFill.c (.../ModeFill.c) (revision a5e4e578efe1af6c82530e73d58b09b2b7ad625c) +++ firmware/App/Modes/ModeFill.c (.../ModeFill.c) (revision 8272c6f212023b3f591454c609088be36a6f5980) @@ -70,12 +70,13 @@ /// Fill conditions status typedef struct { - F32 fillFlowRateRunningSum; ///< Fill flow running sum. - U32 fillSampleCounter; ///< Fill flow sample counter. - F32 fillTemperatureRunningSum; ///< Fill temperature running sum. - F32 fillTemperatureAverage; ///< Fill temperature average value. - F32 fillFlowRateAverage; ///< Fill flow average value. - F32 fillLastTemperature; ///< Fill last temperature value. + F32 fillFlowRateRunningSum; ///< Fill flow running sum. + U32 fillSampleCounter; ///< Fill flow sample counter. + F32 fillTemperatureRunningSum; ///< Fill temperature running sum. + F32 fillTemperatureAverage; ///< Fill temperature average value. + F32 fillFlowRateAverage; ///< Fill flow average value. + F32 fillLastTemperature; ///< Fill last temperature value. + BOOL isThisFirstFill; ///< Fill flag to indicate whether it is the first fill or not. } FILL_CONDITION_STATUS_T; static DG_FILL_MODE_STATE_T fillState; ///< Currently active fill state. @@ -87,13 +88,13 @@ static U32 concentrateTestStartTime; ///< Starting time for concentrate test. static U32 concentratePumpPrimeCount; ///< Interval count for concentrate pump prime. -static F32 totalROFlowRateMLPM; ///< Total RO flow rate over period of time. +static F32 totalROFlowRateMLPM; ///< Total RO flow rate over period of time. static F32 acidConductivityTotal; ///< Total of acid conductivity during fill. static F32 dialysateConductivityTotal; ///< Total of dialysate conductivity during fill. static U32 conductivitySampleCount; ///< Sample count of conductivity during fill. -static OVERRIDE_F32_T usedAcidVolumeML = { 0.0, 0.0, 0.0, 0.0 }; ///< The integrated acid concentration volume has been used in ml. -static OVERRIDE_F32_T usedBicarbVolumeML = { 0.0, 0.0, 0.0, 0.0 }; ///< The integrated bicarb concentration volume has been used in ml. +static OVERRIDE_F32_T usedAcidVolumeML = { 0.0, 0.0, 0.0, 0.0 }; ///< The integrated acid concentration volume has been used in ml. +static OVERRIDE_F32_T usedBicarbVolumeML = { 0.0, 0.0, 0.0, 0.0 }; ///< The integrated bicarb concentration volume has been used in ml. // ********** private function prototypes ********** @@ -288,11 +289,25 @@ // At the beginning the last and average temperatures are considered as the trimmer heater target temperature which // is the dialysate temperature fillStatus.fillTemperatureAverage = getHeaterTargetTemperature( DG_TRIMMER_HEATER ); - fillStatus.fillLastTemperature = getHeaterTargetTemperature( DG_TRIMMER_HEATER ); + fillStatus.fillLastTemperature = getHeaterTargetTemperature( DG_TRIMMER_HEATER ) + RESERVOIR_EXTRA_TEMPERATURE; + fillStatus.isThisFirstFill = TRUE; } /*********************************************************************//** * @brief + * The isThisTheFirstFill function returns the boolean flag that indicates + * whether this is the first fill of a treatment or not. + * @details Inputs: none + * @details Outputs: none + * @return fillStatus.isThisFirstFill + *************************************************************************/ +BOOL isThisTheFirstFill( void ) +{ + return fillStatus.isThisFirstFill; +} + +/*********************************************************************//** + * @brief * The handleCheckInletWaterState function checks for inlet water quality * before jumping to dialysate production state. * @details Inputs: Temperature and conductivity alarms @@ -309,9 +324,10 @@ { concentrateTestStartTime = getMSTimerCount(); #ifndef DISABLE_MIXING - setConcentratePumpTargetSpeed( CONCENTRATEPUMPS_CP2_BICARB, CONCENTRATE_PUMP_MAX_SPEED ); - requestConcentratePumpOff( CONCENTRATEPUMPS_CP1_ACID ); - requestConcentratePumpOn( CONCENTRATEPUMPS_CP2_BICARB ); + + setConcentratePumpTargetSpeed( CONCENTRATEPUMPS_CP2_BICARB, CONCENTRATE_PUMP_MAX_SPEED ); + requestConcentratePumpOff( CONCENTRATEPUMPS_CP1_ACID ); + requestConcentratePumpOn( CONCENTRATEPUMPS_CP2_BICARB ); #endif result = DG_FILL_MODE_STATE_BICARB_PUMP_CHECK; } @@ -587,6 +603,7 @@ fillStatus.fillTemperatureRunningSum = 0.0; fillStatus.fillSampleCounter = 1; fillStatus.fillLastTemperature = getTemperatureValue( (U32)TEMPSENSORS_OUTLET_PRIMARY_HEATER ); + fillStatus.isThisFirstFill = FALSE; // Write the latest fill data into the RTC RAM for heaters control // TODO test this and make sure it is writing it correctly