Why can't I use the "Load Application" button in my deployed SLRT app to switch between MLDATX files to run on my Speedgoat target?

I have created a GUI with App Designer to interact with a Simulink Real-Time (SLRT) simulation running on my Speedgoat target. When running the app in MATLAB, I can switch between multiple MLDATX real-time application files to run on my Speedgoat using the "Load Real-Time Application" dialog:
Then, I packaged this app into a standalone executable using MATLAB Compiler. However, when I try to click the "Load Application" button in the deployed SLRT app, either nothing happens (no dialog opens), or the following error occurs when attempting to load the MLDATX file:
Dot indexing into the result of a function call requires parentheses after the function name. The supported syntax is 'sIrealtime().internal'.
Since R2024a, the error is:
Error communicating with target 'xx.xx.xx.xx': Specify the real-time application name in the 'Application' property of the Load Button component in the instrument panel app.
I also tried to implement a manual logic in my app using app.tg.load() that switches between MLDATX files of the same name located in different folders. This works when launching the app from MATLAB, but not when it's deployed.

 Accepted Answer

What This Issue Means

This is a limitation of Simulink Real-Time (SLRT). Standalone SLRT apps created with MATLAB Compiler can only be used with a single MLDATX file.  For this reason, the dialog to browse for an MLDATX file is disabled when clicking the "Load Application" button in a deployed SLRT app.

Try This Workaround

The name of the MLDATX file must be specified for the LoadButton in the app code before compiling it into a standalone executable.
With SLRT App Generator:
To achieve this with your autogenerated SLRT app from SLRT App Generator, in R2022b and later, select "Options > Configure Components > Load Button". The property inspector will open. Look for the "Application" property and set its value to the model name (e.g. 'slrt_ex_osc_rt'). Now generate the app. Pressing the load button will automatically load 'slrt_ex_osc_rt' without displaying the dialog.
With your custom app:
To achieve this in your custom or previously generated app, you can add a private property containing the model name, as shown in the screenshot below:
Then, you can pass the MLDATX name to the LoadButton object's "Application" property in the app startupFcn(). The total code would look like the following:
properties (Access = private) SLRTApp = 'slrt_ex_osc_rt' %<...> end methods (Access = private) function startupFcn(app) app.LoadButton.Application = app.SLRTApp; %<...> end end
This way, clicking the "Load Application" button loads the single MLDATX file directly, without an additional dialog.
You can find an example app with code that is ready for deployment in:

Additional Notes

1) When compiling the app, make sure the MLDATX file is in the same folder as the MLAPP file and added to the deployable archive. See this MATLAB answer for details:
2) To switch between MLDATX files for fast design iterations, you can use a minimal installation of the two products MATLAB and Simulink Real-Time, as per our Test Operator license model. For more information on this, see:

More Answers (0)

Community Treasure Hunt

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

Start Hunting!