在python中使用OpenOPC启动OpenOPCService以连接到Matrikon OPC服务器的本地实例的可能故障排除

2024-09-28 18:58:43 发布

您现在位置:Python中文网/ 问答频道 /正文

我正试图通过以下steps连接到Matrikon OPC模拟服务器的远程实例。为了确认所有设置都正确,我正在尝试首先连接到本地实例。我正在运行Win10和Python3.9 32位以及32位PyWin32-228版本。因此,我们的目标是让下面的线路正常工作

opc = OpenOPC.open_client('localhost')

我能够使用这些语句成功地连接并释放OPC服务器中的数据

opc = OpenOPC.client()
opc.connect('Matrikon.OPC.Simulation')

然而,由于目标是连接到远程服务器,我需要使用 opc = OpenOPC.open_client('localhost')因此网关服务

我认为问题在于OpenOPCService的实施。我已完成以下步骤:

  1. 设置以下环境变量
  2. 注册OPC自动化包装gbda_aut.dll
  3. 已安装OpenOPC网关服务,返回Service installed
  4. 已将python36.dll复制到我的python安装文件夹
  5. 禁用防火墙
  6. 已将OpenOPC.py文件复制到lib\site\u packages目录
  7. 包括站点包、DLL、脚本和python.exe目录到系统路径

运行命令行时:net start zzzOpenOpcService 返回以下内容:

C:\OpenOPC\src>net start zzzOpenOpcService
The OpenOPC Gateway Service service is starting.
The OpenOPC Gateway Service service could not be started.

The service did not report an error.

More help is available by typing NET HELPMSG 3534.
C:\OpenOPC\src>NET HELPMSG 3534

The service did not report an error.

在调试模式下运行服务时,遇到以下错误:

C:\OpenOPC\src>python OpenOPCService.py debug
Debugging service zzzOpenOPCService - press Ctrl+C to stop.
Error 0xC0000003 - The instance's SvcRun() method failed

<Error getting traceback - traceback.print_exception() failed

(null): (null)

调试OpenOPCService.py程序时,程序崩溃,出现以下错误:

Exception has occurred: SystemExit
1
  File "C:\OpenOPC\src\OpenOPCService.py", line 154, in <module>
    win32serviceutil.usage()

非常感谢您的帮助或建议


Tags: the实例pysrc服务器client目标远程