《OPC UA实践》 - 阅读笔记 3 OPC UA与产业升级

第三章 OPC UA与产业升级

3.1 OPC UA对于控制层的意义和构想。

OPC 为不同控制器之间以及控制器和MES/管理
系统之间的通信打下了坚实的基础。

大量的控制器(PLC)和MES系统厂商只专注于自己的专业领域,而OPC UA提供了一个纵向通信来打通这一点,并提供了标准的接口,且更加安全、实用。

控制器层面所有的相关内容都可以被认为是面向服务控制(SoA-PLC)的基本准则。而控制器的实时性通常由发布-订阅模式来实现。

由于TCP/IP协议的数据完整性需要通过重发来保证,因此缺乏PLC所需要的实时性。(现在机器人行业常用的ROS1通过UDP协议来实现发布订阅,ROS2则利用DDS来实现)
其中的难点在于:
实时域(PLC)与非实时域(OPC UA)之间的数据传输要如何定义接口与传输方式。


PLCopen:控制层映射及功能块
PLCopen国际组织根据不同的国际标准,针对控制器设计定义了许多重要组件(如运动控制)。
他们也发布了两个技术规范:

  • 《PLCopen OPC UA信息模型》:如何在OPC UA环境中描述IEC 61161-3 所定义的数据类型、功能块和数据结构等。(也就是OPC UA到IEC 61161-3 的映射)
  • 《PLCopen OPC UA UA IEC 61161-3客户端》:如何利用PLCopen功能块以客户端角色发起 OPC UA通信

功能块:

建立链接
获取地址空间索引
获取节点句柄
读取数据

OPC UA 发布-订阅模式

客户端-服务器模式更适合非实时、异步的数据通信。
实时通讯通常使用基于以太网的现场总线协议,如EtherCAT等。此时数据传输模式为发布-订阅模式。

发布者
UDP多播组
订阅者
订阅者
订阅者

OPC UA正在对标准的发布者-订阅者通信模式进行扩展, 以便同时支持典型的、标准的OPC UA数据呈现,以及当前所欠缺的实时加密的1:n通信方式。新的标准在工业4.0框架中同时支持基于UDP\IP的数据传输(实时)和基于其他协议(AMQP\MQTT)的数据传输(非实时)。

当不同厂商的控制器采用UDP\IP协议进行数据交换时,它所带来的好处:
只要通信部份在控制器固件的实时域内实现,系统就自然获得了数据交换的实时性。

OPC UA确立标准,不同厂商控制器都需要信息交换,可实现更简单便利的实时通讯。


行业信息模型

OPC UA在控制器领域内还支持所谓的行业伴随标准。
OPC UA元模型(metamodel)的基础上定义用于描述特定应用领域内的专用数据类型、实例和关系。可以从原来的行业标准–映射到OPC UA服务器中。
典型示例:

  • OPC UA ADI(分析仪设备集成,Analyzer Device Integration)标准
  • AMI(自动识别、数据采集以及移动数据通信)协会的AutoID标准

无需对设备做更多配置(定义行业相关数据类型和方法),就可直接对其进行访问。

借助OPC UA特定应用域模型的确立,长久以来讨论中的即插即生产(plug-and-produce)理念才有可能成为现实。

控制器层面的两个可能性:

  1. 通过控制器模拟这些设备
  2. 为控制器添加额外的用于与行业设备通信的库函数。

OPC UA以XML格式描述行业伴随标准,且类型和实例的编码位于节点集合内。OPC UA服务器可以方便地加载或者导入这些信息模型。而控制器厂商只需要确定规则,将节点集合内的数据点与控制器上的实际数据点链接起来。

UA-Nodeset
上述行业伴随标准开源可下载:UA-Nodeset
每个标准下有这些文件:

  • .NodeSet2.xml - The formal definition of the Nodes defined by the specification;
  • .Types.xsd - The XML schema for the DataTypes defined by the specification;
  • .Types.bsd - The OPC Binary schema for the DataTypes defined by the specification (obsolete);
  • .NodeIds.csv - A CSV file containing the NodeIds assigned to Nodes defined by the specification;

通常如其名称所述,为节点、类型的节点集合,偶尔也有信息模型文件。不同领域互相还有引用。
例如Robotics的Nodeset就需要依赖于DI的Nodeset。

<UANodeSet xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" LastModified="2019-05-06T00:00:00Z" xmlns="http://opcfoundation.org/UA/2011/03/UANodeSet.xsd">
  <NamespaceUris>
    <Uri>http://opcfoundation.org/UA/Robotics/</Uri>
    <Uri>http://opcfoundation.org/UA/DI/</Uri>
  </NamespaceUris>
  <Models>
    <Model ModelUri="http://opcfoundation.org/UA/Robotics/" Version="1.0.0" PublicationDate="2019-05-06T00:00:00Z">
      <RequiredModel ModelUri="http://opcfoundation.org/UA/" Version="1.04" PublicationDate="2019-05-01T00:00:00Z" />
      <RequiredModel ModelUri="http://opcfoundation.org/UA/DI/" Version="1.02" PublicationDate="2019-05-01T00:00:00Z" />
    </Model>
  </Models>

基于SoA-PLC的TwinCAT概念
TwinCAT
此现代控制器能够与其他基于OPC UA的控制器或控制系统无障碍数据交换和互操作。
控制器为核心,主要任务为实现实时逻辑处理和控制相应的输入输出信号。
数据由实时域采集,opc ua向外部提供。
基于软PLC概念(控制器内核运行于通用PLC和实时操作系统平台)

  1. 最内层的工程化、诊断、检测等借助OPC UA服务。
  2. 提供自定义类型和高附加值功能(提高语义层面互操作性)
  3. 最外层(传输层),具体的数据通信,分为两种形式:基于TCP/IP的客户端-服务端,基于UDP的发布订阅模式。包括网络安全保护机制。

控制器中的opc ua的现状和未来
独一无二,数据通信、基于类型的系统和网络安全技术的整合。

3.2 西门子控制器中的opc ua

在这里插入图片描述
管理层:制造执行系统(MES)
操作者:数据采集于监视控制系统、工程结构、能源管理
控制层:PLC、HMI、工业PC、通信、运动控制、CNC数控
现场级:电源、工业标识、分布式输入输出、电机驱动器、工业控制器

OPC UA可以与PROFINET在同一线缆上并行。

OPC UA与现有设备升级

  1. 快速大规模移植
  2. 渐进式移植并支持更多现有协议
  3. 基于OPC UA网关实现系统移植。
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&#39;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 &#39;forks&#39;). 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 &#39;pull request&#39;. 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.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

canmoumou

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

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

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

打赏作者

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

抵扣说明:

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

余额充值