ua_client_highlevel.h 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626
  1. /* This Source Code Form is subject to the terms of the Mozilla Public
  2. * License, v. 2.0. If a copy of the MPL was not distributed with this
  3. * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  4. #ifndef UA_CLIENT_HIGHLEVEL_H_
  5. #define UA_CLIENT_HIGHLEVEL_H_
  6. #ifdef __cplusplus
  7. extern "C" {
  8. #endif
  9. #include "ua_client.h"
  10. /**
  11. * .. _client-highlevel:
  12. *
  13. * Highlevel Client Functionality
  14. * ------------------------------
  15. *
  16. * The following definitions are convenience functions making use of the
  17. * standard OPC UA services in the background. This is a less flexible way of
  18. * handling the stack, because at many places sensible defaults are presumed; at
  19. * the same time using these functions is the easiest way of implementing an OPC
  20. * UA application, as you will not have to consider all the details that go into
  21. * the OPC UA services. If more flexibility is needed, you can always achieve
  22. * the same functionality using the raw :ref:`OPC UA services
  23. * <client-services>`.
  24. *
  25. * Read Attributes
  26. * ^^^^^^^^^^^^^^^
  27. *
  28. * The following functions can be used to retrieve a single node attribute. Use
  29. * the regular service to read several attributes at once. */
  30. /* Don't call this function, use the typed versions */
  31. UA_StatusCode UA_EXPORT
  32. __UA_Client_readAttribute(UA_Client *client, const UA_NodeId *nodeId,
  33. UA_AttributeId attributeId, void *out,
  34. const UA_DataType *outDataType);
  35. static UA_INLINE UA_StatusCode
  36. UA_Client_readNodeIdAttribute(UA_Client *client, const UA_NodeId nodeId,
  37. UA_NodeId *outNodeId) {
  38. return __UA_Client_readAttribute(client, &nodeId, UA_ATTRIBUTEID_NODEID,
  39. outNodeId, &UA_TYPES[UA_TYPES_NODEID]);
  40. }
  41. static UA_INLINE UA_StatusCode
  42. UA_Client_readNodeClassAttribute(UA_Client *client, const UA_NodeId nodeId,
  43. UA_NodeClass *outNodeClass) {
  44. return __UA_Client_readAttribute(client, &nodeId, UA_ATTRIBUTEID_NODECLASS,
  45. outNodeClass, &UA_TYPES[UA_TYPES_NODECLASS]);
  46. }
  47. static UA_INLINE UA_StatusCode
  48. UA_Client_readBrowseNameAttribute(UA_Client *client, const UA_NodeId nodeId,
  49. UA_QualifiedName *outBrowseName) {
  50. return __UA_Client_readAttribute(client, &nodeId, UA_ATTRIBUTEID_BROWSENAME,
  51. outBrowseName,
  52. &UA_TYPES[UA_TYPES_QUALIFIEDNAME]);
  53. }
  54. static UA_INLINE UA_StatusCode
  55. UA_Client_readDisplayNameAttribute(UA_Client *client, const UA_NodeId nodeId,
  56. UA_LocalizedText *outDisplayName) {
  57. return __UA_Client_readAttribute(client, &nodeId, UA_ATTRIBUTEID_DISPLAYNAME,
  58. outDisplayName,
  59. &UA_TYPES[UA_TYPES_LOCALIZEDTEXT]);
  60. }
  61. static UA_INLINE UA_StatusCode
  62. UA_Client_readDescriptionAttribute(UA_Client *client, const UA_NodeId nodeId,
  63. UA_LocalizedText *outDescription) {
  64. return __UA_Client_readAttribute(client, &nodeId, UA_ATTRIBUTEID_DESCRIPTION,
  65. outDescription,
  66. &UA_TYPES[UA_TYPES_LOCALIZEDTEXT]);
  67. }
  68. static UA_INLINE UA_StatusCode
  69. UA_Client_readWriteMaskAttribute(UA_Client *client, const UA_NodeId nodeId,
  70. UA_UInt32 *outWriteMask) {
  71. return __UA_Client_readAttribute(client, &nodeId, UA_ATTRIBUTEID_WRITEMASK,
  72. outWriteMask, &UA_TYPES[UA_TYPES_UINT32]);
  73. }
  74. static UA_INLINE UA_StatusCode
  75. UA_Client_readUserWriteMaskAttribute(UA_Client *client, const UA_NodeId nodeId,
  76. UA_UInt32 *outUserWriteMask) {
  77. return __UA_Client_readAttribute(client, &nodeId,
  78. UA_ATTRIBUTEID_USERWRITEMASK,
  79. outUserWriteMask,
  80. &UA_TYPES[UA_TYPES_UINT32]);
  81. }
  82. static UA_INLINE UA_StatusCode
  83. UA_Client_readIsAbstractAttribute(UA_Client *client, const UA_NodeId nodeId,
  84. UA_Boolean *outIsAbstract) {
  85. return __UA_Client_readAttribute(client, &nodeId, UA_ATTRIBUTEID_ISABSTRACT,
  86. outIsAbstract, &UA_TYPES[UA_TYPES_BOOLEAN]);
  87. }
  88. static UA_INLINE UA_StatusCode
  89. UA_Client_readSymmetricAttribute(UA_Client *client, const UA_NodeId nodeId,
  90. UA_Boolean *outSymmetric) {
  91. return __UA_Client_readAttribute(client, &nodeId, UA_ATTRIBUTEID_SYMMETRIC,
  92. outSymmetric, &UA_TYPES[UA_TYPES_BOOLEAN]);
  93. }
  94. static UA_INLINE UA_StatusCode
  95. UA_Client_readInverseNameAttribute(UA_Client *client, const UA_NodeId nodeId,
  96. UA_LocalizedText *outInverseName) {
  97. return __UA_Client_readAttribute(client, &nodeId, UA_ATTRIBUTEID_INVERSENAME,
  98. outInverseName,
  99. &UA_TYPES[UA_TYPES_LOCALIZEDTEXT]);
  100. }
  101. static UA_INLINE UA_StatusCode
  102. UA_Client_readContainsNoLoopsAttribute(UA_Client *client, const UA_NodeId nodeId,
  103. UA_Boolean *outContainsNoLoops) {
  104. return __UA_Client_readAttribute(client, &nodeId,
  105. UA_ATTRIBUTEID_CONTAINSNOLOOPS,
  106. outContainsNoLoops,
  107. &UA_TYPES[UA_TYPES_BOOLEAN]);
  108. }
  109. static UA_INLINE UA_StatusCode
  110. UA_Client_readEventNotifierAttribute(UA_Client *client, const UA_NodeId nodeId,
  111. UA_Byte *outEventNotifier) {
  112. return __UA_Client_readAttribute(client, &nodeId, UA_ATTRIBUTEID_EVENTNOTIFIER,
  113. outEventNotifier, &UA_TYPES[UA_TYPES_BYTE]);
  114. }
  115. static UA_INLINE UA_StatusCode
  116. UA_Client_readValueAttribute(UA_Client *client, const UA_NodeId nodeId,
  117. UA_Variant *outValue) {
  118. return __UA_Client_readAttribute(client, &nodeId, UA_ATTRIBUTEID_VALUE,
  119. outValue, &UA_TYPES[UA_TYPES_VARIANT]);
  120. }
  121. static UA_INLINE UA_StatusCode
  122. UA_Client_readDataTypeAttribute(UA_Client *client, const UA_NodeId nodeId,
  123. UA_NodeId *outDataType) {
  124. return __UA_Client_readAttribute(client, &nodeId, UA_ATTRIBUTEID_DATATYPE,
  125. outDataType, &UA_TYPES[UA_TYPES_NODEID]);
  126. }
  127. static UA_INLINE UA_StatusCode
  128. UA_Client_readValueRankAttribute(UA_Client *client, const UA_NodeId nodeId,
  129. UA_Int32 *outValueRank) {
  130. return __UA_Client_readAttribute(client, &nodeId, UA_ATTRIBUTEID_VALUERANK,
  131. outValueRank, &UA_TYPES[UA_TYPES_INT32]);
  132. }
  133. UA_StatusCode UA_EXPORT
  134. UA_Client_readArrayDimensionsAttribute(UA_Client *client, const UA_NodeId nodeId,
  135. UA_Int32 **outArrayDimensions,
  136. size_t *outArrayDimensionsSize);
  137. static UA_INLINE UA_StatusCode
  138. UA_Client_readAccessLevelAttribute(UA_Client *client, const UA_NodeId nodeId,
  139. UA_Byte *outAccessLevel) {
  140. return __UA_Client_readAttribute(client, &nodeId, UA_ATTRIBUTEID_ACCESSLEVEL,
  141. outAccessLevel, &UA_TYPES[UA_TYPES_BYTE]);
  142. }
  143. static UA_INLINE UA_StatusCode
  144. UA_Client_readUserAccessLevelAttribute(UA_Client *client, const UA_NodeId nodeId,
  145. UA_Byte *outUserAccessLevel) {
  146. return __UA_Client_readAttribute(client, &nodeId,
  147. UA_ATTRIBUTEID_USERACCESSLEVEL,
  148. outUserAccessLevel,
  149. &UA_TYPES[UA_TYPES_BYTE]);
  150. }
  151. static UA_INLINE UA_StatusCode
  152. UA_Client_readMinimumSamplingIntervalAttribute(UA_Client *client,
  153. const UA_NodeId nodeId,
  154. UA_Double *outMinSamplingInterval) {
  155. return __UA_Client_readAttribute(client, &nodeId,
  156. UA_ATTRIBUTEID_MINIMUMSAMPLINGINTERVAL,
  157. outMinSamplingInterval,
  158. &UA_TYPES[UA_TYPES_DOUBLE]);
  159. }
  160. static UA_INLINE UA_StatusCode
  161. UA_Client_readHistorizingAttribute(UA_Client *client, const UA_NodeId nodeId,
  162. UA_Boolean *outHistorizing) {
  163. return __UA_Client_readAttribute(client, &nodeId, UA_ATTRIBUTEID_HISTORIZING,
  164. outHistorizing, &UA_TYPES[UA_TYPES_BOOLEAN]);
  165. }
  166. static UA_INLINE UA_StatusCode
  167. UA_Client_readExecutableAttribute(UA_Client *client, const UA_NodeId nodeId,
  168. UA_Boolean *outExecutable) {
  169. return __UA_Client_readAttribute(client, &nodeId, UA_ATTRIBUTEID_EXECUTABLE,
  170. outExecutable, &UA_TYPES[UA_TYPES_BOOLEAN]);
  171. }
  172. static UA_INLINE UA_StatusCode
  173. UA_Client_readUserExecutableAttribute(UA_Client *client, const UA_NodeId nodeId,
  174. UA_Boolean *outUserExecutable) {
  175. return __UA_Client_readAttribute(client, &nodeId,
  176. UA_ATTRIBUTEID_USEREXECUTABLE,
  177. outUserExecutable,
  178. &UA_TYPES[UA_TYPES_BOOLEAN]);
  179. }
  180. /**
  181. * Write Attributes
  182. * ^^^^^^^^^^^^^^^^
  183. *
  184. * The following functions can be use to write a single node attribute at a
  185. * time. Use the regular write service to write several attributes at once. */
  186. /* Don't call this function, use the typed versions */
  187. UA_StatusCode UA_EXPORT
  188. __UA_Client_writeAttribute(UA_Client *client, const UA_NodeId *nodeId,
  189. UA_AttributeId attributeId, const void *in,
  190. const UA_DataType *inDataType);
  191. static UA_INLINE UA_StatusCode
  192. UA_Client_writeNodeIdAttribute(UA_Client *client, const UA_NodeId nodeId,
  193. const UA_NodeId *newNodeId) {
  194. return __UA_Client_writeAttribute(client, &nodeId, UA_ATTRIBUTEID_NODEID,
  195. newNodeId, &UA_TYPES[UA_TYPES_NODEID]);
  196. }
  197. static UA_INLINE UA_StatusCode
  198. UA_Client_writeNodeClassAttribute(UA_Client *client, const UA_NodeId nodeId,
  199. const UA_NodeClass *newNodeClass) {
  200. return __UA_Client_writeAttribute(client, &nodeId, UA_ATTRIBUTEID_NODECLASS,
  201. newNodeClass, &UA_TYPES[UA_TYPES_NODECLASS]);
  202. }
  203. static UA_INLINE UA_StatusCode
  204. UA_Client_writeBrowseNameAttribute(UA_Client *client, const UA_NodeId nodeId,
  205. const UA_QualifiedName *newBrowseName) {
  206. return __UA_Client_writeAttribute(client, &nodeId, UA_ATTRIBUTEID_BROWSENAME,
  207. newBrowseName,
  208. &UA_TYPES[UA_TYPES_QUALIFIEDNAME]);
  209. }
  210. static UA_INLINE UA_StatusCode
  211. UA_Client_writeDisplayNameAttribute(UA_Client *client, const UA_NodeId nodeId,
  212. const UA_LocalizedText *newDisplayName) {
  213. return __UA_Client_writeAttribute(client, &nodeId, UA_ATTRIBUTEID_DISPLAYNAME,
  214. newDisplayName,
  215. &UA_TYPES[UA_TYPES_LOCALIZEDTEXT]);
  216. }
  217. static UA_INLINE UA_StatusCode
  218. UA_Client_writeDescriptionAttribute(UA_Client *client, const UA_NodeId nodeId,
  219. const UA_LocalizedText *newDescription) {
  220. return __UA_Client_writeAttribute(client, &nodeId, UA_ATTRIBUTEID_DESCRIPTION,
  221. newDescription,
  222. &UA_TYPES[UA_TYPES_LOCALIZEDTEXT]);
  223. }
  224. static UA_INLINE UA_StatusCode
  225. UA_Client_writeWriteMaskAttribute(UA_Client *client, const UA_NodeId nodeId,
  226. const UA_UInt32 *newWriteMask) {
  227. return __UA_Client_writeAttribute(client, &nodeId, UA_ATTRIBUTEID_WRITEMASK,
  228. newWriteMask, &UA_TYPES[UA_TYPES_UINT32]);
  229. }
  230. static UA_INLINE UA_StatusCode
  231. UA_Client_writeUserWriteMaskAttribute(UA_Client *client, const UA_NodeId nodeId,
  232. const UA_UInt32 *newUserWriteMask) {
  233. return __UA_Client_writeAttribute(client, &nodeId,
  234. UA_ATTRIBUTEID_USERWRITEMASK,
  235. newUserWriteMask,
  236. &UA_TYPES[UA_TYPES_UINT32]);
  237. }
  238. static UA_INLINE UA_StatusCode
  239. UA_Client_writeIsAbstractAttribute(UA_Client *client, const UA_NodeId nodeId,
  240. const UA_Boolean *newIsAbstract) {
  241. return __UA_Client_writeAttribute(client, &nodeId, UA_ATTRIBUTEID_ISABSTRACT,
  242. newIsAbstract, &UA_TYPES[UA_TYPES_BOOLEAN]);
  243. }
  244. static UA_INLINE UA_StatusCode
  245. UA_Client_writeSymmetricAttribute(UA_Client *client, const UA_NodeId nodeId,
  246. const UA_Boolean *newSymmetric) {
  247. return __UA_Client_writeAttribute(client, &nodeId, UA_ATTRIBUTEID_SYMMETRIC,
  248. newSymmetric, &UA_TYPES[UA_TYPES_BOOLEAN]);
  249. }
  250. static UA_INLINE UA_StatusCode
  251. UA_Client_writeInverseNameAttribute(UA_Client *client, const UA_NodeId nodeId,
  252. const UA_LocalizedText *newInverseName) {
  253. return __UA_Client_writeAttribute(client, &nodeId, UA_ATTRIBUTEID_INVERSENAME,
  254. newInverseName,
  255. &UA_TYPES[UA_TYPES_LOCALIZEDTEXT]);
  256. }
  257. static UA_INLINE UA_StatusCode
  258. UA_Client_writeContainsNoLoopsAttribute(UA_Client *client, const UA_NodeId nodeId,
  259. const UA_Boolean *newContainsNoLoops) {
  260. return __UA_Client_writeAttribute(client, &nodeId,
  261. UA_ATTRIBUTEID_CONTAINSNOLOOPS,
  262. newContainsNoLoops,
  263. &UA_TYPES[UA_TYPES_BOOLEAN]);
  264. }
  265. static UA_INLINE UA_StatusCode
  266. UA_Client_writeEventNotifierAttribute(UA_Client *client, const UA_NodeId nodeId,
  267. const UA_Byte *newEventNotifier) {
  268. return __UA_Client_writeAttribute(client, &nodeId,
  269. UA_ATTRIBUTEID_EVENTNOTIFIER,
  270. newEventNotifier,
  271. &UA_TYPES[UA_TYPES_BYTE]);
  272. }
  273. static UA_INLINE UA_StatusCode
  274. UA_Client_writeValueAttribute(UA_Client *client, const UA_NodeId nodeId,
  275. const UA_Variant *newValue) {
  276. return __UA_Client_writeAttribute(client, &nodeId, UA_ATTRIBUTEID_VALUE,
  277. newValue, &UA_TYPES[UA_TYPES_VARIANT]);
  278. }
  279. static UA_INLINE UA_StatusCode
  280. UA_Client_writeDataTypeAttribute(UA_Client *client, const UA_NodeId nodeId,
  281. const UA_NodeId *newDataType) {
  282. return __UA_Client_writeAttribute(client, &nodeId, UA_ATTRIBUTEID_DATATYPE,
  283. newDataType, &UA_TYPES[UA_TYPES_NODEID]);
  284. }
  285. static UA_INLINE UA_StatusCode
  286. UA_Client_writeValueRankAttribute(UA_Client *client, const UA_NodeId nodeId,
  287. const UA_Int32 *newValueRank) {
  288. return __UA_Client_writeAttribute(client, &nodeId, UA_ATTRIBUTEID_VALUERANK,
  289. newValueRank, &UA_TYPES[UA_TYPES_INT32]);
  290. }
  291. UA_StatusCode UA_EXPORT
  292. UA_Client_writeArrayDimensionsAttribute(UA_Client *client, const UA_NodeId nodeId,
  293. const UA_Int32 *newArrayDimensions,
  294. size_t newArrayDimensionsSize);
  295. static UA_INLINE UA_StatusCode
  296. UA_Client_writeAccessLevelAttribute(UA_Client *client, const UA_NodeId nodeId,
  297. const UA_Byte *newAccessLevel) {
  298. return __UA_Client_writeAttribute(client, &nodeId, UA_ATTRIBUTEID_ACCESSLEVEL,
  299. newAccessLevel, &UA_TYPES[UA_TYPES_BYTE]);
  300. }
  301. static UA_INLINE UA_StatusCode
  302. UA_Client_writeUserAccessLevelAttribute(UA_Client *client, const UA_NodeId nodeId,
  303. const UA_Byte *newUserAccessLevel) {
  304. return __UA_Client_writeAttribute(client, &nodeId,
  305. UA_ATTRIBUTEID_USERACCESSLEVEL,
  306. newUserAccessLevel,
  307. &UA_TYPES[UA_TYPES_BYTE]);
  308. }
  309. static UA_INLINE UA_StatusCode
  310. UA_Client_writeMinimumSamplingIntervalAttribute(UA_Client *client,
  311. const UA_NodeId nodeId,
  312. const UA_Double *newMinInterval) {
  313. return __UA_Client_writeAttribute(client, &nodeId,
  314. UA_ATTRIBUTEID_MINIMUMSAMPLINGINTERVAL,
  315. newMinInterval, &UA_TYPES[UA_TYPES_DOUBLE]);
  316. }
  317. static UA_INLINE UA_StatusCode
  318. UA_Client_writeHistorizingAttribute(UA_Client *client, const UA_NodeId nodeId,
  319. const UA_Boolean *newHistorizing) {
  320. return __UA_Client_writeAttribute(client, &nodeId, UA_ATTRIBUTEID_HISTORIZING,
  321. newHistorizing, &UA_TYPES[UA_TYPES_BOOLEAN]);
  322. }
  323. static UA_INLINE UA_StatusCode
  324. UA_Client_writeExecutableAttribute(UA_Client *client, const UA_NodeId nodeId,
  325. const UA_Boolean *newExecutable) {
  326. return __UA_Client_writeAttribute(client, &nodeId, UA_ATTRIBUTEID_EXECUTABLE,
  327. newExecutable, &UA_TYPES[UA_TYPES_BOOLEAN]);
  328. }
  329. static UA_INLINE UA_StatusCode
  330. UA_Client_writeUserExecutableAttribute(UA_Client *client, const UA_NodeId nodeId,
  331. const UA_Boolean *newUserExecutable) {
  332. return __UA_Client_writeAttribute(client, &nodeId,
  333. UA_ATTRIBUTEID_USEREXECUTABLE,
  334. newUserExecutable,
  335. &UA_TYPES[UA_TYPES_BOOLEAN]);
  336. }
  337. /**
  338. * Method Calling
  339. * ^^^^^^^^^^^^^^ */
  340. UA_StatusCode UA_EXPORT
  341. UA_Client_call(UA_Client *client, const UA_NodeId objectId,
  342. const UA_NodeId methodId, size_t inputSize, const UA_Variant *input,
  343. size_t *outputSize, UA_Variant **output);
  344. /**
  345. * Node Management
  346. * ^^^^^^^^^^^^^^^
  347. * See the section on :ref:`server-side node management <addnodes>`. */
  348. UA_StatusCode UA_EXPORT
  349. UA_Client_addReference(UA_Client *client, const UA_NodeId sourceNodeId,
  350. const UA_NodeId referenceTypeId, UA_Boolean isForward,
  351. const UA_String targetServerUri,
  352. const UA_ExpandedNodeId targetNodeId,
  353. UA_NodeClass targetNodeClass);
  354. UA_StatusCode UA_EXPORT
  355. UA_Client_deleteReference(UA_Client *client, const UA_NodeId sourceNodeId,
  356. const UA_NodeId referenceTypeId, UA_Boolean isForward,
  357. const UA_ExpandedNodeId targetNodeId,
  358. UA_Boolean deleteBidirectional);
  359. UA_StatusCode UA_EXPORT
  360. UA_Client_deleteNode(UA_Client *client, const UA_NodeId nodeId,
  361. UA_Boolean deleteTargetReferences);
  362. /* Don't call this function, use the typed versions */
  363. UA_StatusCode UA_EXPORT
  364. __UA_Client_addNode(UA_Client *client, const UA_NodeClass nodeClass,
  365. const UA_NodeId requestedNewNodeId,
  366. const UA_NodeId parentNodeId,
  367. const UA_NodeId referenceTypeId,
  368. const UA_QualifiedName browseName,
  369. const UA_NodeId typeDefinition, const UA_NodeAttributes *attr,
  370. const UA_DataType *attributeType, UA_NodeId *outNewNodeId);
  371. static UA_INLINE UA_StatusCode
  372. UA_Client_addVariableNode(UA_Client *client, const UA_NodeId requestedNewNodeId,
  373. const UA_NodeId parentNodeId,
  374. const UA_NodeId referenceTypeId,
  375. const UA_QualifiedName browseName,
  376. const UA_NodeId typeDefinition,
  377. const UA_VariableAttributes attr,
  378. UA_NodeId *outNewNodeId) {
  379. return __UA_Client_addNode(client, UA_NODECLASS_VARIABLE, requestedNewNodeId,
  380. parentNodeId, referenceTypeId, browseName,
  381. typeDefinition, (const UA_NodeAttributes*)&attr,
  382. &UA_TYPES[UA_TYPES_VARIABLEATTRIBUTES],
  383. outNewNodeId);
  384. }
  385. static UA_INLINE UA_StatusCode
  386. UA_Client_addVariableTypeNode(UA_Client *client,
  387. const UA_NodeId requestedNewNodeId,
  388. const UA_NodeId parentNodeId,
  389. const UA_NodeId referenceTypeId,
  390. const UA_QualifiedName browseName,
  391. const UA_VariableTypeAttributes attr,
  392. UA_NodeId *outNewNodeId) {
  393. return __UA_Client_addNode(client, UA_NODECLASS_VARIABLETYPE,
  394. requestedNewNodeId,
  395. parentNodeId, referenceTypeId, browseName,
  396. UA_NODEID_NULL, (const UA_NodeAttributes*)&attr,
  397. &UA_TYPES[UA_TYPES_VARIABLETYPEATTRIBUTES],
  398. outNewNodeId);
  399. }
  400. static UA_INLINE UA_StatusCode
  401. UA_Client_addObjectNode(UA_Client *client, const UA_NodeId requestedNewNodeId,
  402. const UA_NodeId parentNodeId,
  403. const UA_NodeId referenceTypeId,
  404. const UA_QualifiedName browseName,
  405. const UA_NodeId typeDefinition,
  406. const UA_ObjectAttributes attr, UA_NodeId *outNewNodeId) {
  407. return __UA_Client_addNode(client, UA_NODECLASS_OBJECT, requestedNewNodeId,
  408. parentNodeId, referenceTypeId, browseName,
  409. typeDefinition, (const UA_NodeAttributes*)&attr,
  410. &UA_TYPES[UA_TYPES_OBJECTATTRIBUTES], outNewNodeId);
  411. }
  412. static UA_INLINE UA_StatusCode
  413. UA_Client_addObjectTypeNode(UA_Client *client, const UA_NodeId requestedNewNodeId,
  414. const UA_NodeId parentNodeId,
  415. const UA_NodeId referenceTypeId,
  416. const UA_QualifiedName browseName,
  417. const UA_ObjectTypeAttributes attr,
  418. UA_NodeId *outNewNodeId) {
  419. return __UA_Client_addNode(client, UA_NODECLASS_OBJECTTYPE, requestedNewNodeId,
  420. parentNodeId, referenceTypeId, browseName,
  421. UA_NODEID_NULL, (const UA_NodeAttributes*)&attr,
  422. &UA_TYPES[UA_TYPES_OBJECTTYPEATTRIBUTES],
  423. outNewNodeId);
  424. }
  425. static UA_INLINE UA_StatusCode
  426. UA_Client_addViewNode(UA_Client *client, const UA_NodeId requestedNewNodeId,
  427. const UA_NodeId parentNodeId,
  428. const UA_NodeId referenceTypeId,
  429. const UA_QualifiedName browseName,
  430. const UA_ViewAttributes attr,
  431. UA_NodeId *outNewNodeId) {
  432. return __UA_Client_addNode(client, UA_NODECLASS_VIEW, requestedNewNodeId,
  433. parentNodeId, referenceTypeId, browseName,
  434. UA_NODEID_NULL, (const UA_NodeAttributes*)&attr,
  435. &UA_TYPES[UA_TYPES_VIEWATTRIBUTES], outNewNodeId);
  436. }
  437. static UA_INLINE UA_StatusCode
  438. UA_Client_addReferenceTypeNode(UA_Client *client,
  439. const UA_NodeId requestedNewNodeId,
  440. const UA_NodeId parentNodeId,
  441. const UA_NodeId referenceTypeId,
  442. const UA_QualifiedName browseName,
  443. const UA_ReferenceTypeAttributes attr,
  444. UA_NodeId *outNewNodeId) {
  445. return __UA_Client_addNode(client, UA_NODECLASS_REFERENCETYPE,
  446. requestedNewNodeId,
  447. parentNodeId, referenceTypeId, browseName,
  448. UA_NODEID_NULL, (const UA_NodeAttributes*)&attr,
  449. &UA_TYPES[UA_TYPES_REFERENCETYPEATTRIBUTES],
  450. outNewNodeId);
  451. }
  452. static UA_INLINE UA_StatusCode
  453. UA_Client_addDataTypeNode(UA_Client *client, const UA_NodeId requestedNewNodeId,
  454. const UA_NodeId parentNodeId,
  455. const UA_NodeId referenceTypeId,
  456. const UA_QualifiedName browseName,
  457. const UA_DataTypeAttributes attr,
  458. UA_NodeId *outNewNodeId) {
  459. return __UA_Client_addNode(client, UA_NODECLASS_DATATYPE, requestedNewNodeId,
  460. parentNodeId, referenceTypeId, browseName,
  461. UA_NODEID_NULL, (const UA_NodeAttributes*)&attr,
  462. &UA_TYPES[UA_TYPES_DATATYPEATTRIBUTES],
  463. outNewNodeId);
  464. }
  465. static UA_INLINE UA_StatusCode
  466. UA_Client_addMethodNode(UA_Client *client, const UA_NodeId requestedNewNodeId,
  467. const UA_NodeId parentNodeId,
  468. const UA_NodeId referenceTypeId,
  469. const UA_QualifiedName browseName,
  470. const UA_MethodAttributes attr,
  471. UA_NodeId *outNewNodeId) {
  472. return __UA_Client_addNode(client, UA_NODECLASS_METHOD, requestedNewNodeId,
  473. parentNodeId, referenceTypeId, browseName,
  474. UA_NODEID_NULL, (const UA_NodeAttributes*)&attr,
  475. &UA_TYPES[UA_TYPES_METHODATTRIBUTES], outNewNodeId);
  476. }
  477. /**
  478. * .. _client-subscriptions:
  479. *
  480. * Subscriptions Handling
  481. * ^^^^^^^^^^^^^^^^^^^^^^
  482. * At this time, the client does not yet contain its own thread or event-driven
  483. * main-loop. So the client will not perform any actions automatically in the
  484. * background. This is especially relevant for subscriptions. The user will have
  485. * to periodically call `UA_Client_Subscriptions_manuallySendPublishRequest`.
  486. * See also :ref:`here <client-subscriptions>`. */
  487. #ifdef UA_ENABLE_SUBSCRIPTIONS
  488. typedef struct {
  489. UA_Double requestedPublishingInterval;
  490. UA_UInt32 requestedLifetimeCount;
  491. UA_UInt32 requestedMaxKeepAliveCount;
  492. UA_UInt32 maxNotificationsPerPublish;
  493. UA_Boolean publishingEnabled;
  494. UA_Byte priority;
  495. } UA_SubscriptionSettings;
  496. extern const UA_EXPORT UA_SubscriptionSettings UA_SubscriptionSettings_standard;
  497. UA_StatusCode UA_EXPORT
  498. UA_Client_Subscriptions_new(UA_Client *client, UA_SubscriptionSettings settings,
  499. UA_UInt32 *newSubscriptionId);
  500. UA_StatusCode UA_EXPORT
  501. UA_Client_Subscriptions_remove(UA_Client *client, UA_UInt32 subscriptionId);
  502. UA_StatusCode UA_EXPORT
  503. UA_Client_Subscriptions_manuallySendPublishRequest(UA_Client *client);
  504. typedef void (*UA_MonitoredItemHandlingFunction)(UA_UInt32 monId,
  505. UA_DataValue *value,
  506. void *context);
  507. UA_StatusCode UA_EXPORT
  508. UA_Client_Subscriptions_addMonitoredItem(UA_Client *client,
  509. UA_UInt32 subscriptionId,
  510. UA_NodeId nodeId, UA_UInt32 attributeID,
  511. UA_MonitoredItemHandlingFunction hf,
  512. void *hfContext,
  513. UA_UInt32 *newMonitoredItemId);
  514. UA_StatusCode UA_EXPORT
  515. UA_Client_Subscriptions_removeMonitoredItem(UA_Client *client,
  516. UA_UInt32 subscriptionId,
  517. UA_UInt32 monitoredItemId);
  518. #endif
  519. /**
  520. * Misc Highlevel Functionality
  521. * ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ */
  522. /* Get the namespace-index of a namespace-URI
  523. *
  524. * @param client The UA_Client struct for this connection
  525. * @param namespaceUri The interested namespace URI
  526. * @param namespaceIndex The namespace index of the URI. The value is unchanged
  527. * in case of an error
  528. * @return Indicates whether the operation succeeded or returns an error code */
  529. UA_StatusCode UA_EXPORT
  530. UA_Client_NamespaceGetIndex(UA_Client *client, UA_String *namespaceUri,
  531. UA_UInt16 *namespaceIndex);
  532. #ifndef HAVE_NODEITER_CALLBACK
  533. #define HAVE_NODEITER_CALLBACK
  534. /* Iterate over all nodes referenced by parentNodeId by calling the callback
  535. function for each child node */
  536. typedef UA_StatusCode (*UA_NodeIteratorCallback)(UA_NodeId childId,
  537. UA_Boolean isInverse,
  538. UA_NodeId referenceTypeId,
  539. void *handle);
  540. #endif
  541. UA_StatusCode UA_EXPORT
  542. UA_Client_forEachChildNodeCall(UA_Client *client, UA_NodeId parentNodeId,
  543. UA_NodeIteratorCallback callback, void *handle) ;
  544. #ifdef __cplusplus
  545. } // extern "C"
  546. #endif
  547. #endif /* UA_CLIENT_HIGHLEVEL_H_ */