您好,欢迎访问代理记账网站
移动应用 微信公众号 联系我们

咨询热线 -

电话 15988168888

联系客服
  • 价格透明
  • 信息保密
  • 进度掌控
  • 售后无忧

python opc

Matrikon OPC使用教程连载

python 2.7 读写 opc数据

Python2.7 opc-DA 数据采集-OpenOPC使用说明

FreeOpcUa:开源C ++和Python OPC-UA服务器以及客户端库和工具

PYTHON工业互联网监控项目实战4—PYTHON OPCUA

OPC UA设备接入实践树

莓派安装freeopcua server

代码:

openopc_client.py(phpstudy_pro, KEPServerEX6, MatrikonOPC Explorer)

#!/usr/bin/env python
# -*- coding:utf-8 -*-

# openopc 官方文档地址
#http://openopc.sourceforge.net/api.html
# 导入包
import OpenOPC

# 生成OpenOPC实例(Open mode)
# In Open mode a connection is made to the OpenOPC Gateway  Service running on the specified node. This mode is available to both Windows and non-Windows clients.
opc = OpenOPC.open_client('localhost')
# 显示可连接的opc服务器
print opc.servers()
# If the OPC server is running on a different node, you can include the optional host parameter...
opc.connect('Kepware.KEPServerEX.V6', 'localhost')


taglist=['mysqltest.test.test_id', 'mysqltest.test.test_name']
# # 读取一系列数据
opc_datas = opc.read(taglist)
print opc_datas
opc.close()

D:\Python27\Scripts\examples\server-minimal.py

import sys
sys.path.insert(0, "..")
import time
import random


from opcua import ua, Server


if __name__ == "__main__":

    # setup our server
    server = Server()
    server.set_endpoint("opc.tcp://0.0.0.0:4840/freeopcua/server/")

    # setup our own namespace, not really necessary but should as spec
    uri = "http://examples.freeopcua.github.io"
    idx = server.register_namespace(uri)

    # get Objects node, this is where we should put our nodes
    objects = server.get_objects_node()

    myobj = objects.add_object(idx, "Tank4C9")
    status = myobj.add_variable(idx, "Status", 0)
    overheadFlow = myobj.add_variable(idx, "OverheadFlow", 0)
    buttomsFlow = myobj.add_variable(idx, "ButtomsFlow", 0)
    power = myobj.add_variable(idx, "Power", 0)

    #myVar.set_writable()    # Set MyVariable to be writable by clients


    # starting!
    server.start()
    
    try:
        count = 0
        while True:
            time.sleep(5)
            count = count + 1
            print(count%4)
            if count%4>0:
                status.set_value(1)
            else:
                status.set_value(0)

            a= random.randint(100,500)
            print("OverheadFlow:"+str(a))
            overheadFlow.set_value(a)
            buttomsFlow.set_value(random.randint(50,500))
            power.set_value(random.randint(1000,5000))
    finally:
        #close connection, remove subcsriptions, etc
        server.stop()

PYTHON3 + OPENOPC读取OPC服务器方法_工业自动化工作者-CSDN博客_python 读取opc


分享:

低价透明

统一报价,无隐形消费

金牌服务

一对一专属顾问7*24小时金牌服务

信息保密

个人信息安全有保障

售后无忧

服务出问题客服经理全程跟进