'logged in' 用户如何设置不同的对象视图?
How to set different object view by 'logged in' user?
假设我有两个用户 - UserA 和 UserB。当 UserA 基于 open62541 连接到我的 OPC-UA 服务器时,我希望他看到:
Data
- MyData1
- MyData2
- MyData3
当 UserB 连接时我想让他看到:
Data
- MyData1
可能吗?如果是的话,当我设置一个对象节点时我在哪里使用它
UA_Server_addObjectNode(UA_Server *server,
const UA_NodeId requestedNewNodeId,
const UA_NodeId parentNodeId,
const UA_NodeId referenceTypeId,
const UA_QualifiedName browseName,
const UA_NodeId typeDefinition,
const UA_ObjectAttributes attr,
void *nodeContext,
UA_NodeId *outNewNodeId)
您不能直接通过 UA_Server_addObjectNode
.
您在 OPC UA 中寻找的概念称为视图。
来自 OPC UA 规范,第 3 部分:
View NodeClass
Underlying systems are often large and Clients often
have an interest in only a specific subset of the data. They do not
need, or want, to be burdened with viewing Nodes in the AddressSpace
for which they have no interest.
To address this problem, this
standard defines the concept of a View. Each View defines a subset of
the Nodes in the AddressSpace. The entire AddressSpace is the default
View. Each Node in a View may contain only a subset of its References,
as defined by the creator of the View. The View Node acts as the root
for the Nodes in the View. Views are defined using the View NodeClass,
which is specified in Table 5.
All Nodes contained in a View shall be
accessible starting from the View Node when browsing in the context of
the View. It is not expected that all containing Nodes can be browsed
directly from the View Node but rather browsed from other Nodes
contained in the View.
A View Node may not only be used as additional
entry point into the AddressSpace but as a construct to organize the
AddressSpace and thus as the only entry point into a subset of the
AddressSpace. Therefore Clients shall not ignore View Nodes when
exposing the AddressSpace. Simple Clients that do not deal with Views
for filtering purposes can, for example, handle a View Node like an
Object of type FolderType (see 5.5.3)
所以你需要做的就是创建一个View Node,并将相应的节点附加到这个View Node上。然后用户可以从该特定视图开始浏览。
对应的方法调用UA_Server_addViewNode
。然后使用 UA_Server_addReference
方法在您创建的视图节点中引用其他节点。引用类型应该是 Organizes
.
假设我有两个用户 - UserA 和 UserB。当 UserA 基于 open62541 连接到我的 OPC-UA 服务器时,我希望他看到:
Data
- MyData1
- MyData2
- MyData3
当 UserB 连接时我想让他看到:
Data
- MyData1
可能吗?如果是的话,当我设置一个对象节点时我在哪里使用它
UA_Server_addObjectNode(UA_Server *server,
const UA_NodeId requestedNewNodeId,
const UA_NodeId parentNodeId,
const UA_NodeId referenceTypeId,
const UA_QualifiedName browseName,
const UA_NodeId typeDefinition,
const UA_ObjectAttributes attr,
void *nodeContext,
UA_NodeId *outNewNodeId)
您不能直接通过 UA_Server_addObjectNode
.
您在 OPC UA 中寻找的概念称为视图。
来自 OPC UA 规范,第 3 部分:
View NodeClass
Underlying systems are often large and Clients often have an interest in only a specific subset of the data. They do not need, or want, to be burdened with viewing Nodes in the AddressSpace for which they have no interest.
To address this problem, this standard defines the concept of a View. Each View defines a subset of the Nodes in the AddressSpace. The entire AddressSpace is the default View. Each Node in a View may contain only a subset of its References, as defined by the creator of the View. The View Node acts as the root for the Nodes in the View. Views are defined using the View NodeClass, which is specified in Table 5.
All Nodes contained in a View shall be accessible starting from the View Node when browsing in the context of the View. It is not expected that all containing Nodes can be browsed directly from the View Node but rather browsed from other Nodes contained in the View.
A View Node may not only be used as additional entry point into the AddressSpace but as a construct to organize the AddressSpace and thus as the only entry point into a subset of the AddressSpace. Therefore Clients shall not ignore View Nodes when exposing the AddressSpace. Simple Clients that do not deal with Views for filtering purposes can, for example, handle a View Node like an Object of type FolderType (see 5.5.3)
所以你需要做的就是创建一个View Node,并将相应的节点附加到这个View Node上。然后用户可以从该特定视图开始浏览。
对应的方法调用UA_Server_addViewNode
。然后使用 UA_Server_addReference
方法在您创建的视图节点中引用其他节点。引用类型应该是 Organizes
.