This sample demonstrates parameterized testing, tags and calibration groups, reactive Scenarios and TestCases, and a closed-loop system.
The sample includes two projects:
•MxV.mxp - Uses a SIL Easy Transform and an MxVMC to demonstrate the features described below.
•MxVSimulink.mxp - Uses Simulink models with the same Scenarios and TestCases.
Click here to download the projects: https://github.com/DanlawMxTeam/Samples/raw/master/SilEasyCruiseControl.rar
Applies to: •MxSuite 3.41 or later Other Requirements: •A supported version of Visual Studio is required to run the MxV.mxp project. •A licensed copy of a supported version of Matlab Simulink is required to run the MxVSimulink.mxp project. •The user should have an understanding of MxSuite Scenarios, TestCases, Jobs, and Tags. |
The sample project includes a tag group named Gain Sweep and calibration set, P Gain, with 4 possible values: This sample includes 6 Scenarios: •CruiseModeParameter executes the AccToParam TestCase three times using the values of the P Gain Constant consecutively. •CruiseModeReactive executes the AccToTargetReactive TestCase four times using the tags from the Gain Sweep tag group consecutively. •InteractiveScn enables you to test the SUT with an Interactive Test Panel. •LetsRide is a conventional Scenario. •LetsRideReactive includes reactive a TestCase. •VehicleSim Tests tests the Vehicle VMC. Variants are useful when you have Signal Patterns that are similar, but vary in some portion. The Active Variant option is useful when you have a set of input and output patterns where the result depends on the input. The input and output can be controlled by tags. The Any Variant option is useful when you have multiple result patterns that all meet the requirement of your test. Reactive Scenarios enable you to use branching logic in your test. Reactive Scenarios can also activate and deactivate tags. |
CruiseModeParameter is a Reactive Scenario. In the Start tab of the Reactive Code dialog, it uses these commands to load the Low, Medium, and High values of P_Gain into the testSetting array. foreach(var setting in Tags.Gain_Sweep.Tags) { setting.Activate(); allSettingsList.Add(P_Gain.Value); } Tags.Revert();
testSetting = allSettingsList.ToArray();
This command is used in the TestCase Complete tab to start the AccToParamReactive TestCase and pass two parameters to it: AccToParamReactive.Start(testSetting[testIteration], testSetting[testIteration].ToString()); The first parameter (User Data) is used by the TestCase to calculate UserPedalPercent. The second parameter (string) is displayed in title bar of the Job. See Reactive Code. AccToParamReactive is a Reactive TestCase that uses code to calculate the values of the UserPedalPercent Signal. This command from the Pre-Tick tab uses the UserData parameter (first parameter) as part of the calculation: PropTerm = DeltaSpeed * (double)UserData; This Scenario is designed to pass. |
CruiseModeReactive is a Reactive Scenario. It uses a Case statement in the TestCase Complete tab of the Reactive Code dialog to execute its TestCases. It executes the AccToTargetReactive TestCase four times. It activates a different tag from the Gain Sweep tag group each iteration. For example, in Case 4 (Job 5) it uses this command to activate the Medium tag in Gain Sweep: Tags.Gain_Sweep.Medium.Activate(); AccToTargetReactive is a Reactive TestCase that uses code to calculate the values of the UserPedalPercent Signal. This command from the Pre-Tick tab uses the current value of P_Gain as part of the calculation: PropTerm = DeltaSpeed * P_Gain.Value; This Scenario is designed to pass.
|
Use the Project Explorer to open the Interactive Test Panel, CCPanel, and run the Scenario. You can use the ITP to perform a test similar to the TestCases. 1.Adjust the UserPedalPercent slider to bring the mph to a desired speed. 2.For ToggleCruiseOnRisingEdge Signal, select a value of 1 to toggle the Cruise Control on. 3.Increase or decrease the gradient. The SUT (cruise control) adjusts the CCPedalPercent to maintain a constant speed as much as possible. To stop the Scenario, click the Stop button or press F6. |
The LetsRide Scenario is not reactive. The 5 TestCases included are also not reactive. This Scenario can be used for comparison to the other Scenarios. This Scenario is designed to pass. |
LetsRideReactive is not a reactive Scenario, however it includes an example of a simple reactive TestCase, AccTo50mphReactive. The code in the Pre-Tick tab of the Reactive Code dialog calculates the values of the UserPedalPercent stimulus Signal. It responds to the mph Signal which is exported from the Harness. This Scenario is designed to pass. |
The VehicleSim Test Scenario is not reactive. It is designed to test the Vehicle VMC. As the UserPedalPercent increases, the speed (mph) of the vehicle increases. Wind Resistance is a negative value (it acts against the force of the engine). As the speed increases, the wind resistance becomes a larger negative value reflecting more resistance. This Scenario is designed to pass. |
Constants and Calibration Sets
SIL Easy Transform
Delay Transform