ua_client_highlevel.h 29 KB

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