Index: firmware/App/Modes/OperationModes.c =================================================================== diff -u -r2468e56fbecd26da713bc78535bd727f4b105fe1 -raf0faf02f1bd7bffcce083e9b52988a01c343d8e --- firmware/App/Modes/OperationModes.c (.../OperationModes.c) (revision 2468e56fbecd26da713bc78535bd727f4b105fe1) +++ firmware/App/Modes/OperationModes.c (.../OperationModes.c) (revision af0faf02f1bd7bffcce083e9b52988a01c343d8e) @@ -50,6 +50,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 broadcastModeIntervalCtr = 11; ///< Interval counter used to determine when to broadcast operation mode. Initialize to 11 to stagger broadcast. +static U32 priorSubMode = 0; ///< The prior submode 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 ] = @@ -96,6 +97,7 @@ // start in init mode currentMode = DG_MODE_INIT; currentSubMode = 0; + priorSubMode = 0; transitionToNewOperationMode( DG_MODE_INIT ); // call initializers for the individual modes @@ -122,8 +124,9 @@ void execOperationModes( void ) { DG_OP_MODE_T newMode; - U32 priorSubMode = currentSubMode; + priorSubMode = currentSubMode; + // any new mode requests? newMode = arbitrateModeRequest(); // will return current mode if no pending requests newMode = MODE_TRANSITION_TABLE[ currentMode ][ newMode ]; @@ -201,8 +204,9 @@ // Send sub-mode change event when appropriate if ( priorSubMode != currentSubMode ) { - SEND_EVENT_WITH_2_U32_DATA( DG_EVENT_SUB_MODE_CHANGE, priorSubMode, currentSubMode ); + SEND_EVENT_WITH_2_U32_DATA( DG_EVENT_SUB_MODE_CHANGE, priorSubMode, currentSubMode ) } + priorSubMode = currentSubMode; // publish op mode on interval @@ -304,48 +308,52 @@ *************************************************************************/ static void transitionToNewOperationMode( DG_OP_MODE_T newMode ) { - SEND_EVENT_WITH_2_U32_DATA( DG_EVENT_OP_MODE_CHANGE, lastMode, newMode ); + SEND_EVENT_WITH_2_U32_DATA( DG_EVENT_OP_MODE_CHANGE, lastMode, newMode ) // setup for new operating mode switch ( newMode ) { case DG_MODE_FAUL: - transitionToFaultMode(); + currentSubMode = transitionToFaultMode(); break; case DG_MODE_SERV: - transitionToServiceMode(); + currentSubMode = transitionToServiceMode(); break; case DG_MODE_INIT: - transitionToInitAndPOSTMode(); + currentSubMode = transitionToInitAndPOSTMode(); break; case DG_MODE_STAN: - transitionToStandbyMode(); + currentSubMode = transitionToStandbyMode(); break; case DG_MODE_SOLO: - transitionToSoloMode(); + currentSubMode = transitionToSoloMode(); break; case DG_MODE_GENE: - transitionToGenIdleMode(); + currentSubMode = transitionToGenIdleMode(); break; case DG_MODE_FILL: - transitionToFillMode(); + currentSubMode = transitionToFillMode(); break; case DG_MODE_DRAI: - transitionToDrainMode(); + currentSubMode = transitionToDrainMode(); break; case DG_MODE_FLUS: - transitionToFlushMode(); + currentSubMode = transitionToFlushMode(); break; case DG_MODE_HEAT: - transitionToHeatDisinfectMode(); + currentSubMode = transitionToHeatDisinfectMode(); break; case DG_MODE_CHEM: - transitionToChemicalDisinfectMode(); + currentSubMode = transitionToChemicalDisinfectMode(); break; default: SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DG_SOFTWARE_FAULT, SW_FAULT_ID_OP_MODES_INVALID_MODE_TO_TRANSITION_TO, (U32)newMode ) break; } + + SEND_EVENT_WITH_2_U32_DATA( DG_EVENT_SUB_MODE_CHANGE, priorSubMode, currentSubMode ) + + priorSubMode = currentSubMode; } /*********************************************************************//**