ua_client_highlevel.h 29 KB

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