ua_client_highlevel.h 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594
  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. #include "ua_client.h"
  15. _UA_BEGIN_DECLS
  16. /**
  17. * .. _client-highlevel:
  18. *
  19. * Highlevel Client Functionality
  20. * ------------------------------
  21. *
  22. * The following definitions are convenience functions making use of the
  23. * standard OPC UA services in the background. This is a less flexible way of
  24. * handling the stack, because at many places sensible defaults are presumed; at
  25. * the same time using these functions is the easiest way of implementing an OPC
  26. * UA application, as you will not have to consider all the details that go into
  27. * the OPC UA services. If more flexibility is needed, you can always achieve
  28. * the same functionality using the raw :ref:`OPC UA services
  29. * <client-services>`.
  30. *
  31. * Read Attributes
  32. * ^^^^^^^^^^^^^^^
  33. * The following functions can be used to retrieve a single node attribute. Use
  34. * the regular service to read several attributes at once. */
  35. /* Don't call this function, use the typed versions */
  36. UA_StatusCode UA_EXPORT
  37. __UA_Client_readAttribute(UA_Client *client, const UA_NodeId *nodeId,
  38. UA_AttributeId attributeId, void *out,
  39. const UA_DataType *outDataType);
  40. static UA_INLINE UA_StatusCode
  41. UA_Client_readNodeIdAttribute(UA_Client *client, const UA_NodeId nodeId,
  42. UA_NodeId *outNodeId) {
  43. return __UA_Client_readAttribute(client, &nodeId, UA_ATTRIBUTEID_NODEID,
  44. outNodeId, &UA_TYPES[UA_TYPES_NODEID]);
  45. }
  46. static UA_INLINE UA_StatusCode
  47. UA_Client_readNodeClassAttribute(UA_Client *client, const UA_NodeId nodeId,
  48. UA_NodeClass *outNodeClass) {
  49. return __UA_Client_readAttribute(client, &nodeId, UA_ATTRIBUTEID_NODECLASS,
  50. outNodeClass, &UA_TYPES[UA_TYPES_NODECLASS]);
  51. }
  52. static UA_INLINE UA_StatusCode
  53. UA_Client_readBrowseNameAttribute(UA_Client *client, const UA_NodeId nodeId,
  54. UA_QualifiedName *outBrowseName) {
  55. return __UA_Client_readAttribute(client, &nodeId, UA_ATTRIBUTEID_BROWSENAME,
  56. outBrowseName,
  57. &UA_TYPES[UA_TYPES_QUALIFIEDNAME]);
  58. }
  59. static UA_INLINE UA_StatusCode
  60. UA_Client_readDisplayNameAttribute(UA_Client *client, const UA_NodeId nodeId,
  61. UA_LocalizedText *outDisplayName) {
  62. return __UA_Client_readAttribute(client, &nodeId, UA_ATTRIBUTEID_DISPLAYNAME,
  63. outDisplayName,
  64. &UA_TYPES[UA_TYPES_LOCALIZEDTEXT]);
  65. }
  66. static UA_INLINE UA_StatusCode
  67. UA_Client_readDescriptionAttribute(UA_Client *client, const UA_NodeId nodeId,
  68. UA_LocalizedText *outDescription) {
  69. return __UA_Client_readAttribute(client, &nodeId, UA_ATTRIBUTEID_DESCRIPTION,
  70. outDescription,
  71. &UA_TYPES[UA_TYPES_LOCALIZEDTEXT]);
  72. }
  73. static UA_INLINE UA_StatusCode
  74. UA_Client_readWriteMaskAttribute(UA_Client *client, const UA_NodeId nodeId,
  75. UA_UInt32 *outWriteMask) {
  76. return __UA_Client_readAttribute(client, &nodeId, UA_ATTRIBUTEID_WRITEMASK,
  77. outWriteMask, &UA_TYPES[UA_TYPES_UINT32]);
  78. }
  79. static UA_INLINE UA_StatusCode
  80. UA_Client_readUserWriteMaskAttribute(UA_Client *client, const UA_NodeId nodeId,
  81. UA_UInt32 *outUserWriteMask) {
  82. return __UA_Client_readAttribute(client, &nodeId,
  83. UA_ATTRIBUTEID_USERWRITEMASK,
  84. outUserWriteMask,
  85. &UA_TYPES[UA_TYPES_UINT32]);
  86. }
  87. static UA_INLINE UA_StatusCode
  88. UA_Client_readIsAbstractAttribute(UA_Client *client, const UA_NodeId nodeId,
  89. UA_Boolean *outIsAbstract) {
  90. return __UA_Client_readAttribute(client, &nodeId, UA_ATTRIBUTEID_ISABSTRACT,
  91. outIsAbstract, &UA_TYPES[UA_TYPES_BOOLEAN]);
  92. }
  93. static UA_INLINE UA_StatusCode
  94. UA_Client_readSymmetricAttribute(UA_Client *client, const UA_NodeId nodeId,
  95. UA_Boolean *outSymmetric) {
  96. return __UA_Client_readAttribute(client, &nodeId, UA_ATTRIBUTEID_SYMMETRIC,
  97. outSymmetric, &UA_TYPES[UA_TYPES_BOOLEAN]);
  98. }
  99. static UA_INLINE UA_StatusCode
  100. UA_Client_readInverseNameAttribute(UA_Client *client, const UA_NodeId nodeId,
  101. UA_LocalizedText *outInverseName) {
  102. return __UA_Client_readAttribute(client, &nodeId, UA_ATTRIBUTEID_INVERSENAME,
  103. outInverseName,
  104. &UA_TYPES[UA_TYPES_LOCALIZEDTEXT]);
  105. }
  106. static UA_INLINE UA_StatusCode
  107. UA_Client_readContainsNoLoopsAttribute(UA_Client *client, const UA_NodeId nodeId,
  108. UA_Boolean *outContainsNoLoops) {
  109. return __UA_Client_readAttribute(client, &nodeId,
  110. UA_ATTRIBUTEID_CONTAINSNOLOOPS,
  111. outContainsNoLoops,
  112. &UA_TYPES[UA_TYPES_BOOLEAN]);
  113. }
  114. static UA_INLINE UA_StatusCode
  115. UA_Client_readEventNotifierAttribute(UA_Client *client, const UA_NodeId nodeId,
  116. UA_Byte *outEventNotifier) {
  117. return __UA_Client_readAttribute(client, &nodeId, UA_ATTRIBUTEID_EVENTNOTIFIER,
  118. outEventNotifier, &UA_TYPES[UA_TYPES_BYTE]);
  119. }
  120. static UA_INLINE UA_StatusCode
  121. UA_Client_readValueAttribute(UA_Client *client, const UA_NodeId nodeId,
  122. UA_Variant *outValue) {
  123. return __UA_Client_readAttribute(client, &nodeId, UA_ATTRIBUTEID_VALUE,
  124. outValue, &UA_TYPES[UA_TYPES_VARIANT]);
  125. }
  126. static UA_INLINE UA_StatusCode
  127. UA_Client_readDataTypeAttribute(UA_Client *client, const UA_NodeId nodeId,
  128. UA_NodeId *outDataType) {
  129. return __UA_Client_readAttribute(client, &nodeId, UA_ATTRIBUTEID_DATATYPE,
  130. outDataType, &UA_TYPES[UA_TYPES_NODEID]);
  131. }
  132. static UA_INLINE UA_StatusCode
  133. UA_Client_readValueRankAttribute(UA_Client *client, const UA_NodeId nodeId,
  134. UA_Int32 *outValueRank) {
  135. return __UA_Client_readAttribute(client, &nodeId, UA_ATTRIBUTEID_VALUERANK,
  136. outValueRank, &UA_TYPES[UA_TYPES_INT32]);
  137. }
  138. UA_StatusCode UA_EXPORT
  139. UA_Client_readArrayDimensionsAttribute(UA_Client *client, const UA_NodeId nodeId,
  140. size_t *outArrayDimensionsSize,
  141. UA_UInt32 **outArrayDimensions);
  142. static UA_INLINE UA_StatusCode
  143. UA_Client_readAccessLevelAttribute(UA_Client *client, const UA_NodeId nodeId,
  144. UA_Byte *outAccessLevel) {
  145. return __UA_Client_readAttribute(client, &nodeId, UA_ATTRIBUTEID_ACCESSLEVEL,
  146. outAccessLevel, &UA_TYPES[UA_TYPES_BYTE]);
  147. }
  148. static UA_INLINE UA_StatusCode
  149. UA_Client_readUserAccessLevelAttribute(UA_Client *client, const UA_NodeId nodeId,
  150. UA_Byte *outUserAccessLevel) {
  151. return __UA_Client_readAttribute(client, &nodeId,
  152. UA_ATTRIBUTEID_USERACCESSLEVEL,
  153. outUserAccessLevel,
  154. &UA_TYPES[UA_TYPES_BYTE]);
  155. }
  156. static UA_INLINE UA_StatusCode
  157. UA_Client_readMinimumSamplingIntervalAttribute(UA_Client *client,
  158. const UA_NodeId nodeId,
  159. UA_Double *outMinSamplingInterval) {
  160. return __UA_Client_readAttribute(client, &nodeId,
  161. UA_ATTRIBUTEID_MINIMUMSAMPLINGINTERVAL,
  162. outMinSamplingInterval,
  163. &UA_TYPES[UA_TYPES_DOUBLE]);
  164. }
  165. static UA_INLINE UA_StatusCode
  166. UA_Client_readHistorizingAttribute(UA_Client *client, const UA_NodeId nodeId,
  167. UA_Boolean *outHistorizing) {
  168. return __UA_Client_readAttribute(client, &nodeId, UA_ATTRIBUTEID_HISTORIZING,
  169. outHistorizing, &UA_TYPES[UA_TYPES_BOOLEAN]);
  170. }
  171. static UA_INLINE UA_StatusCode
  172. UA_Client_readExecutableAttribute(UA_Client *client, const UA_NodeId nodeId,
  173. UA_Boolean *outExecutable) {
  174. return __UA_Client_readAttribute(client, &nodeId, UA_ATTRIBUTEID_EXECUTABLE,
  175. outExecutable, &UA_TYPES[UA_TYPES_BOOLEAN]);
  176. }
  177. static UA_INLINE UA_StatusCode
  178. UA_Client_readUserExecutableAttribute(UA_Client *client, const UA_NodeId nodeId,
  179. UA_Boolean *outUserExecutable) {
  180. return __UA_Client_readAttribute(client, &nodeId,
  181. UA_ATTRIBUTEID_USEREXECUTABLE,
  182. outUserExecutable,
  183. &UA_TYPES[UA_TYPES_BOOLEAN]);
  184. }
  185. /**
  186. * Write Attributes
  187. * ^^^^^^^^^^^^^^^^
  188. *
  189. * The following functions can be use to write a single node attribute at a
  190. * time. Use the regular write service to write several attributes at once. */
  191. /* Don't call this function, use the typed versions */
  192. UA_StatusCode UA_EXPORT
  193. __UA_Client_writeAttribute(UA_Client *client, const UA_NodeId *nodeId,
  194. UA_AttributeId attributeId, const void *in,
  195. const UA_DataType *inDataType);
  196. static UA_INLINE UA_StatusCode
  197. UA_Client_writeNodeIdAttribute(UA_Client *client, const UA_NodeId nodeId,
  198. const UA_NodeId *newNodeId) {
  199. return __UA_Client_writeAttribute(client, &nodeId, UA_ATTRIBUTEID_NODEID,
  200. newNodeId, &UA_TYPES[UA_TYPES_NODEID]);
  201. }
  202. static UA_INLINE UA_StatusCode
  203. UA_Client_writeNodeClassAttribute(UA_Client *client, const UA_NodeId nodeId,
  204. const UA_NodeClass *newNodeClass) {
  205. return __UA_Client_writeAttribute(client, &nodeId, UA_ATTRIBUTEID_NODECLASS,
  206. newNodeClass, &UA_TYPES[UA_TYPES_NODECLASS]);
  207. }
  208. static UA_INLINE UA_StatusCode
  209. UA_Client_writeBrowseNameAttribute(UA_Client *client, const UA_NodeId nodeId,
  210. const UA_QualifiedName *newBrowseName) {
  211. return __UA_Client_writeAttribute(client, &nodeId, UA_ATTRIBUTEID_BROWSENAME,
  212. newBrowseName,
  213. &UA_TYPES[UA_TYPES_QUALIFIEDNAME]);
  214. }
  215. static UA_INLINE UA_StatusCode
  216. UA_Client_writeDisplayNameAttribute(UA_Client *client, const UA_NodeId nodeId,
  217. const UA_LocalizedText *newDisplayName) {
  218. return __UA_Client_writeAttribute(client, &nodeId, UA_ATTRIBUTEID_DISPLAYNAME,
  219. newDisplayName,
  220. &UA_TYPES[UA_TYPES_LOCALIZEDTEXT]);
  221. }
  222. static UA_INLINE UA_StatusCode
  223. UA_Client_writeDescriptionAttribute(UA_Client *client, const UA_NodeId nodeId,
  224. const UA_LocalizedText *newDescription) {
  225. return __UA_Client_writeAttribute(client, &nodeId, UA_ATTRIBUTEID_DESCRIPTION,
  226. newDescription,
  227. &UA_TYPES[UA_TYPES_LOCALIZEDTEXT]);
  228. }
  229. static UA_INLINE UA_StatusCode
  230. UA_Client_writeWriteMaskAttribute(UA_Client *client, const UA_NodeId nodeId,
  231. const UA_UInt32 *newWriteMask) {
  232. return __UA_Client_writeAttribute(client, &nodeId, UA_ATTRIBUTEID_WRITEMASK,
  233. newWriteMask, &UA_TYPES[UA_TYPES_UINT32]);
  234. }
  235. static UA_INLINE UA_StatusCode
  236. UA_Client_writeUserWriteMaskAttribute(UA_Client *client, const UA_NodeId nodeId,
  237. const UA_UInt32 *newUserWriteMask) {
  238. return __UA_Client_writeAttribute(client, &nodeId,
  239. UA_ATTRIBUTEID_USERWRITEMASK,
  240. newUserWriteMask,
  241. &UA_TYPES[UA_TYPES_UINT32]);
  242. }
  243. static UA_INLINE UA_StatusCode
  244. UA_Client_writeIsAbstractAttribute(UA_Client *client, const UA_NodeId nodeId,
  245. const UA_Boolean *newIsAbstract) {
  246. return __UA_Client_writeAttribute(client, &nodeId, UA_ATTRIBUTEID_ISABSTRACT,
  247. newIsAbstract, &UA_TYPES[UA_TYPES_BOOLEAN]);
  248. }
  249. static UA_INLINE UA_StatusCode
  250. UA_Client_writeSymmetricAttribute(UA_Client *client, const UA_NodeId nodeId,
  251. const UA_Boolean *newSymmetric) {
  252. return __UA_Client_writeAttribute(client, &nodeId, UA_ATTRIBUTEID_SYMMETRIC,
  253. newSymmetric, &UA_TYPES[UA_TYPES_BOOLEAN]);
  254. }
  255. static UA_INLINE UA_StatusCode
  256. UA_Client_writeInverseNameAttribute(UA_Client *client, const UA_NodeId nodeId,
  257. const UA_LocalizedText *newInverseName) {
  258. return __UA_Client_writeAttribute(client, &nodeId, UA_ATTRIBUTEID_INVERSENAME,
  259. newInverseName,
  260. &UA_TYPES[UA_TYPES_LOCALIZEDTEXT]);
  261. }
  262. static UA_INLINE UA_StatusCode
  263. UA_Client_writeContainsNoLoopsAttribute(UA_Client *client, const UA_NodeId nodeId,
  264. const UA_Boolean *newContainsNoLoops) {
  265. return __UA_Client_writeAttribute(client, &nodeId,
  266. UA_ATTRIBUTEID_CONTAINSNOLOOPS,
  267. newContainsNoLoops,
  268. &UA_TYPES[UA_TYPES_BOOLEAN]);
  269. }
  270. static UA_INLINE UA_StatusCode
  271. UA_Client_writeEventNotifierAttribute(UA_Client *client, const UA_NodeId nodeId,
  272. const UA_Byte *newEventNotifier) {
  273. return __UA_Client_writeAttribute(client, &nodeId,
  274. UA_ATTRIBUTEID_EVENTNOTIFIER,
  275. newEventNotifier,
  276. &UA_TYPES[UA_TYPES_BYTE]);
  277. }
  278. static UA_INLINE UA_StatusCode
  279. UA_Client_writeValueAttribute(UA_Client *client, const UA_NodeId nodeId,
  280. const UA_Variant *newValue) {
  281. return __UA_Client_writeAttribute(client, &nodeId, UA_ATTRIBUTEID_VALUE,
  282. newValue, &UA_TYPES[UA_TYPES_VARIANT]);
  283. }
  284. static UA_INLINE UA_StatusCode
  285. UA_Client_writeDataTypeAttribute(UA_Client *client, const UA_NodeId nodeId,
  286. const UA_NodeId *newDataType) {
  287. return __UA_Client_writeAttribute(client, &nodeId, UA_ATTRIBUTEID_DATATYPE,
  288. newDataType, &UA_TYPES[UA_TYPES_NODEID]);
  289. }
  290. static UA_INLINE UA_StatusCode
  291. UA_Client_writeValueRankAttribute(UA_Client *client, const UA_NodeId nodeId,
  292. const UA_Int32 *newValueRank) {
  293. return __UA_Client_writeAttribute(client, &nodeId, UA_ATTRIBUTEID_VALUERANK,
  294. newValueRank, &UA_TYPES[UA_TYPES_INT32]);
  295. }
  296. UA_StatusCode UA_EXPORT
  297. UA_Client_writeArrayDimensionsAttribute(UA_Client *client, const UA_NodeId nodeId,
  298. size_t newArrayDimensionsSize,
  299. const UA_UInt32 *newArrayDimensions);
  300. static UA_INLINE UA_StatusCode
  301. UA_Client_writeAccessLevelAttribute(UA_Client *client, const UA_NodeId nodeId,
  302. const UA_Byte *newAccessLevel) {
  303. return __UA_Client_writeAttribute(client, &nodeId, UA_ATTRIBUTEID_ACCESSLEVEL,
  304. newAccessLevel, &UA_TYPES[UA_TYPES_BYTE]);
  305. }
  306. static UA_INLINE UA_StatusCode
  307. UA_Client_writeUserAccessLevelAttribute(UA_Client *client, const UA_NodeId nodeId,
  308. const UA_Byte *newUserAccessLevel) {
  309. return __UA_Client_writeAttribute(client, &nodeId,
  310. UA_ATTRIBUTEID_USERACCESSLEVEL,
  311. newUserAccessLevel,
  312. &UA_TYPES[UA_TYPES_BYTE]);
  313. }
  314. static UA_INLINE UA_StatusCode
  315. UA_Client_writeMinimumSamplingIntervalAttribute(UA_Client *client,
  316. const UA_NodeId nodeId,
  317. const UA_Double *newMinInterval) {
  318. return __UA_Client_writeAttribute(client, &nodeId,
  319. UA_ATTRIBUTEID_MINIMUMSAMPLINGINTERVAL,
  320. newMinInterval, &UA_TYPES[UA_TYPES_DOUBLE]);
  321. }
  322. static UA_INLINE UA_StatusCode
  323. UA_Client_writeHistorizingAttribute(UA_Client *client, const UA_NodeId nodeId,
  324. const UA_Boolean *newHistorizing) {
  325. return __UA_Client_writeAttribute(client, &nodeId, UA_ATTRIBUTEID_HISTORIZING,
  326. newHistorizing, &UA_TYPES[UA_TYPES_BOOLEAN]);
  327. }
  328. static UA_INLINE UA_StatusCode
  329. UA_Client_writeExecutableAttribute(UA_Client *client, const UA_NodeId nodeId,
  330. const UA_Boolean *newExecutable) {
  331. return __UA_Client_writeAttribute(client, &nodeId, UA_ATTRIBUTEID_EXECUTABLE,
  332. newExecutable, &UA_TYPES[UA_TYPES_BOOLEAN]);
  333. }
  334. static UA_INLINE UA_StatusCode
  335. UA_Client_writeUserExecutableAttribute(UA_Client *client, const UA_NodeId nodeId,
  336. const UA_Boolean *newUserExecutable) {
  337. return __UA_Client_writeAttribute(client, &nodeId,
  338. UA_ATTRIBUTEID_USEREXECUTABLE,
  339. newUserExecutable,
  340. &UA_TYPES[UA_TYPES_BOOLEAN]);
  341. }
  342. /**
  343. * Method Calling
  344. * ^^^^^^^^^^^^^^ */
  345. #ifdef UA_ENABLE_METHODCALLS
  346. UA_StatusCode UA_EXPORT
  347. UA_Client_call(UA_Client *client, const UA_NodeId objectId,
  348. const UA_NodeId methodId, size_t inputSize, const UA_Variant *input,
  349. size_t *outputSize, UA_Variant **output);
  350. #endif
  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. _UA_END_DECLS
  524. #endif /* UA_CLIENT_HIGHLEVEL_H_ */