Third Party Add-On Seeming to Not Compile with App Designer's Application Compiler

5 ビュー (過去 30 日間)
Jesse Johnson
Jesse Johnson 2024 年 11 月 1 日
コメント済み: Jesse Johnson 2024 年 11 月 4 日
MATLAB Version R2021a
I am programming an app in App Designer that uses this third-party Add-On from the Zaber software suite. Its purpose is to control a Zaber stage.
When I use the code in App Designer, I am able to control the stage both in the App Designer environment and through the Matlab command line with the appropriate commands. All "import" functions work and communication through serial ports, stage control, etc., all work without any troubles. However, when I package and then try to run my app independent of Matlab's environment, I receive an error that implies the compiled code is not parsing or processing the Add-On or the Zaber library correctly.
Code error: "Unable to find or import 'zaber.motion.ascii.Connection'. Imported names must end with '.*' or be fully qualified."
When I export/package my app, I am using "Share -> Standalone Desktop App" primarily. I only test with the code shown below in an attempt to get around my error.
>> mcc('-m','myapp.mlapp','-a','Zaber Motion Library.mltbx');
However, when using the above code, I get the exact same error when running the executable.
Here are some solutions I have tried:
  1. Renaming 'import zaber.motion....' to 'import zaber.motion.*' everywhere in the code. However, this produces a "Dot indexing is not supported for variables of this type" error referencing a connection.close() call in a try-catch loop, likely as a result of the code not being able to access the Zaber motion library to send the openSerialPort command.
  2. Including the Motion Library in the "Files Required for your Program to Run" section, which gives the import error
  3. Using matlab.addons.install() function before calling any import functions, which gives the import error
Here is an example code block using the Zaber motion library add-on:
function [connection,axis] = buildapp(app)
global connection axis
import zaber.motion.*; %use this alone
% import zaber.motion.ascii.Connection; %use these together
% import zaber.motion.Units; %use these together
try
connection = Connection.openSerialPort('COM4');
deviceList = connection.detectDevices();
device = deviceList(1);
axis = device.getAxis(1);
catch exception
uialert(app.UIFigure,'Connection error! Most likely that serial port is already open. Restart program.',...
'Connection Failure!');
connection.close();
return;
end
end
  2 件のコメント
Sumukh
Sumukh 2024 年 11 月 4 日
Can you please share the code and application here so as to try to reproduce and resolve the issue?
Jesse Johnson
Jesse Johnson 2024 年 11 月 4 日
The question has been updated with additional code. However, note that the code will never complete the try-catch if you do not own a Zaber stage that is connected to your computer via USB.

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeMATLAB Compiler についてさらに検索

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by