opcua_basictypes.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  1. /*
  2. * opcua_basictypes.h
  3. *
  4. * Created on: 13.03.2014
  5. * Author: mrt
  6. */
  7. #ifndef OPCUA_BASICTYPES_H_
  8. #define OPCUA_BASICTYPES_H_
  9. #include <stdint.h>
  10. typedef uint8_t Byte;
  11. typedef int8_t SByte;
  12. typedef int16_t Int16;
  13. typedef int32_t Int32;
  14. typedef uint16_t UInt16;
  15. typedef uint32_t UInt32;
  16. typedef _Bool UA_Boolean;
  17. typedef int8_t UA_SByte;
  18. typedef uint8_t UA_Byte;
  19. typedef int16_t UA_Int16;
  20. typedef uint16_t UA_UInt16;
  21. typedef int32_t UA_Int32;
  22. typedef uint32_t UA_UInt32;
  23. typedef int64_t UA_Int64;
  24. typedef uint64_t UA_UInt64;
  25. typedef float UA_Float;
  26. typedef double UA_Double;
  27. #define UA_SUCCESS 0
  28. #define UA_TRUE (42==42)
  29. #define UA_FALSE (!UA_TRUE)
  30. Int32 UA_Boolean_calcSize(UA_Boolean const * ptr);
  31. Int32 UA_Boolean_encode(UA_Boolean const * src, Int32* pos, char * dst);
  32. Int32 UA_Boolean_decode(char const * src, Int32* pos, UA_Boolean * dst);
  33. /**
  34. * StatusCodeBinaryEncoding
  35. * Part: 6
  36. * Chapter: 5.2.2.11
  37. * Page: 20
  38. */
  39. typedef UA_Int32 UA_StatusCode;
  40. enum UA_StatusCode_enum
  41. {
  42. // Some Values are called the same as previous Enumerations so we need
  43. //names that are unique
  44. SC_Good = 0x00
  45. };
  46. UInt32 UA_StatusCode_calcSize(UA_StatusCode const * ptr);
  47. /**
  48. * VariantBinaryEncoding
  49. * Part: 6
  50. * Chapter: 5.2.2.16
  51. * Page: 22
  52. */
  53. typedef struct _UA_Variant {
  54. Byte EncodingMask; //Type of Enum UA_VariantTypeEncodingMaskType
  55. UA_Int32 size;
  56. void** data;
  57. } UA_Variant;
  58. UInt32 UA_Variant_calcSize(UA_Variant const * ptr);
  59. /**
  60. * String
  61. * Part: 6
  62. * Chapter: 5.2.2.4
  63. * Page: 16
  64. */
  65. typedef struct UA_String
  66. {
  67. UA_Int32 length;
  68. UA_Byte* data;
  69. }
  70. UA_String;
  71. Int32 UA_String_calcSize(UA_String const * ptr);
  72. /*
  73. * ByteString
  74. * Part: 6
  75. * Chapter: 5.2.2.7
  76. * Page: 17
  77. */
  78. typedef struct UA_ByteString
  79. {
  80. UA_Int32 length;
  81. UA_Byte* data;
  82. }
  83. UA_ByteString;
  84. Int32 UA_ByteString_calcSize(UA_ByteString const * ptr);
  85. /**
  86. * LocalizedTextBinaryEncoding
  87. * Part: 6
  88. * Chapter: 5.2.2.14
  89. * Page: 21
  90. */
  91. typedef struct UA_LocalizedText
  92. {
  93. UA_Byte EncodingMask;
  94. UA_String Locale;
  95. UA_String Text;
  96. }
  97. UA_LocalizedText;
  98. Int32 UA_LocalizedText_calcSize(UA_LocalizedText const * ptr);
  99. /* GuidType
  100. * Part: 6
  101. * Chapter: 5.2.2.6
  102. * Page: 17
  103. */
  104. typedef struct UA_Guid
  105. {
  106. UA_UInt32 Data1;
  107. UA_UInt16 Data2;
  108. UA_UInt16 Data3;
  109. UA_ByteString Data4;
  110. }
  111. UA_Guid;
  112. Int32 UA_Guid_calcSize(UA_Guid const * ptr);
  113. /**
  114. * DateTime
  115. * Part: 6
  116. * Chapter: 5.2.2.5
  117. * Page: 16
  118. */
  119. typedef UA_Int64 UA_DateTime; //100 nanosecond resolution
  120. Int32 UA_DataTime_calcSize(UA_DateTime const * ptr);
  121. /**
  122. * XmlElement
  123. * Part: 6
  124. * Chapter: 5.2.2.8
  125. * Page: 17
  126. */
  127. //Überlegung ob man es direkt als ByteString speichert oder als String
  128. typedef struct UA_XmlElement
  129. {
  130. UA_ByteString Data;
  131. }
  132. UA_XmlElement;
  133. typedef struct UA_XmlElementEncoded
  134. {
  135. UA_UInt32 Length;
  136. UA_Byte StartTag[3];
  137. UA_Byte *Message;
  138. UA_UInt32 EndTag[4];
  139. }
  140. UA_XmlElementEncoded;
  141. typedef struct _UA_NodeId
  142. {
  143. UA_Byte EncodingByte; //enum BID_NodeIdEncodingValuesType
  144. UA_UInt16 Namespace;
  145. union
  146. {
  147. UA_UInt32 Numeric;
  148. UA_String String;
  149. UA_Guid Guid;
  150. UA_ByteString ByteString;
  151. }
  152. Identifier;
  153. } UA_NodeId;
  154. /**
  155. * NodeIds
  156. * Part: 6
  157. * Chapter: 5.2.2.9
  158. * Table 5
  159. */
  160. enum UA_NodeIdEncodingValuesType_enum
  161. {
  162. // Some Values are called the same as previous Enumerations so we need
  163. // names that are unique
  164. NIEVT_TWO_BYTE = 0x00,
  165. NIEVT_FOUR_BYTE = 0x01,
  166. NIEVT_NUMERIC = 0x02,
  167. NIEVT_STRING = 0x03,
  168. NIEVT_GUID = 0x04,
  169. NIEVT_BYTESTRING = 0x05,
  170. NIEVT_NAMESPACE_URI_FLAG = 0x80, //Is only for ExpandedNodeId required
  171. NIEVT_SERVERINDEX_FLAG = 0x40 //Is only for ExpandedNodeId required
  172. };
  173. /**
  174. * ExpandedNodeId
  175. * Part: 6
  176. * Chapter: 5.2.2.10
  177. * Page: 19
  178. */
  179. typedef struct UA_ExpandedNodeId
  180. {
  181. UA_NodeId NodeId;
  182. UA_Int32 EncodingByte; //enum BID_NodeIdEncodingValuesType
  183. UA_String NamespaceUri;
  184. UA_UInt32 ServerIndex;
  185. }
  186. UA_ExpandedNodeId;
  187. /**
  188. * NodeIds
  189. * Part: 6
  190. * Chapter: 5.2.2.9
  191. * Page: 17
  192. */
  193. typedef enum UA_IdentifierType
  194. {
  195. // Some Values are called the same as previouse Enumerations so we need
  196. //names that are unique
  197. IT_NUMERIC = 0,
  198. IT_STRING = 1,
  199. IT_GUID = 2,
  200. IT_OPAQUE = 3
  201. }
  202. UA_IdentifierType;
  203. /**
  204. * ExtensionObjectBinaryEncoding
  205. * Part: 6
  206. * Chapter: 5.2.2.15
  207. * Page: 21
  208. */
  209. typedef struct _UA_ExtensionObject {
  210. UA_NodeId TypeId;
  211. UA_Byte Encoding; //Type of the enum UA_ExtensionObjectEncodingMaskType
  212. UA_ByteString Body;
  213. } UA_ExtensionObject;
  214. /**
  215. * QualifiedNameBinaryEncoding
  216. * Part: 6
  217. * Chapter: 5.2.2.13
  218. * Page: 20
  219. */
  220. typedef struct _UA_QualifiedName {
  221. UInt16 NamespaceIndex;
  222. UInt16 Reserved;
  223. UA_String Name;
  224. } UA_QualifiedName;
  225. /**
  226. * DataValueBinaryEncoding
  227. * Part: 6
  228. * Chapter: 5.2.2.17
  229. * Page: 23
  230. */
  231. typedef struct UA_DataValue {
  232. UA_Byte EncodingMask;
  233. UA_Variant Value;
  234. UA_StatusCode Status;
  235. UA_DateTime SourceTimestamp;
  236. UA_Int16 SourcePicoseconds;
  237. UA_DateTime ServerTimestamp;
  238. UA_Int16 ServerPicoseconds;
  239. } UA_DataValue;
  240. /**
  241. * DiagnoticInfoBinaryEncoding
  242. * Part: 6
  243. * Chapter: 5.2.2.12
  244. * Page: 20
  245. */
  246. typedef struct _UA_DiagnosticInfo {
  247. Byte EncodingMask; //Type of the Enum UA_DiagnosticInfoEncodingMaskType
  248. UA_Int32 SymbolicId;
  249. UA_Int32 NamespaceUri;
  250. UA_Int32 LocalizedText;
  251. UA_Int32 Locale;
  252. UA_String AdditionalInfo;
  253. UA_StatusCode InnerStatusCode;
  254. struct _UA_DiagnosticInfo* InnerDiagnosticInfo;
  255. } UA_DiagnosticInfo;
  256. enum UA_DiagnosticInfoEncodingMaskType_enum
  257. {
  258. // Some Values are called the same as previous Enumerations so we need
  259. //names that are unique
  260. DIEMT_SYMBOLIC_ID = 0x01,
  261. DIEMT_NAMESPACE = 0x02,
  262. DIEMT_LOCALIZED_TEXT = 0x04,
  263. DIEMT_LOCALE = 0x08,
  264. DIEMT_ADDITIONAL_INFO = 0x10,
  265. DIEMT_INNER_STATUS_CODE = 0x20,
  266. DIEMT_INNER_DIAGNOSTIC_INFO = 0x40
  267. };
  268. Int32 UA_Array_calcSize(Int32 noElements, Int32 type, void const ** ptr);
  269. #endif /* OPCUA_BASICTYPES_H_ */