ua_client_highlevel.h 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431
  1. /*
  2. * Copyright (C) 2014-2016 the contributors as stated in the AUTHORS file
  3. *
  4. * This file is part of open62541. open62541 is free software: you can
  5. * redistribute it and/or modify it under the terms of the GNU Lesser General
  6. * Public License, version 3 (as published by the Free Software Foundation) with
  7. * a static linking exception as stated in the LICENSE file provided with
  8. * open62541.
  9. *
  10. * open62541 is distributed in the hope that it will be useful, but WITHOUT ANY
  11. * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  12. * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
  13. * details.
  14. */
  15. #ifndef UA_CLIENT_HIGHLEVEL_H_
  16. #define UA_CLIENT_HIGHLEVEL_H_
  17. #ifdef __cplusplus
  18. extern "C" {
  19. #endif
  20. #include "ua_client.h"
  21. /**
  22. * .. _client-highlevel:
  23. *
  24. * Highlevel Client Functionality
  25. * ------------------------------
  26. * The following definitions are convenience functions making use of the
  27. * standard OPC UA services in the background.
  28. *
  29. * The high level abstractions concetrate on getting the job done in a simple
  30. * manner for the user. This is a less flexible way of handling the stack,
  31. * because at many places sensible defaults are presumed; at the same time using
  32. * these functions is the easiest way of implementing an OPC UA application, as
  33. * you will not have to consider all the details that go into the OPC UA
  34. * services. A concept of how nodes and datatypes are used are completely
  35. * sufficient to use OPC UA with this layer.
  36. *
  37. * If more flexibility is needed, you can always achieve the same functionality
  38. * using the raw :ref:`OPC UA services <client-services>`.
  39. *
  40. * Read Attributes
  41. * ===============
  42. * The following functions can be used to retrieve a single node attribute. Use
  43. * the regular service to read several attributes at once. */
  44. /* Don't call this function, use the typed versions */
  45. UA_StatusCode UA_EXPORT
  46. __UA_Client_readAttribute(UA_Client *client, const UA_NodeId *nodeId, UA_AttributeId attributeId,
  47. void *out, const UA_DataType *outDataType);
  48. static UA_INLINE UA_StatusCode
  49. UA_Client_readNodeIdAttribute(UA_Client *client, const UA_NodeId nodeId, UA_NodeId *outNodeId) {
  50. return __UA_Client_readAttribute(client, &nodeId, UA_ATTRIBUTEID_NODEID, outNodeId, &UA_TYPES[UA_TYPES_NODEID]); }
  51. static UA_INLINE UA_StatusCode
  52. UA_Client_readNodeClassAttribute(UA_Client *client, const UA_NodeId nodeId, UA_NodeClass *outNodeClass) {
  53. return __UA_Client_readAttribute(client, &nodeId, UA_ATTRIBUTEID_NODECLASS, outNodeClass, &UA_TYPES[UA_TYPES_NODECLASS]); }
  54. static UA_INLINE UA_StatusCode
  55. UA_Client_readBrowseNameAttribute(UA_Client *client, const UA_NodeId nodeId, UA_QualifiedName *outBrowseName) {
  56. return __UA_Client_readAttribute(client, &nodeId, UA_ATTRIBUTEID_BROWSENAME, outBrowseName, &UA_TYPES[UA_TYPES_QUALIFIEDNAME]); }
  57. static UA_INLINE UA_StatusCode
  58. UA_Client_readDisplayNameAttribute(UA_Client *client, const UA_NodeId nodeId, UA_LocalizedText *outDisplayName) {
  59. return __UA_Client_readAttribute(client, &nodeId, UA_ATTRIBUTEID_DISPLAYNAME, outDisplayName, &UA_TYPES[UA_TYPES_LOCALIZEDTEXT]); }
  60. static UA_INLINE UA_StatusCode
  61. UA_Client_readDescriptionAttribute(UA_Client *client, const UA_NodeId nodeId, UA_LocalizedText *outDescription) {
  62. return __UA_Client_readAttribute(client, &nodeId, UA_ATTRIBUTEID_DESCRIPTION, outDescription, &UA_TYPES[UA_TYPES_LOCALIZEDTEXT]); }
  63. static UA_INLINE UA_StatusCode
  64. UA_Client_readWriteMaskAttribute(UA_Client *client, const UA_NodeId nodeId, UA_UInt32 *outWriteMask) {
  65. return __UA_Client_readAttribute(client, &nodeId, UA_ATTRIBUTEID_WRITEMASK, outWriteMask, &UA_TYPES[UA_TYPES_UINT32]); }
  66. static UA_INLINE UA_StatusCode
  67. UA_Client_readUserWriteMaskAttribute(UA_Client *client, const UA_NodeId nodeId, UA_UInt32 *outUserWriteMask) {
  68. return __UA_Client_readAttribute(client, &nodeId, UA_ATTRIBUTEID_USERWRITEMASK, outUserWriteMask, &UA_TYPES[UA_TYPES_UINT32]); }
  69. static UA_INLINE UA_StatusCode
  70. UA_Client_readIsAbstractAttribute(UA_Client *client, const UA_NodeId nodeId, UA_Boolean *outIsAbstract) {
  71. return __UA_Client_readAttribute(client, &nodeId, UA_ATTRIBUTEID_ISABSTRACT, outIsAbstract, &UA_TYPES[UA_TYPES_BOOLEAN]); }
  72. static UA_INLINE UA_StatusCode
  73. UA_Client_readSymmetricAttribute(UA_Client *client, const UA_NodeId nodeId, UA_Boolean *outSymmetric) {
  74. return __UA_Client_readAttribute(client, &nodeId, UA_ATTRIBUTEID_SYMMETRIC, outSymmetric, &UA_TYPES[UA_TYPES_BOOLEAN]); }
  75. static UA_INLINE UA_StatusCode
  76. UA_Client_readInverseNameAttribute(UA_Client *client, const UA_NodeId nodeId, UA_LocalizedText *outInverseName) {
  77. return __UA_Client_readAttribute(client, &nodeId, UA_ATTRIBUTEID_INVERSENAME, outInverseName, &UA_TYPES[UA_TYPES_LOCALIZEDTEXT]); }
  78. static UA_INLINE UA_StatusCode
  79. UA_Client_readContainsNoLoopsAttribute(UA_Client *client, const UA_NodeId nodeId, UA_Boolean *outContainsNoLoops) {
  80. return __UA_Client_readAttribute(client, &nodeId, UA_ATTRIBUTEID_CONTAINSNOLOOPS, outContainsNoLoops, &UA_TYPES[UA_TYPES_BOOLEAN]); }
  81. static UA_INLINE UA_StatusCode
  82. UA_Client_readEventNotifierAttribute(UA_Client *client, const UA_NodeId nodeId, UA_Byte *outEventNotifier) {
  83. return __UA_Client_readAttribute(client, &nodeId, UA_ATTRIBUTEID_EVENTNOTIFIER, outEventNotifier, &UA_TYPES[UA_TYPES_BYTE]); }
  84. static UA_INLINE UA_StatusCode
  85. UA_Client_readValueAttribute(UA_Client *client, const UA_NodeId nodeId, UA_Variant *outValue) {
  86. return __UA_Client_readAttribute(client, &nodeId, UA_ATTRIBUTEID_VALUE, outValue, &UA_TYPES[UA_TYPES_VARIANT]); }
  87. static UA_INLINE UA_StatusCode
  88. UA_Client_readDataTypeAttribute(UA_Client *client, const UA_NodeId nodeId, UA_NodeId *outDataType) {
  89. return __UA_Client_readAttribute(client, &nodeId, UA_ATTRIBUTEID_DATATYPE, outDataType, &UA_TYPES[UA_TYPES_NODEID]); }
  90. static UA_INLINE UA_StatusCode
  91. UA_Client_readValueRankAttribute(UA_Client *client, const UA_NodeId nodeId, UA_Int32 *outValueRank) {
  92. return __UA_Client_readAttribute(client, &nodeId, UA_ATTRIBUTEID_VALUERANK, outValueRank, &UA_TYPES[UA_TYPES_INT32]); }
  93. UA_StatusCode UA_EXPORT
  94. UA_Client_readArrayDimensionsAttribute(UA_Client *client, const UA_NodeId nodeId,
  95. UA_Int32 **outArrayDimensions, size_t *outArrayDimensionsSize);
  96. static UA_INLINE UA_StatusCode
  97. UA_Client_readAccessLevelAttribute(UA_Client *client, const UA_NodeId nodeId, UA_UInt32 *outAccessLevel) {
  98. return __UA_Client_readAttribute(client, &nodeId, UA_ATTRIBUTEID_ACCESSLEVEL, outAccessLevel, &UA_TYPES[UA_TYPES_UINT32]); }
  99. static UA_INLINE UA_StatusCode
  100. UA_Client_readUserAccessLevelAttribute(UA_Client *client, const UA_NodeId nodeId, UA_UInt32 *outUserAccessLevel) {
  101. return __UA_Client_readAttribute(client, &nodeId, UA_ATTRIBUTEID_USERACCESSLEVEL, outUserAccessLevel, &UA_TYPES[UA_TYPES_UINT32]); }
  102. static UA_INLINE UA_StatusCode
  103. UA_Client_readMinimumSamplingIntervalAttribute(UA_Client *client, const UA_NodeId nodeId, UA_Double *outMinimumSamplingInterval) {
  104. return __UA_Client_readAttribute(client, &nodeId, UA_ATTRIBUTEID_MINIMUMSAMPLINGINTERVAL, outMinimumSamplingInterval, &UA_TYPES[UA_TYPES_DOUBLE]); }
  105. static UA_INLINE UA_StatusCode
  106. UA_Client_readHistorizingAttribute(UA_Client *client, const UA_NodeId nodeId, UA_Boolean *outHistorizing) {
  107. return __UA_Client_readAttribute(client, &nodeId, UA_ATTRIBUTEID_HISTORIZING, outHistorizing, &UA_TYPES[UA_TYPES_BOOLEAN]); }
  108. static UA_INLINE UA_StatusCode
  109. UA_Client_readExecutableAttribute(UA_Client *client, const UA_NodeId nodeId, UA_Boolean *outExecutable) {
  110. return __UA_Client_readAttribute(client, &nodeId, UA_ATTRIBUTEID_EXECUTABLE, outExecutable, &UA_TYPES[UA_TYPES_BOOLEAN]); }
  111. static UA_INLINE UA_StatusCode
  112. UA_Client_readUserExecutableAttribute(UA_Client *client, const UA_NodeId nodeId, UA_Boolean *outUserExecutable) {
  113. return __UA_Client_readAttribute(client, &nodeId, UA_ATTRIBUTEID_USEREXECUTABLE, outUserExecutable, &UA_TYPES[UA_TYPES_BOOLEAN]); }
  114. /**
  115. * Write Attributes
  116. * ================
  117. * The following functions can be use to write a single node attribute at a
  118. * time. Use the regular write service to write several attributes at once. */
  119. /* Don't call this function, use the typed versions */
  120. UA_StatusCode UA_EXPORT
  121. __UA_Client_writeAttribute(UA_Client *client, const UA_NodeId *nodeId,
  122. UA_AttributeId attributeId, const void *in,
  123. const UA_DataType *inDataType);
  124. static UA_INLINE UA_StatusCode
  125. UA_Client_writeNodeIdAttribute(UA_Client *client, const UA_NodeId nodeId, const UA_NodeId *newNodeId) {
  126. return __UA_Client_writeAttribute(client, &nodeId, UA_ATTRIBUTEID_NODEID, newNodeId, &UA_TYPES[UA_TYPES_NODEID]); }
  127. static UA_INLINE UA_StatusCode
  128. UA_Client_writeNodeClassAttribute(UA_Client *client, const UA_NodeId nodeId, const UA_NodeClass *newNodeClass) {
  129. return __UA_Client_writeAttribute(client, &nodeId, UA_ATTRIBUTEID_NODECLASS, newNodeClass, &UA_TYPES[UA_TYPES_NODECLASS]); }
  130. static UA_INLINE UA_StatusCode
  131. UA_Client_writeBrowseNameAttribute(UA_Client *client, const UA_NodeId nodeId, const UA_QualifiedName *newBrowseName) {
  132. return __UA_Client_writeAttribute(client, &nodeId, UA_ATTRIBUTEID_BROWSENAME, newBrowseName, &UA_TYPES[UA_TYPES_QUALIFIEDNAME]); }
  133. static UA_INLINE UA_StatusCode
  134. UA_Client_writeDisplayNameAttribute(UA_Client *client, const UA_NodeId nodeId, const UA_LocalizedText *newDisplayName) {
  135. return __UA_Client_writeAttribute(client, &nodeId, UA_ATTRIBUTEID_DISPLAYNAME, newDisplayName, &UA_TYPES[UA_TYPES_LOCALIZEDTEXT]); }
  136. static UA_INLINE UA_StatusCode
  137. UA_Client_writeDescriptionAttribute(UA_Client *client, const UA_NodeId nodeId, const UA_LocalizedText *newDescription) {
  138. return __UA_Client_writeAttribute(client, &nodeId, UA_ATTRIBUTEID_DESCRIPTION, newDescription, &UA_TYPES[UA_TYPES_LOCALIZEDTEXT]); }
  139. static UA_INLINE UA_StatusCode
  140. UA_Client_writeWriteMaskAttribute(UA_Client *client, const UA_NodeId nodeId, const UA_UInt32 *newWriteMask) {
  141. return __UA_Client_writeAttribute(client, &nodeId, UA_ATTRIBUTEID_WRITEMASK, newWriteMask, &UA_TYPES[UA_TYPES_UINT32]); }
  142. static UA_INLINE UA_StatusCode
  143. UA_Client_writeUserWriteMaskAttribute(UA_Client *client, const UA_NodeId nodeId, const UA_UInt32 *newUserWriteMask) {
  144. return __UA_Client_writeAttribute(client, &nodeId, UA_ATTRIBUTEID_USERWRITEMASK, newUserWriteMask, &UA_TYPES[UA_TYPES_UINT32]); }
  145. static UA_INLINE UA_StatusCode
  146. UA_Client_writeIsAbstractAttribute(UA_Client *client, const UA_NodeId nodeId, const UA_Boolean *newIsAbstract) {
  147. return __UA_Client_writeAttribute(client, &nodeId, UA_ATTRIBUTEID_ISABSTRACT, newIsAbstract, &UA_TYPES[UA_TYPES_BOOLEAN]); }
  148. static UA_INLINE UA_StatusCode
  149. UA_Client_writeSymmetricAttribute(UA_Client *client, const UA_NodeId nodeId, const UA_Boolean *newSymmetric) {
  150. return __UA_Client_writeAttribute(client, &nodeId, UA_ATTRIBUTEID_SYMMETRIC, newSymmetric, &UA_TYPES[UA_TYPES_BOOLEAN]); }
  151. static UA_INLINE UA_StatusCode
  152. UA_Client_writeInverseNameAttribute(UA_Client *client, const UA_NodeId nodeId, const UA_LocalizedText *newInverseName) {
  153. return __UA_Client_writeAttribute(client, &nodeId, UA_ATTRIBUTEID_INVERSENAME, newInverseName, &UA_TYPES[UA_TYPES_LOCALIZEDTEXT]); }
  154. static UA_INLINE UA_StatusCode
  155. UA_Client_writeContainsNoLoopsAttribute(UA_Client *client, const UA_NodeId nodeId, const UA_Boolean *newContainsNoLoops) {
  156. return __UA_Client_writeAttribute(client, &nodeId, UA_ATTRIBUTEID_CONTAINSNOLOOPS, newContainsNoLoops, &UA_TYPES[UA_TYPES_BOOLEAN]); }
  157. static UA_INLINE UA_StatusCode
  158. UA_Client_writeEventNotifierAttribute(UA_Client *client, const UA_NodeId nodeId, const UA_Byte *newEventNotifier) {
  159. return __UA_Client_writeAttribute(client, &nodeId, UA_ATTRIBUTEID_EVENTNOTIFIER, newEventNotifier, &UA_TYPES[UA_TYPES_BYTE]); }
  160. static UA_INLINE UA_StatusCode
  161. UA_Client_writeValueAttribute(UA_Client *client, const UA_NodeId nodeId, const UA_Variant *newValue) {
  162. return __UA_Client_writeAttribute(client, &nodeId, UA_ATTRIBUTEID_VALUE, newValue, &UA_TYPES[UA_TYPES_VARIANT]); }
  163. static UA_INLINE UA_StatusCode
  164. UA_Client_writeDataTypeAttribute(UA_Client *client, const UA_NodeId nodeId, const UA_NodeId *newDataType) {
  165. return __UA_Client_writeAttribute(client, &nodeId, UA_ATTRIBUTEID_DATATYPE, newDataType, &UA_TYPES[UA_TYPES_NODEID]); }
  166. static UA_INLINE UA_StatusCode
  167. UA_Client_writeValueRankAttribute(UA_Client *client, const UA_NodeId nodeId, const UA_Int32 *newValueRank) {
  168. return __UA_Client_writeAttribute(client, &nodeId, UA_ATTRIBUTEID_VALUERANK, newValueRank, &UA_TYPES[UA_TYPES_INT32]); }
  169. UA_StatusCode UA_EXPORT
  170. UA_Client_writeArrayDimensionsAttribute(UA_Client *client, const UA_NodeId nodeId,
  171. const UA_Int32 *newArrayDimensions, size_t newArrayDimensionsSize);
  172. static UA_INLINE UA_StatusCode
  173. UA_Client_writeAccessLevelAttribute(UA_Client *client, const UA_NodeId nodeId, const UA_UInt32 *newAccessLevel) {
  174. return __UA_Client_writeAttribute(client, &nodeId, UA_ATTRIBUTEID_ACCESSLEVEL, newAccessLevel, &UA_TYPES[UA_TYPES_UINT32]); }
  175. static UA_INLINE UA_StatusCode
  176. UA_Client_writeUserAccessLevelAttribute(UA_Client *client, const UA_NodeId nodeId, const UA_UInt32 *newUserAccessLevel) {
  177. return __UA_Client_writeAttribute(client, &nodeId, UA_ATTRIBUTEID_USERACCESSLEVEL, newUserAccessLevel, &UA_TYPES[UA_TYPES_UINT32]); }
  178. static UA_INLINE UA_StatusCode
  179. UA_Client_writeMinimumSamplingIntervalAttribute(UA_Client *client, const UA_NodeId nodeId, const UA_Double *newMinimumSamplingInterval) {
  180. return __UA_Client_writeAttribute(client, &nodeId, UA_ATTRIBUTEID_MINIMUMSAMPLINGINTERVAL, newMinimumSamplingInterval, &UA_TYPES[UA_TYPES_DOUBLE]); }
  181. static UA_INLINE UA_StatusCode
  182. UA_Client_writeHistorizingAttribute(UA_Client *client, const UA_NodeId nodeId, const UA_Boolean *newHistorizing) {
  183. return __UA_Client_writeAttribute(client, &nodeId, UA_ATTRIBUTEID_HISTORIZING, newHistorizing, &UA_TYPES[UA_TYPES_BOOLEAN]); }
  184. static UA_INLINE UA_StatusCode
  185. UA_Client_writeExecutableAttribute(UA_Client *client, const UA_NodeId nodeId, const UA_Boolean *newExecutable) {
  186. return __UA_Client_writeAttribute(client, &nodeId, UA_ATTRIBUTEID_EXECUTABLE, newExecutable, &UA_TYPES[UA_TYPES_BOOLEAN]); }
  187. static UA_INLINE UA_StatusCode
  188. UA_Client_writeUserExecutableAttribute(UA_Client *client, const UA_NodeId nodeId, const UA_Boolean *newUserExecutable) {
  189. return __UA_Client_writeAttribute(client, &nodeId, UA_ATTRIBUTEID_USEREXECUTABLE, newUserExecutable, &UA_TYPES[UA_TYPES_BOOLEAN]); }
  190. /**
  191. * Method Calling
  192. * ============== */
  193. UA_StatusCode UA_EXPORT
  194. UA_Client_call(UA_Client *client, const UA_NodeId objectId, const UA_NodeId methodId,
  195. size_t inputSize, const UA_Variant *input, size_t *outputSize, UA_Variant **output);
  196. /**
  197. * Node Management
  198. * ===============
  199. *
  200. * See the section on :ref:`server-side node management <addnodes>`.
  201. */
  202. UA_StatusCode UA_EXPORT
  203. UA_Client_addReference(UA_Client *client, const UA_NodeId sourceNodeId, const UA_NodeId referenceTypeId,
  204. UA_Boolean isForward, const UA_String targetServerUri,
  205. const UA_ExpandedNodeId targetNodeId, UA_NodeClass targetNodeClass);
  206. UA_StatusCode UA_EXPORT
  207. UA_Client_deleteReference(UA_Client *client, const UA_NodeId sourceNodeId, const UA_NodeId referenceTypeId,
  208. UA_Boolean isForward, const UA_ExpandedNodeId targetNodeId,
  209. UA_Boolean deleteBidirectional);
  210. UA_StatusCode UA_EXPORT
  211. UA_Client_deleteNode(UA_Client *client, const UA_NodeId nodeId, UA_Boolean deleteTargetReferences);
  212. /* Don't call this function, use the typed versions */
  213. UA_StatusCode UA_EXPORT
  214. __UA_Client_addNode(UA_Client *client, const UA_NodeClass nodeClass,
  215. const UA_NodeId requestedNewNodeId, const UA_NodeId parentNodeId,
  216. const UA_NodeId referenceTypeId, const UA_QualifiedName browseName,
  217. const UA_NodeId typeDefinition, const UA_NodeAttributes *attr,
  218. const UA_DataType *attributeType, UA_NodeId *outNewNodeId);
  219. static UA_INLINE UA_StatusCode
  220. UA_Client_addVariableNode(UA_Client *client, const UA_NodeId requestedNewNodeId,
  221. const UA_NodeId parentNodeId, const UA_NodeId referenceTypeId,
  222. const UA_QualifiedName browseName, const UA_NodeId typeDefinition,
  223. const UA_VariableAttributes attr, UA_NodeId *outNewNodeId) {
  224. return __UA_Client_addNode(client, UA_NODECLASS_VARIABLE, requestedNewNodeId,
  225. parentNodeId, referenceTypeId, browseName, typeDefinition,
  226. (const UA_NodeAttributes*)&attr, &UA_TYPES[UA_TYPES_VARIABLEATTRIBUTES],
  227. outNewNodeId); }
  228. static UA_INLINE UA_StatusCode
  229. UA_Client_addVariableTypeNode(UA_Client *client, const UA_NodeId requestedNewNodeId,
  230. const UA_NodeId parentNodeId, const UA_NodeId referenceTypeId,
  231. const UA_QualifiedName browseName, const UA_VariableTypeAttributes attr,
  232. UA_NodeId *outNewNodeId) {
  233. return __UA_Client_addNode(client, UA_NODECLASS_VARIABLETYPE, requestedNewNodeId,
  234. parentNodeId, referenceTypeId, browseName, UA_NODEID_NULL,
  235. (const UA_NodeAttributes*)&attr, &UA_TYPES[UA_TYPES_VARIABLETYPEATTRIBUTES],
  236. outNewNodeId); }
  237. static UA_INLINE UA_StatusCode
  238. UA_Client_addObjectNode(UA_Client *client, const UA_NodeId requestedNewNodeId,
  239. const UA_NodeId parentNodeId, const UA_NodeId referenceTypeId,
  240. const UA_QualifiedName browseName, const UA_NodeId typeDefinition,
  241. const UA_ObjectAttributes attr, UA_NodeId *outNewNodeId) {
  242. return __UA_Client_addNode(client, UA_NODECLASS_OBJECT, requestedNewNodeId,
  243. parentNodeId, referenceTypeId, browseName, typeDefinition,
  244. (const UA_NodeAttributes*)&attr, &UA_TYPES[UA_TYPES_OBJECTATTRIBUTES],
  245. outNewNodeId); }
  246. static UA_INLINE UA_StatusCode
  247. UA_Client_addObjectTypeNode(UA_Client *client, const UA_NodeId requestedNewNodeId,
  248. const UA_NodeId parentNodeId, const UA_NodeId referenceTypeId,
  249. const UA_QualifiedName browseName, const UA_ObjectTypeAttributes attr,
  250. UA_NodeId *outNewNodeId) {
  251. return __UA_Client_addNode(client, UA_NODECLASS_OBJECTTYPE, requestedNewNodeId,
  252. parentNodeId, referenceTypeId, browseName, UA_NODEID_NULL,
  253. (const UA_NodeAttributes*)&attr, &UA_TYPES[UA_TYPES_OBJECTTYPEATTRIBUTES],
  254. outNewNodeId); }
  255. static UA_INLINE UA_StatusCode
  256. UA_Client_addViewNode(UA_Client *client, const UA_NodeId requestedNewNodeId,
  257. const UA_NodeId parentNodeId, const UA_NodeId referenceTypeId,
  258. const UA_QualifiedName browseName, const UA_ViewAttributes attr,
  259. UA_NodeId *outNewNodeId) {
  260. return __UA_Client_addNode(client, UA_NODECLASS_VIEW, requestedNewNodeId,
  261. parentNodeId, referenceTypeId, browseName, UA_NODEID_NULL,
  262. (const UA_NodeAttributes*)&attr, &UA_TYPES[UA_TYPES_VIEWATTRIBUTES],
  263. outNewNodeId); }
  264. static UA_INLINE UA_StatusCode
  265. UA_Client_addReferenceTypeNode(UA_Client *client, const UA_NodeId requestedNewNodeId,
  266. const UA_NodeId parentNodeId, const UA_NodeId referenceTypeId,
  267. const UA_QualifiedName browseName, const UA_ReferenceTypeAttributes attr,
  268. UA_NodeId *outNewNodeId) {
  269. return __UA_Client_addNode(client, UA_NODECLASS_REFERENCETYPE, requestedNewNodeId,
  270. parentNodeId, referenceTypeId, browseName, UA_NODEID_NULL,
  271. (const UA_NodeAttributes*)&attr, &UA_TYPES[UA_TYPES_REFERENCETYPEATTRIBUTES],
  272. outNewNodeId); }
  273. static UA_INLINE UA_StatusCode
  274. UA_Client_addDataTypeNode(UA_Client *client, const UA_NodeId requestedNewNodeId,
  275. const UA_NodeId parentNodeId, const UA_NodeId referenceTypeId,
  276. const UA_QualifiedName browseName, const UA_DataTypeAttributes attr,
  277. UA_NodeId *outNewNodeId) {
  278. return __UA_Client_addNode(client, UA_NODECLASS_DATATYPE, requestedNewNodeId,
  279. parentNodeId, referenceTypeId, browseName, UA_NODEID_NULL,
  280. (const UA_NodeAttributes*)&attr, &UA_TYPES[UA_TYPES_DATATYPEATTRIBUTES],
  281. outNewNodeId); }
  282. static UA_INLINE UA_StatusCode
  283. UA_Client_addMethodNode(UA_Client *client, const UA_NodeId requestedNewNodeId,
  284. const UA_NodeId parentNodeId, const UA_NodeId referenceTypeId,
  285. const UA_QualifiedName browseName, const UA_MethodAttributes attr,
  286. UA_NodeId *outNewNodeId) {
  287. return __UA_Client_addNode(client, UA_NODECLASS_METHOD, requestedNewNodeId,
  288. parentNodeId, referenceTypeId, browseName, UA_NODEID_NULL,
  289. (const UA_NodeAttributes*)&attr, &UA_TYPES[UA_TYPES_METHODATTRIBUTES],
  290. outNewNodeId); }
  291. /**
  292. * .. _client-subscriptions:
  293. *
  294. * Subscriptions Handling
  295. * ======================
  296. *
  297. * At this point, the client does not yet contain its own thread or event-driven
  298. * main-loop. So the client will not perform any actions automatically in the
  299. * background. This is especially relevant for subscriptions. The user will have
  300. * to periodically call `UA_Client_Subscriptions_manuallySendPublishRequest`.
  301. * See also :ref:`here <client-subscriptions>`. */
  302. #ifdef UA_ENABLE_SUBSCRIPTIONS
  303. typedef struct {
  304. UA_Double requestedPublishingInterval;
  305. UA_UInt32 requestedLifetimeCount;
  306. UA_UInt32 requestedMaxKeepAliveCount;
  307. UA_UInt32 maxNotificationsPerPublish;
  308. UA_Boolean publishingEnabled;
  309. UA_Byte priority;
  310. } UA_SubscriptionSettings;
  311. extern const UA_EXPORT UA_SubscriptionSettings UA_SubscriptionSettings_standard;
  312. UA_StatusCode UA_EXPORT
  313. UA_Client_Subscriptions_new(UA_Client *client, UA_SubscriptionSettings settings,
  314. UA_UInt32 *newSubscriptionId);
  315. UA_StatusCode UA_EXPORT
  316. UA_Client_Subscriptions_remove(UA_Client *client, UA_UInt32 subscriptionId);
  317. UA_StatusCode UA_EXPORT UA_Client_Subscriptions_manuallySendPublishRequest(UA_Client *client);
  318. typedef void (*UA_MonitoredItemHandlingFunction) (UA_UInt32 monId, UA_DataValue *value, void *context);
  319. UA_StatusCode UA_EXPORT
  320. UA_Client_Subscriptions_addMonitoredItem(UA_Client *client, UA_UInt32 subscriptionId,
  321. UA_NodeId nodeId, UA_UInt32 attributeID,
  322. UA_MonitoredItemHandlingFunction handlingFunction,
  323. void *handlingContext, UA_UInt32 *newMonitoredItemId);
  324. UA_StatusCode UA_EXPORT
  325. UA_Client_Subscriptions_removeMonitoredItem(UA_Client *client, UA_UInt32 subscriptionId,
  326. UA_UInt32 monitoredItemId);
  327. #endif
  328. /**
  329. * Misc Highlevel Functionality
  330. * ============================ */
  331. /* Get the namespace-index of a namespace-URI
  332. *
  333. * @param client The UA_Client struct for this connection
  334. * @param namespaceUri The interested namespace URI
  335. * @param namespaceIndex The namespace index of the URI. The value is unchanged
  336. * in case of an error
  337. * @return Indicates whether the operation succeeded or returns an error code */
  338. UA_StatusCode UA_EXPORT
  339. UA_Client_NamespaceGetIndex(UA_Client *client, UA_String *namespaceUri, UA_UInt16 *namespaceIndex);
  340. #ifndef HAVE_NODEITER_CALLBACK
  341. #define HAVE_NODEITER_CALLBACK
  342. /* Iterate over all nodes referenced by parentNodeId by calling the callback
  343. function for each child node */
  344. typedef UA_StatusCode (*UA_NodeIteratorCallback)(UA_NodeId childId, UA_Boolean isInverse,
  345. UA_NodeId referenceTypeId, void *handle);
  346. #endif
  347. UA_StatusCode UA_EXPORT
  348. UA_Client_forEachChildNodeCall(UA_Client *client, UA_NodeId parentNodeId,
  349. UA_NodeIteratorCallback callback, void *handle) ;
  350. #ifdef __cplusplus
  351. } // extern "C"
  352. #endif
  353. #endif /* UA_CLIENT_HIGHLEVEL_H_ */