MATLAB Answers

OPC connection fails in Matlab standalone/deployed application

16 views (last 30 days)
Balakumara Vignesh M
Balakumara Vignesh M on 19 Feb 2020
My matlab application communicates with dymola software (for dynamic modeling/simulation/calculation) by giving inputs and fetching outputs. Everything working fine in Matlab command window. The standalone application developed in the matlab (using Application compiler) works fine in the same system as the one it was developed in.
Once I install the application (with matlab runtime) into an host system without the full matlab installation, The OPC code fails.
Code developed/compiled in : Windows 10 Pro,
deployed to/Host system : Windows 10 Pro,
Matlab version 2017b
OPC toolbox version 4.0.4
Matlab runtime 9.3
The OPC code snippet is as follows:
%% File: SetupOPCDA_MatlabDymolaConnection()
try
%opcregister('install')
hostInfo = opcserverinfo('localhost');
disp(hostInfo.ServerID);
da = opcda('localhost','Dymosim.OPCServer.1');
% Connect to Dymola OPC server
connect(da);
grp = addgroup(da);
ns = getnamespace(da);
catch Err % line 33
The below given outputs are from running the generated exe file from command line in the host system.
Its failing with error:
OPC Foundation Core Components not installed. Run OPCREGISTER to install the OPC Foundation Core Components.
On uncommenting the line
opcregister('install')
I'm getting the following error (Please note I'm running the exe from commandline):
Setting OPC connection...Warning: OPC Core Components are already installed. Reinstalling may require a repair of the Core Components.
Continuing this operation will modify any OPC Foundation files already installed.
MATLAB may shut down, and a system reboot may occur.
Type 'Yes' (exactly as shown) to install the OPC Foundation files
Confirmation string: Yes
'Yes' is not recognized as an internal or external command,
operable program or batch file.
Operation cancelled by user.
On giving the line as:
opcregister('install','-silent')
Error:
Warning: OPC Core Components are already installed. Reinstalling may require a repair of the Core Components.
TWarning: Installation was not successful. Exit code was 1619.
OPC Foundation Core Components not installed. Run OPCREGISTER to install the OPC Foundation Core Components.
To compare, This is the output I get in my system, the one in which the code was developed and compiled:
It works fine in the developer system, but it fails in host system.

  2 Comments

Tuba Abbasi
Tuba Abbasi on 3 Jun 2020
Have you tried including the OPC Foundations Core Components installation via the "Files required for your application to run" section within the "deploytool" GUI instead of using the opcregister command in the compiled application?
Balakumara Vignesh M
Balakumara Vignesh M on 4 Jun 2020
I haven't tried including the exe files of OPC Fondations Core components (FCC) in the deploytool but after manually installing the OPC FCC (before the matlab app installation), then registering the Dymola OPC server via cmd
\regsvr <dll>
The OPC connection was established successfully.
Thanks for the suggestion, I'll try it and let you know soon.

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!