主要内容

本页采用了机器翻译。点击此处可查看英文原文。

Target.Stimulation

目标计算机模型根端口激励器对象

自 R2021a 起

说明

Target.Stimulation 对象表示对运行在 Speedgoat® 目标计算机上的模型的根输入端口或 Playback 模块的激励。

该对象提供对以下方法的访问:

  • 启动或停止根部输入端口或 Playback 模块的激励。

  • 暂停根部输入或 Playback 模块激励。

  • 返回根输入端口或 Playback 模块模拟的状态。

  • 重新加载根输入端口或 Playback 模块的数据信号。

创建对象

当您使用 slrealtime 命令创建 Target 对象时,会生成一个 Target.Stimulation 对象。在创建计算机并将其连接到 Target 对象后,即可访问 Target.Stimulation 对象。此示例创建并连接到 Target 对象 tg,随后在目标计算机上启动根输入端口或 Playback 模块的激励过程。

打开模型 slrt_ex_osc_inport 并添加一个额外的输入端口。

tg = slrealtime;
mdlSTF = getSTFName(tg);
mdlName = 'slrt_ex_osc_inport';
openExample(mdlName);
set_param(mdlName,"SystemTargetFile",mdlSTF);
load('slrt_ex_inport_square.mat');
waveform = square;
set_param(mdlName,'ExternalInput','waveform');
set_param(mdlName,'LoadExternalInput','on');
set_param(mdlName,'StopTime','Inf');

构建模型。加载实时应用程序。开始执行。开始激励。

slbuild(mdlName);
connect(tg);
load(tg,mdlName);
start(tg,'StartStimulation','off');
start(tg.Stimulation,'all');

对象函数

getStatusReturn status of root inports stimulation of model on target computer
pausePause stimulation of root inports of model on target computer
reloadDataReload data signal of root inports of model on target computer
startStart stimulation of root inports of model on target computer
stopStop stimulation of root inports of model on target computer

示例

全部折叠

在模型中,启动名为 In1In2 的输入端口激励。

start(tg.Stimulation,{'In1','In2'}); 
% if the port number of inport named 'In1' is 1
% and the port number of inport named 'In2' is 2
% this syntax is equivalent to:
%
% start(tg.Stimulation,[1,2]);

在模型中,暂停对名为 In1In2 的输入端口的激励。

pause(tg.Stimulation,{'In1','In2'});
% this syntax is equivalent to:
% pause(tg.Stimulation,[1,2]);

在模型中,停止对名为 In1In2 的输入端口的激励。

stop(tg.Stimulation,{'In1','In2'}); 
% this syntax is equivalent to:
% stop(tg.Stimulation,[1,2]);

版本历史记录

在 R2021a 中推出