필터 지우기
필터 지우기

A number of the Target object functions produce event status. How can I use the MATLAB listener function to monitor event states?

조회 수: 1 (최근 30일)
As stated in Simulink® Real- Time™API Guide,“A number of the Target object functions produce event status. You can use the MATLAB listener function to monitor event states.”
But,How can I use the MATLAB listener function to monitor event states?
For example, I want to get the connect status of target.How do I code?

답변 (1개)

Jon Lobo
Jon Lobo 2022년 12월 19일
편집: Jon Lobo 2022년 12월 19일
Hi Yuxuan,
I'm including some example code for how to do this.
tg = slrealtime;
listenerConnected = listener(tg,'Connected',@(~,~)disp('Connected to target computer'));
listenerDisconnected = listener(tg,'Disconnected',@(~,~)disp('Disconnected from target computer'));
listenerLoaded = listener(tg,'Loaded',@(~,~)disp('Loaded application on target computer'));
listenerStarted = listener(tg,'Started',@(~,~)disp('Started application on target computer'));
listenerStopped = listener(tg,'Stopped',@(~,~)disp('Stopped application on target computer'));
listenerStopped = listener(tg,'Stopped',@(~,~)disp('Stopped application on target computer'));
This code executes a series of target computer operations with pauses between the operations to provide time to observethe event status messages.
connect(tg);
load(tg,model);
start(tg);
stop(tg);
disconnect(tg);
Connected to target computer
Stopped application on target computer
Loaded application on target computer
Started application on target computer
Stopped application on target computer
Disconnected from target computer
Ultimately, there are a lot of other events you can use. To list the available events, use:
events(tg)
-Jon

카테고리

Help CenterFile Exchange에서 Target Computer Setup에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by