Test Automation: Referenced models with C# and ASAM XIL API

2 views (last 30 days)
Hello,
I am evaluating different strategies for test automation using SpeedGoat and Simulink Real Time. As a part of this, I've found at this link a useful example involving C# and the ASAM XIL API.
Unfortunately, when trying to replicate the script myRealTimeAppController.cs with our model, an exception is being thrown at line 85 MAPort.Configure(portConfig, false);:
An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in System.Private.CoreLib.dll: 'Error using slrealtime.internal.xil.MAPort/getVariableInfo
No referenced model named 'my_referenced_model'
Note that the model is running perfectly with Simulink.
Since I've noticed that running the script is opening a new instance of Matlab, with working directory in C:\Program Files\MATLAB\R2022a\bin\win64, my guess is that Matlab is not finding the referenced model since the working directory is not in the path.
Any suggestions on how to solve this issue will be appreciated.

Answers (1)

Chris Zhang
Chris Zhang on 19 Dec 2022
Hello, Leonardo,
You can open a MATLAB session and type the following commands:
comserver('register','User','current');
enableservice('AutomationServer', true);
These two commands will convert your currently running MATLAB session as a COM server so that XIL C# API can find this running MATLAB instead of opening a new one.
And then you can CD to your working directory before running your C# script.

Categories

Find more on Real-Time Simulation and Testing in Help Center and File Exchange

Products


Release

R2022a

Community Treasure Hunt

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

Start Hunting!