Index: firmware/App/Modes/OperationModes.c =================================================================== diff -u -r383c4be0d9ad14570c87cf5b7330f5f83d92383e -r0901ce3d946bab5cae73edb102fc228a6533cb4b --- firmware/App/Modes/OperationModes.c (.../OperationModes.c) (revision 383c4be0d9ad14570c87cf5b7330f5f83d92383e) +++ firmware/App/Modes/OperationModes.c (.../OperationModes.c) (revision 0901ce3d946bab5cae73edb102fc228a6533cb4b) @@ -22,9 +22,9 @@ #include "ModeService.h" #include "ModeFault.h" #include "ModeStandby.h" -//#include "ModeTreatmentParams.h" +#include "ModeTxParams.h" //#include "ModePreTreat.h" -//#include "ModeTreatment.h" +#include "ModeTreatment.h" //#include "ModePostTreat.h" //#include "NVDataMgmt.h" #include "OperationModes.h" @@ -62,7 +62,7 @@ static U32 current4thLevelState; ///< current 4th level state. /// Interval (in task intervals) at which to publish operation mode data to CAN bus. -static OVERRIDE_U32_T opModePublishInterval = { BROADCAST_TD_OP_MODE_INTERVAL, BROADCAST_TD_OP_MODE_INTERVAL, BROADCAST_TD_OP_MODE_INTERVAL, 0 }; +static OVERRIDE_U32_T opModePublishInterval; /// Local structure init for saving confirmation requests static CONFIRMATION_REQUEST_T confirmRequests[ MAX_PENDING_CONFIRM_REQUESTS ] = { GENERIC_CONFIRM_ID_NONE, GENERIC_CONFIRM_CMD_REQUEST_OPEN, 0, CONFIRMATION_REQUEST_STATUS_UNUSED, @@ -106,12 +106,16 @@ } // Start in init mode - lastMode = MODE_INIT; - currentMode = MODE_INIT; - currentSubMode = 0; - currentSubState = NO_SUB_STATE; - current4thLevelState = NO_SUB_STATE; - broadcastModeIntervalCtr = DATA_PUBLISH_COUNTER_START_COUNT; + lastMode = MODE_INIT; + currentMode = MODE_INIT; + currentSubMode = 0; + currentSubState = NO_SUB_STATE; + current4thLevelState = NO_SUB_STATE; + broadcastModeIntervalCtr = DATA_PUBLISH_COUNTER_START_COUNT; + opModePublishInterval.data = BROADCAST_TD_OP_MODE_INTERVAL; + opModePublishInterval.ovData = BROADCAST_TD_OP_MODE_INTERVAL; + opModePublishInterval.ovInitData = BROADCAST_TD_OP_MODE_INTERVAL; + opModePublishInterval.override = OVERRIDE_RESET; transitionToNewOperationMode( MODE_INIT ); @@ -120,9 +124,9 @@ initServiceMode(); initInitAndPOSTMode(); initStandbyMode(); -// initTreatParamsMode(); + initTreatParamsMode(); // initPreTreatmentMode(); -// initTreatmentMode(); + initTreatmentMode(); // initPostTreatmentMode(); } @@ -144,10 +148,11 @@ // Any new mode requests? newMode = arbitrateModeRequest(); // Will return current mode if no pending requests - if ( getTestConfigStatus( TEST_CONFIG_RECOVER_TREATMENT ) != TRUE ) - { - newMode = MODE_TRANSITION_TABLE[ currentMode ][ newMode ]; - } + // Verify mode transition is legal unless tester working with system TODO - restore check when all modes are implemented +// if ( ( isTestingActivated() != TRUE ) && ( getTestConfigStatus( TEST_CONFIG_RECOVER_TREATMENT ) != TRUE ) ) +// { +// newMode = MODE_TRANSITION_TABLE[ currentMode ][ newMode ]; +// } // Is requested new mode valid and legal at this time? if ( newMode >= MODE_NLEG ) @@ -168,8 +173,9 @@ { // If the last mode is treatment but the new mode is not treatment // it means the treatment is done. Get the elapsed time since the beginning of the treatment and convert it to hours to be written -// U32 txElapsedTimeMS = calcTimeSince( getTreatmentStartTimeStamp() ); -// F32 txElapsedTimeHrs = (F32)txElapsedTimeMS / ( (F32)( MIN_PER_HOUR * SEC_PER_MIN * MS_PER_SECOND ) ); + U32 txElapsedTimeMS = calcTimeSince( getTreatmentStartTimeStamp() ); + F32 txElapsedTimeHrs = (F32)txElapsedTimeMS / ( (F32)( MIN_PER_HOUR * SEC_PER_MIN * MS_PER_SECOND ) ); + // Write the treatment hours and set the service to be false so the treatment hours is not reset // setTxTimeHours( txElapsedTimeHrs ); } @@ -195,18 +201,18 @@ currentSubMode = execStandbyMode(); break; -// case MODE_TPAR: -// currentSubMode = execTreatParamsMode(); -// break; -// + case MODE_TPAR: + currentSubMode = execTreatParamsMode(); + break; + // case MODE_PRET: // currentSubMode = execPreTreatmentMode(); // break; // -// case MODE_TREA: -// currentSubMode = execTreatmentMode(); -// break; -// + case MODE_TREA: + currentSubMode = execTreatmentMode(); + break; + // case MODE_POST: // currentSubMode = execPostTreatmentMode(); // break; @@ -318,15 +324,15 @@ case MODE_STAN: signalAlarmActionToStandbyMode( action ); break; -// case MODE_TPAR: -// signalAlarmActionToTreatParamsMode( action ); -// break; + case MODE_TPAR: + signalAlarmActionToTreatParamsMode( action ); + break; // case MODE_PRET: // signalAlarmActionToPreTreatmentMode( action ); // break; -// case MODE_TREA: -// signalAlarmActionToTreatmentMode( action ); -// break; + case MODE_TREA: + signalAlarmActionToTreatmentMode( action ); + break; // case MODE_POST: // signalAlarmActionToPostTreatmentMode( action ); // break; @@ -402,15 +408,15 @@ case MODE_STAN: currentSubMode = transitionToStandbyMode(); break; -// case MODE_TPAR: -// currentSubMode = transitionToTreatParamsMode(); -// break; + case MODE_TPAR: + currentSubMode = transitionToTreatParamsMode(); + break; // case MODE_PRET: // currentSubMode = transitionToPreTreatmentMode(); // break; -// case MODE_TREA: -// currentSubMode = transitionToTreatmentMode(); -// break; + case MODE_TREA: + currentSubMode = transitionToTreatmentMode(); + break; // case MODE_POST: // currentSubMode = transitionToPostTreatmentMode(); // break; @@ -607,7 +613,7 @@ /*********************************************************************//** * @brief - * The sendOperationStatusEvent function constructs and sends an HD operation + * The sendOperationStatusEvent function constructs and sends an TD operation * status event. * @details \b Message \b Sent: MSG_ID_TD_EVENT * @details \b Inputs: currentMode, currentSubMode, currentSubState, current4thLevelState @@ -644,51 +650,47 @@ * mode if the transition is legal. * @details \b Inputs: none * @details \b Outputs: modeRequest[] - * @param newMode ID of requested mode to transition to + * @param message message from Dialin which includes the op mode to + * transition to. * @return TRUE if request successful, FALSE if not *************************************************************************/ -//BOOL testSetOperationMode( TD_OP_MODE_T newMode ) -//{ -// BOOL result = FALSE; -// -// if ( TRUE == isTestingActivated() ) -// { -// TD_OP_MODE_T check = MODE_TRANSITION_TABLE[ currentMode ][ newMode ]; -// -// // Is mode transition legal? -// if ( check == newMode ) -// { -// requestNewOperationMode( newMode ); -// result = TRUE; -// } -// } -// -// return result; -//} +BOOL testSetOperationMode( MESSAGE_T *message ) +{ + BOOL result = FALSE; + // Verify message payload length is valid + if ( sizeof( U32 ) == message->hdr.payloadLen ) + { + U32 newMode; + + memcpy( &newMode, message->payload, sizeof( U32 ) ); + if ( (TD_OP_MODE_T)newMode < NUM_OF_MODES ) + { + TD_OP_MODE_T reqMode = (TD_OP_MODE_T)newMode; + + requestNewOperationMode( reqMode ); + result = TRUE; + } + } + + return result; +} + /*********************************************************************//** * @brief * The testSetOpModePublishIntervalOverride function sets the override of the * operation mode publication interval. * @details \b Inputs: none * @details \b Outputs: opModePublishInterval - * @param ms milliseconds between operation mode broadcasts + * @param message override message from Dialin which includes the interval + * (in ms) to set the op mode publish to. * @return TRUE if override set successful, FALSE if not *************************************************************************/ -//BOOL testSetOpModePublishIntervalOverride( U32 ms ) -//{ -// BOOL result = FALSE; -// -// if ( TRUE == isTestingActivated() ) -// { -// U32 intvl = ms / TASK_GENERAL_INTERVAL; -// -// result = TRUE; -// opModePublishInterval.ovData = intvl; -// opModePublishInterval.override = OVERRIDE_KEY; -// } -// -// return result; -//} +BOOL testSetOpModePublishIntervalOverride( MESSAGE_T *message ) +{ + BOOL result = u32BroadcastIntervalOverride( message, &opModePublishInterval, TASK_GENERAL_INTERVAL ); + return result; +} + /**@}*/