Author, Manage, and Execute Simulation-Based Tests of Generated Code
Author, manage, and execute simulation-based tests of the generated code, by using金宝app®Test™withSimulink PLC Coder™.
If you do not have the
plcdemo_simple_subsystem
model open, open it.Create a signal build test harness for the subsystem. To create a test harness for a subsystem, select the subsystem, right-click, and from the context menu, selectTest Harness>Create for
. Set test harness properties through the Create Test Harness dialog box. Open thePLC Coderapp. Click thePLC Codetab.
ClickSettings.
In the Configuration Parameters dialog box, on thePLC Code Generationpane, select a target and click theGenerate testbench for subsystemcheck box.
ClickOK.
Select the
Test Harness Window
subsystem, click thePLC Codetab and clickGenerate PLC Code. The generated code contains multiple test benches from the signal builder. You can run this code in the PLC emulator to make sure it matches your model simulation.
Limitations
If you use anything other than a signal builder block in the test harness, you must create a top-level atomic subsystem in the test harness that contains the subsystem under test and the testing blocks (for example, test sequence block) and generate code for this subsystem.
Simulink PLC Coderdoes not support the
verify
keyword in the test sequence blockSimulink PLC Codersupports the
duration
keyword in the test sequence block but it requires that you run the generated code with the same sample rate as in the Simulink model.