Test Automation: Referenced models with C# and ASAM XIL API
2 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
回答(1 个)
Chris Zhang
2022-12-19
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.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Real-Time Simulation and Testing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!