binary_node_management.cpp
Go to the documentation of this file.
00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 #include "common.h"
00011 
00012 #include <opc/ua/protocol/extension_identifiers.h>
00013 #include <opc/ua/protocol/message_identifiers.h>
00014 #include <opc/ua/protocol/binary/stream.h>
00015 #include <opc/ua/protocol/types.h>
00016 #include <opc/ua/protocol/node_management.h>
00017 
00018 #include <algorithm>
00019 #include <stdexcept>
00020 
00021 
00022 class AddNodesSerialization : public OpcUaBinarySerialization
00023 {
00024 };
00025 
00026 class AddNodesDeSerialization : public OpcUaBinarySerialization
00027 {
00028 };
00029 
00030 //-------------------------------------------------------
00031 // AddnodesItem
00032 //-------------------------------------------------------
00033 
00034 TEST_F(AddNodesSerialization, AddNodesItem)
00035 {
00036 
00037   using namespace OpcUa;
00038   using namespace OpcUa::Binary;
00039 
00040 
00041   AddNodesItem item;
00042   item.BrowseName = OpcUa::QualifiedName("titi", 2);
00043   item.ParentNodeId = OpcUa::NodeId(85, 0);
00044   item.RequestedNewNodeId = OpcUa::NodeId(99, 3);
00045   item.Class = NodeClass::Variable;
00046   item.ReferenceTypeId = ReferenceId::HasComponent; 
00047   item.TypeDefinition = ObjectId::BaseVariableType; 
00048   VariableAttributes attr;
00049   attr.DisplayName = LocalizedText(item.BrowseName.Name);
00050   attr.Description = LocalizedText(item.BrowseName.Name);
00051   attr.WriteMask = 0;
00052   attr.UserWriteMask = 0;
00053   attr.Value = 7;
00054   attr.Type = ObjectId::UInt32;
00055   attr.Rank  = 0;
00056   //attr.Dimensions = 0;
00057   attr.AccessLevel = VariableAccessLevel::CurrentRead;
00058   attr.UserAccessLevel = VariableAccessLevel::CurrentWrite;
00059   attr.MinimumSamplingInterval = 1;
00060   attr.Historizing = true;
00061   item.Attributes = attr;
00062 
00063 
00064   GetStream() << item << flush;
00065 
00066   const std::vector<char> expectedData = {
00067   2 ,0 ,0 ,(char)0x55 ,0 ,0 ,0 , //parent node id
00068   2 ,0 ,0 ,(char)0x2f ,0 ,0 ,0 , //referencetypeid
00069   2 ,3 ,0 ,(char)0x63 ,0 ,0 ,0 , //requested nodeid
00070   2 ,0 ,4 ,0 ,0 ,0 ,(char)0x74 ,(char)0x69 ,(char)0x74 ,(char)0x69 , //browsename
00071   2 ,0 ,0 ,0 , //Node class
00072   //start NodeAttributes
00073     1 ,0 ,(char)0x65 ,1 ,//TypeId
00074     1 , //encoding
00075     //start attributes
00076       (char)0x3d ,0 ,0 ,0 , //size
00077       (char)0x73 ,(char)0x12 ,(char)0x3d ,0 , //Specified Attributes
00078       2 ,4 ,0 ,0 ,0 ,(char)0x74 ,(char)0x69 , (char)0x74 ,(char)0x69 ,//disaply name
00079       2 ,4 ,0 ,0 ,0,(char)0x74 ,(char)0x69 ,(char)0x74 ,(char)0x69 , //description
00080       0 ,0 ,0 ,0 , //writemask
00081       0 ,0 ,0 ,0 ,//Userwritemask
00082       //variant
00083         6, //variant type
00084         7, 0, 0 ,0, //variant value
00085       2, 0 ,0 ,7 ,0 ,0, 0, //DataType
00086       0, 0, 0, 0, //value rank
00087       (char)0xff ,(char)0xff ,(char)0xff ,(char)0xff , //array of simple type ??
00088       1 , //access
00089       2 , //user access level
00090       0 , 0 , 0 ,0 , 0, 0, (char)0xf0, (char)0x3f, //Minimum sampleing rate
00091       1, //historyzing
00092       2, 0, 0, (char)0x3e, 0 , 0, 0 //type definition
00093   };
00094 
00095 
00096   ASSERT_EQ(expectedData, GetChannel().SerializedData) << "Actual:" << std::endl << PrintData(GetChannel().SerializedData) << std::endl << "Expected" << std::endl << PrintData(expectedData);
00097   ASSERT_EQ(expectedData.size(), RawSize(item));
00098 }
00099 


ros_opcua_impl_freeopcua
Author(s): Denis Štogl
autogenerated on Sat Jun 8 2019 18:24:39