Index: firmware/App/Modes/ModeGenIdle.c =================================================================== diff -u -r81769c6bea6ed32d70698fb03ad5823de1814b27 -reb57e092118ff2f79ba7cb48c551bacd01ad8aef --- firmware/App/Modes/ModeGenIdle.c (.../ModeGenIdle.c) (revision 81769c6bea6ed32d70698fb03ad5823de1814b27) +++ firmware/App/Modes/ModeGenIdle.c (.../ModeGenIdle.c) (revision eb57e092118ff2f79ba7cb48c551bacd01ad8aef) @@ -54,16 +54,17 @@ // ********** private data ********** +static U32 dataPublishCounter; ///< Used to schedule gen idle data publication to CAN bus. static DG_GEN_IDLE_MODE_STATE_T genIdleState; ///< Currently active generation idle state. // NOTE: the bad fill state must be initialized here and not in the transition function since in case of a bad fill, the transition function is called // several times to drain and fill and handle a bad fill. 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 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, - BAD_FILL_SUBSTATES_PUB_INTERVAL, - 0, 0 }; ///< Interval (in ms) at which to publish bad fill sub-states to CAN bus. +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. // ********** private function prototypes ********** @@ -77,7 +78,7 @@ static DG_GEN_IDLE_MODE_BAD_FILL_STATE_T handleSecondDrainState( void ); static DG_GEN_IDLE_MODE_BAD_FILL_STATE_T handleRefillState( void ); -static void publishBadFillSubstates( U32 badFill ); +static void publishGenIdleSubstates(); /*********************************************************************//** * @brief @@ -226,6 +227,8 @@ break; } + publishGenIdleSubstates(); + return (U32)genIdleState; } @@ -325,9 +328,6 @@ { DG_GEN_IDLE_MODE_BAD_FILL_STATE_T state = DG_HANDLE_BAD_FILL_STATE_FIRST_DRAIN; - // Publish the state prior to requesting a drain and transitioning to drain mode - publishBadFillSubstates( state ); - // Drain the bad filled reservoir first requestNewOperationMode( DG_MODE_DRAI ); @@ -354,16 +354,9 @@ state = DG_HANDLE_BAD_FILL_STATE_FLUSH_FILL; - // Publish the state prior to transitioning to fill mode - publishBadFillSubstates( state ); - // Start the flush fill startFillCmd( BAD_FLUSH_FILL_TARGET_VOLUME_ML, getTargetFillFlowRateLPM() ); } - else - { - publishBadFillSubstates( state ); - } return state; } @@ -380,9 +373,6 @@ { DG_GEN_IDLE_MODE_BAD_FILL_STATE_T state = DG_HANDLE_BAD_FILL_STATE_SECOND_DRAIN; - // Publish the state prior to transitioning to drain mode - publishBadFillSubstates( state ); - requestNewOperationMode( DG_MODE_DRAI ); return state; @@ -400,9 +390,6 @@ { DG_GEN_IDLE_MODE_BAD_FILL_STATE_T state = DG_HANDLE_BAD_FILL_STATE_REFILL; - // Publish the state prior to transitioning to fill mode - publishBadFillSubstates( state ); - // Refill to the saved target fill volume (~1500 mL) startFillCmd( targetFillVolumeML, getTargetFillFlowRateLPM() ); @@ -421,8 +408,6 @@ { DG_GEN_IDLE_MODE_BAD_FILL_STATE_T state = DG_HANDLE_BAD_FILL_STATE_START; - publishBadFillSubstates( state ); - // Clear wait for dialysate alarm condition to allow resume clearAlarmCondition( ALARM_ID_CREATING_DIALYSATE_PLEASE_WAIT ); // resume option will appear // Set flag to FALSE here so next call to idle exec will move to normal flush water state @@ -433,20 +418,29 @@ /*********************************************************************//** * @brief - * The publishBadFillSubstates function publishes idle mode bad fill + * The publishGenIdleSubstates function publishes gen idle * sub-states at the set interval. - * @details Inputs: none + * @details Inputs: handleBadFillFlag, badFillState, targetFillVolumeML * @details Outputs: none - * @param badFill the bad fill state that has to be published * @return none *************************************************************************/ -static void publishBadFillSubstates( U32 badFill ) +static void publishGenIdleSubstates( void ) { - GEN_IDLE_BAD_FILL_STATE data; + // publish Gen Idle pump data on interval + if ( ++dataPublishCounter >= getU32OverrideValue( &genIdleDataPublicationInterval ) ) + { + DG_GEN_IDLE_DATA_T data; - data.badFillState = badFill; + // Populate the data structure for publication + data.badFillSignal = (U32)handleBadFillFlag; + data.badFillState = (U32)badFillState; + data.genIdleState = (U32)getCurrentGenIdleState(); + data.targetFillVolumemL = targetFillVolumeML; - broadcastData( MSG_ID_DG_BAD_FILL_SUB_STATE, COMM_BUFFER_OUT_CAN_DG_BROADCAST, (U08*)&data, sizeof( GEN_IDLE_BAD_FILL_STATE ) ); + broadcastData( MSG_ID_DG_GEN_IDLE_DATA, COMM_BUFFER_OUT_CAN_DG_BROADCAST, (U08*)&data, sizeof( DG_GEN_IDLE_DATA_T ) ); + + dataPublishCounter = 0; + } } @@ -471,8 +465,8 @@ if ( TRUE == isTestingActivated() ) { U32 intvl = value / TASK_GENERAL_INTERVAL; - badFillSubstatesPublishInterval.ovData = intvl; - badFillSubstatesPublishInterval.override = OVERRIDE_KEY; + genIdleDataPublicationInterval.ovData = intvl; + genIdleDataPublicationInterval.override = OVERRIDE_KEY; result = TRUE; } @@ -493,8 +487,8 @@ if ( TRUE == isTestingActivated() ) { - badFillSubstatesPublishInterval.override = OVERRIDE_RESET; - badFillSubstatesPublishInterval.ovData = badFillSubstatesPublishInterval.ovInitData; + genIdleDataPublicationInterval.override = OVERRIDE_RESET; + genIdleDataPublicationInterval.ovData = genIdleDataPublicationInterval.ovInitData; result = TRUE; }