主要内容

Test Models in Real Time

您可以在类似于您申请的环境中测试系统。您从开发计算机上的模型仿真开始,然后使用循环(SIL)和处理器内(PIL)模拟。实时测试在可以连接到物理系统的独立目标计算机上执行应用程序。实时测试可以包括定时,信号接口,系统响应和生产硬件的影响。

实时测试包括:

  • Rapid prototyping, which tests a system on a standalone target connected to plant hardware. You verify the real-time tests against requirements and model results. Using rapid prototyping results, you can change your model and update your requirements, after which you retest on the standalone target.

  • 硬件循环(HIL)使用万博1manbetx®Real-Time™,测试已通过多个验证阶段的系统,通常是SIL和PIL模拟。

Overall Workflow

This example workflow describes the major steps of creating and executing a real-time test:

  1. 创建验证模型以防止要求的测试用例。运行模型仿真测试并保存基线数据。

  2. 设置实时目标计算机。

  3. Create test harnesses for real-time testing, or reuse model simulation test harnesses. In测试序列要么Test Assessment块,核实statements assess the real-time execution.

  4. 在里面Test Manager, create real-time test cases.

  5. For the real-time test cases, configure target settings, inputs, callbacks, and iterations. Add baseline or equivalence criteria.

  6. Execute the real-time tests.

  7. 一种nalyze the results in the Test Manager. Report the results.

实时测试考虑因素

  • 基线要么equivalence comparisons can fail because of missing data or time-shifted data from the real-time target computer. When investigating real-time test failures, look for time shifts or missing data points.

  • 您无法覆盖从包含a的模型构建的应用程序的实时执行示例时间测试序列堵塞。为此生成的代码测试序列block contains a hard-coded sample time. Overriding the target computer sample time can produce unexpected results.

  • 您无法记录输出端口或状态。

  • Your target computer must have a file system to use核实statements and test case logging.

  • 您的目标计算机必须运行万博1manbetxSimulink实时

Complete Basic Model Testing

实时测试通常需要比较模型测试,特别是如果执行涵盖多个方案的实时测试套件。在执行实时测试之前,使用桌面仿真完成基于要求的测试。使用桌面仿真结果:

  • Debug your model or make design changes that meet requirements.

  • 调试您的测试序列。使用测试序列编辑器中的调试功能。看调试测试序列

  • Update your requirements and add corresponding test cases.

设置目标计算机

Real-time testing requires a standalone target computer.万博1manbetxSimulink Test™only supports target computers running万博1manbetxSimulink实时。有关更多信息,请参阅:

Configure the Model or Test Harness

实时应用程序需要特定的配置参数和信号属性。

Code Generation

实时测试用例需要实时系统目标文件。在模型或线束配置参数中,在一种pps标签,在代码生成下,单击万博1manbetxSimulink编码器。在里面C代码tab, verify that the system target file isslrealtime.tlc.。如果是按钮Output部分是自定义目标,单击该按钮并验证Custom targetslrealtime.tlc.。如果不是,请选择选择系统目标文件和selectslrealtime.tlc.生成系统目标代码。

如果您的模型需要不同的系统目标文件,则可以使用测试用例或测试套件回调设置参数。执行实时测试后,将参数设置为使用清理回调的原始设置。例如,这个回调打开了SltestProjectorController.model and sets the system target file parameter toslrealtime.tlc.

OpenExample('sltestProjectorController');set_param('sltestProjectorController',。。。'systemtargetfile','slrealtime.tlc');

数据导入/导出格式

模型必须使用除此之外的数据格式dataset。要设置数据格式:

  1. 打开配置参数。

  2. 选择数据导入/导出窗格。

  3. 选择格式

Log Signals from Real-Time Execution

配置您的兴趣信号进行实时测试:

  • 在数据导入/导出窗格中启用配置参数中的信号日志记录。

  • 使用信号属性命名每个感兴趣的信号。可以为未命名的信号分配默认名称,其与基线或等价信号的名称不匹配。在此示例测试线束中,记录的信号具有显式名称。

Test harness showing logged signals

一种dd Test Cases for Real-Time Testing

使用测试管理器创建实时测试用例。

  1. 在Simuli万博1manbetxnk ToolStrip中,在一种ppstab under Model Verification, Validation, and Test, select万博1manbetxSimulink测试

  2. Click万博1manbetxSimulink测试Manager

  3. 在测试管理器中,选择新的>Real-Time Test

测试类型

您可以选择基线,等价或模拟实时测试。用于仿真测试类型,核实陈述作为测试结果中的通过/失败标准。对于等价和基线测试类型,等价或基线标准也可作为通过/失败标准。

  • 基线- 将从目标计算机返回的信号数据与测试用例中的基线进行比较。要将实时执行结果与模型仿真结果进行比较,请将型号基线结果添加到实时测试用例,并将可选的公差应用于信号。

  • 等价- 从模拟和实时测试或两个实时测试的信号数据进行比较。要在目标计算机上进行实时测试,请将结果与模型模拟进行比较:

    • Select模拟1on target

    • 清除模拟2.on target

    测试用例显示两个模拟部分,模拟1模拟2.

    比较两个实时测试类似,除了您在目标上选择两种模拟。在里面等价Criteriasection, you can capture logged signals from the simulation and apply tolerances for pass/fail analysis.

  • 模拟:仅使用使用测试结果核实陈述和实时执行。如果不核实语句失败,实时测试执行,测试用例通过。

Load Application From

使用此选项,指定要如何加载实时应用程序的方式。实时应用程序是由模型或测试线束构建的。您可以从以下方式加载应用程序:

  • 模型- 选择模型如果您第一次运行实时测试,或者您的模型自上次实时执行以来更改。模型通常需要最长,因为它包括模型构建和下载。模型从模型中加载应用程序,构建实时应用程序,将其下载到目标计算机,并在目标计算机上执行它。

  • 目标应用程序- 选择目标应用程序to send the target application from the host to a target computer, and execute the application.目标应用程序如果要在多个目标上加载已构建的应用程序,可以很有用。

  • 目标计算机- 此选项执行已加载在实时目标计算机上的应用程序。您可以更新测试用例中的参数并执行使用目标计算机

此表总结了每个选项执行哪些步骤和回调。

测试案例执行步骤(首先持续) Load Application From
模型 目标应用程序 目标计算机
Executes pre-load callback 是的 是的 是的
加载Simu万博1manbetxlink模型 是的
Executes post-load callback 是的
设置信号编辑器方案 是的
从模型构建实时应用程序 是的
下载real-time application to target computer 是的 是的
设置运行时参数 是的 是的 是的
运行测试序列方案 是的
Executes pre-start real-time callback 是的 是的 是的
Executes real-time application 是的 是的 是的
执行清理回调 是的 是的 是的

模型

选择从中生成实时应用程序的模型。

测试线束

如果使用测试线束生成实时应用程序,请选择测试线束。

模拟Settings Overrides

对于实时测试,您可以覆盖模拟停止时间,这可以在调试实时测试失败时很有用。考虑一个60秒的测试,返回一个核实statement failure at 15 seconds due to a bug in the model. After debugging your model, you execute the real-time test to verify the fix. You can override the stop time to terminate the execution at 20 seconds, which reduces the time it takes to verify the fix.

回调

实时测试提供了一个预启动实时应用callback which executes commands just before the application executes on the target computer. Real-time test callbacks execute in a sequence along with the model load, build, download, and execute steps. Callbacks and step execution depends on how the test case loads the application.

顺序

Load application from:

模型

Load application from:

Target application

Load application from:

Target computer

Executes first

Preload callback

Preload callback

Preload callback

负载后回调

预先启动实时回调

预先启动实时回调

预先启动实时回调

Executes last

清理回调

清理回调

清理回调

迭代

您可以在实时测试中执行迭代。迭代方便执行扫描通过参数值或信号编辑器方案的实时测试。结果通过迭代进行分组。有关设置迭代的更多信息,请参阅测试迭代。您可以创建:

  • 从参数集中的图表迭代 - 定义多个参数集参数覆盖section of the test case. Under迭代>表迭代, 点击自动生成和select参数集

  • 从信号编辑器方案中提取的迭代 - 如果您的型号或测试线束使用信号编辑器输入,请在下方迭代表迭代表,点击自动生成和selectSignal Editor Scenario。If you use a Signal Editor scenario, load the application from the model.

  • Tabled iterations from Test Sequence scenarios — If your test harness uses Test Sequence block scenarios, you can create an iteration for each scenario in the Test Manager. Below the迭代表,点击自动生成和select测试序列场景。If you use Test Sequence scenarios, load the application from the model.

  • 脚本迭代 - 使用脚本使用模型变量或参数来迭代。例如,假设您正在测试振荡器系统并使用a测试序列块使用该参数创建方波测试信号frequency

    测试序列场景

    在里面test file, you can use real-time test scripted iterations to cover a frequency sweep from 5 Hz to 35 Hz. The script iterates the value offrequency在里面测试序列堵塞。

    %%迭代频率以确定最佳振荡器设置%创建参数集freq = 5.0:1.0:35.0;为了i_iter = 1:长度(频率)%创建迭代对象testItr = sltestiteration ();%设置参数可变(睾丸,'Name','频率','资源',。。。'测试序列','Value',freq(i_iter));%注册迭代Adderation(SLTEST_TESTCASE,TESTITR);结尾

一种ssess Real-Time Execution Using核实陈述

除了基线和等效信号比较外,还可以使用实时测试执行核实陈述。一种核实语句评估逻辑表达式并将结果返回到测试管理器。采用核实在A内测试序列要么Test Assessment块,或者,如果您有状态流®license, in a Stateflow chart. See使用验证语句评估模型仿真

验证陈述的测试结果

相关话题