Index: firmware/App/Modes/OperationModes.c =================================================================== diff -u -r383c4be0d9ad14570c87cf5b7330f5f83d92383e -r036a75d76ab01912646a480b935d97187a231a19 --- firmware/App/Modes/OperationModes.c (.../OperationModes.c) (revision 383c4be0d9ad14570c87cf5b7330f5f83d92383e) +++ firmware/App/Modes/OperationModes.c (.../OperationModes.c) (revision 036a75d76ab01912646a480b935d97187a231a19) @@ -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" @@ -120,9 +120,9 @@ initServiceMode(); initInitAndPOSTMode(); initStandbyMode(); -// initTreatParamsMode(); + initTreatParamsMode(); // initPreTreatmentMode(); -// initTreatmentMode(); + initTreatmentMode(); // initPostTreatmentMode(); } @@ -144,10 +144,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 +169,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 +197,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 +320,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 +404,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; @@ -644,51 +646,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; +} + /**@}*/