论技术领域学好英文的重要性

OPCUASDKHelp

 

 

 

 

 

 

 

 

 

 

 

封页

 

 

 

 

Welcome to the UA SDK(欢迎使用UA SDK)

//欢迎使用统一体系结构软件开发工具包

Welcome to the Unified Architecture Software Development Kit

 

// uasdk是一组接口、库和可执行文件,允许开发人员使用.NET编程环境快速创建UA应用程序。SDK包括:

The UA SDK is a set of interfaces, libraries and executables that allow developers to quickly create UA applications with the .NET programming environment. The SDK includes:

 

// XML Web服务和UA本机二进制堆栈配置文件的实现;

Implementations of the XML Web Services and UA Native Binary stack profiles;

 

//服务器和客户端开发工具包;

Server and Client development toolkits;

 

//样品应用;

Sample Applications;

 

//用于服务器的AEDA-051.00和AEDA-051.00;

A wrapper for COM-DA Servers (DA 2.05a, DA3.00 and AE1.1);

 

// COM-DA和COM-AE客户端的代理(DA 2.05a和AE1.1);

A proxy for COM-DA and COM-AE clients (DA 2.05a and AE1.1);

 

//本地发现服务器;

Local Discovery Server;

 

//配置工具

Configuration Tool

 

//示例应用程序随源代码提供。堆栈和开发工具包仅作为二进制文件提供。

The sample applications are available with source code. The stack and development toolkits are available only as binaries.

 

// In This Section

在本节中

 

//本文档概述了UA软件开发工具包(SDK)。它讨论了体系结构、与SDK和工具箱api一起分发的组件。

This document provides an overview of the UA Software Development Kit (SDK). It discusses architecture, components distributed with the SDK and toolkit APIs.

 

// UA-SDK是为不同的开发环境而发布的。本文档主要描述使用.NET Framework的SDK,但是,许多通用概念适用于所有版本的SDK。

The UA SDK is distributed for different development environments. This document primarily describes the SDK that uses the .NET Framework, however, many of the general concepts apply to all versions of the SDK.

 

//读者应熟悉Microsoft.NET和C#的术语,以及Windows Communication Foundation(WCF)背后的基本概念。

The reader is expected to be familiar with Microsoft .NET and C# terminology as well as the basic concepts behind the Windows Communication Foundation (WCF).

 

//本文并没有详尽地描述SDK中的每个类。它旨在补充visualstudiointellisense文档,帮助开发人员了解如何开发生产服务器、客户机和DCOM代理/包装器。

This document does not exhaustively describe every class in the SDK. It is intended to supplement the Visual Studio intellisense documentation and help developers understand how to develop production server, client and DCOM proxy/wrapper.

 

//相关章节

Related Sections

 

//介绍

Introduction

 

//入门教程

Getting Started Tutorial

 

//基本编程

Basic Programming

 

//功能详细信息

Feature Details

 

//指导方针和最佳做法

Guidelines and Best Practices

 

// DCOM互操作性

DCOM interoperability

 

//示例应用程序

Sample Applications

 

//可交付成果

Deliverables

 

//工具

Tools

 

//发行说明

Release Notes

 

//许可协议

License agreement

 

//反馈和社区

Feedback and Community

Introduction(介绍)

// UA软件开发工具包(SDK)是一个库、应用程序和源代码的集合,允许开发人员构建UA应用程序。

The UA Software Development Kit (SDK) is a collection of libraries, applications and source code that allow developers to build UA applications.

 

// Related Sections

相关章节

 

//概述

Overview

 

//客户端、服务器和发现服务器

Clients, Servers and Discovery Servers

 

//Web服务

Web Services

Overview(概述)

 

//UA软件开发工具包(SDK)是一个库、应用程序和源代码的集合,允许开发人员构建UA应用程序。图1说明了SDK、网络和应用程序之间的接口。

The UA Software Development Kit (SDK) is a collection of libraries, applications and source code that allow developers to build UA applications. Figure 1 illustrates the interfaces between the SDK, the network and the applications.

 

UA有线协议

传输协议

安全协议

消息编码

堆栈 API

客户端/服务器 工具集

工具API

组件对象 代理/包装器

OPC应用程序

OPC组件对象API

组件对象应用程序

 

// UA SDK中的软件接口

Software Interfaces in the UA SDK

 

//堆栈API将wire协议的细节封装在一组类和接口之后。这些接口实现了[UA UASPECPart 4]中定义的所有UA服务作为方法调用。使用堆栈API构建的应用程序不直接依赖于wire协议,并且支持堆栈支持的所有协议。

The Stack API encapsulates the details of the wire protocol behind a set of classes and interfaces. These interfaces implement all of the UA services defined in [UA UASPECPart 4] as method calls. Applications which are built with the Stack API do not have any direct dependencies on the wire protocol and support all protocols which are supported by the Stack.

 

// UA中使用的每个有线协议都是消息编码、安全协议和传输协议的组合。这些组合称为堆栈配置文件,它们在[UA UASPECPart 7]中定义。堆栈尽可能利用开发环境提供的特性(例如,堆栈使用WS-Secure Conversation实现,它是.NETFramework3.0的一部分)。

Each wire protocol used in UA is a combination of a messaging encoding, a security protocol and a transport protocol. These combinations are called Stack Profiles and they are defined in [UA UASPECPart 7]. The Stack makes use of features provided by the development environment whenever possible (e.g. the Stack uses the WS-Secure Conversation implementation which is a part of .NET Framework 3.0).

 

//该堆栈提供了wire协议的实现以及各种helper类,但不包含任何应用程序级代码。因此,UA-SDK还提供了工具包,这些工具包实现了所有UA应用程序所共有的特性。这些工具箱构建在堆栈API之上,并公开第二个API(称为ToolkitAPI)。ToolkitAPI的设计易于使用,使用它的应用程序将与Toolkit紧密耦合。客户端的工具箱API也称为UA客户端API。类似地,服务器的工具箱API称为UA服务器API。

The Stack provides an implementation of the wire protocol(s) plus a variety of helper classes but does not contain any application level code. For this reason the UA SDK also provides toolkits which implement features which are common to all UA applications. These toolkits are built on top of the Stack API and expose a second API (called the Toolkit API). The Toolkit API is designed ease of use and applications which use it will be tightly coupled to the Toolkit. The Toolkit API for the Client is also called the UA Client API. Similarly, the Toolkit API for a Server is called the UA Server API.

 

// COM代理和包装器是使用工具箱构建的UA应用程序,这些工具箱使用COM接口与现有的OPC COM应用程序进行通信。代理是允许COM客户端与UA服务器通信的COM服务器。包装器是允许UA客户端与COM服务器通信的COM客户端。请注意,COM包装器/代理是使用SDK构建的应用程序的示例,而不是SDK本身的一部分。

The COM Proxies and Wrappers are UA Applications built with the Toolkits that use COM interfaces to communicate with existing OPC COM applications. The Proxies are COM Servers that allow COM Clients to communicate with UA Servers. The Wrappers are COM Clients that allow UA Clients to communicate with COM Servers. Note that the COM wrappers/proxies are examples of applications built with the SDK and not part of the SDK itself.

 

//图2说明了使用SDK构建的UA应用程序如何通过网络相互交互。

Figure 2 illustrates how UA applications built with the SDK interact with each other over a network.

 

图2:使用SDK构建的UA应用程序之间的交互

服务器必须在其计算机上向发现服务器注册

OPC 组件对象服务

D组件对象

UA堆栈
UA服务工具

UA组件对象包装

UA堆栈
UA服务工具

UA服务应用程序

UA堆栈
UA本地发现服务器

UA堆栈API

SOAP简单对象访问协议
HTTP超文本传输协议
UA TCP协议

UA堆栈API

UA客户端应用程序
UA客户端工具

UA堆栈

UA组件对象
UA客户端工具

UA堆栈

D组件对象

OPC组件对象客户端

 

 

 

 

 

 

// UA本地发现服务器(LDS)是一个特殊的应用程序,它允许远程客户端发现存在于一台机器上的UA服务器。在计算机上运行的所有UA服务器都应该使用堆栈API向UA本地发现服务器注册。UA本地发现服务器是与SDK一起分发的独立可执行文件。

A UA Local Discovery Server (LDS) is a specialized application which allows remote Clients to discover the UA Servers that exist on a single machine. All UA Servers running on a machine should register with the UA Local Discovery Server using the Stack API. The UA Local Discovery Server is a standalone executable that is distributed with the SDK.

Clients, Servers and Discovery Servers(客户端、服务器和发现服务器)

// UA应用程序有三种类型:客户端、服务器和发现服务器。服务器应用程序提供对底层实时进程生成的数据和事件的访问,发现服务器提供有关网络上可用服务器的信息,客户端使用发现服务器识别可用服务器并使用服务器提供的数据和事件。一些UA应用程序将是客户端和服务器。不同类型的应用程序之间的关系如图1所示。

There are three types of UA applications: Clients, Server and Discovery Servers. Server applications provide access the data and events produced by an underlying real-time process, Discovery Servers provide information about Servers that are available on a network and Clients recognize available servers using discovery servers and consume the data and events provided by Servers. Some UA applications will be a Client and a Server. The relationships between the different types of applications are illustrated in Figure 1.

 

图1:UA应用程序之间的关系

服务器向发现服务器注册

本地发现服务器

服务器

发现服务器向其他发现服务器注册

客户端使用发现服务器搜索服务器

客户端与服务器创建会话

全局发现服务器

客户端

 

 

 

 

// SDK提供的接口和类允许开发人员创建上述任何类型的UA应用程序。

The SDK provides the interfaces and classes that allow developers to create any of the mentioned above types of UA Applications.

 

// SDK还包括UA本地发现服务器(LDS)的实现,该服务器允许客户端发现与LDS在同一主机上运行的服务器。服务器可以使用SDK中定义的api向LDS注册自己。开发人员还可以创建自己的发现服务器,这些服务器了解网络上的机器和/或服务器。

The SDK also includes an implementation of the UA Local Discovery Server (LDS) which allows Clients to discover Servers running on the same host as the LDS. Servers can register themselves with the LDS using APIs defined in the SDK. Developers may also create their own Discovery Servers which have knowledge of the machines and/or servers on the network.

Web Services(Web服务)

// WCF编程模型允许应用程序开发人员创建交换SOAP消息的应用程序。

The WCF programming model allows application developers to create applications which exchange SOAP messages.

WCF Implementation(windows组件模型基金会实施)

// WCF编程模型允许应用程序开发人员创建交换SOAP消息的应用程序。

The WCF programming model allows application developers to create applications which exchange SOAP messages.

 

// UA SDK是使用Windows Communication Foundation(WCF)构建的,后者是.NET Framework 3.0及更高版本的一部分。。编程模型如图1所示。

The UA SDK is built using the Windows Communication Foundation (WCF) which is part of the .NET Framework Version 3.0 and later.. The programming model is illustrated in Figure 1.

 

图1:WCF编程模型

服务器

结束点:

地址

绑定端口

合约

结束点:

地址

绑定端口

合约

通道
消息

客户端

 

 

 

 

//启动消息交换的应用程序称为WCF客户端,等待传入消息的应用程序称为WCF服务(请注意,WCF中术语“服务”的使用不同于UA中的术语使用。UA服务相当于WCF操作)。

An application which initiates a message exchange is called the WCF Client and the application which waits for incoming messages is called a WCF Service (Note that the use of the term ‘Service’ in WCF is different from the use of the term in UA. A UA Service is equivalent to a WCF Operation).

 

// WCF服务可以公开表示网络上可寻址位置的一个或多个WCF端点。每个WCF端点都由一个地址、一个绑定和一个协定来描述。地址指定发送消息的位置。绑定描述了如何发送消息。合同描述了信息包含的内容。WCF客户端需要知道这些信息,然后才能访问WCF服务。

A WCF Service may expose one or more WCF Endpoints which represent an addressable location on the network. Each WCF Endpoint is described by an address, a binding and a contract. The address specifies where to send messages. The binding describes how to send messages. And the contract describes what the messages contain. WCF Clients need to know this information before they can access a WCF Service.

 

// WCF合同有4个部分:ServiceContract、OperationContract、MessageContract和DataContract。ServiceContract定义WCF端点支持的操作。它被实现为一个用ServiceContract属性修饰的接口。OperationContract定义了客户端可以启动的单个消息交换。OperationContract可以定义单个消息或请求-响应消息对(UA应用程序仅使用请求-响应消息对)。它被实现为用OperationContract属性修饰的方法。MessageContract定义操作期间交换的SOAP消息体。它被实现为一个用MessageContract属性修饰的类。DataContract描述消息中的一个参数,也作为类实现。

A WCF contract has 4 parts: a ServiceContract, an OperationContract, a MessageContract and a DataContract. The ServiceContract defines the operations supported by an WCF Endpoint. It is implemented as an interface decorated with the ServiceContract attribute. The OperationContract defines a single message exchange that a Client may initiate. An OperationContract may define a single message or a request-response message pair (UA applications only use request-response message pairs). It is implemented as method decorated with OperationContract attribute. A MessageContract defines the body of a SOAP message exchanged during an operation. It is implemented as a class decorated with MessageContract attribute. The DataContract describes a parameter in the message and is also implement as a class.

 

// WCF通道是可用于交换多个消息的逻辑网络连接。WCF客户端在连接到终结点时必须创建WCF通道。当创建通道时,协商安全令牌,并分配一个唯一标识符。应用程序使用此标识符将UA会话与特定的WCF通道相关联。在任何给定时间,单个UA会话只能通过一个WCF通道访问。如果WCF通道因任何原因关闭(例如网络中断),客户端必须创建一个新的WCF通道,并通过调用ActivateSession服务将其与UA会话关联。

A WCF Channel is logical network connection that can be used to exchange multiple messages. A WCF Client must create a WCF Channel when it connects to an Endpoint. When a channel is created the security tokens are negotiated an a unique identifier is assigned. This identifier is used by the application to associate a UA session with a particular WCF channel. A single UA session can only be accessed via one WCF channel at any given time. If the WCF channel is closed for any reason (e.g. a network interruption) the client must create a new WCF channel and associate it with UA Session by calling the ActivateSession service.

 

//关于WCF编程模型的更多信息可以在微软提供的MSDN文档中找到。

More information on the WCF programming model can be found in the MSDN documentation provided by Microsoft.

Glossary(词汇表)

Basic Programming(基本编程)

//本节介绍创建OPC统一体系结构应用程序的基本原理。

This section presents the fundamentals for creating OPC Unified Architecture applications.

//在本节中

In This Section

 

//配置DCOM

Configuring DCOM

 

//描述如何配置COM包装器和COM代理

Describes how to configure the COM Wrapper and the COM Proxy

Server

Overview(概述)

// SDK提供的服务器工具包实现了所有UA服务器通用的功能。它被设计成可扩展的,并允许集成来自许多不同来源的数据和事件。

The Server toolkit provided by the SDK implements the features which are common to all UA servers. It is designed to be extensible and allow the integration of data and events from many different sources.

 

//要使用SDK提供生产服务器,开发人员必须实现以下功能:

To provide a production server using the SDK the developers have to implement the following functionality:

 

//公开一个或多个终结点,每个端点使用选定的平台环境公开一个或多个服务操作。

Exposes one or more endpoints, each of which exposes one or more service operations using selected platform environment.

 

//安全环境;(认证、授权、证书维护、安全策略和模式)

Security environment; (authentication, authorization, certificates maintenance, security policies and modes )

 

//配置维护;

Configuration maintenance;

 

//连接处理(端点管理、协议等)。

Connections handling (endpoints management, protocols, ..).

 

//地址空间和命名空间管理。

Address space and namespaces management.

 

//底层实时进程互操作性(读写数据、通信基础设施管理)。

Underlying real-time process interoperability (read and write data, communication infrastructure management).

 

// AE包装器提供了使用sdkapi实现这些函数所需的步骤的介绍性理解。

AE Wrapper provides an introductory understanding of the steps required to implement theise functions using the SDK API.

Architecture(建筑)

//模型

Model

 

// ServerSDK中的类如图1所示。

The classes in the Server SDK are shown in Figure 1.

Client(客户端)

Overview(概述)

//客户机SDK旨在通过处理所有客户机需要执行的标准任务来促进客户机开发。任务包括:

The Client SDK is designed to facilitate client development by handling the standard tasks which all clients need to do. The tasks include:

 

//发送会话保持活动请求

sending the session keep alive requests

 

//管理发布管道

managing the publish pipeline

 

//跟踪订阅和监视项目的当前状态

keeping track of the current status for subscription and monitored items

 

//管理客户端节点缓存

managing a client side node cache

 

//处理和缓存传入的数据更改和事件通知

processing and caching incoming data change and event notifications

 

//保存和恢复包括订阅和监视项的会话状态

saving and restoring the session state including the subscriptions and monitored items

 

//客户机SDK中的类如图1所示。

The classes in the Client SDK are shown in Figure 1.

 

使用

订阅

监控项状态

监控项

类型表

节点缓存

命名空间列表

会话

 

Sessions(会话)

// Session类继承自SessionClient,这意味着所有的UA服务都可以作为Session对象上的方法访问。

The Session class inherits from the SessionClient which means all of the UA services are accessible as methods on the Session object.

 

// Session对象提供了许多helper方法,包括创建和激活会话的Open(String,IUserIdentity)方法。与服务器建立会话时所需的过程如图1所示。

The Session object provides a number of helper methods including an Open(String, IUserIdentity) method which Creates and Activate a Session. The process required when establishing a session with a Server is shown in Figure 1.

 

选择结束点

图:1–开放式会话流程图

服务端只使用一次

服务端证书们

会话ID

认证令牌

服务端只使用一次

通道

结束点描述

激活会话

创建会话

创建安全通道

客户端的证书们

认证令牌

用户标识令牌

客户端签名

用户签名

通道

客户端证书

会话名称

客户端只使用一次的

结束点描述

结束点配置

绑定工厂

客户端证书

协议

安全模式

安全策略

 

 

 

 

 

 

 

 

//在第一步中,客户端应用程序必须选择要使用的EndpointDescription。这可以手动完成,也可以使用发现服务来完成。在下一步中,客户端获取EndpointDescription并使用它来创建Channel对象。直到第一次服务调用(在本例中为CreateSession),安全通道才真正建立。在下一步中,将创建会话对象并调用Open(String,IUserIdentity)方法。Open(String,IUserIdentity)方法将验证服务器提供的信息,然后使用传递给方法调用的用户标识调用ActivateSession。如果ActivateSession成功,客户端应用程序将能够调用其他方法。

In the first step the Client application must choose the EndpointDescription to use. This can be done manually or by using the Discovery Services. In the next step the Client takes the EndpointDescription and uses it to create the Channel object. The Secure Channel is not actually established until the first Service call (CreateSession in this case). In the next step, the Session object is created and the Open(String, IUserIdentity) method is called. The Open(String, IUserIdentity) method will validate the information provided by the Server and then call ActivateSession with the user identity passed to the method call. If ActivateSession succeeds the client application will be able to call other methods.

 

//激活会话后,session对象开始以KeepAliveInterval指定的速率定期从服务器读取当前状态(默认为5s)。每次接收到响应时,状态和最新时间戳都会报告为KeepAlive事件。如果响应在经过2个keepaliveinterval之后未到达,则引发KeepAlive事件并返回错误。KeepAliveStopped属性将设置为true。如果通信恢复,将报告正常的KeepAlive事件,KeepAliveStopped属性将返回false。

After activating the session the Session object starts periodically reading the current state from the Server at a rate specified by the KeepAliveInterval (default is 5s). Each time a response is received the state and latest timestamp is reported as a KeepAlive event. If the response does not arrive after 2 KeepAliveIntervals have elapsed a KeepAlive event with an error is raised. The KeepAliveStopped property will be set to true. If communication resumes the normal KeepAlive events will be reported and the KeepAliveStopped property will go back to false.

 

//客户机应用程序使用KeepAlive事件和KeepAliveStopped属性来检测与服务器的通信问题。在某些情况下,这些通信问题将是暂时的,但是当这些问题发生时,客户机应用程序可能会选择不调用任何服务,因为它们可能会超时。如果通道不能自行返回,客户机应用程序将执行它所拥有的任何错误恢复逻辑。

The client application uses the KeepAlive event and KeepAliveStopped property to detect communication problems with the server. In some cases these communication problems will be temporary but while they are going on the client application may choose not to invoke any services because they would likely timeout. If the channel does not come back on its own the client application will execute whatever error recovery logic it has.

 

//客户端应用程序需要确保OperationTimeout设置得太低。如果调用超时,WCF通道将自动关闭,客户端应用程序将需要创建一个新通道。创建一个新的频道需要一段时间才能激活。KeepAliveStopped属性允许应用程序检测故障,即使它们使用的是LonOperationTimeout OperationTimeout。

Client applications need to ensure that the OperationTimeout is not set too low. If a call times out the WCF channel is closed automatically and the client application will need to create a new one . Creating a new channel will take time and require another call to ActivateSession. The KeepAliveStopped property allows applications to detect failures even if they are using a lonOperationTimeoutg OperationTimeout.

 

// Session对象提供了一个缓存,可用于存储频繁访问的节点。缓存对于存储服务器定义的类型特别有用,因为客户端通常需要检查一个类型是否是另一个类型的子类型。可以通过会话对象的NodeCache属性访问缓存。可以使用NodeCache或Session对象的TypeTree属性搜索缓存中存储的类型层次结构(两者都返回对同一对象的引用)。

The Session object provides a cache that can be used to store Nodes that are accessed frequently. The cache is particularly useful for storing the types defined by the server because the client will often need to check if one type is a subtype of another. The cache can be accessed via the NodeCache property of the Session object. The type hierarchies stored in the cache can be searched using the TypeTree property of the NodeCache or Session object (the both return a reference to the same object).

 

// NodeCache使用FetchNode(ExpandedNodeId)方法填充,该方法将读取节点的所有属性并获取其所有引用。NodeCache上的Find(ExpandedNodeId)方法查找以前缓存的节点版本,如果FetchNode(ExpandedNodeId)不存在,则调用FetchNode(ExpandedNodeId)方法。

The NodeCache is populated with the FetchNode(ExpandedNodeId) method which will read all of the attributes for the Node and the fetch all of its references. The Find(ExpandedNodeId) method on the NodeCache looks for a previously cached version of the Node and calls the FetchNode(ExpandedNodeId) method if it does not exist.

 

//希望使用NodeCache的客户端应用程序必须通过调用Session对象上的FetchTypeTree(ExpandedNodeId)方法预获取服务器支持的所有ReferenceType层次结构。

Client applications that wish to use the NodeCache must pre-fetch all the ReferenceType hierarchy supported by the Server by calling FetchTypeTree(ExpandedNodeId) method on the Session object.

 

// Session对象负责发送和处理发布请求。只要通过订阅发布事件接收到新的NotificationMessage,客户端应用程序就可以接收通知。每当发布响应报告错误时,都会引发PublishError事件。

The Session object is responsible for sending and processing the Publish requests. Client applications can receive notifications whenever a new NotificationMessage is received by subscribing to the Publish event. The PublishError event is raised whenever a Publish response reports an error.

 

// SubscriptionsChanged事件指示何时添加或删除订阅。

The SubscriptionsChanged event indicates when a Subscription is added or removed.

 

// SessionClosing事件表示会话即将关闭。

The SessionClosing event indicates that the Session is about to be closed.

 

//会话对象及其订阅可以作为XML元素持久化。然后可以将此元素添加到ConfiguredEndpoint对象并添加到ConfiguredEndpointCollection

Session objects and their Subscriptions can be persisted as an XML element. This element can then be added to a ConfiguredEndpoint object and added to a ConfiguredEndpointCollection

 

//会话是为多线程操作而设计的,因为客户端应用程序经常需要同时对服务器进行多个调用。但是,更新会话(CreateSession或ActivateSession)状态的调用必须按顺序进行,以便这些操作具有特定的同步锁定。使用Session类但直接调用这些服务的客户端应用程序必须在调用CreateSession或ActivateSession之前获取StateLock。在处理发布或保持链接响应时,会话还为所有数据访问维护同步锁。此锁在引发任何事件之前被释放。

The Session is designed for multi-threaded operation because client application frequently need to make multiple simultaneous calls to the Server. However, calls that update the Session (CreateSession or ActivateSession) state must proceed in order so there is a specific synchronization lock for those operations. Client applications that use the Session class yet call these Services directly must acquire the StateLock before calling CreateSession or ActivateSession. The Session also maintains a synchronization lock for all data access while processing Publish or KeepAlive responses. This lock is released before any events are raised.

Subscriptions(订阅)

//订阅类存储服务器订阅的客户端状态。它维护两组属性:创建订阅时请求的值和基于服务器返回的修订值的当前值。

The Subscription class stores the client-side state for a Subscription with a Server. It maintains two sets of properties: the values requested when the Subscription is/was created and the current values based on the revised values returned by the Server.

 

//订阅对象是为批处理操作而设计的。这意味着订阅参数和MonitoredItem可以更新多次,但在调用ApplyChanges()()()()方法之前,不会对服务器上的订阅进行更改。更改完成后,将报告StateChange事件,并使用位掩码指示更新的内容。

The Subscription object is designed for batch operations. This means the subscription parameters and the MonitoredItem can be updated several times but the changes to the Subscription on the Server do not happen until the ApplyChanges()()()() method is called. After the changes are complete the StateChange event is reported with a bit mask indicating what was updated.

 

//创建订阅后,它必须开始发送发布请求。它通过告诉Session对象发送一个或多个请求来启动泵来启动进程。请求数由PipelineDepth属性控制,默认值为1。应用程序使用较长的管道深度来补偿高网络延迟,因为一旦管道填满,服务器将能够返回稳定的通知流。

When a Subscription is created it must start sending Publish requests. It starts off the process by telling the Session object to send one or more requests to prime the pump. The number of requests is controlled by the PipelineDepth property and the default is one. Applications use longer pipeline depths to compensate for high network latencies because once the pipeline is filled the Server will be able to return a steady stream of notifications.

 

//订阅启动泵后,会话对象通过在收到成功响应时发送新的发布来保持泵的运行。如果发生错误,会话将引发PublishError事件,而不发送另一个发布。

Once the Subscription has primed the pump the Session object keeps it going by sending a new Publish whenever it receives a successful response. If an error occurs the Session raises a PublishError event and does not send another Publish.

 

//如果一切正常,会话应在每个保持活动间隔至少调用一次SaveMessageInCache(IList<(Of<'(UInt32>)>>)、NotificationMessage、IList<(Of<'(String>)>>)方法。如果NotificationMessage未到达,则表示存在网络问题、服务器中的错误或高优先级订阅优先。keep-alive计时器旨在检测这些问题并自动发送额外的发布请求。当keep alive计时器过期时,它将检查自上次通知消息以来经过的时间。如果发布似乎已停止,则PublishingStopped属性将为true,订阅将引发PublishStateChanged事件并发送另一个发布请求。客户端应用程序在接收到PublishStateChanged事件时,必须假定任何缓存数据值都已过期(例如,状态代码应设置为UncertificateLastKnownValue)。但是,客户机应用程序不需要执行任何其他操作,因为中断可能是暂时的。由客户机应用程序决定何时放弃会话并使用新会话重试。订阅/会话实现的发布状态机如图1所示。

If everything is working properly the Session should be calling the SaveMessageInCache(IList<(Of <<'(UInt32>)>>), NotificationMessage, IList<(Of <<'(String>)>>)) method at least once per keep alive interval. If a NotificationMessage does not arrive it means there are network problems, bugs in the Server or high priority Subscriptions are taking precedence. The keep alive timer is designed to detect these problems and to automatically send additional Publish requests. When the keep alive timer expires it checks the time elapsed since the last notification message. If publishing appears to have stopped the PublishingStopped property will be true and the Subscription will raise a PublishStateChanged event and send another Publish request. Client applications must assume that any cache data values are out of date when they receive the PublishStateChanged event (e.g. the StatusCode should be set to UncertainLastKnownValue). However, client applications do not need to do anything else since the interruption may be temporary. It is up to the client application to decide when to give up on a Session and to try again with a new Session. The publishing state machine implemented by the Subscription/Session is shown in Figure 1.

 

图:1–发布状态机

报告错误

报告错误

结束订阅

更新时间戳

等待响应

开始发布

填充发布队列

检查时间戳

等待保活

 

 

 

 

//订阅对象在接收到NotificationMessage时检查缺少的序列号如果存在间隔,它将启动一个计时器,如果间隔仍然存在,该计时器将在1s内调用重新发布(UInt32)。这种延迟是必要的,因为客户端的多线程堆栈可能会处理无序的响应,即使它们是按顺序接收的。

The Subscription object checks for missing sequence numbers when it receives a NotificationMessage If there is a gap it starts a timer that will call Republish(UInt32) in 1s if the gap still exists. This delay is necessary because the multi-threaded stack on the client side may process responses out of order even if they are received in order.

 

//订阅维护接收到的消息的缓存。此缓存的大小由MaxMessageCount属性控制。当收到新消息时,订阅会将其添加到缓存中,并删除任何额外的消息。然后它提取通知并将它们推送到由通知中的ClientHandle标识的MonitoredItem。

The Subscription maintains a cache of messages received. The size of this cache is controlled by the MaxMessageCount property. When a new message is received the Subscription adds it to the cache and removes any extras. It then extracts the notifications and pushes them to the MonitoredItem identified by the ClientHandle in the notification.

 

//订阅是为多线程操作设计的,因为Publish(OperationContext,UInt32Collection%,Boolean%)请求可能到达任何线程。但是,在处理传入消息时访问的数据使用与更新订阅参数时使用的数据不同的同步锁进行保护。这意味着更新服务器上订阅状态的网络操作正在进行时,通知可以继续到达。但是,一次只能进行一个更新订阅状态的操作。关闭会话将中断任何未完成的操作。在引发任何事件之前,将释放订阅持有的所有同步锁。

The Subscription is designed for multi-threaded operation because the Publish(OperationContext, UInt32Collection%, Boolean%) requests may arrive on any thread. However, data which is accessed while processing an incoming message is protected with a separate synchronization lock from data that is used while updating the Subscription parameters. This means notifications can continue to arrive while network operations to update the Subscription state on the server are in progress. However, no more than one operation to update the Subscription state can proceed at one time. Closing the Session will interrupt any outstanding operations. Any synchronization locks held by the subscription are released before any events are raised.

MonitoredItem(监测数据)

// MonitoredItem类存储属于服务器上订阅的MonitoredItem的客户端状态。它维护两组属性:创建MonitoredItem时请求的值和基于服务器返回的修订值的当前值。请求的属性是序列化MonitoredItem时保存的属性。

The MonitoredItem class stores the client-side state for a MonitoredItem belonging to a Subscription on a Server. It maintains two sets of properties: the values requested when the MonitoredItem is/was created and the current values based on the revised values returned by the Server. The requested properties are what is saved when then MonitoredItem is serialized.

 

// MonitoredItem的NodeId可以指定为绝对NodeId,也可以指定为起始NodeId,后跟RelativePath字符串,该字符串符合[UA Part 4]中定义的语法。堆栈中包含的RelativePath类可以解析这些字符串并生成UA服务所需的结构。

The NodeId for the MonitoredItem can be specified as an absolute NodeId or as a starting NodeId followed by RelativePath string which conforms to the syntax defined in [UA Part 4]. The RelativePath class included in the Stack can parse these strings and produce the structures required by the UA services.

 

//对影响服务器上MonitoredItem状态的任何属性的更改都不会立即应用。而是设置ParametersModified标志,并且只有在调用订阅上的ApplyChanges方法时才会应用更改。请注意,如果已经创建了MonitoredItem,则忽略对仅在创建MonitoredItem时指定的参数的更改。希望更改这些参数的客户端应用程序必须删除受监视的项,然后重新创建它。

Changes to any of the properties which affect the state of the MonitoredItem on the Server are not applied immediately. Instead the ParametersModified flag is set and the changes will only be applied when the ApplyChanges method on the Subscription is called. Note that changes to parameters which can only be specified when the MonitoredItem was created are ignored if the MonitoredItem has already been created. Client applications that wish to change these parameters must delete the monitored item and then re-create it.

 

//监视参数的当前值存储在Status属性中。客户端应用程序必须使用状态。用于检查在创建或修改项时发生错误的错误属性。指定RelativePath字符串的MonitoredItem在分析或转换RelativePath时可能遇到错误。当发生此类错误时,将设置error属性,而不会创建MonitoredItem。

The current values for monitoring parameters are stored in the Status property. Client application must use the Status. Error property to check an error occurs while creating or modifying the item. MonitoredItems that specify a RelativePath string may have encountered an error parsing or translating the RelativePath . When such an error occurs the Error property is set and the MonitoredItem is not created.

 

// MonitoredItem为从服务器接收的数据更改或事件维护本地队列。这意味着客户机应用程序不需要显式地处理NotificationMessages,只要需要,就可以从MonitoredItem中读取最新的值。本地队列的长度由CacheQueueSize属性控制。

The MonitoredItem maintains a local queue for data changes or events received from the Server. This means the client application does not need to explicitly process NotificationMessages and can simply read the latest value from the MonitoredItem whenever it is required. The length of the local queue is controlled by the CacheQueueSize property.

 

//每当应用程序接收到来自应用程序的新事件通知时,客户端将提供一个新的通知。它总是在添加到缓存后被调用。

The MonitoredItem provides a Notification event which can be used by the client application to receive events whenever a new notification is received from the Server. It is always called after it is added to the cache.

 

// MonitoredItem是为多线程操作而设计的,因为发布请求可能到达任何线程。但是,在更新高速缓存时访问的数据通过与更新MonitoredItem参数时使用的数据分开的同步锁进行保护。这意味着通知可以在其他线程更新MonitoredItem参数时继续到达。

The MonitoredItem is designed for multi-threaded operation because the Publish requests may arrive on any thread. However, data which is accessed while updating the cache is protected with a separate synchronization lock from data that is used while updating the MonitoredItem parameters. This means notifications can continue to arrive while other threads update the MonitoredItem parameters.

 

//当另一个线程在订阅上调用ApplyChanges时,客户端应用程序在更新MonitoredItem参数时必须小心,因为这可能导致服务器上MonitoredItem的状态与客户端上MonitoredItem的状态不匹配的情况。希望从多个线程更新MonitoredItems的客户端应用程序必须首先获取所属订阅上的StateLock。

Client applications must be careful when update MonitoredItem parameters while another thread has called ApplyChanges on the Subscription because it could lead to situation where the state of the MonitoredItem on the Server does not match the state of the MonitoredItem on the client. Client applications that expect to update MonitoredItems from multiple threads must acquire the StateLock on the owning Subscription first.

Configuring DCOM(配置D组件对象)

// Configuring the COM Wrapper

配置组件服务包装器

 

//这个应用程序配置每个示例应用程序的文件都包含一个名为Opc.Ua.SampleServer.

The app.config file for each of the sample applications contains a configuration section called Opc.Ua.SampleServer.

 

//该部分包含控制包装的以下元素:

The section has the following elements which control the wrapper:

 

//命名空间包装器使用的命名空间的URI

NamespaceurThe URI for the namespace used by the wrapper

 

//包含包装的服务器地址空间的文件夹的BrowseName。

Browsenameof the folder that contains the wrapped server address space .

 

// URL COM服务器的URL

UrlThe URL of the COM server

 

// separatorchars指定sense为其项id指定的分隔符字符。此字段不是必需的,仅用于在可以从项目id提取浏览名称时提高性能

seperatorchars specifies the separator characters that the senes for its item ids . this field is not required and is only used to improve performance when it is possible to extract the browse name from an item id

 

//服务器进程必须可以访问COM服务器

The COM server must be accessible to the server process

 

//当运行使用aspnet帐户运行的服务器的iis托管版本时,这是一个特别关注的问题

this is a particular concern when running the iis hosted version of the server which runs using the aspnet account

 

// Configuring the COM Proxy

配置COM代理

 

//这个Opc.Ua.配置工具应用程序用于创建COM客户端可以连接到的COM服务器。COM服务器在注册表中存储连接到UA服务器所需的所有信息。

The Opc.Ua.ConfigurationTool application is used to create COM servers that COM clients can connect to. The COM server stores all of the information required to connect to a UA server in the registry.

 

//这个Opc.Ua.配置工具应用程序包括一个向导,允许管理员使用本地发现服务器浏览服务器,选择一个端点,然后创建一个新的COM服务器。

The Opc.Ua.ConfigurationTool application includes a wizard that will allow administrators to browse for servers using the Local Discovery Server, select an endpoint and then create a new COM server.

 

//此应用程序也可以用作命令行实用程序。

This application can also be used as a command line utility.

 

//当COM客户端通过代理连接到UA服务器时,它将启动OpcUaComDllHost.exe过程。这是一个用C++编写的本地COM服务器,它封装了Opc.Ua.ComInterop公司.DLL。需要主机进程,因为.NET不支持EXE COM服务器。

When a COM client connects to a UA server via the proxy it launches the OpcUaComDllHost.exe process. This is a local COM server written in C++ that wraps the Opc.Ua.ComInterop.DLL. The host process is required because .NET does not support EXE COM servers.

 

//默认情况下,连接到UA服务器的错误将写入OpcUaComDllHost.log.txt文件与可执行文件位于同一目录中。

By default, errors connecting to the UA server are written to the OpcUaComDllHost.log.txt file in the same directory as the executable.

Feature Details(功能详细信息)

Stack(堆栈)

// Interfaces and WCF Service Contracts

WCF接口和服务合同

 

//服务器和发现服务器实现UASPECPart 4(服务)中定义的服务。每个服务都被实现为对支持C接口的对象的方法调用。定义为服务参数的结构和枚举是用C类和枚举实现的。

Servers and Discovery Servers implement the Services defined in UASPECPart 4 (Services). Each Service is implemented as a method call on an object supporting an C# interface. The structures and enumerations defined as Service parameters are implemented with C# classes and enumerations.

 

//uaspecpart4中定义的服务分为三个接口:ISessionEndpoint、IDiscoveryEndpoint和IRegistrationEndpoint。每个接口都声明为WCF ServiceContracts。接口中的每个方法都为UA服务定义WCF OperationContract。为服务定义的参数声明为WCF DataContracts。

The Services defined in UASPECPart 4 are grouped into three interfaces: ISessionEndpoint, IDiscoveryEndpoint and IRegistrationEndpoint. Each of these interfaces are declared as WCF ServiceContracts. Each of the methods in the interfaces define the WCF OperationContract for a UA Service. The parameters defined for the Services are declared as WCF DataContracts.

 

//所有接口都继承自定义invokeServiceOperationContract的IEndpointBase。所有的UA服务都可以使用相同名称的方法直接调用,也可以通过通用的invokeServiceOperationContract来调用。当使用包含二进制编码的二进制消息的InvokeService数组传递时,将使用该方法传递包含该二进制编码的消息。如果服务由客户机直接调用,则消息将由当前WCF通道序列化。堆栈还提供标准绑定(请参阅WCF绑定和行为),这些绑定可以配置WCF通道以使用UA二进制文件序列化消息,并在后台调用InvokeService方法。这些绑定允许开发人员构建仅使用标准方法的客户端应用程序,同时使用配置设置在UA二进制和UA-XML编码之间切换。

All of the interfaces inherit from IEndpointBase which defines the InvokeService OperationContract. All UA Services can be invoked directly with the method of the same name or via the generic InvokeService OperationContract. The parameters passed when using InvokeService method are byte arrays containing the messages encoded with UA Binary encoding. If services are invoked directly by a client the messages are serialized by the current WCF channel. The Stack also provides standard bindings (see WCF Bindings and Behaviors ) which can configure the WCF channel to serialize messages using UA Binary and call the InvokeService method in the background. These bindings allow developers to build client applications that only use the standard methods while using configuration settings to switch between the UA Binary and UA XML encoding.

 

//接口和接口使用的类型是使用代码生成器自动生成的。这确保了ServiceContracts准确地实现了官方uawsdl。WSDL(Web服务定义语言)(发音为Wiz-Dill)是一种用于描述xmlweb服务的语言(W3C标准,基于XML)。开发人员可以使用visualstudio提供的工具从WSDL生成接口,而不是使用SDK提供的版本。表1总结了这些接口。

The interfaces and the types used by the interfaces are generated automatically using a Code Generator. This ensures that the ServiceContracts exactly implement the official UA WSDL. A WSDL (Web Services Definition Language) (pronounced Wiz-Dill) is a language (W3C standard, based on XML) that is used to describe XML Web Services. Developers may use the tools provided with Visual Studio to generate the interfaces from the WSDL instead of using the versions provided with the SDK. These interfaces are summarized in Table 1.

 

//表1——WCF服务合同

Table 1 – WCF Service Contracts

 

//ISessionEndpoint定义用于访问服务器公开的数据和事件的所有方法。这些方法只能在客户端与服务器创建会话后使用。用于创建会话的方法也是此接口的一部分。

ISessionEndpoint

 Defines all methods used to access the data and events exposed by a Server. These methods can only be used after the client has created a Session with the Server. The methods used to create Sessions are also part of this interface.

 

//IDiscoveryEndpoint定义用于发现服务器及其终结点的方法。此接口由服务器和发现服务器实现。

IDiscoveryEndpoint Defines the methods used to discover Servers and their endpoints. This interface is implemented by Servers and Discovery Servers.

 

//IRegistrationEndpoint定义用于向发现服务器注册服务器的方法。此接口仅由发现服务器实现。

IRegistrationEndpoint Defines the methods use to register a Server with a Discovery Server. This interface is only implemented by Discovery Servers.

 

//WCF端点、服务和主机

WCF Endpoints, Services and Hosts

 

//WCF服务需要一个ServiceHost对象,该对象管理WCF服务实例的生存期,并在从客户端收到请求时调用适当的方法。此ServiceHost还允许WCF服务托管在不同类型的进程中,包括IIS和Windows服务(也称为NT服务)。

A WCF Service requires a ServiceHost object which manages the lifetime of the WCF Service instance and calls the appropriate method when a request is received from a Client. This ServiceHost also allows a WCF Service to be hosted in different types of processes including IIS and a Windows Service (a.k.a. an NT Service).

 

//一个ServiceHost对象可以支持多个协议,但是它只能支持一个安全策略。因此,UA服务器或UA发现服务器的单个实例可能具有多个与之关联的ServiceHost对象。ServerBase类用于实现UA服务器或UA发现服务器的实例。启动UA服务器或发现服务器应用程序时,将创建此类的单个实例,然后读取其配置并创建必要的ServiceHost对象。

A single ServiceHost object can support multiple protocols, however, it can only support one security policy. For this reason, a single instance of a UA Server or UA Discovery Server may have multiple ServiceHost objects associated with it. The ServerBase class is used to implement an instance of a UA Server or UA Discovery Server. When the UA Server or Discovery Server application is started a single instance of this class is created which then reads its configuration and creates the necessary ServiceHost objects.

 

//SDK提供了ServerBase类的两个抽象(虚拟)子类,它们声明了UA服务器或UA发现服务器可能实现的所有UA服务的框架(这些子类称为SessionServerBase和DiscoveryServerBase,如图5所示)。如果开发人员没有提供实现,那么BadNotImplemented错误将返回给任何试图调用UA服务的客户机。这些应用程序的方法是由虚拟应用程序堆栈定义的。

The SDK provides two abstract (virtual) subclasses of the ServerBase class which declares skeletons for all of the UA Services which a UA Server or UA Discovery Server may implement (these subclasses are called SessionServerBase and DiscoveryServerBase and are shown in Figure 5). A BadNotImplemented fault will be returned to any Client that tries to invoke a UA Service if the developer has not provided an implementation. The virtual methods defined by these classes are the Stack API for use by UA Server applications.

 

//WCF框架要求ServiceHost创建实现服务器支持的ServiceContracts的类的实例。EndpointBase类是基类,SessionEndpoint和DiscoveryEndpoint是分别用于UA服务器和UA发现服务器的子类。这些类实现了表1中描述的wcfservicecontracts。

The WCF Framework requires that the ServiceHost create instances of a class which implements the ServiceContracts supports by the Server. The EndpointBase class is the base class and the SessionEndpoint and DiscoveryEndpoint are the subclasses for use with UA Servers and UA Discovery Servers respectively. These classes implement the WCF ServiceContracts described in Table 1.

 

//ServiceHost实现Windows Communication Foundation(WCF)服务模型编程模型使用的主机。ServiceHost类用于配置和公开服务,以便在不使用Internet信息服务(IIS)或Windows激活服务(WAS)公开服务时供客户端应用程序使用

ServiceHost implements the host used by the Windows Communication Foundation (WCF) service model programming model. The ServiceHost class is used to configure and expose a service for use by client applications when you are not using Internet Information Services (IIS) or Windows Activation Services (WAS) to expose a service

 

//ServiceHost对象将为客户端创建的每个WCF通道创建EndpointBase对象的新实例。EndpointBase类还实现InvokeService方法,并自动解码传入的UA二进制编码请求,并在ServerBase实例上调用适当的方法。开发人员使用SecureChannelContext。当前属性确定客户端对给定请求使用的编码。

The ServiceHost object will create a new instance of an EndpointBase object for each WCF channel created by a Client. The EndpointBase class also implements the InvokeService method and automatically decodes incoming UA Binary encoded requests and calls the appropriate method on the ServerBase instance. Developers use the SecureChannelContext.Current property to determine what encoding the Client used with a given request.

 

//WCF行为可以添加到.NET中应用程序配置通过引用SessionEndpoint或DiscoveryEndpoint类创建。通过指定SessionEndpoint或DiscoveryEndpoint类作为服务实现,还可以添加支持与UA无关的ServiceContract的其他端点(例如IMetadataExchange)。

WCF behaviors can be added in the .NET app.config file by referring to the SessionEndpoint or DiscoveryEndpoint classes. It also possible to add additional endpoints that support ServiceContracts unrelated to UA (e.g. IMetadataExchange) by specifying the SessionEndpoint or DiscoveryEndpoint classes as the service implementation.

 

//SDK将UA-TCP协议作为自定义WCF传输绑定元素提供支持(请参阅WCF绑定和行为)。与其他WCF绑定不同,UA-TCP绑定支持每个ServiceHost实例的多个安全策略。在这些情况下,ServiceHost将创建NonHttpSessionEndpoint或NonHttpDiscoveryEndpoint类的实例。

The SDK provides support for the UA TCP protocol as a custom WCF transport binding element (see WCF Bindings and Behaviors ). Unlike other WCF bindings the UA TCP binding does support multiple security policies per instance of ServiceHost . In these cases, the ServiceHost will create instances of the NonHttpSessionEndpoint or NonHttpDiscoveryEndpoint classes.

 

//图1定义了用于实现UA服务器的类。

Figure 1 defines the classes used to implement UA Servers.

 

//WCF Channels and Clients

WCF通道和客户端们

 

//SDK包括一个称为ISessionChannel、IDiscoveryChannel和IRegistrationChannel的WCF服务契约的客户端版本。这些接口继承了用于服务器的wcfservicecontracts,但为每个操作的异步版本添加了原型。接口的继承树如图2所示。

The SDK includes a client-side version of the WCF ServiceContracts called ISessionChannel, IDiscoveryChannel and IRegistrationChannel. These interfaces inherit from the WCF ServiceContracts used for the Servers but add prototypes for the asynchronous versions of each operation. The inheritance tree for the interfaces is shown in Figure 2.

 

 

图:2–客户端堆栈API中的接口

 

 

 

 

//这些接口由SessionChannel、DiscoveryChannel或RegistrationChannel类实现,这些类都继承自WCF ClientBase<T>类。这些类几乎与使用WCF工具从uawsdl生成的类完全相同。

These interfaces are implemented by the SessionChannel, DiscoveryChannel or RegistrationChannel classes which all inherit from the WCF ClientBase<T> class. These classes are almost identical to the classes that are generated from the UA WSDL using WCF tools.

 

//SDK还包括不依赖WCF的通道类的包装器。这些包装器的基类是ClientBase,每个可能的ServiceContract都有一个子类型。包装器存储诸如会话Id之类的状态信息,如果方法调用中没有提供任何信息,它将自动填充请求头。通道和客户机类之间的关系如图3所示。

The SDK also includes a wrapper for the channel classes that do not depend on WCF. The base class for these wrappers is ClientBase and a subtype exists for each possible ServiceContract. The wrappers store state information such as the Session Id and will automatically fill in the Request Header if none is provided in the method call. The relationship between the channel and client classes are shown Figure 3.

 

 

图:3–客户端堆栈API中的类

 

 

 

 

//客户机应用程序开发人员可以直接使用客户机类,也可以创建添加附加功能的子类型。子类型对于可能被许多不同的应用程序使用的类库最有意义。

Client application developers can use the client classes directly or create subtypes that add additional features. Subtypes make the most sense for class libraries that may be used by many different applications.

 

//WCF绑定和行为

WCF Bindings and Behaviors

 

//WCF通道和终结点需要WCF绑定,该绑定指定要使用的协议以及任何配置或安全参数。如果WCF绑定不匹配,则客户端和服务器应用程序无法相互通信。

WCF Channels and Endpoints require a WCF Binding that specifies the protocol to use plus any configuration or security parameters. Client and server applications cannot communicate with each other if the WCF Bindings do not match.

 

//WCF通道和终结点也可能具有WCF行为,允许应用程序将自定义处理步骤插入到WCF堆栈中。SDK使用WCF行为来添加对UA二进制编码的支持,以及可扩展参数和结构化数据值的自动序列化(请参阅扩展对象和可编码对象)。

WCF Channels and Endpoints may also have WCF Behaviors which allow the application to insert custom processing steps into the WCF stack. WCF Behaviors are used by the SDK to add support for the UA Binary encoding and for automatic serialization of extensible parameters and structured data values (see Extension Objects and Encodeable Objects ).

 

//许多非WCF的应用程序在与大量WCF绑定通信时会产生互操作性问题。因此,uasdk为不同的wire协议定义了许多自定义WCF绑定。表2描述了可用的WCF绑定。

WCF Bindings provide a large number of configurable parameters which can create interoperability problems especially when communicating with non-WCF applications. For this reason the UA SDK defines a number of custom WCF Bindings for different wire protocols. Table 2 describes the available WCF Bindings.

 

//表2-UA堆栈中的WCF绑定

Table 2 - WCF Bindings in the UA Stack

 

//UaSoapXmlBinding http协议 使用SOAP/HTTP+WS-SecureConversation+UA XML或UA二进制编码。实现WsHttpXmlOrBinary传输配置文件。

UaSoapXmlBinding http Uses SOAP/HTTP + WS-SecureConversation + UA XML or UA Binary encodings. Implements the WsHttpXmlOrBinary Transport Profile.

 

//UATCP绑定opc.tcp协议 使用UA TCP+UA SecureConversation+UA二进制编码。实现UATCP二进制传输配置文件。

UaTcpBinding opc.tcp Uses UA TCP + UA-SecureConversation + UA Binary encoding. Implements the UaTcpBinary Transport Profile.

 

//UaSoapXmlOverTcpBinding 网络.tcp 使用SOAP/.NET TCP+WS-SecureConversation+UA XML或UA二进制编码。不是受支持的绑定。提供的目的是证明开发人员可以使用规范要求之外的协议。

UaSoapXmlOverTcpBinding  net.tcp  Uses SOAP/.NET TCP + WS-SecureConversation + UA XML or UA Binary encodings. Not a supported binding. Provided to demonstrate that developers can use protocols other than ones required by the specifications.

 

//NativeStackBinding公司 opc.tcp协议 使用UA TCP+UA SecureConversation+UA二进制编码。实现UATCP二进制传输配置文件。这与UaTcpBinding相同,只是它使用UA-TCP协议的ansic实现。它主要用于测试。

NativeStackBinding  opc.tcp  Uses UA TCP + UA-SecureConversation + UA Binary encoding. Implements the UaTcpBinary Transport Profile. This is the same as the UaTcpBinding except it uses the ANSI C implementation of the UA TCP protocol. It is used primarily for testing.

 

//绑定可以在创建通道对象时直接传递给通道对象(请参见WCF通道和客户端),但是SDK还提供了BindingFactory机制,允许通道根据当前配置信息创建正确的绑定。开发人员应该从应用程序配置初始化BindingFactory,然后将BindingFactory传递给Channel对象。然后,Channel对象将创建与端点的URL中的方案匹配的绑定。

The Binding may be passed directly to the Channel objects (See WCF Channels and Clients ) when they are created, however, the SDK also provides a BindingFactory mechanism that allows the Channel to create the correct Binding from the current configuration information. Developers should initialize the BindingFactory from the application configuration and then pass the BindingFactory to the Channel object. The Channel object will then create the Binding that matches the scheme in the URL for the endpoint.

 

//然后,管理员可以在应用程序配置文件中指定不同URL方案和.NET类之间的映射(请参阅应用程序配置)。

Administrators can then specify the mapping between different URL schemes and .NET classes in the application configuration file (See Application Configuration ).

 

//此机制允许在部署新的WCF绑定和协议之后将它们添加到应用程序中,但是,它不提供在配置文件中构造任意WCF绑定的功能。这个功能被故意忽略了,因为当多个供应商开发的应用程序部署到一个生产环境中时,WCF绑定中的细微差异可能会造成互操作性问题。也就是说,管理员可以像对待任何其他WCF应用程序一样向配置文件添加行为。

This mechanism allows new WCF Bindings and protocols to be added to applications after they have been deployed, however, it does not offer the ability to construct an arbitrary WCF Binding in a configuration file. This capability was intentionally left out because minor differences in WCF Bindings can create interoperability problems when applications developed by multiple vendors are deployed in a production environment. That said, administrators may add behaviors to configuration files as they would with any other WCF application.

 

//开发人员可以创建新的绑定来创建BaseBinding类的子类型。子类型必须使用表3中描述的参数定义构造函数。

Developers can create new Bindings creating subtypes of the BaseBinding class. The subtypes must define a constructor with the parameters described in Table 3.

 

//表3–自定义绑定构造函数参数

Table 3 – Custom Binding Constructor Parameters

 

//命名空间URI  命名空间表  对服务器命名空间表的引用。

namespaceUris   NamespaceTable   A reference to the Server’s namespace table.

 

//工厂  可编码工厂  工厂对可扩展参数和结构化数据值进行编码/解码的能力的引用

factory   EncodeableFactory   A reference to a factory capability of encoding/decoding extensible parameters and structured data values

 

//配置  端点配置  终结点的配置。

configuration   EndpointConfiguration   The configuration for Endpoint.

 

//端点描述和端点配置

EndpointDescriptions and EndpointConfigurations

 

//EndpointDescription描述UA服务器提供的端点。该对象指定(除其他外)服务器的名称和URI(允许将来自同一服务器的端点分组在一起)、所需的安全策略和安全模式、支持的传输配置文件和服务器的应用程序实例证书。EndpointDescription对象由服务器用来初始化其端点(当服务器启动时,这些端点将传递给ServiceHost)。客户端也使用它来初始化通道对象。客户端可以在连接之前使用发现服务获取服务器的端点描述。EndpointDescription类在uaspecpart4中进行了完整的描述。

An EndpointDescription describes an endpoint provided by a UA Server. The object specifies (among other things) the name and URI for the server (which allows endpoints from the same server to be grouped together), the required security policy and security mode, the supported transport profile and the Server’s application instance certificate. The EndpointDescription object is used by the Server to initialize its Endpoints (they are passed to the ServiceHost (s) when the Server starts). It is also used by the Client to initialize the Channel objects. Clients can use the Discovery Services to fetch the EndpointDescriptions for a Server before connecting. The EndpointDescription class is described completely in UASPECPart 4.

 

//EndpointConfiguration指定WCF堆栈使用的附加参数,但不影响WCF通道的协商。表4描述了EndpointConfiguration对象的属性。

An EndpointConfiguration specifies additional parameters which are used by the WCF stack but do not affect the negotiation of the WCF channel. Table 4 describes the properties of the EndpointConfiguration object.

 

//表4–端点配置属性

Table 4 – EndpointConfiguration Properties

 

//操作超时  Int32型  等待服务器响应的毫秒数。此值仅由客户端使用。

OperationTimeout   Int32   The number of milliseconds to wait for a response from the Server. This value is only used by Clients.

 

//使用二进制编码  布尔型  当端点支持时,使用UA二进制编码对消息进行编码。EndpointDescription中的TransportProfileUri指示是否支持它。

UseBinaryEncoding   Boolean   Encodes messages using the UA Binary encoding when supported by the Endpoint. The TransportProfileUri in the EndpointDescription indicates whether it is supported.

 

//最大字符串长度  Int32型  消息中包含的单个字符串的最大字符长度。

MaxStringLength   Int32   The maximum length in characters of a single string contained in a message.

 

//最大测试环长度  Int32型  消息中包含的单字节字符串的最大长度(以字节为单位)。只有使用UA二进制编码时,才完全支持此参数。如果使用UA-XML编码,它应该与MaxArrayLength相同。

MaxByteStringLength   Int32   The maximum length in bytes of a single byte string contained in a message. This parameter is only completely supported when the UA Binary Encoding is used. If UA XML encoding is used it should be the same as the MaxArrayLength.

 

//最大阵列长度  Int32型  消息中包含的单个数组的最大长度。当UA二进制文件与SOAP/HTTP传输一起使用时,此值必须足够大,以容纳整个消息。

MaxArrayLength   Int32   The maximum length of a single array contained in a message. This value must be large enough to accommodate an entire message when UA Binary is used with the SOAP/HTTP transport.

 

//最大消息大小  Int32型  单个消息的最大长度(以字节为单位)。

MaxMessageSize   Int32   The maximum length in bytes for a single message.

 

//水位标记  Int32型  发送或接收时使用的最大缓冲区大小。请注意,WCF堆栈将分配此大小的内存块,因此将此参数设置为大值将消耗内存并降低性能。默认值为65535。

MaxBufferSize   Int32   The maximum buffer size to use when sending or receiving. Note that the WCF stack will allocate memory blocks of this size so setting this parameter to large values will consume memory and reduce performance. The default value is 65,535.

 

//SecurityTokenLifetime  Int32型  必须续订安全令牌之前的毫秒数。

SecurityTokenLifetime   Int32   The number of milliseconds before a security token must be renewed.

 

//信道寿命  Int32型  服务器释放已损坏的安全通道的资源之前的毫秒数。此参数仅用于UA TCP传输。

ChannelLifetime   Int32   The number of milliseconds before a server releases the resources for a broken secure channel. This parameter is only used with the UA TCP transport.

 

//自定义绑定使用EndpointConfiguration初始化WCF通道对象。

The EndpointConfiguration is used by custom Bindings to initialize the WCF Channel objects.

 

//服务器根据管理员提供的配置创建其EndpointDescription和EndpointConfiguration。客户端可以使用发现服务检索不同服务器的endpointdescription,但是它们也可以由管理员和/或用户提供。客户端的EndpointConfiguration始终由管理员和/或用户指定。

Servers create their EndpointDescription and EndpointConfigurations from the configuration provided by the Administrator. Clients can retrieve the EndpointDescriptions for different Servers using the Discovery Services, however, they may also be provided by the Administrator and/or User. The Client’s EndpointConfiguration are always specified by the Administrator and/or User.

 

//配置的Dendpoints

ConfiguredEndpoints

 

//客户机应用程序经常需要保存允许它们重新连接到服务器的信息。但是,它可能包含用户名/其他信息,例如端点配置。ConfiguredEndpoint和ConfiguredEndpointCollection类允许客户端保存此类信息。它们还提供方便的功能,帮助使用发现服务更新信息。

Client applications frequently need to persist information that will allow them to reconnect to a Server. This information includes the EndpointDescription and EndpointConfiguration, however, it could include other information such as the username/password. The ConfiguredEndpoint and ConfiguredEndpointCollection classes allow Clients to persist this kind information. They also provide convenience functions that assist with updating the information using the Discovery Services.

 

//ConfiguredEndpoint定义了一个Extensions属性,该属性允许应用程序开发人员将自己的配置信息与端点一起保存。

The ConfiguredEndpoint defines an Extensions property which allows application developers to save their own configuration information with the endpoint.

 

//应用程序配置

Application Configuration

 

//堆栈提供了一种可扩展的机制,用于将应用程序配置存储在XML文件中。该类是可扩展的,因此开发人员可以向它添加自己的配置信息。表5描述了ApplicationConfiguration类的主要元素。

The stack provides a extensible mechanism for storing the application configuration in an XML file. The class is extensible so developers can add their own configuration information to it. Table 5 describes primary elements of the ApplicationConfiguration class.

 

//表5—应用程序配置属性

Table 5 – ApplicationConfiguration Properties

 

//应用程序名称  字符串  应用程序的可读名称。

ApplicationName   String   A human readable name for the application.

 

//应用程序URI  字符串  应用程序的全局唯一名称。这应该是一个URL,以计算机域名或IP地址作为主机名,后跟供应商/产品名称,然后是实例标识符。例如:http://machine1/OPC/UASampleServer/4853DB1C-776D-4ADA-9188-00CAA737B780

ApplicationUri   String   A globally unique name for the application. This should be a URL with which the machine domain name or IP address as the hostname followed by the vendor/product name followed by an instance identifier. For example: http://machine1/OPC/UASampleServer/4853DB1C-776D-4ADA-9188-00CAA737B780

 

//产品URI  字符串  产品的可读名称。

ProductUri   String   A human readable name for the product.

 

//应用程序类型  应用程序类型  应用程序的类型。可能的值:Server、Client、ClientAndServer和DiscoveryServer

ApplicationType   ApplicationType   The type of application. Possible values: Server, Client, ClientAndServer and DiscoveryServer

 

//安全配置  安全配置  应用程序的安全配置。指定应用程序实例证书、受信任对等方和受信任证书颁发机构的列表。

SecurityConfiguration   SecurityConfiguration   The security configuration for the application. Specifies the application instance certificate, list of trusted peers and trusted certificate authorities.

 

//传输配置  传输配置集合  指定应用程序使用的每个传输协议要使用的绑定。

Transport Configurations   TransportConfiguration Collection   Specifies the Bindings to used for each transport protocol used by the application.

 

//运输配额  运输配额  指定初始化WCF通道和终结点时要使用的默认限制。

TransportQuotas   TransportQuotas   Specifies the default limits to use when initializing WCF channels and endpoints.

 

//服务器配置  服务器配置   指定服务器的配置

ServerConfiguration   ServerConfiguration   Specifies the configuration for Servers

 

//客户端配置  客户端配置  指定客户端的配置

ClientConfiguration   ClientConfiguration   Specifies the configuration for Clients

 

//DiscoveryServer配置  DiscoveryServer配置  指定发现服务器的配置

DiscoveryServerConfiguration   DiscoveryServer Configuration   Specifies the configuration for Discovery Servers

 

//轨迹配置  轨迹配置  指定跟踪文件的位置。将静默处理的意外异常写入跟踪文件。开发人员可以使用实用程序。跟踪(…)函数。

TraceConfiguration   TraceConfiguration   Specifies the location of the Trace file. Unexpected exceptions that are silently handled are written to the trace file. Developers can add their own trace output with the Utils.Trace(…) functions.

 

//扩展  XmlElementCollection  允许开发人员向文件中添加附加信息。

Extensions   XmlElementCollection   Allows developers to add additional information to the file.

 

//消息上下文  服务消息上下文  序列化/反序列化消息时要使用的上下文。在扩展对象和可编码对象中讨论了此参数的使用

MessageContext   ServiceMessageContext   The context to use when serializing/deserializing messages. The use of this parameter is discussed in Extension Objects and Encodeable Objects

 

//认证评估员  认证评估员  这是应用程序使用的自定义证书验证器。此参数的使用在其他Helper类中进行了讨论。

CertificateValidator   CertificateValidator   This is the custom certificate validator used by the application. The use of this parameter is discussed in Other Helper Classes .

 

//应用程序配置可以保存在任何地方,但是类提供了将配置加载/保存为磁盘上的XML文件的函数。XML文件的位置可以在应用程序配置如果ConfigurationLocation指定为配置节,则为应用程序的文件。

The ApplicationConfiguration can be persisted anywhere but the class provides functions that load/save the configuration as an XML file on disk. The location of the XML file can be specified in the app.config file for the application if the ConfigurationLocation is specified as a configuration section.

 

//配置节的声明如下所示:

The declaration for the configuration section look like this XML fragment:

//名称可以是应用程序配置文件。ConfigurationLocation类似于以下XML片段:

The name may be any text that is unique within the app.config file. The ConfigurationLocation would look like this XML fragment:

 

//文件路径可以是绝对路径或相对路径。如果是相对路径,则搜索当前目录,后跟可执行文件所在的目录。堆栈还支持可以用环境变量替换的前缀。后一个功能需要在消息开头用“%”符号括起来的令牌。堆栈将首先检查是否有符号与来自环境.特殊文件夹枚举。如果找不到,它将使用同名的环境变量。

The FilePath can be an absolute path or a relative path. If it is a relative path the current directory is searched followed by the directory where the executable resides. The stack also supports prefixes which can be replaced with environment variables. The latter functionality requires a token enclosed by ‘%’ symbols at the start of the message. The stack will first check for a symbol that matches one of the values from the Environment.SpecialFolder enumeration. If not found it will use the environment variable of the same name.

 

//请注意,对于表示ApplicationConfiguration对象中文件目录路径的所有字段,都存在相同的功能。开发人员可以在他们自己的代码中使用Utils.GetAbsoluteFilePath方法。

Note that the same feature exists for all fields that represent file directory paths in the ApplicationConfiguration object. Developers can use this feature in their own code with the Utils.GetAbsoluteFilePath method.

 

//内置类型和数据类型

Built-in Types and Data Types

 

//UA定义了许多内置类型。堆栈为每种类型定义类或结构,并提供对标准接口(如IComparable、ICloneable和IFormattable)的支持。表6描述了内置类型。

UA defines a number of built in types. The Stack defines classes or structures for each of these types and provides support for standard interfaces like IComparable, ICloneable and IFormattable. Table 6 describes built-in types.

 

//表6-内置类型

Table 6 – Built-in Types

 

//构造之后,不能修改NodeId、ExpandedNodeId、QualifiedName和LocalizedText类。这意味着它们可以安全地作为参考文献传递,而不会产生副作用。这些类型还定义了一个名为Null的静态属性,应该使用该属性来代替默认构造函数。

The NodeId, ExpandedNodeId, QualifiedName and LocalizedText classes cannot be modified after construction. This means they can be safely passed around as references without risk of side effects. These types also define a static property called Null which should be used instead of the default constructor.

 

//堆栈提供了一个名为builtype的枚举,可用于设置switch语句。每个内置类型的数值与相应数据类型节点的NodeId相同。

The stack provides an enumeration called BuiltInType that can be used to set up switch statements. The numeric value for each BuiltInType is the same as the NodeId for the corresponding DataType Node.

 

//堆栈还提供了一个名为TypeInfo的助手类,该类提供了检测对象的内置类型和在类型之间转换的方法。

The stack also provides a helper class called TypeInfo which provides methods to detect the Built-in Type for an object and to convert between types.

 

//变体

Variants

 

//UA变量是UA应用程序之间交换的任何属性值的容器。Variant结构只是一个对象的包装器,但它负责将对象转换为可以在网络上序列化的类型。例如,实现IList的任何类都将转换为数组,而实现IEncodeable的任何类都将转换为ExtensionObject。该变量还负责将多维数组转换为矩阵对象。

UA Variants are the containers for any attribute values that are exchanged between UA applications. The Variant structure is simply a wrapper for an object but it takes care of converting objects to types that can be serialized on the wire. For example, any class that implements IList will be converted to an array and any class that implements IEncodeable will be converted to an ExtensionObject. The Variant also takes care of converting multidimensional arrays to Matrix objects.

 

//Variant结构还实现了uaspecpart6中定义的uaxml编码规则。

The Variant structure also implements the UA XML encoding rules defined in UASPECPart 6.

 

//扩展对象和可编码对象

Extension Objects and Encodeable Objects

 

//UA扩展对象是可由应用程序供应商定义的结构化值的容器。这些对象有一个TypeId,它是数据类型编码节点的NodeId,另一个Body是ByteString或xmleelement,具体取决于所使用的编码。

UA ExtensionObjects are containers for structured values that can be defined by the application vendor. These objects have a TypeId which is the NodeId of the DataType Encoding Node and a Body which is a ByteString or an XmlElement depending on the encoding used.

 

//可编码对象是任何实现IEncodeableObject接口的对象,该接口允许堆栈自动序列化和反序列化已注册到堆栈中的类型。EncodeableFactory是一个由nodeid为支持的数据类型编码编制索引的可编码对象的表。

Encodeable Objects are any objects that implement the IEncodeableObject interface which allows the Stack to automatically serialize and deserialize types which have been registered with the stack. The EncodeableFactory is a table of Encodeable Objects indexed by the NodeIds for the supported DataType Encodings.

 

//IEncoder和IDecoder接口提供了一个抽象层,可编码对象可以使用该抽象层在流和流之间进行序列化。堆栈为uaspecpart6中定义的所有编码提供编码器/解码器(此时UA二进制和UA XML)。开发人员可以实现可编码对象,这些对象使用嵌入在UA二进制或UA XML流中的其他编码。

The IEncoder and IDecoder interfaces provide an abstraction layer which Encodeable Objects can use to serialize themselves to and from a stream. The stack provides encoder/decoders for all the encodings defined in UASPECPart 6 (UA Binary and UA XML at this time). Developers can implement Encodeable Objects that use other encodings which are embedded in a UA Binary or UA XML stream.

 

//实现IEncodeableObject的类必须为对象的二进制和XML版本提供绝对的nodeid。绝对NodeId包括限定已知NodeId的NamespaceUri。这个NamespaceUri由定义要实现的类型的组织分配。

Classes that implement IEncodeableObject must provide absolute NodeIds for the binary and XML version of the object. The absolute NodeIds include the NamespaceUri that qualifies the well known NodeId. This NamespaceUri is assigned by the organization that defines the type being implemented.

 

//堆栈负责将NamespaceUri转换为NamespaceIndex,以便在网络上使用,但这要求WCF通道能够访问服务器的名称空间表。这就是为什么堆栈表中包含的绑定是命名空间表作为参数的原因。堆栈中包含的绑定使用自定义WCF行为,这些行为设置WCF操作上下文和服务消息上下文。线程上下文属性以确保命名空间表在消息序列化期间可用。创建自定义绑定的开发人员需要将这些行为添加到其绑定中(ServiceMessageContextMessageInspector for UA XML和BinaryEncodingMessageInspector for UA Binary)

The Stack takes care of converting the NamespaceUri to a NamespaceIndex for use on the wire but this requires that the WCF Channel have access to the table of Namespaces for the Server. This is why the Bindings included in the stack table a NamespaceTable as a parameter. The Bindings included in the stack use custom WCF Behaviors which set the WCF OperationContext and the ServiceMessageContext.ThreadContext property to ensure the Namespace table is available during message serialization. Developers that create custom Bindings will need to add these behaviors to their Bindings (ServiceMessageContextMessageInspector for UA XML and BinaryEncodingMessageInspector for UA Binary)

 

//ServiceMessageContext还提供对EncodableFactory对象的访问。

The ServiceMessageContext also provides access to the EncodeableFactory object.

 

//请注意,开发人员总是可以选择手动序列化ExtensionObject中的可编码对象,如果需要使用与当前wire协议不匹配的编码,则必须执行此操作。例如,使用UA二进制编码的客户端可以请求使用XML编码返回结构。在这种情况下,服务器必须手动对对象进行编码。

Note that developers always have the option of manually serializing an Encodeable Object in a ExtensionObject and they will have to do this if they need to use an encoding that does not match the current wire protocol. For example, a Client using the UA binary encoding may request that structures be returned using the XML encoding. The Server will have to manually encode the objects in this case.

 

//其他帮助程序类

Other Helper Classes

 

//该堆栈包括许多其他helper类,这些类在表7中进行了总结。

The stack includes a number of other helper classes which are summarized in Table 7.

 

//表7–堆栈助手类

Table 7 – Stack Helper Classes

 

//引用类型  定义分配给已知引用类型节点的数字ID。

ReferenceTypes   Defines the numeric ids assigned to well known ReferenceType Nodes.

 

//数据类型  定义分配给已知数据类型节点的数字标识。

DataTypes   Defines the numeric ids assigned to well known DataType Nodes.

 

//可变类型  定义分配给已知VariableType节点的数字标识。

VariableTypes   Defines the numeric ids assigned to well known VariableType Nodes.

 

//对象类型  定义分配给已知ObjectType节点的数字标识。

ObjectTypes   Defines the numeric ids assigned to well known ObjectType Nodes.

 

//变量  定义分配给已知变量节点的数字标识。

Variables   Defines the numeric ids assigned to well known Variable Nodes.

 

//物体  定义分配给已知对象节点的数字标识。

Objects   Defines the numeric ids assigned to well known Object Nodes.

 

//方法  定义分配给已知方法节点的数字标识。

Methods   Defines the numeric ids assigned to well known Method Nodes.

 

//名称空间  定义公共命名空间URI的常量。

Namespaces   Defines the constants for common NamespaceUris.

 

//配置文件  定义堆栈使用的配置文件的uri的常量。

Profiles   Defines the constants for the URIs of the Profiles used by the Stack.

 

//安全策略  定义堆栈支持的SecurityPolicy的URI的常量。

SecurityPolicies   Defines the constants for the URIs of the SecurityPolicies supported by the Stack.

 

//属性  定义UA属性的数字标识符。

Attributes   Defines the numeric identifier for the UA attributes.

 

//状态代码  定义UA定义的状态代码的数字标识符。

StatusCodes   Defines the numeric identifier for the StatusCodes defined by UA.

 

//相对路径  格式化并解析使用UASPECPart 4中定义的语法的相对路径。

RelativePath   Formats and parses relative paths which use the syntax defined in UASPECPart 4.

 

//字符串表  线程安全的字符串表(用于存储serveruri和namespaceuri)。

StringTable   A thread-safe table of strings (used for storing ServerUris and NamespaceUris).

 

//命名空间表  命名空间URI的线程安全表(继承自StringTable)。

NamespaceTable   A thread-safe table of NamespaceUris (inherits from StringTable).

 

//证书管理和验证

Certificate Management and Validation

 

//该堆栈提供了许多证书管理功能,包括实现规范所需验证规则的自定义CertificateValidator。在加载应用程序配置时,将自动创建CertificateValidator。使用该应用程序配置创建的任何WCF通道或终结点都将使用它。

The stack provides a number of certificate management functions including a custom CertificateValidator that implements the validation rules required by the specification. The CertificateValidator is created automatically when the ApplicationConfiguration is loaded. Any WCF channels or endpoints that are created with that ApplicationConfiguration will use it.

 

//CertificateValidator使用应用程序配置中的信任列表来确定证书是否受信任。验证失败的证书总是放在被拒绝的证书存储中。当遇到无效证书时,应用程序可以通过使用在CertificateValidator类上定义的事件接收通知。

The CertificateValidator uses the trust lists in the ApplicationConfiguration to determine whether a certificate is trusted. A certificate that fails validation is always placed in the Rejected Certificates store. Applications can receive notifications when an invalid certificate is encountered by using the event defined on the CertificateValidator class.

 

//堆栈还提供了证书标识符类,可用于指定证书的位置。Find()方法将根据指定的条件(SubjectName、Thumbprint或DER Encoded Blob)查找证书。

The Stack also provides the Certificate Identifier class which can be used to specify the location of certificate . The Find() method will look up the certificate based on the criteria specified (SubjectName, Thumbprint or DER Encoded Blob).

 

//每个应用程序都有一个SecurityConfiguration,管理员必须小心管理该配置,因为犯错误可能会阻止应用程序通信或产生安全风险。表8描述了SecurityConfiguration的元素。

Each application has a SecurityConfiguration which must be managed carefully by the Administrator since making a mistake could prevent applications from communicating or create security risks. The elements of the SecurityConfiguration are described in Table 8.

 

//表8–安全配置

Table 8 – SecurityConfiguration

 

//申请证书  指定应用程序实例证书的私钥所在的位置。私钥应该在LocalMachine或CurrentUser的个人(我的)存储区中。安装在LocalMachine存储中的私钥只能由已显式授予权限的用户访问。

ApplicationCertificate   Specifies where the private key for the Application Instance Certificate is located. Private keys should be in the Personal (My) store for the LocalMachine or the CurrentUser. Private keys installed in the LocalMachine store are only accessible to users that have been explicitly granted permissions.

 

//信托发行人   指定颁发应用程序可以信任的证书的证书颁发机构。该结构包括证书存储的位置和单个证书的列表。

TrustedIssuerCertificates   Specifies the Certificate Authorities that issue certificates which the application can trust. The structure includes a the location of a Certificate Store and a list of individual Certificates.

 

//受信任的PeerCertificates  指定应用程序可以信任的其他应用程序的证书。该结构包括证书存储的位置和单个证书的列表。

TrustedPeerCertificates   Specifies the certificates for other applications which the application can trust. The structure includes a the location of a Certificate Store and a list of individual Certificates.

 

//无效的证书目录  指定被拒绝的证书可以放在何处供管理员以后审阅(也称为拒绝的证书存储)

InvalidCertificateDirectory   Specifies where rejected Certificates can be placed for later review by the Admistrator (a.k.a. Rejected Certificates Store)

 

//管理员需要在安装应用程序、ApplicationUri或主机名更改时创建应用程序实例证书。管理员可以使用SDK中包含的配置工具,也可以使用其公钥基础设施(PKI)提供的工具。如果证书已更改,则需要更新应用程序配置。

The Administrator needs to create an application instance certificate when applications are installed, when the ApplicationUri or when the hostname changes. The Administrator can use the Configuration Tool included in the SDK or use the tools provided by their Public Key Infrastructure (PKI). If the certificate is changed the Application Configuration needs to be updated.

 

//安装证书后,管理员需要确保允许访问应用程序的所有用户都有访问证书私钥的权限。这也可以通过UA配置工具完成,也可以通过icecertificateStore接口以编程方式完成。

Once the certificate is installed the Administrator needs to ensure that all users who are allowed to access the application have permission to access the Certificate’s private key. This can be also be done with the UA Configuration Tool or it can be done programmatically via the ICertificateStore interface.

 

//有时证书由于非关键原因验证失败,管理员希望以任何方式允许证书(例如证书已过期)。在这些情况下,管理员必须将单个证书添加到TrustedIssuerCertificates或TrustedPeerCertificates元素,并指定证书的验证标志。表9描述了支持的验证标志。

Sometimes a Certificate will fail validation for non-critical reasons and the Administrator wishes to allow the Certificate anyways (e.g. the certificate has expired). In these situations the Administrator must add the individual Certificate to either the TrustedIssuerCertificates or TrustedPeerCertificates element and specify the validation flags for the certificate. The supported validation flags are described in Table 9.

 

//表9–证书验证标志

Table 9 – Certificate Validation Flags

 

//抑制器认证  允许过期或尚未生效的证书。

SuppressCertificateExpired   Allows certificates that are expired or not yet valid.

 

//SuppressHostName无效  允许主机名与URL不匹配的证书。每个服务器证书都在证书中嵌入了主机名。这些主机名必须与用于连接到服务器的URL匹配。

SuppressHostNameInvalid   Allows certificates where the hostname does not match the URL. Each server Certificate has the hostnames embedded in the certificate. These hostnames must match the URL being used to connect to the Server.

 

//禁止使用抑制器  允许未设置证书使用的证书是的。是的UA应用程序实例证书所需的使用集在[UA UASPECPart 6]中指定。

SuppressUseNotAllowed   Allows certificates where the certificate use was not set correctly.The set of uses required for UA application instance Certificates are specified in [UA UASPECPart 6].

 

//禁止撤销状态未知  允许证书,即使无法检查证书是否已被颁发机构吊销。

SuppressRevocationStatusUnknown   Allows certificates even if it not possible to check whether they have been revoked by the issuing authority.

 

//UserIdentity和UserIdentityTokens

UserIdentity and UserIdentityTokens

 

//堆栈提供了UserIdentity类,该类将UA用户标识令牌与WCF使用的securitytoken进行转换。该堆栈当前支持UserNameSecurityToken、X509SecurityToken、SamlSecurityToken和WCF WSSecurityTokenSerializer类支持的任何其他SecurityToken子类型。

The stack provides the UserIdentity class which convert UA user identity tokens to and from the SecurityTokens used by WCF. The Stack currently supports UserNameSecurityToken, X509SecurityToken, SamlSecurityToken and any other subtype of SecurityToken which is supported by the WCF WSSecurityTokenSerializer class.

 

//UA规范要求在将UserIdentityTokens发送到服务器之前对其进行加密或签名。UserIdentityToken类提供了许多实现这些特性的方法。

The UA specification requires that UserIdentityTokens be encrypted or signed before they are sent to the Server. UserIdentityToken class provides a number of methods that implement these features.

 

//节点、节点集和节点表

Nodes, NodeSets and NodeTables

 

//UA堆栈提供了一种通过NodeSet类序列化一组节点和引用的标准方法。单个节点对象的模式作为标准UA-XML模式的一部分包括在内。NodeSet只是这些节点对象的集合,以及节点引用的名称空间和服务器uri的表。

The UA stack provides a standard way to serialize a set of Nodes and the References via the NodeSet class. The schema for the individual Node objects is included as part of the standard UA XML Schema. The NodeSet is simply a collection of those Node objects along with the table of Namespace and Server URIs referenced by the Nodes.

 

//nodeid、expandedNodeId和QualifiedNames都包含表示URI的命名空间索引。分配给特定URI的NamespaceIndex会随着时间的推移而变化,因此开发人员必须确保在保留其中一个类型时保存实际的URI字符串。NodeSet类提供的函数可以自动将保存的uri转换为服务器当前使用的索引。

NodeIds, ExpandedNodeIds and QualifiedNames all contain NamespaceIndexes which represent a URI. The NamespaceIndex assigned to a particular URI will change over time so developers much make sure that the actual URIs strings are saved whenever one of these types is persisted. The NodeSet class provides functions that automatically convert the saved URIs to the indexes currently used by the Server.

 

//当值的数据类型是NodeId、ExpandedNodeId、QualifiedName或参数时,NodeSet还将处理属性值的转换。任何其他包含索引的值都必须由应用程序手动修复。

The NodeSet will also handle conversions of Attribute values when the data type of the value is a NodeId, ExpandedNodeId, QualifiedName or Argument. Any other values that contain indexes will have to be fixed manually by the application.

 

//NodeTable是一个内存中的节点数据库,可以有效地进行搜索。它利用了图4中定义的接口,这意味着开发人员可以创建自己的对象,这些对象可以存储在NodeTable中。作为NodeSet的一部分序列化的Node对象实现了这些接口,并且可以存储在NodeTable中,前提是更新了NamespaceIndexes以匹配NodeTable中使用的NamespaceTable。客户机SDK还使用这些接口来创建从服务器获取的节点的本地缓存(请参阅会话)。

The NodeTable is an in-memory database of Nodes that can be efficiently searched. It makes use of the interfaces defined in Figure 4 which means developers can create their own objects can be stored in the NodeTable. The Node objects serialized as part of the NodeSet implement these interfaces and can be stored in a NodeTable provide the NamespaceIndexes are updated to match the NamespaceTable used in the NodeTable. These interfaces are also used by the Client SDK to create a local cache of Nodes fetched from the Server (see Sessions).

 

//ServiceResults、ServiceResultExceptions和DiagnosticInfos

ServiceResults, ServiceResultExceptions and DiagnosticInfos

 

//UA规范引入了状态码的概念以及关联的DiagnosticInfo,其中DiagnosticInfo包含对公共表中包含的字符串的引用。这个模型对于优化网络上的调用很有用,但是对于程序员来说,它是很麻烦的。因此,堆栈提供了ServiceResult类,该类结合了StatusCode和DiagnosticInfo。ServiceResultException是包含相同信息的异常。

The UA specification introduces the concept of a StatusCode with an associated DiagnosticInfo where the DiagnosticInfo contains references to strings contained in a common table. This model is useful for optimizing calls across a network, however, it is cumbersome for programmers. For that reason the Stack provides the ServiceResult class which combines a StatusCode with a DiagnosticInfo. The ServiceResultException is an exception that contains the same information.

 

//对这些类的支持内置在堆栈中。例如,如果在处理UA请求时发生错误,应用程序可以抛出ServiceResultException。堆栈将捕获异常并返回正在使用的协议所需的正确错误(即,如果正在使用SOAP/HTTP,则堆栈将其转换为符合UA WSDL的SOAP错误)。类似地,ClientBase类检查服务器返回的错误,并在查找ResponseHeader中的所有字符串后将其转换为servicesultexception。

Support for these classes is built into the Stacks. For example, if an error occurs processing a UA request a application can throw a ServiceResultException. The Stack will trap the exception and return the correct fault required by the protocol being used (i.e. if SOAP/HTTP is being used the Stack will convert it to a SOAP Fault that complies with the UA WSDL). Similarly, the ClientBase classes check for Faults returned by the Server and convert them to ServiceResultException after looking up all of the strings in the ResponseHeader.

 

//服务可以被单独的应用程序用来处理结果。所有操作完成后,应用程序可以将servicesult转换为StatusCode和diagnosticsinfo组件。ServiceResult类还具有helper函数,这些函数从StatusCode、DiagnosticInfo和StringTable构造对象。

ServiceResult class can be used by applications while they are processing individual operations. Once all operations are complete the application can convert the ServiceResult into the StatusCode and DiagnosticInfo components. The ServiceResult class also has helper functions that construct the object from a StatusCode, DiagnosticInfo and a StringTable.

Sample(样品)

 

//这些示例提供了有关统一体系结构软件开发工具包各个方面的说明。这些样本被分组,以便您可以轻松地找到适合您需要的样本。

These samples provide instruction on various aspects of Unified Architecture Software Development Kit. The samples are grouped so that you can easily locate the samples appropriate to your needs.

 

//SDK捆绑了两个示例应用程序:

There are two sample applications bundled with the SDK:

 

//UA示例客户端是一个带有GUI的UA客户端应用程序。它也是UA服务器的主机,它与GUI应用程序完全分离。

UA Sample Client is a UA client spplication with a GUI. It also is a host for a UA server which is completely seperate from the GUI application.

 

//UA Sample Server是一个没有GUI的独立UA服务器应用程序。它可以作为Windows服务运行。

UA Sample Server is a standalone UA server application without a GUI. It may be run as a Windows Service.

 

//应用程序可以从程序菜单中的OPC Foundation\UA SDK 1.00目录启动。

The applications can be launched from OPC Foundation\UA SDK 1.00 directory in the Programs menu.

 

//UA示例服务器应用程序也可以托管在IIS中。安装程序在此处为IIS托管服务器创建虚拟目录:http://localhost/UASampleService/Service.svc。单击该链接将在web浏览器中显示ASP.NET测试页。

The UA Sample Server application can also be hosted inside IIS. The installer creates a virtual directory for the IIS hosted server here: http://localhost/UASampleService/Service.svc. Clicking on that link should display an ASP .NET test page in a web browser.

 

//如果ASP.NET测试页没有出现,则说明ASP.NET配置有问题。本页可能会有所帮助。

If the ASP .NET test page does not appear it is a problem with your ASP .NET configuration. This page may help .

 

//运行本地发现服务器

Running the Local Discovery Server

 

//本地发现服务器安装为自动启动的Windows服务。客户端应用程序使用此过程来发现计算机上运行的服务器。

The Local Discovery Server is installed as a Windows Service that starts automatically. This process is used by the client applications to discover servers running on a machine.

 

//与COM不同,必须先启动UA服务器,然后客户端才能在本地发现服务器中看到它们或连接到它们。(除此之外,示例二进制文件安装程序将示例服务器作为Windows服务安装并自动启动。

Unlike COM, UA servers must be started before a client can see them in the Local Discovery Server or connect to them. (aside, the sample binaries installer installs the Sample Server as a Windows Service and starts it automatically.

 

//如果安装二进制文件后本地发现服务器未运行,则可能发生错误。将调用安装程序日志文件Opc.Ua.配置工具.日志.txt在$(MyDocuments)文件夹中创建。

If the Local Discovery Server is not running after installing the binaries then an error likely occurred. The installer log file is called Opc.Ua.ConfigurationTool.log.txt is created in the $(MyDocuments) folder.

 

//参考文献

Reference

 

//Visual Studio SDK:无法识别服务(.svc)文件类型

Visual Studio SDK: Service (.svc) File Type Not Recognized

Getting Started(入门)

 

//本节中包含的主题旨在让您快速了解PC-UA示例应用程序。通过本教程,您可以初步了解使用示例服务器和客户机应用程序所需的步骤。示例服务器是一个公开几个端点的构造。

The topics contained in this section are intended to give you quick exposure to the PC UA sample application. Working through this tutorial gives you an introductory understanding of the steps required to use sample server and client applications. The sample server is a construct that exposes a few endpoints.

 

//在本节中

In This Section

 

//本节介绍如何使用MMC插件浏览证书存储并管理其中的证书。

This section describes how to use an MMC plug-in to browse the certificate store and manage the certificates in it.

How to Manage the Certificates(如何管理证书)

 

//有一个MMC插件,允许计算机管理员浏览证书存储并管理其中的证书。它可以通过以下步骤启动:

There is an MMC plug-in that allows computer administrators to browse the certificate store and manage the certificates in it. It can be launched with the following steps:

 

//管理证书

To Manage the Certificates

 

//跑mmc.exe文件

Run mmc.exe

 

//单击文件|添加/删除管理单元

Click Files | Add/Remove Snap In

 

//单击“添加…”。。。

Click Add...

 

//选择证书并单击添加

Select Certificates and click Add

 

//选择“计算机帐户”,然后单击“下一步”。

Select Computer account and click Next.

 

//选择本地计算机,然后单击下一步

Select Local computer and click Next

 

//单击“关闭”

Click Close

 

//单击“确定”

Click OK

 

//评论

Remarks

 

//如果安装程序成功运行,个人文件夹中应该有UA证书。

If the installer ran successfully there should be UA certificates in the Personal folder.

Sample Client(客户示例)

 

//UA示例客户机可以连接到任何示例服务器。

The UA Sample Client can connect to any of the sample servers.

 

//选择服务器

Selecting a Server

 

//启动此应用程序时,会出现一个带有多个URL的下拉菜单。

When this application is launched a drop down menu with several URL appears.

 

//示例服务器的URL为:

The URLs of the sample servers are:

 

//在连接到UA示例服务器应用程序之前,必须手动启动它。如果UA示例服务器应用程序正在运行,则应在任务栏的托盘中看到OPC图标。右键单击此图标将允许您停止应用程序。

You must manually start the UA Sample Server application before you can connect to it. If the UA Sample Server application is running an OPC icon should be visible in the tray of the task bar. Right clicking on this icon will allow you to stop the application.

 

//通过在下拉列表中选择服务器并单击“连接”按钮,可以连接到服务器。

You connect to a server by selecting it in the drop down and click on the Connect button.

 

//您还将在URL后面看到其他文本,指示正在使用的安全性和/或消息编码。服务器可能支持具有不同安全设置的多个端点。这些端点可以通过单击<Browse..>选项并在查看服务器的端点时单击Discover按钮来找到。

You will also see additional text after the URL that indicates what security and/or message encoding is being used. Servers may support multiple endpoints with different security settings. These endpoints can be found by clicking on the <Browse..> option and clicking on the Discover button when the endpoints for a server are in view.

 

//选择端点

Choosing an Endpoint

 

//任何有效的URL都可以输入地址栏。但是,客户端假设可以通过在输入的URL的末尾添加/发现来构造服务器的发现端点。如果服务器在该地址上没有发现终结点,则客户端将无法连接。可以通过在下拉菜单中选择<Browse..>手动输入端点的发现URL。

Any valid URL can be typed into the address bar. However, the client assumes that the discovery endpoint for the server can be constructed by appending /discovery to the end of the URL typed in. The client will not be able to connect if the server does not have a discovery endpoint at that address. It is possible to manually enter the Discovery URLs for the endpoint by selecting <Browse..> in the drop down menu.

 

//单击“连接”按钮后,客户端将在服务器的发现终结点上调用GetEndpoints服务。

After the Connect button is clicked the client calls the GetEndpoints service on the discovery endpoint for the server.

 

//选择以http:开头的端点URL将使用xmlweb服务进行通信。选择以开头的URLopc.tcp协议将使用UA本机二进制进行通信。

Selecting an endpoint URL starting with http: will use XML Web Services for communication. Selecting a URL starting with opc.tcp will use UA Native Binary for communication.

 

//当前版本的UA本机二进制堆栈配置文件没有实现安全性,即使用户界面声称正在使用它。

The current release of the UA Native Binary stack profile does not implement security even though the user interface claims it is being used.

 

//XMLWeb服务堆栈配置文件允许客户机使用纯XML消息或UA二进制编码的消息。可以在端点的配置中更改该设置。下拉列表中的<Browse..>条目允许您编辑EndpointDescription和EndpointConfiguration。

The XML Web Services stack profile allows clients to use either pure XML messages or UA binary encoded messages. The setting can be changed in the configuration for the endpoint. The <Browse..> entry in the dropdown allows you to edit the EndpointDescription and EndpointConfiguration.

 

//允许您浏览服务器上的服务器。

The <Browse...> will allow you to browse servers on the network using the Local Discovery Server.

 

//创建会话

Creating a Session

 

//单击“连接”后,将显示“打开会话”对话框。此对话框允许您为会话和客户端用户凭据指定名称。身份验证模式取决于端点。只有可用于当前终结点的选项可用。

The Open Session dialog appears after clicking Connect. This dialog allows you specify a name for the session and the clients user credentials. The authentication modes depend on the endpoint. Only options available for the current endpoint are available.

 

//会话的名称仅用作服务器地址空间中包含会话诊断信息的节点的名称。

The name of the session is only used as the name of the node containing the diagnostic information for the session in the server address space.

 

//用户名/密码可能为空。如果指定了用户名,则它必须是服务器计算机上的有效windows帐户。

The user name/password may be left blank. If a user name is specified then it must be a valid windows account on the server machine.

 

//单击“确定”连接到服务器。

Click OK to connect to server.

 

//此时数据将出现在控件中。

At this point data will appear in the controls.

 

//会话面板位于左侧,它显示活动会话及其所有订阅。

The Session Panel is on the left and it displays the active sessions and any subscriptions that they have.

 

//浏览面板在右侧,它显示服务器地址空间中的对象实例。

The Browse Panel is on the right and it displays the Object instances in the server address space.

 

//通知面板位于底部,它显示从服务器返回的发布响应的内容。

The Notification Panel is at the bottom and it displays the contents of Publish responses returned from the server.

 

//浏览服务器地址空间

Browsing the Server Address Space

 

//客户端在创建会话后立即浏览Objects文件夹,并在右侧面板中显示结果。

The client browses the Objects folder immediately after creating a session and displays the results in the right hand panel.

 

//顶层节点包括:

The top level nodes are:

 

//服务器  第5部分规定的诊断信息

Server  Diagnostics information specified in Part 5

 

//数据  模拟节点是UA服务器参考实现的一部分。

Data  Simulation nodes which are part of the UA Server reference implementation.

 

//供应商  包含描述锅炉示例中使用的设备供应商的元数据。

Vendors  Contains metadata describing equipment vendors used in the Boiler example.

 

//博伊雷亚  包含样本锅炉的报警区域

BoilerArea  An alarm area containing the sample Boilers

 

//区域1  另一个警报区域包含样本锅炉

Area1   Another alarm area containing the sample Boilers

 

//锅炉1  样品锅炉。

Boiler1  A sample Boiler.

 

//锅炉2  样本锅炉的第二个实例。

Boiler2  A second instance of the sample Boiler.

 

//在UA DevCon的演示文稿中详细描述了锅炉示例。概览幻灯片可以在这里找到。出现在每个锅炉的地址空间中的节点在这里。

The Boiler example is described in detail in the presentations from the UA DevCon. The overview slide can be found here. The nodes that appear in the address space for each boiler are here.

 

//在任何子节点上点击并显示子节点的结果。默认情况下,客户端只遵循前向分层引用。

右键单击任何节点都会弹出一个上下文菜单。

Clicking on the plus sign next to any of these nodes with cause the client to issue a Browse request and display the results as children of the node. By default, the client only follows forward hierarchical references.

Right clicking on any node will bring up a context menu.

 

//此菜单中的操作执行以下操作:

The actions in this menu do the following:

 

//浏览选项  显示对话框,该对话框设置传递给浏览请求的选项。

Browse Options   Displays dialog that sets the options passed to the Browse request.

 

//显示引用   将表示引用的节点添加到树中。

Show References   Adds nodes representing the references into the tree.

 

//查看属性   显示节点的所有属性和属性的值。

View Attributes   Displays the values of all attributes and properties for the node.

 

//刷新   使用当前选项重新发出浏览请求。

Refresh   Re-issues the Browse request with the current options.

 

//也可以通过右键单击左侧面板中的会话来打开一个新的浏览窗口。出现的菜单为起始节点提供了许多选项。选择“全部”将显示地址空间中的所有节点。

It is also possible to open a new browse window by right clicking on the session in the left hand panel. The menu that appears provides a number of choices for a starting node. Selecting All will display all nodes in the address space.

 

//更改浏览选项

Changing the Browse Options

 

//UA地址空间是一个完全网状的网络,但是这种网络很难在典型的二维用户界面中呈现。因此,示例客户机使用传递给浏览请求的过滤器来限制在任何给定视图中显示的信息。

The UA address space is a full mesh network, however, such a network is difficult to render in a typical two dimensional user interface. For that reason, the sample client uses filters passed to the Browse request to limit the information displayed in any given view.

 

//用户可以通过以下步骤更改这些过滤器:

The user can change these filters by following these steps:

 

//右键单击任意节点并选择“显示引用”。这将在树控件中添加一个额外的节点,该控件显示两个节点之间引用的引用类型。

Right click on any node and select Show References. This will add an extra node into the tree control that displays the reference type for the reference between two nodes.

 

//右键单击地址空间中的Boiler1节点并选择Browse Options。

Right click on the Boiler1 node in the address space and select Browse Options.

 

//将“引用类型”设置为“引用”。这将告诉服务器从正在浏览的节点返回所有引用。

Set the Reference Type to References. This tells the server to return all references from the node being browsed.

 

//当按下“确定”按钮时,客户端将重新发出浏览请求。树控件现在应该显示名为HasTypeDefinition的子文件夹。在那个文件夹中应该有一个名为BoilerType的节点。

The client will re-issue the Browse request when the OK button is pressed. The tree control should now display a child folder called HasTypeDefinition. In that folder there should be a node called BoilerType.

 

//在更改浏览选项之前,只显示层次引用引用类型的子类型。在本例中,来自Boiler1的唯一满足这些条件的引用是HasComponent引用。

Before changing the browse options the only references displayed were subtypes of the Hierarchical References reference type. In this case, the only references from Boiler1 that met these criteria were the HasComponent references.

 

//使用视图

Using Views

 

//服务器提供了一种很有用的浏览子视图的方式。示例服务器提供了一个名为[BoilerView]的视图。通过右键单击左侧树中的会话并选择Browse | Server Defined Views | BoilerView,可以浏览此视图。

Server defined Views offer a way to browse a sub-set of the address space that the server feels is useful to some clients. The sample servers provide a single view called [BoilerView]. This view can be browsed by right-clicking on the session in the left-hand tree and selecting Browse | Server Defined Views | BoilerView .

 

//BoilerView显示示例锅炉及其组件。对类型模型的引用不会出现在此视图中。

The BoilerView displays the sample boilers and their components. References to the type model do not appear in this view.

 

//读取数据

Reading Data

 

//可以通过多种方式读取数据。最简单的方法是在浏览地址空间时使用上下文菜单中提供的视图属性选项。如果节点是一个允许读取访问的变量,则“读取”选项将出现在上下文菜单中。

Reading data can be done in a number of ways. The simplest approach uses the View Attributes option that is available in the context menu when browsing the address space. If the node is a Variable that allows read access then the Read option will appear in the context menu.

 

//节点Area1/Boiler1/LC1001/测量是可读的。找到它并单击“阅读”。这将显示“读取”对话框。单击Read按钮将发送请求并显示结果。

The node Area1/ Boiler1/LC1001/Measurement is readable. Find it and click Read. This should display the Read dialog. Clicking the Read button will send the request and display the results.

 

//通过右键单击“读取”对话框的顶部面板,可以向请求添加更多节点。“选择节点”选项将打开“选择节点”对话框。

You can add more nodes to the request by right-clicking in the top panel of the Read dialog. The Select Nodes option brings up the Select Node dialog.

 

//双击树控件中的节点只需展开或折叠树。如果要选择节点,必须右键单击并单击“选择项”或“选择子项”选项。

Double clicking on a node in a tree control simply expands or collapses the tree. If you wish to select a node you must right-click and click on the Select Item or Select Children options.

 

//也可以从会话面板访问“读取”对话框。

It is also possible to access the Read dialog from the Session Panel.

 

//写入数据

Writing Data

 

//也可以从浏览面板进行写入。选择任何允许写入访问的变量都会导致“写入”选项出现在上下文菜单中。

Writing can also be done from the Browse Panel. Selecting any Variable that allows write access will cause the Write option to appear in the context menu.

 

//节点Area1/Boiler1/LC1001/设定点是可写的。找到它并单击“写入”。这将显示“写入”对话框。单击Write按钮将发送请求并显示结果。

The node Area1/Boiler1/LC1001/SetPoint is writable. Find it and click Write. This should display the Write dialog. Clicking the Write button will send the request and display the results.

 

//双击“写入”对话框中的某个值可以更改它。

Double clicking on a value in the Write dialog will allow you to change it.

 

//也可以从会话面板访问“写入”对话框。

It is also possible to access the Write dialog from the Session Panel.

 

//正在创建订阅

Creating Subscriptions

 

//可以通过右键单击会话面板中的会话来创建新订阅。这将打开“订阅参数”对话框。单击“确定”将显示空订阅。

It is possible to create new subscriptions by right-clicking on a session in the Session Panel. This will bring up the Subscription Parameters dialog. Clicking OK brings up an empty Subscription.

 

//此时通知消息应该开始出现在通知面板中。这些是订阅的keep-alive消息,告诉客户机和服务器通信仍然正常,即使有可用的通知。

At this point notification messages should start to appear in the Notifications Panel. These are the keep alive messages for the subscription and tell the client and server that communication is still functional even if there are notifications available.

 

//通过选择主菜单中的“添加项目”,可以监视订阅的项目。节点Area1/Boiler1生成事件,因此请尝试将其添加到订阅中。大约20秒后,第一个事件通知应出现在订阅窗口中。

You can monitored items to the subscription by choosing the Add Items in the main menu. The node Area1/Boiler1 produces events so try adding it to the subscription. After about 20 seconds the first event notification should appear in the Subscription window.

 

//通过选择一个被监视的项目并从上下文菜单中单击setfilter命令,可以更改事件通知中返回的字段。

It is possible to alter the fields returned in the event notification by selecting a monitored item and clicking the Set Filter command from the context menu.

 

//尝试将Area1/Boiler1/CC1001的子级添加到订阅中。这些都是变量,每次订阅发布间隔过期时,它们都应该更改。

Try adding the children of Area1/Boiler1/CC1001 to the subscription. These are all variables and they should change each time the subscription publish interval expires.

 

//调用方法

Calling Methods

 

//示例锅炉的每个实例都有一个名为SetSimulationMode的方法。可以通过右键单击方法节点并选择调用选项来调用它。这将打开“调用”对话框,其中显示方法的输入和输出参数。

Each instance of the sample boilers has a method called SetSimulationMode. It can be called by right-clicking on the method node and selecting the Call option. This brings up the call dialog which displays the input and output parameters for the method.

 

//双击输入参数将允许您更改其值。在此示例中,必须为每个参数指定一个有效值。

Double-clicking on an input parameter will allow you to change its value. You must specify a valid value for every parameter in this example.

 

//尝试将RequestedMode设置为False这将停止模拟。可以通过读取或订阅同一锅炉的变量来验证模拟是否已停止。当模拟未运行时,它们不会更改。

Try setting the RequestedMode to False this will stop the simulation. You can verify that the simulation has stopped by reading or subscribing to variables for the same boiler. They do not change when the simulation is nor running.

 

//使用条件

Using Conditions

 

//“订阅”窗口有一个名为“条件”的菜单选项,它将显示订阅筛选器捕获的所有条件事件。订阅Boiler1对象将显示4个活动条件:

The subscription window has a menu option called Conditions that will display all of the condition events captured by the subscription filters. Subscribing to the Boiler1 object will display 4 active conditions:

 

//一般情况下,

a generic Condition,

 

//对话条件,

a Dialog Condition,

 

//可确认的条件

an Acknowledgeable Condition

 

//还有液位报警器。

and a Level Alarm.

 

//上下文菜单中显示了每个条件的可用方法。

The methods available to for each condition are shown in the context menu.

 

//可通过写入AREA 1/Boiler1/LC1001/设定点节点来控制液位报警。有效值介于0和10之间。如果值<=3或>=7,警报将关闭。

The LevelAlarm can be controlled by writing to the Area1/ Boiler1/LC1001/SetPoint node. Valid values are between 0 and 10. Alarms will go off if the value is <=3 or >=7.

  • 2
    点赞
  • 1
    收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
©️2022 CSDN 皮肤主题:数字20 设计师:CSDN官方博客 返回首页
评论

打赏作者

工控IT陈生开

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

¥2 ¥4 ¥6 ¥10 ¥20
输入1-500的整数
余额支付 (余额:-- )
扫码支付
扫码支付:¥2
获取中
扫码支付

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

打赏作者

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

抵扣说明:

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

余额充值