首页 > 解决方案 > OpenOPC-内核在试图读取数据时死机

问题描述

我正在尝试按照此视频教程从模拟的 opc 服务器读取一些数据。我在 jupyterlab 中运行的代码是这样的:

import OpenOPC
opc = OpenOPC.client()
# opc.servers()
opc.connect(opc_server = 'Matrikon.OPC.Simulation.1')
print(opc.info())
print(opc.list())
# opc.read('Simulation Items/Random/Random.Int1')
# opc.read(['Random.Int1', 'Random.Real4'])

返回

[('Protocol', 'DCOM'), ('Class', 'Graybox.OPC.DAWrapper'), ('Client Name', 'OpenOPC'), ('OPC Host', 'DESKTOP-H750JUT'), ('OPC Server', 'Matrikon.OPC.Simulation.1'), ('State', 'Running'), ('Version', '1.5 (Build 0)'), ('Browser', 'Hierarchical'), ('Start Time', '2020-05-15 18:56:04.231000+00:00'), ('Current Time', '2020-05-15 20:15:52.009000+00:00'), ('Vendor', 'Matrikon Inc (780) 448-1010 http://www.matrikonopc.com')]
['Simulation Items', 'Configured Aliases']

表明它确实连接到服务器,但是当我取消注释读取语句时,我收到以下错误消息

Kernel Restarting
The kernel for Downloads/openopc-master/Untitled.ipynb appears to have died. It will restart automatically.

在 spyder 上运行代码也是如此,我还在运行代码之前将标签添加到了模拟服务器。我正在使用今天下载的全新 anaconda x64 安装(python 3.x)和 pywin32-227.win-amd64-py3.7。关于为什么它什么都不读的任何想法?

我的目标是连接到位于另一台机器上的外部 OPC 服务器以读取和写入标签数据。我已经配置了 DCOM 并测试了与 OPC Expert 和其他软件的连接。这对 OpenOPC 可行吗?

事先谢谢你。

标签: pythonopcopc-da

解决方案


推荐阅读