opcua_basictypes.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  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 int64_t Int64;
  15. typedef uint16_t UInt16;
  16. typedef uint32_t UInt32;
  17. typedef uint64_t UInt64;
  18. #define UA_SUCCESS 0
  19. #define UA_TRUE (42==42)
  20. #define UA_FALSE (!UA_TRUE)
  21. #define UA_TYPE_METHOD_PROTOTYPES(TYPE) \
  22. Int32 TYPE##_calcSize(TYPE const * ptr);\
  23. Int32 TYPE##_encode(TYPE const * src, Int32* pos, char * dst);\
  24. Int32 TYPE##_decode(char const * src, Int32* pos, TYPE * dst);\
  25. Int32 TYPE##_delete(TYPE * p);\
  26. Int32 TYPE##_deleteMembers(TYPE * p); \
  27. typedef _Bool UA_Boolean;
  28. UA_TYPE_METHOD_PROTOTYPES (UA_Boolean)
  29. typedef int8_t UA_Byte;
  30. UA_TYPE_METHOD_PROTOTYPES (UA_Byte)
  31. typedef uint8_t UA_SByte;
  32. UA_TYPE_METHOD_PROTOTYPES (UA_SByte)
  33. typedef int16_t UA_Int16;
  34. UA_TYPE_METHOD_PROTOTYPES (UA_Int16)
  35. typedef uint16_t UA_UInt16;
  36. UA_TYPE_METHOD_PROTOTYPES (UA_UInt16)
  37. typedef int32_t UA_Int32;
  38. UA_TYPE_METHOD_PROTOTYPES (UA_Int32)
  39. typedef uint32_t UA_UInt32;
  40. UA_TYPE_METHOD_PROTOTYPES (UA_UInt32)
  41. typedef int64_t UA_Int64;
  42. UA_TYPE_METHOD_PROTOTYPES (UA_Int64)
  43. typedef uint64_t UA_UInt64;
  44. UA_TYPE_METHOD_PROTOTYPES (UA_UInt64)
  45. typedef float UA_Float;
  46. UA_TYPE_METHOD_PROTOTYPES (UA_Float)
  47. typedef double UA_Double;
  48. UA_TYPE_METHOD_PROTOTYPES (UA_Double)
  49. /**
  50. * StatusCodeBinaryEncoding
  51. * Part: 6
  52. * Chapter: 5.2.2.11
  53. * Page: 20
  54. */
  55. typedef UA_Int32 UA_StatusCode;
  56. enum UA_StatusCode_enum
  57. {
  58. // Some Values are called the same as previous Enumerations so we need
  59. //names that are unique
  60. SC_Good = 0x00
  61. };
  62. UA_TYPE_METHOD_PROTOTYPES (UA_StatusCode)
  63. /* VariantBinaryEncoding - Part: 6, Chapter: 5.2.2.16, Page: 22 */
  64. typedef struct T_UA_Variant {
  65. Byte encodingMask; // Type of Enum UA_VariantTypeEncodingMaskType
  66. UA_Int32 size;
  67. void** data;
  68. } UA_Variant;
  69. UA_TYPE_METHOD_PROTOTYPES (UA_Variant)
  70. /* String - Part: 6, Chapter: 5.2.2.4, Page: 16 */
  71. typedef struct T_UA_String
  72. {
  73. UA_Int32 length;
  74. UA_Byte* data;
  75. }
  76. UA_String;
  77. UA_TYPE_METHOD_PROTOTYPES (UA_String)
  78. /* ByteString - Part: 6, Chapter: 5.2.2.7, Page: 17 */
  79. typedef struct T_UA_ByteString
  80. {
  81. UA_Int32 length;
  82. UA_Byte* data;
  83. }
  84. UA_ByteString;
  85. UA_TYPE_METHOD_PROTOTYPES (UA_ByteString)
  86. /** LocalizedTextBinaryEncoding - Part: 6, Chapter: 5.2.2.14, Page: 21 */
  87. typedef struct T_UA_LocalizedText
  88. {
  89. UA_Byte encodingMask;
  90. UA_String locale;
  91. UA_String text;
  92. }
  93. UA_LocalizedText;
  94. UA_TYPE_METHOD_PROTOTYPES (UA_LocalizedText)
  95. /* GuidType - Part: 6, Chapter: 5.2.2.6 Page: 17 */
  96. typedef struct T_UA_Guid
  97. {
  98. UA_UInt32 data1;
  99. UA_UInt16 data2;
  100. UA_UInt16 data3;
  101. UA_ByteString data4;
  102. } UA_Guid;
  103. UA_TYPE_METHOD_PROTOTYPES (UA_Guid)
  104. /* DateTime - Part: 6, Chapter: 5.2.2.5, Page: 16 */
  105. typedef UA_Int64 UA_DateTime; //100 nanosecond resolution
  106. UA_TYPE_METHOD_PROTOTYPES (UA_DateTime)
  107. typedef struct T_UA_NodeId
  108. {
  109. UA_Byte encodingByte; //enum BID_NodeIdEncodingValuesType
  110. UA_UInt16 namespace;
  111. union
  112. {
  113. UA_UInt32 numeric;
  114. UA_String string;
  115. UA_Guid guid;
  116. UA_ByteString byteString;
  117. }
  118. identifier;
  119. } UA_NodeId;
  120. UA_TYPE_METHOD_PROTOTYPES (UA_NodeId)
  121. /** XmlElement - Part: 6, Chapter: 5.2.2.8, Page: 17 */
  122. typedef struct T_UA_XmlElement
  123. {
  124. //TODO Überlegung ob man es direkt als ByteString speichert oder als String
  125. UA_ByteString Data;
  126. } UA_XmlElement;
  127. UA_TYPE_METHOD_PROTOTYPES (UA_XmlElement)
  128. /** NodeIds - Part: 6, Chapter: 5.2.2.9, Table 5 */
  129. enum UA_NodeIdEncodingValuesType_enum
  130. {
  131. // Some Values are called the same as previous Enumerations so we need names that are unique
  132. NIEVT_TWO_BYTE = 0x00,
  133. NIEVT_FOUR_BYTE = 0x01,
  134. NIEVT_NUMERIC = 0x02,
  135. NIEVT_STRING = 0x03,
  136. NIEVT_GUID = 0x04,
  137. NIEVT_BYTESTRING = 0x05,
  138. NIEVT_NAMESPACE_URI_FLAG = 0x80, //Is only for ExpandedNodeId required
  139. NIEVT_SERVERINDEX_FLAG = 0x40 //Is only for ExpandedNodeId required
  140. };
  141. /* ExpandedNodeId - Part: 6, Chapter: 5.2.2.10, Page: 19 */
  142. typedef struct T_UA_ExpandedNodeId
  143. {
  144. UA_NodeId nodeId;
  145. UA_Int32 encodingByte; //enum BID_NodeIdEncodingValuesType
  146. UA_String namespaceUri;
  147. UA_UInt32 serverIndex;
  148. }
  149. UA_ExpandedNodeId;
  150. UA_TYPE_METHOD_PROTOTYPES(UA_ExpandedNodeId)
  151. /* NodeIds - Part: 6, Chapter: 5.2.2.9, Page: 17 */
  152. enum UA_IdentifierType_enum {
  153. // Some Values are called the same as previouse Enumerations so we need
  154. //names that are unique
  155. IT_NUMERIC = 0,
  156. IT_STRING = 1,
  157. IT_GUID = 2,
  158. IT_OPAQUE = 3
  159. };
  160. typedef UA_Int32 UA_IdentifierType;
  161. UA_TYPE_METHOD_PROTOTYPES(UA_IdentifierType)
  162. /* ExtensionObjectBinaryEncoding - Part: 6, Chapter: 5.2.2.15, Page: 21 */
  163. typedef struct T_UA_ExtensionObject {
  164. UA_NodeId typeId;
  165. UA_Byte encoding; //Type of the enum UA_ExtensionObjectEncodingMaskType
  166. UA_ByteString body;
  167. } UA_ExtensionObject;
  168. UA_TYPE_METHOD_PROTOTYPES(UA_ExtensionObject)
  169. /* QualifiedNameBinaryEncoding - Part: 6, Chapter: 5.2.2.13, Page: 20 */
  170. typedef struct T_UA_QualifiedName {
  171. UInt16 namespaceIndex;
  172. UInt16 reserved;
  173. UA_String name;
  174. } UA_QualifiedName;
  175. UA_TYPE_METHOD_PROTOTYPES(UA_QualifiedName)
  176. /*
  177. * DataValueBinaryEncoding
  178. * Part: 6
  179. * Chapter: 5.2.2.17
  180. * Page: 23
  181. */
  182. typedef struct UA_DataValue {
  183. UA_Byte encodingMask;
  184. UA_Variant value;
  185. UA_StatusCode status;
  186. UA_DateTime sourceTimestamp;
  187. UA_Int16 sourcePicoseconds;
  188. UA_DateTime serverTimestamp;
  189. UA_Int16 serverPicoseconds;
  190. } UA_DataValue;
  191. UA_TYPE_METHOD_PROTOTYPES(UA_DataValue)
  192. /* DiagnosticInfo - Part: 6, Chapter: 5.2.2.12, Page: 20 */
  193. typedef struct T_UA_DiagnosticInfo {
  194. Byte encodingMask; //Type of the Enum UA_DiagnosticInfoEncodingMaskType
  195. UA_Int32 symbolicId;
  196. UA_Int32 namespaceUri;
  197. UA_Int32 localizedText;
  198. UA_Int32 locale;
  199. UA_String additionalInfo;
  200. UA_StatusCode innerStatusCode;
  201. struct T_UA_DiagnosticInfo* InnerDiagnosticInfo;
  202. } UA_DiagnosticInfo;
  203. UA_TYPE_METHOD_PROTOTYPES(UA_DiagnosticInfo)
  204. enum UA_DiagnosticInfoEncodingMaskType_enum
  205. {
  206. // Some Values are called the same as previous Enumerations so we need
  207. //names that are unique
  208. DIEMT_SYMBOLIC_ID = 0x01,
  209. DIEMT_NAMESPACE = 0x02,
  210. DIEMT_LOCALIZED_TEXT = 0x04,
  211. DIEMT_LOCALE = 0x08,
  212. DIEMT_ADDITIONAL_INFO = 0x10,
  213. DIEMT_INNER_STATUS_CODE = 0x20,
  214. DIEMT_INNER_DIAGNOSTIC_INFO = 0x40
  215. };
  216. Int32 UA_Array_calcSize(Int32 noElements, Int32 type, void const ** ptr);
  217. #endif /* OPCUA_BASICTYPES_H_ */