连接Fatek PLC和OPC UA服务器的驱动程序

时间:2019-05-03 07:11:34

标签: python plc opc

我已经创建了一个OPC-UA服务器以及客户端。现在,我想将OPC-UA服务器连接到Fatek PLC,但是我不知道该怎么做。有人可以帮我吗?

一个小小的驱动程序/脚本将不胜感激,因为我不想使用现有的软件来连接PLC和OPC-UA服务器。最好使用python来编写代码。

下面是供参考的OPC UA服务器代码:

from opcua import Server
import datetime
from random import randint
import time

server = Server()
port = "4840"
url = "opc.tcp://127.0.0.1:4840"
server.set_endpoint(url)
name = 'OPCUA_SIMULATION_SERVER'
addspace = server.register_namespace(name)
node = server.get_objects_node()
Param = node.add_object(addspace, "Parameters")
Temp = Param.add_variable(addspace, "Temperature", 0)
Press = Param.add_variable(addspace, "Pressure", 0)
Time = Param.add_variable(addspace, "Time", 0)
Temp.set_writable()
Press.set_writable()
Time.set_writable()
server.start()
print("Server started at {}".format(url))
print(addspace)
while True:
    Temperature = randint(10,50)
    Pressure = randint(200,999)
    TIME = datetime.datetime.now()
    print(Temperature, Pressure, TIME)
    Temp.set_value(Temperature)
    Press.set_value(Pressure)
    Time.set_value(TIME)
    time.sleep(2)

0 个答案:

没有答案