探秘Go语言实现的OPC/UA库:gopcua

探秘Go语言实现的OPC/UA库:gopcua

项目介绍

gopcua 是一个由Go语言编写的OPC/UA(开放平台通信统一架构)二进制协议的原生实现。这个项目旨在提供高效、稳定且易于使用的接口,用于与OPC-UA服务器进行通讯。OPC-UA是一种跨平台的标准,广泛应用于工业自动化和物联网领域,它支持安全的数据交换,并提供强类型的数据模型。

项目技术分析

gopcua库实现了OPC-UA的Binary编码,目前不支持JSON或XML编码。它基于TCP协议,提供了包括匿名、用户名密码以及X509证书在内的多种安全认证方式。gopcua支持的基本服务包括发现服务、安全通道服务和会话服务等,让你能够方便地创建、管理和关闭连接。

项目还拥有全面的测试覆盖,确保在各种环境中都能稳定运行。开发者们正努力使API更加稳定,以满足大型生产环境的需求。

项目及技术应用场景

gopcua适用于需要与OPC-UA服务器交互的各种场景,例如:

  1. 工业自动化:监控和控制工厂设备,收集传感器数据,实现远程操作。
  2. 物联网(IoT):将不同类型的智能设备连接到中央管理系统,进行数据采集和分析。
  3. 数据集成:通过gopcua与InfluxDB的Telegraf插件配合,收集OPC-UA服务器的数据并存储到时序数据库中。
  4. 云服务:连接到各种品牌的PLC(可编程逻辑控制器),如Siemens S7-1500、Beckhoff C6015等,进行实时数据传输和处理。

项目特点

  1. Go语言原生实现:利用Go语言的并发特性,提供高效的性能和内存管理。
  2. 多安全模式:支持无加密、Basic128Rsa15、Basic256和Basic256Sha256等多种安全性设置,保护敏感信息。
  3. 简单易用的API:提供清晰的API接口,帮助开发者快速构建应用程序。
  4. 广泛的平台兼容性:已在多个生产环境中测试,适应不同的硬件和操作系统。
  5. 活跃社区支持:有多个赞助商支持,且用户和贡献者不断增多,意味着持续的技术支持和更新。

为了更直观地了解如何使用gopcua,项目包含了几个简单的示例脚本,如获取服务器当前日期时间、读取特定节点值等,助你快速上手。

总之,无论你是工业自动化领域的开发者还是寻求可靠数据源的IoT专家,gopcua都是值得信赖的OPC-UA客户端实现。赶快来尝试并参与这个项目的发展,共同提升OPC-UA在Go生态中的应用水平吧!

  • 5
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
Overview This OPC UA reference implementation is targeting the .NET Standard Library. .Net Standard allows developing apps that run on all common platforms available today, including Linux, iOS, Android (via Xamarin) and Windows 7/8/8.1/10 (including embedded/IoT editions) without requiring platform-specific modifications. Furthermore, cloud applications and services (such as ASP.Net, DNX, Azure Websites, Azure Webjobs, Azure Nano Server and Azure Service Fabric) are also supported. Features included 1. Fully ported Core UA stack and SDK (Client, Server, Configuration & Sample assemblies) 2. Sample Servers and Clients, including all required controls, for .Net 4.6, .NetCore and UWP. 3. X.509 certificate support for client and server authentication 4. Anonymous, username, X.509 certificate (experimental) and JWT (experimental) user authentication 5. UA-TCP & HTTPS transports (client and server) 6. Folder certificate-store support 7. Sessions (including UI support in the samples) 8. Subscriptions (including UI support in the samples) Getting Started All the tools you need for .Net Standard come with the .Net Core tools. See here for what you need. How to create self signed certificates for the sample applications On Windows 1. Open a command prompt in the root folder of your repository 2. Run the script CreateAllCerts.cmd in the root folder of your repository to create the certificates for all sample applications. 3. Alternatively, you can run the script CreateCert.cmd in each sample project folder to create new self signed certificates for the application. 4. The self signed certificates are stored in OPC Foundation/CertificateStores/MachineDefault in each application project folder On Linux 1. Open a command prompt 2. Navigate to the project folder of the sample app, e.g. SampleApplications/Samples/NetCoreConsoleClient 3. Run the script ./createcert.sh to create the certificates for the sample applications. 4. The self signed certificates are stored in OPC Foundation/CertificateStores/MachineDefault in each application project folder How to build and run the samples in Visual Studio on Windows 1. Create certificates for all sample applications. 2. Open the solution UA-NetStandard.sln with VisualStudio. 3. Choose a project in the Solution Explorer and set it with a right click as Startup Project. 4. Hit F5 to build and execute the sample. How to build and run the console samples on Windows, Linux and iOS This section describes how to run the NetCoreConsoleClient, NetCoreConsolePublisher and NetCoreConsoleServer sample applications. Please follow instructions in this article to setup the dotnet command line environment for your platform. Prerequisites 1. Once the dotnet command is available, navigate to the root folder in your local copy of the repository and execute dotnet restore. This command calls into NuGet to restore the tree of dependencies. Start the server 1. Open a command prompt 2. Now navigate to the folder SampleApplications/Samples/NetCoreConsoleServer. 3. Run the script ./createcert.sh on Linux or CreateCert.cmd on Windows to create the self signed certificate for the command line application. 4. To run the server sample type dotnet run. The server is now running and waiting for connections. In this sample configuration the server always accepts new client certificates. Start the client 1. Open a command prompt 2. Now navigate to the folder SampleApplications/Samples/NetCoreConsoleClient. 3. Run the script ./createcert.sh on Linux or CreateCert.cmd on Windows to create the self signed certificate for the command line application. 4. To execute the sample type dotnet run to connect to the OPC UA console sample server running on the same host. To connect to another OPC UA server specify the server as first argument and type e.g. dotnet run opc.tcp://myserver:51210/UA/SampleServer. How to build and run the OPC UA Web Telemetry sample • Go to the Azure portal and create a new Storage account. • Open the solution OpcUaWebTelemetry.sln with VisualStudio 2015. • Open the MessageProcessing\Configuration.cs file to configure the app to use your Azure resources (Storage account and IoTHub). // {StorageAccountName} is the name of the storage account and could be found // under Settings->Access keys->Storage account name of your storage account on the Azure portal. // {AccessKey} is the access key of the storage account and could be found // under Settings->Access keys->key1 of your storage account on the Azure portal. public static string StorageConnectionString = "DefaultEndpointsProtocol=https;AccountName={StorageAccountName};AccountKey={AccessKey}"; // {ConsumerGroupName} is the name of a aonsumer group of your IoTHub. The IoTHub you use is the // one you have created for use with the OPC UA Publisher sample. // You need to create this consumer group via the messaging settings of your IoTHub in the Azure portal. // We recommend that you do not share this Consumer group with other consumers, nor that you use the $Default consumer group. public static string EventHubConsumerGroup = "{ConsumerGroupName}"; // {EventHubEndpoint} is the Event Hub compatible endpoint of your IoTHub and could be found // under Settings->Messaging->Event Hub-compatible endpoint of your IoTHub in the Azure portal. // {PrimaryKey} is the IoT Hub primary key for access with iothubowner policy and could be found // under Settings->Shared access policies->iothubowner->Primary key of your IoTHub in the Azure portal. public static string EventHubConnectionString = "Endpoint={EventHubEndpoint};SharedAccessKeyName=iothubowner;{PrimaryKey}"; // {HubName} is the Event Hub compatible name of your IoTHub and could be found // under Settings->Messaging->Event Hub-compatible name of your IoTHub in the Azure portal. public static string EventHubName = "{HubName}"; • Save the file, rebuild the solution and start it. This will start a local instance of the application. • The solution can also be deployed into a Azure App service. Please use VisualStudio 2015's Azure publishing functionality for this purpose. • Now run the OPC UA Publisher sample, connect to a OPC UA server and publish a node. • You should see the node value on the web page after a few seconds. License This repository includes the UA .NetStandard Stack, sample libraries, and sample applications. The UA .NetStandard Stack follows a dual-license: • OPC Foundation Corporate Members: RCL • Everybody else: GPL 2.0 • RCL enables OPC Foundation members to deploy their applications using the UA .NetStandard stack without being required to disclose the application code. Non-members must disclose their application code when using the UA .NetStandard Stack. • Note: Dual license applies to this repository only; GPL 2.0 applies to all derived repositories (for example 'forks'). For details check the License section below. • All samples are provided under the MIT license. Contributing We strongly encourage community participation and contribution to this project. First, please fork the repository and commit your changes there. Once happy with your changes you can generate a 'pull request'. You must agree to the contributor license agreement before we can accept your changes. The CLA and "I AGREE" button is automatically displayed when you perform the pull request. You can preview CLA here.
《Boost程序:深度解析C++准标准》是一本详细介绍Boost程序的书籍。Boost是一个开源的C++程序集合,提供了许多重要的功能和工具,帮助开发者更高效地开发C++应用程序。 《Boost程序:深度解析C++准标准》首先介绍了Boost程序的概念、历史和发展。然后,逐一介绍了Boost的各个模块和组件,包括: 1. 智能指针:详细介绍了shared_ptr、scoped_ptr和weak_ptr等智能指针的使用方法和原理,帮助开发者更好地管理资源和避免内存泄漏。 2. 容器:介绍了各种常用的数据容器,如vector、map、set等,并介绍了它们在Boost中的实现和扩展功能。 3. 函数对象和算法:介绍了Boost中的函数对象和算法,其中包含了丰富的算法和函数对象,方便开发者进行各种数据处理和计算操作。 4. 正则表达式:详细介绍了Boost中正则表达式的使用,包括基本语法、匹配规则和替换操作等。 5. 多线程和并发:介绍了Boost中多线程和并发编程的相关模块,包括线程、互斥锁、条件变量等,帮助开发者编写高效的并发程序。 6. 其他模块:还介绍了Boost中的其他模块,如日期时间、解析、文件系统等,帮助开发者完成更多的任务和功能。 《Boost程序:深度解析C++准标准》不仅介绍了Boost的具体用法,还深入解析了其实现原理和设计思想,帮助开发者更好地理解和使用Boost程序。对于想要提高自己的C++编程技能和加快开发效率的开发者来说,这本书是一本非常实用的参考资料。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

明俪钧

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值