1

我的 matlab 应用程序通过提供输入和获取输出与 dymola 软件(用于动态建模/模拟/计算)进行通信。在 Matlab 命令窗口中一切正常。在 matlab 中开发的独立应用程序(使用应用程序编译器)在与其开发的系统相同的系统中运行良好。一旦我将应用程序(使用 matlab 运行时)安装到没有完整安装 matlab 的主机系统中,OPC 代码将失败. * 开发/编译的代码:Windows 10 Pro,* 部署到/主机系统:Windows 10 Pro,* Matlab 版本 2017b * OPC 工具箱版本 4.0.4 * Matlab 运行时 9.3

OPC 代码片段如下:

%% 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

下面给出的输出来自在主机系统中从命令行运行生成的 exe 文件。它失败并出现错误:

OPC Foundation Core Components not installed. Run OPCREGISTER to install the OPC Foundation Core Components.

在取消注释该行时opcregister('install') ,我收到以下错误(请注意我正在从命令行运行 exe):

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.

将行设为:opcregister('install','-silent') 错误:

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.

比较一下,这是我在系统中得到的输出,其中开发和编译了代码: OPC 工作正常,将服务器名称作为输出

'Matrikon.OPC.Simulation.1'    'Dymosim.OPCServer.1'

它在开发人员系统中运行良好,但在主机系统中失败。

4

1 回答 1

0

我可以通过手动安装OPC 核心组件来解决这个问题。

在运行 Matlab exe 之前安装它们,解决了这个问题。

PS 在下载 OPC 核心组件之前,您需要创建一个帐户。

于 2020-02-29T11:59:08.077 回答