ua_client_highlevel.h 28 KB

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