Index: firmware/App/Modes/OperationModes.c =================================================================== diff -u -rb01542f8e4ef5a29e9b08fc0d465478de516bf02 -r30f049651877229042e3f8700c8596e5b9a1e0f4 --- firmware/App/Modes/OperationModes.c (.../OperationModes.c) (revision b01542f8e4ef5a29e9b08fc0d465478de516bf02) +++ firmware/App/Modes/OperationModes.c (.../OperationModes.c) (revision 30f049651877229042e3f8700c8596e5b9a1e0f4) @@ -49,7 +49,7 @@ /// This matrix determines legal transitions from one mode to another static const HD_OP_MODE_T MODE_TRANSITION_TABLE[ NUM_OF_MODES - 1 ][ NUM_OF_MODES - 1 ] = { -// from to-> FAULT SERVICE INIT STANBY TRT.PARAMS PRE-TREAT TREATMENT POST_TREA +// From to-> FAULT SERVICE INIT STANBY TRT.PARAMS PRE-TREAT TREATMENT POST_TREA /* FAUL */{ MODE_FAUL, MODE_SERV, MODE_NLEG, MODE_NLEG, MODE_NLEG, MODE_NLEG, MODE_NLEG, MODE_NLEG, }, /* SERV */{ MODE_FAUL, MODE_SERV, MODE_NLEG, MODE_NLEG, MODE_NLEG, MODE_NLEG, MODE_NLEG, MODE_NLEG, }, /* INIT */{ MODE_FAUL, MODE_NLEG, MODE_INIT, MODE_STAN, MODE_NLEG, MODE_NLEG, MODE_NLEG, MODE_NLEG, }, @@ -76,18 +76,18 @@ { U32 i; - // initialize mode requests to none pending + // Initialize mode requests to none pending for ( i = 0; i < ( NUM_OF_MODES - 1 ); i++ ) { modeRequest[ i ] = FALSE; } - // start in init mode + // Start in init mode currentMode = MODE_INIT; currentSubMode = 0; transitionToNewOperationMode( MODE_INIT ); - // call initializers for the individual modes + // Call initializers for the individual modes initFaultMode(); initServiceMode(); initInitAndPOSTMode(); @@ -109,27 +109,27 @@ { HD_OP_MODE_T newMode; - // any new mode requests? - newMode = arbitrateModeRequest(); // will return current mode if no pending requests + // Any new mode requests? + newMode = arbitrateModeRequest(); // Will return current mode if no pending requests newMode = MODE_TRANSITION_TABLE[ currentMode ][ newMode ]; - // is requested new mode valid and legal at this time? + // Is requested new mode valid and legal at this time? if ( newMode >= MODE_NLEG ) { SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_OP_MODES_ILLEGAL_MODE_TRANSITION_REQUESTED, newMode ) newMode = currentMode; } - // has mode changed? + // Has mode changed? if ( currentMode != newMode ) { - // handle transition to new mode + // Handle transition to new mode lastMode = currentMode; transitionToNewOperationMode( newMode ); currentMode = newMode; } - // mode specific processing to be done continuously + // Mode specific processing to be done continuously switch ( currentMode ) { case MODE_FAUL: @@ -169,9 +169,9 @@ currentSubMode = 0; SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_OP_MODES_INVALID_MODE_STATE, currentMode ) break; - } // end switch + } // End switch - // broadcast current operation mode on interval + // Broadcast current operation mode on interval broadcastOperationMode(); } @@ -186,14 +186,14 @@ *************************************************************************/ void requestNewOperationMode( HD_OP_MODE_T newMode ) { - // validate requested mode + // Validate requested mode if ( newMode < MODE_NLEG ) { - // make request + // Make request modeRequest[ newMode ] = TRUE; } else - { // invalid mode requested + { // Invalid mode requested SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_OP_MODES_INVALID_MODE_REQUESTED, newMode ) } } @@ -212,6 +212,50 @@ /*********************************************************************//** * @brief + * The initiateAlarmAction function initiate an alarm or alarm recovery + * action according to the current operation mode. + * @details Inputs: currentMode + * @details Outputs: given action forwarded to current operation mode for execution + * @param action ID of action to be initiated + * @return none + *************************************************************************/ +void initiateAlarmAction( ALARM_ACTION_T action ) +{ + // Forward request to the current operation mode + switch ( currentMode ) + { + case MODE_FAUL: + signalAlarmActionToFaultMode( action ); + break; + case MODE_SERV: + signalAlarmActionToServiceMode( action ); + break; + case MODE_INIT: + signalAlarmActionToInitAndPOSTMode( action ); + break; + case MODE_STAN: + signalAlarmActionToStandbyMode( action ); + break; + case MODE_TPAR: + signalAlarmActionToTreatParamsMode( action ); + break; + case MODE_PRET: + signalAlarmActionToPreTreatmentMode( action ); + break; + case MODE_TREA: + signalAlarmActionToTreatmentMode( action ); + break; + case MODE_POST: + signalAlarmActionToPostTreatmentMode( action ); + break; + default: + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_OP_MODES_INVALID_MODE_TO_SIGNAL_ACTION, currentMode ) + break; + } +} + +/*********************************************************************//** + * @brief * The arbitrateModeRequest function arbitrates any pending mode transition * requests. * @details Inputs: modeRequest[] @@ -223,10 +267,10 @@ HD_OP_MODE_T reqMode = currentMode; U32 i; - // block additional requests until after mode arbitration + // Block additional requests until after mode arbitration _disable_IRQ(); - // select highest priority mode request -or- current mode if no requests pending + // Select highest priority mode request -or- current mode if no requests pending for ( i = 0; i < MODE_NLEG; i++ ) { if ( modeRequest[ i ] != FALSE ) @@ -236,13 +280,13 @@ } } - // clear all requests now that an arbitration winner is selected + // Clear all requests now that an arbitration winner is selected for ( i = 0; i < MODE_NLEG; i++ ) { modeRequest[ i ] = FALSE; } - // un-block requests + // Un-block requests _enable_IRQ(); return reqMode; @@ -258,7 +302,7 @@ *************************************************************************/ static void transitionToNewOperationMode( HD_OP_MODE_T newMode ) { - // setup for new operating mode + // Setup for new operating mode switch ( newMode ) { case MODE_FAUL: