Index: firmware/App/Modes/ModeGenIdle.c =================================================================== diff -u -rc9368ea4b6e7b4a1ea5428a72cac86f317a9a460 -r674e18b10904e97f4b2624b826abc21f3220dd32 --- firmware/App/Modes/ModeGenIdle.c (.../ModeGenIdle.c) (revision c9368ea4b6e7b4a1ea5428a72cac86f317a9a460) +++ firmware/App/Modes/ModeGenIdle.c (.../ModeGenIdle.c) (revision 674e18b10904e97f4b2624b826abc21f3220dd32) @@ -43,23 +43,22 @@ // ********** private definitions ********** -#define TARGET_RO_PRESSURE_PSI 130 ///< Target pressure for RO pump. -#define TARGET_RO_FLOW_RATE_L 0.3 ///< Target flow rate for RO pump. -#define BAD_FLUSH_FILL_TARGET_VOLUME_ML 1000 ///< Target fill volume in the bad flush fill state. +#define TARGET_RO_PRESSURE_PSI 130 ///< Target pressure for RO pump. +#define TARGET_RO_FLOW_RATE_L 0.3 ///< Target flow rate for RO pump. +#define BAD_FLUSH_FILL_TARGET_VOLUME_ML 1000 ///< Target fill volume in the bad flush fill state. +#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. -/// The time of HD lost comm before DG transition back to standby. -#define HD_LOST_COMM_TIMEOUT_MS (5 * SEC_PER_MIN * MS_PER_SECOND ) -#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. - // ********** private data ********** -static DG_GEN_IDLE_MODE_STATE_T genIdleState; ///< Currently active generation idle state. -static DG_GEN_IDLE_MODE_BAD_FILL_STATE_T badFillState = DG_HANDLE_BAD_FILL_STATE_START; ///< Initialize bad fill sub-state. -static U32 hdLostCommStartTime_ms; ///< Lost communication with HD start time in ms. -static U32 badFillSubstatesPublicationTimerCounter; ///< Used to schedule bad fill sub-states publication to CAN bus. -static U32 targetFillVolumeML; ///< Save the target fill volume before calling startFillCmd(). -static BOOL handleBadFillFlag; ///< Internal signal flag to handle bad fill. -static OVERRIDE_U32_T badFillSubstatesPublishInterval = { BAD_FILL_SUBSTATES_PUB_INTERVAL, ///< Interval (in ms) at which to publish bad fill sub-states to CAN bus. +static DG_GEN_IDLE_MODE_STATE_T genIdleState; ///< Currently active generation idle state. +static DG_GEN_IDLE_MODE_BAD_FILL_STATE_T badFillState = DG_HANDLE_BAD_FILL_STATE_START; ///< Initialize bad fill sub-state. +static U32 hdLostCommStartTime_ms; ///< Lost communication with HD start time in ms. +static U32 genIdlePublicationTimerCounter; ///< Used to schedule bad fill sub-states publication to CAN bus. +static U32 targetFillVolumeML; ///< Save the target fill volume before calling startFillCmd(). +static BOOL handleBadFillFlag; ///< Internal signal flag to handle bad fill. +static OVERRIDE_U32_T badFillSubstatesPublishInterval = { BAD_FILL_SUBSTATES_PUB_INTERVAL, ///< Interval (in ms) at which to publish bad fill sub-states to CAN bus. BAD_FILL_SUBSTATES_PUB_INTERVAL, 0, 0 }; @@ -86,11 +85,11 @@ *************************************************************************/ void initGenIdleMode( void ) { - genIdleState = DG_GEN_IDLE_MODE_STATE_START; - hdLostCommStartTime_ms = 0; - targetFillVolumeML = 0; - badFillSubstatesPublicationTimerCounter = 0; - handleBadFillFlag = FALSE; + genIdleState = DG_GEN_IDLE_MODE_STATE_START; + hdLostCommStartTime_ms = 0; + targetFillVolumeML = 0; + genIdlePublicationTimerCounter = DATA_PUBLISH_COUNTER_START_COUNT; + handleBadFillFlag = FALSE; } /*********************************************************************//** @@ -423,24 +422,30 @@ * @brief * The publishBadFillSubstates function publishes idle mode bad fill * sub-states at the set interval. - * @details Inputs: badFillSubstatesPublicationTimerCounter - * @details Outputs: badFillSubstatesPublicationTimerCounter + * @details Inputs: genIdlePublicationTimerCounter + * @details Outputs: genIdlePublicationTimerCounter * @return none *************************************************************************/ static void publishBadFillSubstates( void ) { // publish bad fill sub-states on interval - if ( ++badFillSubstatesPublicationTimerCounter >= getU32OverrideValue( &badFillSubstatesPublishInterval ) ) + if ( ++genIdlePublicationTimerCounter >= getU32OverrideValue( &badFillSubstatesPublishInterval ) ) { GEN_IDLE_BAD_FILL_STATE data; data.badFillState = (U32)badFillState; broadcastData( MSG_ID_DG_BAD_FILL_SUB_STATE, COMM_BUFFER_OUT_CAN_DG_BROADCAST, (U08*)&data, sizeof( GEN_IDLE_BAD_FILL_STATE ) ); - badFillSubstatesPublicationTimerCounter = 0; + genIdlePublicationTimerCounter = 0; } } + +/************************************************************************* + * TEST SUPPORT FUNCTIONS + *************************************************************************/ + + /*********************************************************************//** * @brief * The testSetBadFillSubstatesPublishIntervalOverride function overrides the