日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程语言 > python >内容正文

python

python opc

發(fā)布時間:2023/12/16 python 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python opc 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

工業(yè)數(shù)據(jù)采集:Python從OPC讀、寫設(shè)備實(shí)時數(shù)據(jù)so easy - 知乎 (zhihu.com)
?

Matrikon OPC使用教程連載

python 2.7 讀寫 opc數(shù)據(jù)

Python2.7 opc-DA 數(shù)據(jù)采集-OpenOPC使用說明

OpenOPC Gateway Service

The Gateway Service is an optional Windows service which handles all the Win32 COM/DCOM calls used by the OpenOPC library module. This offers the following potential advantages:

  • Avoidance of DCOM security headaches and firewall issues when running the OPC client and OPC server on different nodes.
  • The ability to write OPC client applications that can run on non-Windows platforms such as Linux, Unix, and Mac OS X.

    Installing the service

    C:\OpenOPC\bin> OpenOPCService.exe -install Installing service OpenOpcService Service installed

    Starting the service

    C:\OpenOPC\bin> net start zzzOpenOpcService

    Stopping the service

    C:\OpenOPC\bin> net stop zzzOpenOpcService

FreeOpcUa:開源C ++和Python OPC-UA服務(wù)器以及客戶端庫和工具

PYTHON工業(yè)互聯(lián)網(wǎng)監(jiān)控項(xiàng)目實(shí)戰(zhàn)4—PYTHON OPCUA

OPC UA設(shè)備接入實(shí)踐樹

莓派安裝freeopcua server

代碼:

openopc_client.py(phpstudy_pro, KEPServerEX6, MatrikonOPC Explorer)

#!/usr/bin/env python # -*- coding:utf-8 -*-# openopc 官方文檔地址 #http://openopc.sourceforge.net/api.html # 導(dǎo)入包 import OpenOPC# 生成OpenOPC實(shí)例(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服務(wù)器 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'] # # 讀取一系列數(shù)據(jù) 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 randomfrom opcua import ua, Serverif __name__ == "__main__":# setup our serverserver = Server()server.set_endpoint("opc.tcp://0.0.0.0:4840/freeopcua/server/")# setup our own namespace, not really necessary but should as specuri = "http://examples.freeopcua.github.io"idx = server.register_namespace(uri)# get Objects node, this is where we should put our nodesobjects = 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 = 0while True:time.sleep(5)count = count + 1print(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, etcserver.stop()

PYTHON3 + OPENOPC讀取OPC服務(wù)器方法_工業(yè)自動化工作者-CSDN博客_python 讀取opc

用OPC采集mysql的配置

1.先安裝mysql

2.在安裝ODBC驅(qū)動?mysql-connector-odbc**

3.在控制面板或window搜索框 找到ODBC數(shù)據(jù)源管理器

? ? 選擇"系統(tǒng)DSN" -> 添加 ->mysql odbc *** driver->配置mysql連接信息 [配置數(shù)據(jù)源名稱 TESTER]

4.打開KeepServerEX

? ?1、新建 一個channel?

? ? ? ?Input Name-> [driver] Advanced Simulator ->next-> [DataSource] TESTER [User Name] root [password] ****** (mysql 用戶密碼)

? ?2. 新建一個Decvie

? ? ? Input Name -> [decvice mode] Mysql -> 選擇表名稱->Next..Next->Ok

? ?這樣就聯(lián)通了

DDE OPC服務(wù)器 (OPC Server) (matrikonopc.cn)

3、讀取opc服務(wù)器數(shù)據(jù)

taglist=['Channel_4.Device_6.Word_1','Channel_4.Device_6.Word_2','Channel_2.Device_3.Tag_1','Channel_2.Device_3.Tag_2','Channel_2.Device_3.Tag_3','Channel_4.Device_5.Tag_1','Channel_3.Device_4.Word_1','Channel_3.Device_4.Word_2',] # 讀取一系列數(shù)據(jù) opc_datas = opc.read(taglist) datas = [i[1] for i in opc_data] # 讀取一個點(diǎn) opc_data = opc.read(taglist) data = opc_data[1]

4、寫入opc服務(wù)器

# 寫入一個點(diǎn) # 方式1 opc.write( ('Triangle Waves.Real8', 100.0) ) # 方式2 opc['Triangle Waves.Real8'] = 100.0# 寫入多個點(diǎn) opc.write( [('Triangle Waves.Real4', 10.0), ('Random.String', 20.0)] )

OPC測試常用的OPCClient和OPCServer軟件推薦

原文鏈接:http://sns.ca800.com/space.php?uid=45972&do=blog&id=2310

各位在進(jìn)行OPC通訊時,常會遇到兩種情況:

1)使用一個OPCClient在同一臺計(jì)算機(jī)上連接遠(yuǎn)程計(jì)算機(jī)上的多個OPCServer時,發(fā)現(xiàn)某個OPCServer是通暢的,但其他的OPCServer卻無論如何都不通。不知該如何定位問題了?

2)多個廠家的OPCClient連接同一計(jì)算機(jī)上的OPCServer,發(fā)現(xiàn)有的OPCClient通了,有的不通,有的能獲取數(shù)據(jù),有的不能獲取數(shù)據(jù)。

基于以上情況,將一直以來常用的OPCClient和OPCServer推薦幾款,以備大家不時之需。

不是最好,但可能是恰好!

1. OPC DA Client推薦

推薦的理由(此標(biāo)準(zhǔn)僅僅代表個人意見):

1) 單文件;攜帶方便,無需安裝,綠色環(huán)保。

2) 遵循OPC標(biāo)準(zhǔn),穩(wěn)定。

3) 功能無需多,但適用功能有一個或多個。

推薦的第一位:OPCClient.exe

把它放在第一位并不是有多好,而是100KB的體積,單文件,也很符合OPC標(biāo)準(zhǔn),所以是個超便攜的OPCClient。

推薦的第二位:Matrikon公司的OPCClient.

很不錯的一個OPCClient,標(biāo)準(zhǔn),穩(wěn)定,單文件,通訊過程的信息還比較豐富,我是比較喜歡用它在創(chuàng)建OPC組時定義同步方式或異步方式來驗(yàn)證遠(yuǎn)程計(jì)算機(jī)的OPC配置是否正確。缺點(diǎn)就是大了點(diǎn),2M多。

推薦的第三位:Kepware公司的OPCClient

功能很強(qiáng)大,標(biāo)準(zhǔn),穩(wěn)定,日志信息很豐富,最推薦的功能是支持對OPCServer中點(diǎn)名的條件過濾,支持點(diǎn)表的導(dǎo)入導(dǎo)出,支持自動導(dǎo)入OPCServer的所有點(diǎn),根據(jù)點(diǎn)表識別好點(diǎn)壞點(diǎn),按照列排序,用它可以彌補(bǔ)很多國產(chǎn)組態(tài)軟件不能在線遍歷OPCServer點(diǎn)表的功能、不能過濾OPCServer點(diǎn)的功能、不能識別OPCServer中好點(diǎn)壞點(diǎn)的功能等。缺點(diǎn)就是非單文件。

其實(shí)還有其他很多的很好的OPCClient軟件,歡迎各位推薦分享。

2. OPC DA Server推薦:

推薦的理由(此標(biāo)準(zhǔn)僅僅代表個人意見):

1) 依然單文件;攜帶方便,無需安裝,綠色環(huán)保。

2) 依然遵循OPC標(biāo)準(zhǔn),穩(wěn)定。

3) 能模擬常見的大多數(shù)應(yīng)用場景和數(shù)據(jù),如各種曲線(三角函數(shù)曲線等),各種數(shù)據(jù)類型,各種故障類型,這一條大多數(shù)情況下與第一點(diǎn)是沖突的,所以基本上是常備幾種OPCServer

推薦的第一位:Knight.OPCServer

簡單,還是簡單,單文件運(yùn)行起來啥都有了,148KB,很適合做簡單的測試。

推薦的第二位:Matrikon公司的OPCServer Simulator

簡單,單文件注冊后,各種數(shù)據(jù)類型,各種點(diǎn)類型(只讀點(diǎn),只寫點(diǎn),讀寫點(diǎn))都有了,更好的一點(diǎn)是,如果想做大規(guī)模的測試,10萬點(diǎn),那么只需要在它的Random.下添加任意名稱即可,OPCServer會自動給你建出對應(yīng)的測點(diǎn),還是隨機(jī)數(shù)變化。

推薦的第三位:Kepware公司的OPCServer

本來不想推薦,因?yàn)檫@是一個商業(yè)軟件,需要花費(fèi)金錢購買License的,但Kepware公司的OPCServer需要花錢的不是OPCServer本身,而是采集驅(qū)動。不過Kepware公司的OPCServer提供了不花錢的仿真驅(qū)動,用來測試上正是殺人越貨的好東西啊,推薦理由的第三條就是說它老兄了。?缺點(diǎn)就是太龐大,不簡單,學(xué)習(xí)成本較高。但為了能滿足OPC這類產(chǎn)品的各種測試,它真的是最佳選擇。由于它是商業(yè)軟件,我就不提供下載地址了,各位去它的官方網(wǎng)站可以下載,做好的幾萬點(diǎn)的測試工程需要的找我要。

總結(jié)

以上是生活随笔為你收集整理的python opc的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。