Basic App Designer App for Real-Time Application Interface
This example shows a basic App Designer app that provides an interface to a real-time application.
Create Target Object and Connect
Create a Target object for the default target computer and connect to the target computer. In the Command Window, type:
tg = slrealtime; connect(tg);
Build Real-Time Application
To build the model, in the Command Window, type:
model = 'slrt_ex_sine_waves'; open_system(model); modelSTF = getSTFName(tg); set_param(model,"SystemTargetFile",modelSTF) evalc('slbuild(model)');
Open Real-Time Application Interface App
Open the real-time application interface app slrt_sine_waves_App
.
Control Run Real-Time Application
Use the App Designer app controls to:
Select the target computer by using the target selector list.
Toggle from Disconnected to Connected by using the connect button.
Load the real-time application by using the load button.
Start the real-time application by using the start button.
When done, stop the application by using the stop button.
Examing Code View for Interface App
In App Designer, click the Code View tab to view the code that connects the real-time application to the App Designer app. This code that executes after the app creates components uses a small number of Simulink® Real-Time™ functions to:
Create and configure the tuner component
Create and configure the instrument component
Start the instrument manager for the app
function startupFcn(app) % Add Parameter Tuner Component Tuner = slrealtime.ui.tool.ParameterTuner(app.UIFigure); Tuner.Component = app.AmplitudeKnob; Tuner.BlockPath = 'slrt_ex_sine_waves/Sine Wave'; Tuner.ParameterName = 'Amplitude';
% Add Instrument Component Instrument = slrealtime.Instrument; Instrument.connectLine(app.UIAxes,'slrt_ex_sine_waves/Sine Wave',1); Instrument.AxesTimeSpan = 1;
InstrumentManager = slrealtime.ui.tool.InstrumentManager(app.UIFigure); InstrumentManager.Instruments = Instrument; end
Close All Open Files
bdclose(model);