Index: firmware/App/Modes/OperationModes.c =================================================================== diff -u -rd7c545dff2f13dd75ebab0af997c45047c844f7a -r345a9b1694f4b0a9c9d3e9be45ee2e1f113dc942 --- firmware/App/Modes/OperationModes.c (.../OperationModes.c) (revision d7c545dff2f13dd75ebab0af997c45047c844f7a) +++ firmware/App/Modes/OperationModes.c (.../OperationModes.c) (revision 345a9b1694f4b0a9c9d3e9be45ee2e1f113dc942) @@ -50,6 +50,8 @@ static OVERRIDE_U32_T ddOpModePublishInterval = { BROADCAST_DD_OP_MODE_INTERVAL, BROADCAST_DD_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. +static U32 testRequestedSubMode; ///< Requested operation sub mode from dialin. +static BOOL testChangeSubMode; ///< Flag to determine change operation sub mode request status. /// This matrix determines legal transitions from one mode to another. static const DD_OP_MODE_T MODE_TRANSITION_TABLE[ NUM_OF_DD_MODES - 1 ][ NUM_OF_DD_MODES - 1 ] = @@ -74,6 +76,8 @@ static U32 getDDOpModePublishInterval( void ); static void broadcastOperationMode( void ); static void sendOperationStatusEvent( void ); +static void testRequestNewDDOperationSubMode( void ); +static BOOL testValidateDDSubModeChangeRequest( DD_OP_MODE_T reqMode, U32 reqSubMode ); /*********************************************************************//** * @brief @@ -98,6 +102,8 @@ currentSubMode = 0; currentSubState = NO_SUB_STATE; dataPublishCounter = DATA_PUBLISH_COUNTER_START_COUNT; + testRequestedSubMode = 0; + testChangeSubMode = FALSE; transitionToNewOperationMode( DD_MODE_INIT ); @@ -164,6 +170,13 @@ sendOperationStatusEvent(); } + // Is DD sub mode change request active? + if ( TRUE == testChangeSubMode ) + { + testChangeSubMode = FALSE; + testRequestNewDDOperationSubMode(); + } + // mode specific processing to be done continuously switch ( currentMode ) { @@ -585,4 +598,151 @@ return result; } +/*********************************************************************//** + * @brief + * The testSetOperationSubMode function will transition to a given operation + * sub mode if the transition is legal. + * @details \b Inputs: none + * @details \b Outputs: request new sub mode function called + * @param message a pointer to the message to handle which includes the + * override value for the new mode and sub mode change. + * @return TRUE if request successful, FALSE if not + *************************************************************************/ +BOOL testSetOperationSubMode( MESSAGE_T *message ) +{ + OP_MODES_DATA_T payload; + BOOL result = FALSE; + + if ( TRUE == isTestingActivated() ) + { + if( sizeof(OP_MODES_DATA_T) == message->hdr.payloadLen ) + { + DD_OP_MODE_T reqMode; + U32 reqSubMode; + + memcpy( (U08*)(&payload), message->payload, sizeof( OP_MODES_DATA_T ) ); + + reqMode = (DD_OP_MODE_T)payload.opMode; + reqSubMode = payload.subMode; + + if ( reqMode < NUM_OF_DD_MODES ) + { + // verify if the requested submode transition is valid + result = testValidateDDSubModeChangeRequest( reqMode, reqSubMode ); + + //send mode change request only if the requested sub mode transition is valid + if ( TRUE == result ) + { + if ( currentMode != reqMode ) + { + requestNewOperationMode( reqMode ); + testRequestedSubMode = reqSubMode; + testChangeSubMode = TRUE; + } + // requested sub mode change only as the requested operation mode is current mode + else if ( currentSubMode != reqSubMode ) + { + testRequestedSubMode = reqSubMode; + testChangeSubMode = TRUE; + } + } + + } + } + } + + return result; +} + +/*********************************************************************//** + * @brief + * The testRequestNewDDOperationSubMode function requests transition to a new + * DD operation sub mode. + * @details \b Inputs: currentMode, testRequestedSubMode + * @details \b Outputs: none + * @return none + *************************************************************************/ +static void testRequestNewDDOperationSubMode( void ) +{ + switch ( currentMode ) + { + case DD_MODE_FAUL: + testSignalNewDDFaultSubMode( testRequestedSubMode ); + break; + + case DD_MODE_STAN: + testSignalNewDDStandbySubMode( testRequestedSubMode ); + break; + + case DD_MODE_PREG: + testSignalNewDDPreGenDialysateSubMode( testRequestedSubMode ); + break; + + case DD_MODE_GEND: + testSignalNewDDGenDialysateSubMode( testRequestedSubMode ); + break; + + case DD_MODE_POSG: + testSignalNewDDPostGenDialysateSubMode( testRequestedSubMode ); + break; + + case DD_MODE_SERV: + case DD_MODE_INIT: + case DD_MODE_HEAT: + case DD_MODE_HCOL: + case DD_MODE_ROPS: + default: + break; + } +} + +/*********************************************************************//** + * @brief + * The testValidateDDSubModeChangeRequest function validates transition + * request to a new DD operation sub mode. + * @details \b Inputs: none + * @details \b Outputs: none + * @param reqMode DD operation mode enumeration + * @param reqSubMode operation sub mode requested + * @return TRUE if request is legal, FALSE if not. + *************************************************************************/ +static BOOL testValidateDDSubModeChangeRequest( DD_OP_MODE_T reqMode, U32 reqSubMode ) +{ + BOOL result = FALSE; + + switch ( reqMode ) + { + case DD_MODE_FAUL: + result = testValidateDDFaultChangeReq( reqSubMode ); + break; + + case DD_MODE_STAN: + result = testValidateDDStandbyChangeReq( reqSubMode ); + break; + + case DD_MODE_PREG: + result = testValidateDDPreGenDialysateChangeReq( reqSubMode ); + break; + + case DD_MODE_GEND: + result = testValidateDDGenDialysateChangeReq( reqSubMode ); + break; + + case DD_MODE_POSG: + result = testValidateDDPostGenDialysateChangeReq( reqSubMode ); + break; + + // No need to validate the request for the following modes as it is not supported + case DD_MODE_SERV: + case DD_MODE_INIT: + case DD_MODE_HEAT: + case DD_MODE_HCOL: + case DD_MODE_ROPS: + default: + break; + } + + return result; +} + /**@}*/