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
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
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 ,
00068 2 ,0 ,0 ,(char)0x2f ,0 ,0 ,0 ,
00069 2 ,3 ,0 ,(char)0x63 ,0 ,0 ,0 ,
00070 2 ,0 ,4 ,0 ,0 ,0 ,(char)0x74 ,(char)0x69 ,(char)0x74 ,(char)0x69 ,
00071 2 ,0 ,0 ,0 ,
00072
00073 1 ,0 ,(char)0x65 ,1 ,
00074 1 ,
00075
00076 (char)0x3d ,0 ,0 ,0 ,
00077 (char)0x73 ,(char)0x12 ,(char)0x3d ,0 ,
00078 2 ,4 ,0 ,0 ,0 ,(char)0x74 ,(char)0x69 , (char)0x74 ,(char)0x69 ,
00079 2 ,4 ,0 ,0 ,0,(char)0x74 ,(char)0x69 ,(char)0x74 ,(char)0x69 ,
00080 0 ,0 ,0 ,0 ,
00081 0 ,0 ,0 ,0 ,
00082
00083 6,
00084 7, 0, 0 ,0,
00085 2, 0 ,0 ,7 ,0 ,0, 0,
00086 0, 0, 0, 0,
00087 (char)0xff ,(char)0xff ,(char)0xff ,(char)0xff ,
00088 1 ,
00089 2 ,
00090 0 , 0 , 0 ,0 , 0, 0, (char)0xf0, (char)0x3f,
00091 1,
00092 2, 0, 0, (char)0x3e, 0 , 0, 0
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