You can use the MxVSetScnStateFunction to access the state (status) of the current Scenario from the MxVMC.
The Scenario states are defined in an enum named e_ScnState:
typedef enum
{
SCN_READY=0,
SCN_RUN,
SCN_PAUSE,
SCN_REWIND,
SCN_COMPLETE,
SCN_RESETTING,
SCN_RESETCOMPLETE
} e_ScnState;
In the MxVHarness.h file there is a function prototype:
extern void MxVSetScnStateFunction(void (__cdecl * pFunc)(e_ScnState));
With this function, you can register a callback function to be invoked when the Scenario state changes. Typically this callback function resides in the AppIF.c file as shown in this example:
e_ScnState ScnState;
void TestStateCallback(e_ScnState lScnState)
{
ScnState = lScnState;
}
void MxVOpen(void)
{
MxVSetScnStateFunction( TestStateCallback);
}
Note: You can create a VMC port (ScnState in the example above), export the port, and use the Signal in a TestCase. However, most of the state transitions occur when the Scenario is not running, so not all states can be observed in MxVDev. For an example, see the State Machine Scenario in the TurnDoorSample project.
State Transition Logic
SCN_RESETTING is set before the SUT is unloaded during a reset event
SCN_RESETCOMPLETE is set after the SUT is reloaded AND all the inputs have been reset to their current values.
There may be a state change to SCN_RUNNING during a module reset if the scenario was already in a run state when the reload of the SUT occurs. In addition, there is a state change from RUN to PAUSE back to RUN every time a scenario is paused, INCLUDING while the scenario is being stepped.
When the module is loaded (Setup) during harness load:
•MxVOpen is called
•SCN_READY is sent to the SUT
When a scenario is started (current state will be either SCN_READY or SCN_COMPLETE depending upon whether a previous scenario has been run without reloading the harness):
If the module reset backward compatibility flag is SET (previous behavior):
{
SCN_RESETTING is sent
SUT is unloaded
MxVClose is called
SUT is reloaded
MxVOpen is called
Initial Values sent
SCN_RESETCOMPLETE is sent
}
SCN_RUNNING is sent
<scenario runs>
While SCN_RUNNING is true, one of the following occurs:
Scenario is paused (breakpoint or pause button)
SCN_PAUSE is sent
transition to SCN_COMPLETE if rewind or pause
OR transition to SCN_RUNNING if continue/step pressed
Scenario completes (end)
SCN_COMPLETE is sent
MxVModuleReset signal in the scenario:
{
SCN_RESETTING is sent
SUT is unloaded
SUT is reloaded
NOTE: POTENTIAL SCN_RUNNING sent to the SUT here due to the previous state being running)
Initial Values sent
SCN_RESETCOMPLETE is sent
}
When SCN_COMPLETE is the current state, it will transition to the first phase.
MxVOpen() is called upon SUT load, regardless of current state.
MxVClose() is called upon SUT unload, regardless of current state.