2017-04-24 4 views
0

enter image description hereenter image description hereから「Channel1.Device1.Tag1」の値を読み、私はここからNetCoreConsoleClientサンプルを使用しています:https://github.com/OPCFoundation/UA-.NETStandardLibraryがKepserver

私はコードおよびサーバ全体をブラウズし、タイムスタンプのような値を取得することができ、カスタマイズ、説明、データ型など、サーバー上のすべてのノードに適用されます。ノード「Channel1.Device1.Tag1」私は(データ型、アドレス、説明など)すべてのプロパティ/ vlauesを取得することができていますが、私は「タグ1」の実際の値を保持するプロパティを取得していないです

については

Kepserverでは、 "Channel1.Device.Tag1"には実際のタグ値を保持する "Value"という名前のプロパティはないことに気付きました。

KepServerが提供する「クイッククライアント」を使用すると「タグ1」の値が表示されます。

私は自分のクライアントを使って "タグ"の値を何とか取り出す必要があります。コードの一部修正

:サンプルコードでのヒットと裁判では

`Console.WriteLine("4 - Browse the OPC UA server namespace."); 
     ReferenceDescriptionCollection references; 
     Byte[] continuationPoint; 

     references = session.FetchReferences(ObjectIds.ObjectsFolder); 

     session.Browse(
      null, 
      null, 
      ObjectIds.ObjectsFolder, 
      //ObjectIds.RootFolder, 
      0u, 
      BrowseDirection.Forward, 
      ReferenceTypeIds.HierarchicalReferences, 
      true, 
      (uint)NodeClass.Variable | (uint)NodeClass.Object | (uint)NodeClass.Method, 
      out continuationPoint, 
      out references); 

     Console.WriteLine(" DisplayName, BrowseName, NodeClass"); 
     foreach (var rd in references) 
     { 
      Console.WriteLine(" {0}, {1}, {2}", rd.DisplayName, rd.BrowseName, rd.NodeClass); 
      ReferenceDescriptionCollection nextRefs; 
      byte[] nextCp; 
      session.Browse(
       null, 
       null, 
       ExpandedNodeId.ToNodeId(rd.NodeId, session.NamespaceUris), 
       0u, 
       BrowseDirection.Forward, 
       ReferenceTypeIds.HierarchicalReferences, 
       true, 
       (uint)NodeClass.Variable | (uint)NodeClass.Object | (uint)NodeClass.Method, 
       out nextCp, 
       out nextRefs); 
      foreach (var nextRd in nextRefs) 
      { 
       Console.WriteLine(" + {0}, {1}, {2}", nextRd.DisplayName, nextRd.BrowseName, nextRd.NodeClass); 
       ReferenceDescriptionCollection nextRefs1; 
       byte[] nextCp1; 
       session.Browse(
        null, 
        null, 
        ExpandedNodeId.ToNodeId(nextRd.NodeId, session.NamespaceUris), 
        0u, 
        BrowseDirection.Forward, 
        ReferenceTypeIds.HierarchicalReferences, 
        true, 
        (uint)NodeClass.Variable | (uint)NodeClass.Object | (uint)NodeClass.Method, 
        out nextCp1, 
        out nextRefs1); 
       foreach (var nextRd1 in nextRefs1) 
       { 
        Console.WriteLine(" + {0}, {1}, {2}", nextRd1.DisplayName, nextRd1.BrowseName, nextRd1.NodeClass); 
        ReferenceDescriptionCollection nextRefs2; 
        byte[] nextCp2; 
        var res = session.Browse(
         null, null, 
         ExpandedNodeId.ToNodeId(nextRd1.NodeId, session.NamespaceUris), 0u, BrowseDirection.Forward, 
         ReferenceTypeIds.HierarchicalReferences, true, 
         (uint)NodeClass.Variable | (uint)NodeClass.Object | (uint)NodeClass.Method, out nextCp2, out nextRefs2); 
        double maxAge = 0; //Pick 0 millisecond old value directly from device not from the cache. 
        DataValueCollection results; 
        DiagnosticInfoCollection diagInfos; 
        ReadValueIdCollection readValueIds; 
        foreach (var nextRd2 in nextRefs2) 
        { 
         try 
         { 
          if (!nextRd2.NodeId.IsNull) 
          { 
           var node = ExpandedNodeId.ToNodeId(nextRd2.NodeId, session.NamespaceUris); 
           if (node != null) 
           { 
            DataValue dv = session.ReadValue(node); 
            ReferenceDescriptionCollection nextRefs3; 
            byte[] nextCp3; 
            var res1 = session.Browse(null, null, 
              ExpandedNodeId.ToNodeId(nextRd2.NodeId, session.NamespaceUris), 0u, BrowseDirection.Forward, 
              ReferenceTypeIds.HierarchicalReferences, true, 
              (uint)NodeClass.Variable | (uint)NodeClass.Object | (uint)NodeClass.Method, out nextCp3, out nextRefs3); 
            foreach (var nextRd3 in nextRefs3) 
            { 
             if (!nextRd3.NodeId.IsNull) 
             { 
              var node1 = ExpandedNodeId.ToNodeId(nextRd3.NodeId, session.NamespaceUris); 
              if (node1 != null) 
              { 
               DataValue dv2 = session.ReadValue(node1); 
              } 
             } 
            } 
           } 
          } 
         } 
         catch (ServiceResultException srex) 
         { 
          //eat exception yum yum yum! 
         } 
         catch (Exception ex) 
         { 

          //eat exception yum yum yum! 
         }` 
+0

「私は価値を得ることができません....」と説明してください。観察された行動は何ですか? – ZbynekZ

+0

私はすべてのノードのすべてのプロパティ/値を得ることができますまた、ノード "Channel1.Device1.Tag1"私はすべてのプロパティ/ vlaues(データ型、アドレス、説明のような)をフェッチすることができますが、私は午前"Tag1"の実際の値を保持するプロパティを取得していない –

答えて

0

は、私は答えを見つけました。

値を与える魔法のステートメントは、次のとおり

DataValueはDV1 = session.ReadValue( "NS = 2、S = Channel1.Device1.Tag1")。

   foreach (var nextRd1 in nextRefs1) 
       { 
        Console.WriteLine(" + {0}, {1}, {2}", nextRd1.DisplayName, nextRd1.BrowseName, nextRd1.NodeClass); 
        try 
        { 
         var _node = ExpandedNodeId.ToNodeId(nextRd1.NodeId, session.NamespaceUris); 
         DataValue dv2 = session.ReadValue(_node); 
        }