Index: firmware/App/Controllers/DrainPump.c =================================================================== diff -u -r025612ad77fe630889a364586de54bffe5262d56 -r44222e803e04d057ab793ce6b72902b8bfe9b7d0 --- firmware/App/Controllers/DrainPump.c (.../DrainPump.c) (revision 025612ad77fe630889a364586de54bffe5262d56) +++ firmware/App/Controllers/DrainPump.c (.../DrainPump.c) (revision 44222e803e04d057ab793ce6b72902b8bfe9b7d0) @@ -118,7 +118,7 @@ static DRAIN_PUMP_STATE_T pendingDrainPumpCmd = DRAIN_PUMP_OFF_STATE; ///< Delayed (pending) drain pump command. static F32 pendingDrainPumpCmdTarget = 0.0; ///< Delayed (pending) drain pump command target (rpm or PSI depending on command). static U32 pendingDrainPumpCmdCountDown = 0; ///< Delayed (pending) drain pump command count down timer (in task intervals). -static F32 targetFlushLineVolume_L = 0.0; ///< Target flush volume in liters. +static DG_DRAIN_LINE_VOLUME_T drainLineVolumeRecord; /// ADC to RPM conversion coefficient or RPM to ADC conversion. static const F32 CONVERSION_COEFF = SEC_PER_MIN / ( 2 * TOGGLE_PERIOD_RESOLUTION_SECONDS * ROTATIONAL_TO_TOGGLE_PERIOD_CONVERSION ); @@ -130,22 +130,19 @@ static DRAIN_PUMP_STATE_T handleDrainPumpOpenLoopState( void ); static void stopDrainPump( void ); static void publishDrainPumpData( void ); -static BOOL processCalibrationData( void ); /*********************************************************************//** * @brief * The initDrainPump function initializes the DrainPump module. * @details Inputs: none - * @details Outputs: hasClosedLoopBeenRequested, targetFlushLineVolume_L, - * signalNewRPMRequest + * @details Outputs: hasClosedLoopBeenRequested, signalNewRPMRequest * @return none *************************************************************************/ void initDrainPump( void ) { stopDrainPump(); hasClosedLoopBeenRequested = FALSE; - targetFlushLineVolume_L = 0.0; signalNewRPMRequest = FALSE; // Initialize the drain pump PI controller @@ -379,6 +376,14 @@ *************************************************************************/ void execDrainPumpController( void ) { + // Check if a new calibration is available + if ( TRUE == isNewCalibrationRecordAvailable() ) + { + // This is only one record the number of items to check is 0 since the get NV data function does not do a for loop to check the calibration time + getNVRecord2Driver( GET_CAL_DRAIN_LINE_VOLUME_RECORD, (U08*)&drainLineVolumeRecord, sizeof( DG_DRAIN_LINE_VOLUME_T ), 0, + ALARM_ID_DG_DRAIN_LINE_VOLUME_INVALID_CAL_RECORD ); + } + // Handle pending drain pump command if ( pendingDrainPumpCmdCountDown > 0 ) { @@ -440,7 +445,9 @@ { SELF_TEST_STATUS_T result = SELF_TEST_STATUS_IN_PROGRESS; - BOOL calStatus = processCalibrationData(); + // This is only one record the number of items to check is 0 since the get NV data function does not do a for loop to check the calibration time + BOOL calStatus = getNVRecord2Driver( GET_CAL_DRAIN_LINE_VOLUME_RECORD, (U08*)&drainLineVolumeRecord, sizeof( DG_DRAIN_LINE_VOLUME_T ), 0, + ALARM_ID_DG_DRAIN_LINE_VOLUME_INVALID_CAL_RECORD ); if ( TRUE == calStatus ) { @@ -514,14 +521,15 @@ /*********************************************************************//** * @brief - * The getFlushLineVolume function returns the target flush line volume. - * @details Inputs: targetFlushLineVolume_L + * The getFlushLineVolumeL function returns the target flush line volume in + * liters. + * @details Inputs: drainLineVolumeRecord * @details Outputs: none * @return the target flush line volume in Liter *************************************************************************/ -F32 getFlushLineVolume( void ) +F32 getFlushLineVolumeL( void ) { - return targetFlushLineVolume_L; + return drainLineVolumeRecord.volume; } /*********************************************************************//** @@ -663,39 +671,7 @@ } } -/*********************************************************************//** - * @brief - * The processCalibrationData function gets the calibration data and makes - * sure it is valid by checking the calibration date. The calibration date - * should not be 0. - * @details Inputs: none - * @details Outputs: modeRecircTargetFlushVolL - * @return TRUE if the calibration record is valid, otherwise FALSE - *************************************************************************/ -static BOOL processCalibrationData( void ) -{ - BOOL status = TRUE; - // Get the calibration record from NVDataMgmt - DG_DRAIN_LINE_VOLUME_T calData = getDGDrainLineVolumeRecord(); - - // Check if the calibration data that was received from NVDataMgmt is legitimate - // The calibration date item should not be zero. If the calibration date is 0, - // then the data is not stored in the NV memory or it was corrupted. - if ( 0 == calData.calibrationTime ) - { -#ifndef SKIP_CAL_CHECK - activateAlarmNoData( ALARM_ID_DG_DRAIN_LINE_VOLUME_INVALID_CAL_RECORD ); - status = FALSE; -#endif - } - - // The calibration data was valid, update the local copy - targetFlushLineVolume_L = calData.volume; - - return status; -} - /************************************************************************* * TEST SUPPORT FUNCTIONS *************************************************************************/