Index: firmware/App/Modes/ModeGenIdle.c =================================================================== diff -u -r137f0bcce332075c1aade79b52c572a095934775 -r42128f305793acaf5f4387ec1825281911d62bff --- firmware/App/Modes/ModeGenIdle.c (.../ModeGenIdle.c) (revision 137f0bcce332075c1aade79b52c572a095934775) +++ firmware/App/Modes/ModeGenIdle.c (.../ModeGenIdle.c) (revision 42128f305793acaf5f4387ec1825281911d62bff) @@ -47,7 +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 200.0F ///< Maximum mL gain of inactive reservoir in Gen Idle mode +#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. @@ -67,7 +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 incative reservoir in Gen Idle mode. +static F32 initialReservoirWeight; ///< Initial weight of inactive reservoir in Gen Idle mode. +static DG_RESERVOIR_ID_T inactiveReservoir; ///< Inactive reservoir // ********** private function prototypes ********** @@ -142,7 +143,8 @@ setCPLDCleanLEDColor( CPLD_CLEAN_LED_OFF ); - initialReservoirWeight = getReservoirWeight( getInactiveReservoir() ); + inactiveReservoir = getInactiveReservoir(); + initialReservoirWeight = getReservoirWeight( inactiveReservoir ); return genIdleState; } @@ -300,7 +302,8 @@ static DG_GEN_IDLE_MODE_STATE_T handleFlushWaterState( void ) { DG_GEN_IDLE_MODE_STATE_T result = DG_GEN_IDLE_MODE_STATE_FLUSH_WATER; - F32 reservoirWeight = getReservoirWeight( getInactiveReservoir() ); + DG_RESERVOIR_ID_T currentInactiveReservoir = getInactiveReservoir(); + F32 reservoirWeight = getReservoirWeight( currentInactiveReservoir ); if ( ( TRUE == isAlarmActive( ALARM_ID_DG_ACID_BOTTLE_LOW_VOLUME ) ) || ( TRUE == isAlarmActive( ALARM_ID_DG_BICARB_BOTTLE_LOW_VOLUME ) ) ) { @@ -316,10 +319,17 @@ startFillCmd( getTargetFillVolumeML(), getTargetFillFlowRateLPM() ); } + if ( currentInactiveReservoir != inactiveReservoir ) + { + // Inactive Reservoir changed, update the start value + inactiveReservoir = currentInactiveReservoir; + initialReservoirWeight = getReservoirWeight( inactiveReservoir ); + } + // Check for unwanted filling - if ( reservoirWeight > ( initialReservoirWeight + MAX_IDLE_RSVR_WEIGHT_GAIN ) ) + if ( reservoirWeight > ( initialReservoirWeight + MAX_IDLE_RSVR_WEIGHT_GAIN_ML ) ) { - SET_ALARM_WITH_1_U32_DATA( ALARM_ID_DG_INACTIVE_RESERVOIR_WEIGHT_OUT_OF_RANGE, reservoirWeight ); + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DG_INACTIVE_RESERVOIR_WEIGHT_OUT_OF_RANGE, initialReservoirWeight, reservoirWeight ); } return result;