Index: firmware/App/Services/Reservoirs.c =================================================================== diff -u -r9826fc85bd1497ec617ae0e825f78b91972de2b3 -r98a1a2a624373a1d140daed0136522ab6e635237 --- firmware/App/Services/Reservoirs.c (.../Reservoirs.c) (revision 9826fc85bd1497ec617ae0e825f78b91972de2b3) +++ firmware/App/Services/Reservoirs.c (.../Reservoirs.c) (revision 98a1a2a624373a1d140daed0136522ab6e635237) @@ -103,6 +103,9 @@ static F32 targetFillFlowRateLPM; ///< Target fill flow rate in L/min. static BOOL isThisTheFirstCycle; ///< Boolean flag to indicate whether this is the first cycle. static RESERVOIRS_PREVIOUS_STATUS reservoirPreviousStatus[ NUM_OF_DG_RESERVOIRS ]; ///< Reservoirs previous status. +static HD_MODE_SUB_MODE_T hdModes; ///< HD operations mode. +static BOOL hasROVolBeenWrittenToNV; ///< Boolean flag to indicate whether the RO volume has been written to NV RAM or not. +static BOOL hasDisinfectStatusBeenSet; ///< Boolean flag to indicate whether disinfect has been voided after starting treatment. /*********************************************************************//** * @brief @@ -115,15 +118,17 @@ *************************************************************************/ void initReservoirs( void ) { - activeReservoir.data = (U32)DG_RESERVOIR_1; - fillVolumeTargetMl.data = DEFAULT_FILL_VOLUME_ML; - drainVolumeTargetMl.data = DEFAULT_DRAIN_VOLUME_ML; - targetFillFlowRateLPM = 0.0; - isThisTheFirstCycle = TRUE; - dataPublishCounter = DATA_PUBLISH_COUNTER_START_COUNT; + activeReservoir.data = (U32)DG_RESERVOIR_1; + fillVolumeTargetMl.data = DEFAULT_FILL_VOLUME_ML; + drainVolumeTargetMl.data = DEFAULT_DRAIN_VOLUME_ML; + targetFillFlowRateLPM = 0.0; + isThisTheFirstCycle = TRUE; + dataPublishCounter = DATA_PUBLISH_COUNTER_START_COUNT; + hasROVolBeenWrittenToNV = FALSE; + hasDisinfectStatusBeenSet = FALSE; memset( &reservoirPreviousStatus, 0.0, sizeof( RESERVOIRS_PREVIOUS_STATUS ) * NUM_OF_DG_RESERVOIRS ); -} +} /*********************************************************************//** * @brief @@ -145,7 +150,42 @@ getNVRecord2Driver( GET_CAL_HEATING_RECORD, (U08*)&heatingConstsCalRecord, sizeof( heatingConstsCalRecord ), NUM_OF_CAL_DATA_RSRVRS, ALARM_ID_DG_HEATING_INVALID_CAL_RECORD ); } - + + if ( ( ( DG_MODE_FAUL == getCurrentOperationMode() ) || ( DG_MODE_STAN == getCurrentOperationMode() ) ) && ( FALSE == hasROVolBeenWrittenToNV ) ) + { + BOOL status; + DG_OP_MODE_T prevMode = getPreviousOperationMode(); + + switch( prevMode ) + { + case DG_MODE_GENE: + case DG_MODE_FILL: + case DG_MODE_DRAI: + case DG_MODE_FLUS: + case DG_MODE_HEAT: + case DG_MODE_CHEM: + // Mode is changing, write the RO generated volume to the RTC RAM and set the service flag to FALSE + // since this is not a from a service change + status = setROWaterGeneratedL( getROGeneratedVolumeL() ); + break; + } + + if ( TRUE == status ) + { + hasROVolBeenWrittenToNV = TRUE; + } + } + + if ( ( FALSE == hasDisinfectStatusBeenSet ) && ( MODE_TREA == hdModes.hdMode ) ) + { + BOOL status = setDisinfectStatus( FALSE ); + + if ( TRUE == status ) + { + hasDisinfectStatusBeenSet = TRUE; + } + } + // publish active reservoir, fill/drain volume targets at 1 Hz. if ( ++dataPublishCounter >= RESERVOIR_DATA_PUB_INTERVAL ) { @@ -202,8 +242,8 @@ } return result; -} - +} + /*********************************************************************//** * @brief * The setActiveReservoirCmd function sets the given reservoir as active @@ -457,6 +497,35 @@ /*********************************************************************//** * @brief + * The setHDOperationMode function sets HD operation mode value. + * @details Inputs: none + * @details Outputs: hdMode + * @param mode which is HD mode + * @param subMode which is HD submode + * @return none + *************************************************************************/ +void setHDOperationMode( U32 mode, U32 subMode ) +{ + hdModes.hdMode = (HD_OP_MODE_T)mode; + hdModes.hdSubMode = subMode; +} + +/*********************************************************************//** + * @brief + * The getHDOperationMode function copies the provided buffer with the HD + * mode and submode. + * @details Inputs: none + * @details Outputs: hdMode + * @param mode* pointer to the buffer of type HD_MODE_SUB_MODE_T + * @return none + *************************************************************************/ +void getHDOperationMode( HD_MODE_SUB_MODE_T* mode ) +{ + memcpy( mode, &hdModes, sizeof( HD_MODE_SUB_MODE_T ) ); +} + +/*********************************************************************//** + * @brief * The getInactiveReservoir function gets the inactive reservoir. * @details Inputs: activeReservoir * @details Outputs: none