Index: firmware/App/Modes/OperationModes.c =================================================================== diff -u -rc230be1bd4296324bf5dfc288c212eb7c2ce5d2d -rd19a072db6880577f677093929b53445e34a33e3 --- firmware/App/Modes/OperationModes.c (.../OperationModes.c) (revision c230be1bd4296324bf5dfc288c212eb7c2ce5d2d) +++ firmware/App/Modes/OperationModes.c (.../OperationModes.c) (revision d19a072db6880577f677093929b53445e34a33e3) @@ -57,6 +57,7 @@ /// DG operation mode data publish interval. static OVERRIDE_U32_T dgOpModePublishInterval = { BROADCAST_DG_OP_MODE_INTERVAL, BROADCAST_DG_OP_MODE_INTERVAL, 0, 0 }; static U32 dataPublishCounter; ///< Interval counter used to determine when to broadcast operation mode. Initialize to 11 to stagger broadcast. +static U32 currentSubState; ///< The currently active sub state. /// This matrix determines legal transitions from one mode to another. static const DG_OP_MODE_T MODE_TRANSITION_TABLE[ NUM_OF_DG_MODES - 1 ][ NUM_OF_DG_MODES - 1 ] = @@ -83,6 +84,7 @@ static void transitionToNewOperationMode( DG_OP_MODE_T newMode ); static U32 getDGOpModePublishInterval( void ); static void broadcastOperationMode( void ); +static void sendOperationStatusEvent( void ); /*********************************************************************//** * @brief @@ -106,6 +108,7 @@ lastMode = DG_MODE_INIT; currentMode = DG_MODE_INIT; currentSubMode = 0; + currentSubState = 0xFF; dataPublishCounter = DATA_PUBLISH_COUNTER_START_COUNT; transitionToNewOperationMode( DG_MODE_INIT ); @@ -137,6 +140,8 @@ { DG_OP_MODE_T newMode; U32 priorSubMode = currentSubMode; + U32 priorOpMode = currentMode; + U32 priorSubState = currentSubState; // any new mode requests? newMode = arbitrateModeRequest(); // will return current mode if no pending requests @@ -220,9 +225,10 @@ break; } - // Send sub-mode change event when appropriate - if ( priorSubMode != currentSubMode ) + // Send operation status event when appropriate + if ( priorOpMode != currentMode || priorSubMode != currentSubMode || priorSubState != currentSubState ) { + sendOperationStatusEvent(); SEND_EVENT_WITH_2_U32_DATA( DG_EVENT_SUB_MODE_CHANGE, priorSubMode, currentSubMode ) } @@ -426,7 +432,47 @@ return result; } +/*********************************************************************//** + * @brief + * The setCurrentSubState function sets the current subState. + * @details Inputs: subState + * @details Outputs: currentSubState + * @param subState the enumerated sub state. + * @return none + *************************************************************************/ +void setCurrentSubState( U32 subState ) +{ + currentSubState = subState; +} +/*********************************************************************//** + * @brief + * The sendOperationStatusEvent function constructs and sends an DG operation + * status event. + * @details Inputs: currentMode, currentSubMode, currentSubState + * @details Outputs: dat1, dat2. + * @param none + * @return none + *************************************************************************/ +static void sendOperationStatusEvent() +{ + + EVENT_DATA_T dat1; + EVENT_DATA_T dat2; + U32 opData = ( (U08)currentMode + + ( (U08)currentSubMode << SHIFT_8_BITS_FOR_BYTE_SHIFT ) + + ( (U08)currentSubState << SHIFT_16_BITS_FOR_WORD_SHIFT ) ); + + dat2.dataType = EVENT_DATA_TYPE_U32; + dat2.data.uInt.data = 0; + + dat1.dataType = EVENT_DATA_TYPE_U32; + dat1.data.uInt.data = opData; + + sendEvent( DG_EVENT_OPERATION_STATUS, dat1, dat2 ); +} + + /************************************************************************* * TEST SUPPORT FUNCTIONS *************************************************************************/