如何使用python制作OPC UA服务器客户端程序。 我发现这个链接-https://github.com/FreeOpcUa/python-opcua/tree/master/examples 但我无法获得代码流。请给出你的建议,如果有人有任何相关的支持文件。请分享它。使用OPC UA协议在python中进行服务器端客户端编程
1
A
回答
0
你想要完成什么?结构是相当重要的问题,因为你可以摆脱它。 Onces它的安装运行的服务器并检查它witth他的命令行
opcua-client
这个GUI可能会帮助很多见的服务器的结构。
opcua服务器存在于节点组合之外。他们中的一些标准节点,你会在你运行 编程时许多这些基本的节点可以接收使用最基本的OPC服务器看到:
server.nodes#.<some node use your IDE>
对于你需要找到他们所有自定义节点,你可以通过打电话给孩子来做到这一点。例如:
# To get the root node ALL other nodes are a child fro; this one eventually
root = server.get_root_node()
# To get a child:
root.get_child("0:Objects") #Objects is one of those basic nodes
# You can get a child from a path
# Once again first study the tree with the opcua-client gui
# This gui is installed automatically and under the commane opcua-client
root.get_child(["0:Objects", "0:Server"])
# The above will get the child of Objects called Server
# directly starting at the root node
现在你可以自己创建子节点。你去你想要添加孩子的节点通常:
# The Objects node
# Later you'll probably want to put that all in 1 line
objects = server.nodes.objects
id, name, type = 2, "testName", None
test = objects.add_object(id, name, type)
# This will add a object named testName to the objects node
# To acces this node again we can use it's id
server.get_node(test.nodeid)
# I know this will return test again.
# However the ua methods "parent' parameter is this nodeid so can come in very handy
创建ua方法可能也将成为您的服务器的一项重要任务。
@uamethod
def methode(parent, input):
print(input) # You can do all things here offcourse
server.nodes.objects.add_method(0, "myMethod", methode, ua.VariantType.ByteString, None)
这将方法添加到对象节点
0是你想给它的ID。我不能真正解释你应该选择什么号码...我通常只是选择2 ...
“mymethod”将是它的浏览名称,它允许您使用节点
的get_child和call_method方法找到它方法不合适您的方法
ua.VariantType。需要解析inputargs的数据
无同上,但outputargs ...这我functiond没有
希望这有助于你一点理解,你可以用做最基础知识freeopcua库
相关问题
- 1. OPC UA客户端 - BadCertificateHostNameInvalid - opcfoundation.org
- 2. 树莓派pi2上的OPC UA服务器客户端
- 3. OPC UA客户端数据访问服务器
- 4. 强制bazaar客户端协议使用服务器协议2?
- 5. 客户端服务器,设计协议
- 6. 使用Python进行网络编程 - TCP客户端/服务器
- 7. 关于流行的客户端/服务器协议的建议
- 8. OPC客户端 - 如何从远程OPC服务器读取
- 9. 最佳Python支持的服务器/客户端协议?
- 10. 用Python进行服务器端客户端推送通知
- 11. python服务器的客户端改进
- 12. 西门子OPC UA和.NET C#客户端无法连接到服务器?
- 13. 如何将OPC UA节点红色客户端连接到本地服务器?
- 14. 强制一个OPC客户端读取OPC服务器缓存
- 15. MySQL协议客户端/服务器Authenication - 令牌生成从客户端
- 16. Java OPC-UA客户端Eclipse Milo端点URL更改为localhost
- 17. 进行服务器端编程时需要多少客户端编程?
- 18. C客户端在服务器客户端应用程序中的进程ID
- 19. 编写一个具有客户端和服务器端软件的协议
- 20. 使用进程在客户端服务器上执行utl_recomp
- 21. Android中的客户端服务器协议
- 22. 使用RESTful API进行客户端和服务器端验证
- 23. 客户端服务器socket编程
- 24. android - 客户端服务器编程
- 25. Netbeans 7+协作客户端/服务器
- 26. c使用TCP/IP协议的服务器客户端应用程序
- 27. Android客户端服务器编程。
- 28. Java客户端服务器编程
- 29. UDP客户端和服务器缓冲区协议
- 30. 更改客户端到服务器的协议
嗨。我指的是你提到的同一个链接。你运行了吗? –