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

7 vues (au cours des 30 derniers jours)
Leonardo Ricupero
Leonardo Ricupero le 14 Juil 2022
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.

Réponses (1)

Chris Zhang
Chris Zhang le 19 Déc 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.

Catégories

En savoir plus sur Test Scripts dans Help Center et File Exchange

Produits


Version

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by