ua_client_highlevel.h 29 KB

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