tests/protocol/binary_node_management.cpp
Go to the documentation of this file.
1 
10 #include "common.h"
11 
15 #include <opc/ua/protocol/types.h>
17 
18 #include <algorithm>
19 #include <stdexcept>
20 
21 
23 {
24 };
25 
27 {
28 };
29 
30 //-------------------------------------------------------
31 // AddnodesItem
32 //-------------------------------------------------------
33 
35 {
36 
37  using namespace OpcUa;
38  using namespace OpcUa::Binary;
39 
40 
41  AddNodesItem item;
42  item.BrowseName = OpcUa::QualifiedName("titi", 2);
43  item.ParentNodeId = OpcUa::NodeId(85, 0);
44  item.RequestedNewNodeId = OpcUa::NodeId(99, 3);
45  item.Class = NodeClass::Variable;
48  VariableAttributes attr;
51  attr.WriteMask = 0;
52  attr.UserWriteMask = 0;
53  attr.Value = 7;
54  attr.Type = ObjectId::UInt32;
55  attr.Rank = 0;
56  //attr.Dimensions = 0;
57  attr.AccessLevel = VariableAccessLevel::CurrentRead;
58  attr.UserAccessLevel = VariableAccessLevel::CurrentWrite;
59  attr.MinimumSamplingInterval = 1;
60  attr.Historizing = true;
61  item.Attributes = attr;
62 
63 
64  GetStream() << item << flush;
65 
66  const std::vector<char> expectedData =
67  {
68  2 , 0 , 0 , (char)0x55 , 0 , 0 , 0 , //parent node id
69  2 , 0 , 0 , (char)0x2f , 0 , 0 , 0 , //referencetypeid
70  2 , 3 , 0 , (char)0x63 , 0 , 0 , 0 , //requested nodeid
71  2 , 0 , 4 , 0 , 0 , 0 , (char)0x74 , (char)0x69 , (char)0x74 , (char)0x69 , //browsename
72  2 , 0 , 0 , 0 , //Node class
73  //start NodeAttributes
74  1 , 0 , (char)0x65 , 1 , //TypeId
75  1 , //encoding
76  //start attributes
77  (char)0x3d , 0 , 0 , 0 , //size
78  (char)0x73 , (char)0x12 , (char)0x3d , 0 , //Specified Attributes
79  2 , 4 , 0 , 0 , 0 , (char)0x74 , (char)0x69 , (char)0x74 , (char)0x69 , //disaply name
80  2 , 4 , 0 , 0 , 0, (char)0x74 , (char)0x69 , (char)0x74 , (char)0x69 , //description
81  0 , 0 , 0 , 0 , //writemask
82  0 , 0 , 0 , 0 , //Userwritemask
83  //variant
84  6, //variant type
85  7, 0, 0 , 0, //variant value
86  2, 0 , 0 , 7 , 0 , 0, 0, //DataType
87  0, 0, 0, 0, //value rank
88  (char)0xff , (char)0xff , (char)0xff , (char)0xff , //array of simple type ??
89  1 , //access
90  2 , //user access level
91  0 , 0 , 0 , 0 , 0, 0, (char)0xf0, (char)0x3f, //Minimum sampleing rate
92  1, //historyzing
93  2, 0, 0, (char)0x3e, 0 , 0, 0 //type definition
94  };
95 
96 
97  ASSERT_EQ(expectedData, GetChannel().SerializedData) << "Actual:" << std::endl << PrintData(GetChannel().SerializedData) << std::endl << "Expected" << std::endl << PrintData(expectedData);
98  ASSERT_EQ(expectedData.size(), RawSize(item));
99 }
100 
TEST_F(AddNodesSerialization, AddNodesItem)
const char LocalizedText[]
Definition: strings.h:96
std::string PrintData(const std::vector< char > &vec)
Test of opc ua binary handshake. GNU LGPL.
TypeWithSize< 4 >::UInt UInt32
Opc Ua Binary. Subscription service. GNU LGPL.
OStream< ChannelType > & flush(OStream< ChannelType > &os)
Definition: stream.h:147
OPC UA Address space part. GNU LGPL.
const char HasComponent[]
Definition: strings.h:69
#define ASSERT_EQ(val1, val2)
std::string Name
Definition: types.h:74
const char AddNodesItem[]
Definition: strings.h:18
const char BaseVariableType[]
Definition: strings.h:31
std::size_t RawSize(const T &obj)


ros_opcua_impl_freeopcua
Author(s): Denis Štogl
autogenerated on Tue Jan 19 2021 03:06:03