binary_serialize_monitored_items.cpp
Go to the documentation of this file.
1 
11 #include "common.h"
12 
17 #include <opc/ua/protocol/types.h>
18 
19 #include <algorithm>
20 #include <stdexcept>
22 {
23 };
24 
26 {
27 };
28 
29 
30 //-------------------------------------------------------
31 // std::vector<MonitoredItemCreateResult>
32 //-------------------------------------------------------
33 
34 // TEST_F(MonitoredItemsSerialization, DISABLED_std::vector<MonitoredItemCreateResult>)
35 // {
36 // using namespace OpcUa;
37 // using namespace OpcUa::Binary;
38 //
39 // MonitoredItemCreateResult monitoringResult;
40 // monitoringResult.Status = StatusCode::BadNotImplemented;
41 // monitoringResult.MonitoredItemId = 1;
42 // monitoringResult.RevisedSamplingInterval = 1200000;
43 // monitoringResult.RevisedQueueSize = 3;
44 // //monitoringResult.ExtensionObjectHeader FilterResult;
45 //
46 // std::vector<MonitoredItemCreateResult> data;
47 // data.push_back(monitoringResult);
48 //
49 // GetStream() << data << flush;
50 //
51 // const std::vector<char> expectedData = {
52 // 1,0,0,0, // Results count
53 // 0,0,(char)0x40,(char)0x80, // StatusCode
54 // 1,0,0,0, // MonitoredItemId
55 // 0,0,0,0,(char)0x80,(char)0x4f,(char)0x32,(char)0x41, // RevisedSamplingInterval
56 // 3,0,0,0, // RevisedQueueSize
57 // 0,0,0, // FilterResult (empty Extension object)
58 //
59 // 0,0,0,0 // Diagnostics Count
60 // };
61 //
62 // EXPECT_EQ(expectedData, GetChannel().SerializedData) <<
63 // "Expected:" << std::endl <<
64 // PrintData(expectedData) << std::endl <<
65 // "Serialized:" << std::endl <<
66 // PrintData(GetChannel().SerializedData) <<
67 // std::endl;
68 //
69 // EXPECT_EQ(expectedData.size(), RawSize(data));
70 // }
71 
72 TEST_F(MonitoredItemsSerialization, DISABLED_CreateMonitoredItemsResponse)
73 {
74  using namespace OpcUa;
75  using namespace OpcUa::Binary;
76 
78 
79  MonitoredItemCreateResult monitoringResult;
80  monitoringResult.Status = StatusCode::BadNotImplemented;
81  monitoringResult.MonitoredItemId = 1;
82  monitoringResult.RevisedSamplingInterval = 1200000;
83  monitoringResult.RevisedQueueSize = 3;
84  //monitoringResult.ExtensionObjectHeader FilterResult;
85 
86  response.Results.push_back(monitoringResult);
87 
88 
92 
94 
95  GetStream() << response << flush;
96 
97  const std::vector<char> expectedData =
98  {
99  1, 0, (char)0xF2, 0x2, // TypeId
100  // RequestHeader
102 
103  1, 0, 0, 0, // Results count
104  0, 0, (char)0x40, (char)0x80, // StatusCode
105  1, 0, 0, 0, // MonitoredItemId
106  0, 0, 0, 0, (char)0x80, (char)0x4f, (char)0x32, (char)0x41, // RevisedSamplingInterval
107  3, 0, 0, 0, // RevisedQueueSize
108  0, 0, 0, // FilterResult (empty Extension object)
109 
110  0, 0, 0, 0 // Diagnostics Count
111  };
112 
113  ASSERT_EQ(expectedData, GetChannel().SerializedData) <<
114  "Expected: " << std::endl << PrintData(expectedData) << std::endl <<
115  "Serialized: " << std::endl << PrintData(GetChannel().SerializedData) << std::endl;
116  ASSERT_EQ(expectedData.size(), RawSize(response));
117 }
118 
#define TEST_RESPONSE_HEADER_BINARY_DATA
std::string PrintData(const std::vector< char > &vec)
Test of opc ua binary handshake. GNU LGPL.
OStream< ChannelType > & flush(OStream< ChannelType > &os)
Definition: stream.h:147
#define FILL_TEST_RESPONSE_HEADER(header)
TEST_F(MonitoredItemsSerialization, DISABLED_CreateMonitoredItemsResponse)
std::vector< OpcUa::MonitoredItemCreateResult > Results
struct OpcUa::NodeId::FourByteDataType FourByteData
OPC UA Address space part. GNU LGPL.
#define ASSERT_EQ(val1, val2)
NodeIdEncoding Encoding
Definition: nodeid.h:46
Test of opc ua binary monitored items. GNU LGPL.
std::size_t RawSize(const T &obj)


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