Index: firmware/App/Modes/ModeGenIdle.c =================================================================== diff -u -r4bd3bf3483660050d3026f7f9adff43782bfc620 -r7a58e4adbfabe04c56ddca3f5aecdac2071cd1d0 --- firmware/App/Modes/ModeGenIdle.c (.../ModeGenIdle.c) (revision 4bd3bf3483660050d3026f7f9adff43782bfc620) +++ firmware/App/Modes/ModeGenIdle.c (.../ModeGenIdle.c) (revision 7a58e4adbfabe04c56ddca3f5aecdac2071cd1d0) @@ -47,6 +47,7 @@ #define TARGET_RO_PRESSURE_PSI 130 ///< Target pressure for RO pump. #define TARGET_RO_FLOW_RATE_L 0.8F ///< Target flow rate for RO pump. +#define MAX_IDLE_RSVR_WEIGHT_GAIN_ML 200.0F ///< Maximum fluid gain of inactive reservoir in Gen Idle mode (mL) #define HD_LOST_COMM_TIMEOUT_MS (5 * SEC_PER_MIN * MS_PER_SECOND ) ///< The time of HD lost comm before DG transition back to standby. #define BAD_FILL_SUBSTATES_PUB_INTERVAL ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ///< Interval (ms/task time) at which the bad fill sub-states is published on the CAN bus. #define DATA_PUBLISH_COUNTER_START_COUNT 61 ///< Data publish counter start count. @@ -66,6 +67,8 @@ static OVERRIDE_U32_T genIdleDataPublicationInterval = { BAD_FILL_SUBSTATES_PUB_INTERVAL, BAD_FILL_SUBSTATES_PUB_INTERVAL, 0, 0 }; ///< Interval (in ms) at which to publish bad fill sub-states to CAN bus. +static F32 initialReservoirWeight; ///< Initial weight of inactive reservoir in Gen Idle mode. +static DG_RESERVOIR_ID_T inactiveReservoir; ///< Inactive reservoir // ********** private function prototypes ********** @@ -79,6 +82,7 @@ static DG_GEN_IDLE_MODE_BAD_FILL_STATE_T handleSecondDrainState( void ); static DG_GEN_IDLE_MODE_BAD_FILL_STATE_T handleRefillState( DG_GEN_IDLE_MODE_STATE_T* idleState ); +static void checkInvalidReservoirFill( void ); static void publishGenIdleSubstates(); /*********************************************************************//** @@ -140,6 +144,9 @@ setCPLDCleanLEDColor( CPLD_CLEAN_LED_OFF ); + inactiveReservoir = getInactiveReservoir(); + initialReservoirWeight = getReservoirWeight( inactiveReservoir ); + return genIdleState; } @@ -247,6 +254,7 @@ break; } + checkInvalidReservoirFill(); publishGenIdleSubstates(); return (U32)genIdleState; @@ -467,6 +475,34 @@ /*********************************************************************//** * @brief + * The checkInvalidReservoirFill function checks for reservoir filling in + * generation idle mode when it should be constant. + * @details Inputs: inactiveReservoir, initialReservoirWeight + * @details Outputs: inactiveReservoir, initialReservoirWeight + * @return the next state + *************************************************************************/ +static void checkInvalidReservoirFill( void ) +{ + DG_RESERVOIR_ID_T currentInactiveReservoir = getInactiveReservoir(); + F32 reservoirWeight = getReservoirWeight( currentInactiveReservoir ); + + if ( currentInactiveReservoir != inactiveReservoir ) + { + // Inactive Reservoir changed, update the start value + inactiveReservoir = currentInactiveReservoir; + initialReservoirWeight = getReservoirWeight( inactiveReservoir ); + } + + // Check for unwanted filling unless a transfer is in progress + if ( ( FALSE == isReservoirTransferInProgress() ) && ( reservoirWeight > ( initialReservoirWeight + MAX_IDLE_RSVR_WEIGHT_GAIN_ML ) ) ) + { + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DG_INACTIVE_RESERVOIR_WEIGHT_OUT_OF_RANGE, initialReservoirWeight, reservoirWeight ); + } + +} + +/*********************************************************************//** + * @brief * The publishGenIdleSubstates function publishes gen idle * sub-states at the set interval. * @details Inputs: handleBadFillFlag, badFillState, targetFillVolumeML,