ua_client_highlevel.h 29 KB

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