Index: firmware/App/Controllers/DrainPump.c =================================================================== diff -u -r6f1f269cd7d91f41c51797d17a85a7ea249e21f3 -rdf0a0b9ce1414b00b381e516714f9089d8e4ae21 --- firmware/App/Controllers/DrainPump.c (.../DrainPump.c) (revision 6f1f269cd7d91f41c51797d17a85a7ea249e21f3) +++ firmware/App/Controllers/DrainPump.c (.../DrainPump.c) (revision df0a0b9ce1414b00b381e516714f9089d8e4ae21) @@ -22,6 +22,7 @@ #include "DrainPump.h" #include "FPGA.h" +#include "NVDataMgmt.h" #include "OperationModes.h" #include "PersistentAlarm.h" #include "PIControllers.h" @@ -115,6 +116,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 modeRecircTargetFlushVolL = 0.0; ///< Mode recirculation target flush volume in liters. /// 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 ); @@ -127,6 +129,7 @@ static void stopDrainPump( void ); static void publishDrainPumpData( void ); static U32 getPublishDrainPumpDataInterval( void ); +static BOOL processCalibrationData( void ); /*********************************************************************//** * @brief @@ -140,6 +143,7 @@ stopDrainPump(); hasClosedLoopBeenRequested = FALSE; + modeRecircTargetFlushVolL = 0.0; // Initialize the drain pump PI controller initializePIController( PI_CONTROLLER_ID_DRAIN_PUMP, DRAIN_PUMP_MIN_DAC, @@ -419,6 +423,31 @@ /*********************************************************************//** * @brief + * The execDrainPumpSelfTest function executes the drain pump's self-test. + * @details Inputs: none + * @details Outputs: none + * @return PressuresSelfTestResult (SELF_TEST_STATUS_T) + *************************************************************************/ +SELF_TEST_STATUS_T execDrainPumpSelfTest( void ) +{ + SELF_TEST_STATUS_T result = SELF_TEST_STATUS_IN_PROGRESS; + + BOOL calStatus = processCalibrationData(); + + if ( TRUE == calStatus ) + { + result = SELF_TEST_STATUS_PASSED; + } + else + { + result = SELF_TEST_STATUS_FAILED; + } + + return result; +} + +/*********************************************************************//** + * @brief * The getTargetDrainPumpRPM function gets the current target drain pump * RPM. * @details Inputs: targetDrainPumpRPM @@ -457,6 +486,19 @@ /*********************************************************************//** * @brief + * The getRecirculationDrainVol function returns the mode recirculation + * target flush volume. + * @details Inputs: modeRecircTargetFlushVolL + * @details Outputs: none + * @return modeRecircTargetFlushVolL which is a float + *************************************************************************/ +F32 getRecirculationDrainVol( void ) +{ + return modeRecircTargetFlushVolL; +} + +/*********************************************************************//** + * @brief * The handleDrainPumpOffState function handles the drain pump off state of * the drain pump controller state machine. * @details Inputs: drainPumpControlModeSet, drainPumpDACSet, drainPumpDAC @@ -612,6 +654,39 @@ } } +/*********************************************************************//** + * @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 DISABLE_CAL_CHECK + activateAlarmNoData( ALARM_ID_DG_DRAIN_LINE_VOLUME_INVALID_CALIBRATION ); +#endif + status = FALSE; + } + + // The calibration data was valid, update the local copy + modeRecircTargetFlushVolL = calData.volume; + + return status; +} + /************************************************************************* * TEST SUPPORT FUNCTIONS *************************************************************************/