Reactive TestCases use C# code to define a numeric Signal Pattern. You can use the reactive code for both stimulus and response Signals:
•Stimulus Signals: The reactive code defines the Specified (commanded) pattern of the Signal.
•Response Signals: The reactive code defines the Expected pattern of the Signal. However, when the code reads a Signal value, it reads the Actual value.
Example 1: Define a Signal based on the values of other Signals in the same TestCase:
SignalA.Value = SignalB.Value - SignalC.Value;
Example 2: The Reactive TestCase, AccTo50mphReactive, in the SilEasyCruiseControl sample project uses this code to calculate the value of the UserPedalPercent stimulus Signal based on the Actual value of the mph response Signal:
DeltaSpeed = (TargetSpeed - mph.Value);
PropTerm = DeltaSpeed * PropGain;
IntTerm = IntTerm + DeltaSpeed/20;
UserPedalPercent.Value = PropTerm + (IntTerm * IntGain);
if(UserPedalPercent.Value <0) UserPedalPercent.Value = 0;
User Interface
To open the Reactive Code dialog, select View->Reactive Code from the MxVDev main menu. Click on an open TestCase to select it. (To see Reactive Code for a Scenario, open and select the Scenario.)
To use Reactive TestCase code, select the Enabled checkbox:
View the Reactive Code in the Reactive Code tab of the Project Explorer.
Select the check boxes for the Signals that are defined in the Reactive Code.
Select a tab:
•Start: This method is executed when the TestCase starts.
•Pre-Tick: This method is executed before the TestCase is ticked each time. At this point, stimulus values are propagated from the TestCase to the SUT. The tick interval of the Scenario is specified in the Tick Settings.
•Post-Tick: This method is executed after the TestCase is ticked. At this point, response values from the SUT are propagated back to the TestCase. If Expected Values are calculated, do it in this method.
•Transition Received: This method is executed when a transition occurs on a response Signal or on an included Stimulus Signal.
•Pass/Fail Complete: This method is executed after the TestCase completes pass/fail analysis.
•Other: Use this tab for static declarations and method definitions. This code is compiled, but executed only if called from user code.
•References: Use this tab to add or remove DLL references to your code. Also, see Project Settings—Reactive Defaults.
•All Code: This tab displays all the generated code associated with the TestCase.
Select a tab to select a settings category:
•Constants
•Pre-Tick
•Post-Tick
•Transition Received
•Signals
•TestCase
•Tags
To use an identifier listed, select it and click Insert to put it into your user code.
Sample Project—SIL Easy Cruise Control