2016-11-29 11 views
0

OPC-UAに関して "フィールド" NameAgeのタイプPersonを定義したいとします(ByteStreamの任意の構造のノードを定義し、データをシリアライズ/デシリアライズするのは簡単です) )。また、タイプPersonの変数ノードpersonを定義して、そのノードに1ステップで書き込みたいと思います。 どのようにするには?カスタム構造タイプを定義して使用する方法は?

ご注意:(Kevin,22)好きではない、直接何かをのみ2組の変数を読むとき、私はそのようなデータ(Kevin, 47)personを更新するとき、(Jane, 22)クライアントは、サブスクリプションで取得、または必要があります。

私はOPC-UA .Net公式スタックを使用しますが、私は任意のフレームワークから "翻訳"できる必要があります。上記を達成しようとしてきたものOPC UAで

答えて

1

は可能..ですそれが情報モデリングと呼ばれます。..

それは

...それがサポートされているかどうかSDKへのOPC UA SDK(フレームワーク)に依存

SDKがカスタムオブジェクトタイプ、カスタム変数タイプの作成をサポートしている場合は、カスタムタイプを作成するための単純なノードセットXMLファイルを使用して作成できます。

この例では、Person同じインスタンスを作成します。

カスタムオブジェクトタイプカスタム変数を作成し、同じインスタンスを作成するには、以下のノードセットXMLスニペットを参照してください。

<!-- Below XML logic will explain on how to create Custom Object Type and Custom Variable Type--> 
 

 
<UAObjectType NodeId="ns=2;s=PersonType" BrowseName="2:PersonType"> 
 
    <DisplayName>PersonType</DisplayName> 
 
    <Description>A Person Object Type</Description> 
 
    <References> 
 
    <Reference ReferenceType="HasComponent">ns=2;s=NameType</Reference> 
 
    <Reference ReferenceType="HasComponent">ns=2;s=AgeType</Reference> 
 
    <Reference ReferenceType="HasSubtype" IsForward="false">i=58</Reference> 
 
    </References> 
 
</UAObjectType> 
 

 
<UAVariableType NodeId="ns=2;s=AgeType" BrowseName="2:AgeType" DataType="Byte"> 
 
    <DisplayName>AgeType</DisplayName> 
 
    <Description>A Age variable type. it is component of AgeType</Description> 
 
    <References> 
 
    <Reference ReferenceType="HasComponent" IsForward="false" >ns=2;s=PersonType</Reference> 
 
    <Reference ReferenceType="HasSubtype" IsForward="false">i=63</Reference> 
 
    </References> 
 
</UAVariableType> 
 

 
<UAVariableType NodeId="ns=2;s=NameType" BrowseName="2:NameType" DataType="LocalizedText"> 
 
    <DisplayName>NameType</DisplayName> 
 
    <Description>A Name Variable type. it is component of NameType</Description> 
 
    <References> 
 
    <Reference ReferenceType="HasComponent" IsForward="false" >ns=2;s=PersonType</Reference> 
 
    <Reference ReferenceType="HasSubtype" IsForward="false">i=63</Reference> 
 
    </References> 
 
</UAVariableType> 
 

 
<!-- Below XML logic will explain on how to create instance of an object using above mentioned types--> 
 
<!-- This will create a person1 object inside the Object folder --> 
 

 
<UAObject NodeId="ns=2;s=Person1" BrowseName="2:Person1"> 
 
    <DisplayName>Person1</DisplayName> 
 
    <References> 
 
    <Reference ReferenceType="Organizes" IsForward="false">i=85</Reference> 
 
    <Reference ReferenceType="HasComponent">ns=2;s=Name1</Reference> 
 
    <Reference ReferenceType="HasComponent">ns=2;s=Age1</Reference> 
 
    <Reference ReferenceType="HasTypeDefinition" IsForward="false">ns=2;s=PersonType</Reference> 
 
    </References> 
 
</UAObject> 
 

 
<UAVariable NodeId="ns=2;s=Age1" BrowseName="2:Age1" DataType="Byte"> 
 
    <DisplayName>Age1</DisplayName> 
 
    <Description>A Age variable type. it is component of AgeType</Description> 
 
    <References> 
 
    <Reference ReferenceType="HasComponent" IsForward="false" >ns=2;s=Person1</Reference> 
 
    <Reference ReferenceType="HasTypeDefinition" IsForward="false">ns=2;s=AgeType</Reference> 
 
    </References> 
 
    <Value> 
 
    <Byte>10</Byte> 
 
    </Value> 
 
</UAVariable> 
 

 
<UAVariable NodeId="ns=2;s=Name1" BrowseName="2:Name1" DataType="LocalizedText"> 
 
    <DisplayName>Name1</DisplayName> 
 
    <Description>A Name Variable type. it is component of NameType</Description> 
 
    <References> 
 
    <Reference ReferenceType="HasComponent" IsForward="false" >ns=2;s=Person1</Reference> 
 
    <Reference ReferenceType="HasTypeDefinition" IsForward="false">ns=2;s=NameType</Reference> 
 
    </References> 
 
    <Value> 
 
    <LocalizedText> 
 
     <Locale>en</Locale> 
 
     <Text>MyName</Text> 
 
    </LocalizedText> 
 
    </Value> 
 
</UAVariable>

SDKは、ノードセットのファイルの解析をサポートしている場合は、既存のノードセットのファイルとインポートにこのスニペットを入れてください。または、ノードセットファイルを作成し、このスニペットを挿入してサーバーコードにインポートします。

これは、オブジェクトタイプとそのインスタンスを簡単に作成します。

こちらがお役に立てば幸いです。

ありがとうございます。

+0

多くのおかげで、今すぐテストしてコードに変換することはできませんが、できるだけ早く試していきます。あなたの答えは私のために非常に役立つので、再びありがとう! – astrowalker

+0

確かに..歓迎です..詳細が必要な場合はお知らせください。 –

関連する問題