client_highlevel.h 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656
  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. * Copyright 2018 (c) Fabian Arndt
  12. * Copyright 2018 (c) Peter Rustler, basyskom GmbH
  13. */
  14. #ifndef UA_CLIENT_HIGHLEVEL_H_
  15. #define UA_CLIENT_HIGHLEVEL_H_
  16. #include <open62541/client.h>
  17. _UA_BEGIN_DECLS
  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. * Historical Access
  189. * ^^^^^^^^^^^^^^^^^
  190. * The following functions can be used to read a single node historically.
  191. * Use the regular service to read several nodes at once.
  192. */
  193. #ifdef UA_ENABLE_HISTORIZING
  194. typedef UA_Boolean
  195. (*UA_HistoricalIteratorCallback)(UA_Client *client,
  196. const UA_NodeId *nodeId,
  197. UA_Boolean moreDataAvailable,
  198. const UA_ExtensionObject *data, void *callbackContext);
  199. #ifdef UA_ENABLE_EXPERIMENTAL_HISTORIZING
  200. UA_StatusCode UA_EXPORT
  201. UA_Client_HistoryRead_events(UA_Client *client, const UA_NodeId *nodeId,
  202. const UA_HistoricalIteratorCallback callback,
  203. UA_DateTime startTime, UA_DateTime endTime,
  204. UA_String indexRange, const UA_EventFilter filter, UA_UInt32 numValuesPerNode,
  205. UA_TimestampsToReturn timestampsToReturn, void *callbackContext);
  206. #endif // UA_ENABLE_EXPERIMENTAL_HISTORIZING
  207. UA_StatusCode UA_EXPORT
  208. UA_Client_HistoryRead_raw(UA_Client *client, const UA_NodeId *nodeId,
  209. const UA_HistoricalIteratorCallback callback,
  210. UA_DateTime startTime, UA_DateTime endTime,
  211. UA_String indexRange, UA_Boolean returnBounds, UA_UInt32 numValuesPerNode,
  212. UA_TimestampsToReturn timestampsToReturn, void *callbackContext);
  213. #ifdef UA_ENABLE_EXPERIMENTAL_HISTORIZING
  214. UA_StatusCode UA_EXPORT
  215. UA_Client_HistoryRead_modified(UA_Client *client, const UA_NodeId *nodeId,
  216. const UA_HistoricalIteratorCallback callback,
  217. UA_DateTime startTime, UA_DateTime endTime,
  218. UA_String indexRange, UA_Boolean returnBounds, UA_UInt32 numValuesPerNode,
  219. UA_TimestampsToReturn timestampsToReturn, void *callbackContext);
  220. #endif // UA_ENABLE_EXPERIMENTAL_HISTORIZING
  221. UA_StatusCode UA_EXPORT
  222. UA_Client_HistoryUpdate_insert(UA_Client *client,
  223. const UA_NodeId *nodeId,
  224. UA_DataValue *value);
  225. UA_StatusCode UA_EXPORT
  226. UA_Client_HistoryUpdate_replace(UA_Client *client,
  227. const UA_NodeId *nodeId,
  228. UA_DataValue *value);
  229. UA_StatusCode UA_EXPORT
  230. UA_Client_HistoryUpdate_update(UA_Client *client,
  231. const UA_NodeId *nodeId,
  232. UA_DataValue *value);
  233. UA_StatusCode UA_EXPORT
  234. UA_Client_HistoryUpdate_deleteRaw(UA_Client *client,
  235. const UA_NodeId *nodeId,
  236. UA_DateTime startTimestamp,
  237. UA_DateTime endTimestamp);
  238. #endif // UA_ENABLE_HISTORIZING
  239. /**
  240. * Write Attributes
  241. * ^^^^^^^^^^^^^^^^
  242. *
  243. * The following functions can be use to write a single node attribute at a
  244. * time. Use the regular write service to write several attributes at once. */
  245. /* Don't call this function, use the typed versions */
  246. UA_StatusCode UA_EXPORT
  247. __UA_Client_writeAttribute(UA_Client *client, const UA_NodeId *nodeId,
  248. UA_AttributeId attributeId, const void *in,
  249. const UA_DataType *inDataType);
  250. static UA_INLINE UA_StatusCode
  251. UA_Client_writeNodeIdAttribute(UA_Client *client, const UA_NodeId nodeId,
  252. const UA_NodeId *newNodeId) {
  253. return __UA_Client_writeAttribute(client, &nodeId, UA_ATTRIBUTEID_NODEID,
  254. newNodeId, &UA_TYPES[UA_TYPES_NODEID]);
  255. }
  256. static UA_INLINE UA_StatusCode
  257. UA_Client_writeNodeClassAttribute(UA_Client *client, const UA_NodeId nodeId,
  258. const UA_NodeClass *newNodeClass) {
  259. return __UA_Client_writeAttribute(client, &nodeId, UA_ATTRIBUTEID_NODECLASS,
  260. newNodeClass, &UA_TYPES[UA_TYPES_NODECLASS]);
  261. }
  262. static UA_INLINE UA_StatusCode
  263. UA_Client_writeBrowseNameAttribute(UA_Client *client, const UA_NodeId nodeId,
  264. const UA_QualifiedName *newBrowseName) {
  265. return __UA_Client_writeAttribute(client, &nodeId, UA_ATTRIBUTEID_BROWSENAME,
  266. newBrowseName,
  267. &UA_TYPES[UA_TYPES_QUALIFIEDNAME]);
  268. }
  269. static UA_INLINE UA_StatusCode
  270. UA_Client_writeDisplayNameAttribute(UA_Client *client, const UA_NodeId nodeId,
  271. const UA_LocalizedText *newDisplayName) {
  272. return __UA_Client_writeAttribute(client, &nodeId, UA_ATTRIBUTEID_DISPLAYNAME,
  273. newDisplayName,
  274. &UA_TYPES[UA_TYPES_LOCALIZEDTEXT]);
  275. }
  276. static UA_INLINE UA_StatusCode
  277. UA_Client_writeDescriptionAttribute(UA_Client *client, const UA_NodeId nodeId,
  278. const UA_LocalizedText *newDescription) {
  279. return __UA_Client_writeAttribute(client, &nodeId, UA_ATTRIBUTEID_DESCRIPTION,
  280. newDescription,
  281. &UA_TYPES[UA_TYPES_LOCALIZEDTEXT]);
  282. }
  283. static UA_INLINE UA_StatusCode
  284. UA_Client_writeWriteMaskAttribute(UA_Client *client, const UA_NodeId nodeId,
  285. const UA_UInt32 *newWriteMask) {
  286. return __UA_Client_writeAttribute(client, &nodeId, UA_ATTRIBUTEID_WRITEMASK,
  287. newWriteMask, &UA_TYPES[UA_TYPES_UINT32]);
  288. }
  289. static UA_INLINE UA_StatusCode
  290. UA_Client_writeUserWriteMaskAttribute(UA_Client *client, const UA_NodeId nodeId,
  291. const UA_UInt32 *newUserWriteMask) {
  292. return __UA_Client_writeAttribute(client, &nodeId,
  293. UA_ATTRIBUTEID_USERWRITEMASK,
  294. newUserWriteMask,
  295. &UA_TYPES[UA_TYPES_UINT32]);
  296. }
  297. static UA_INLINE UA_StatusCode
  298. UA_Client_writeIsAbstractAttribute(UA_Client *client, const UA_NodeId nodeId,
  299. const UA_Boolean *newIsAbstract) {
  300. return __UA_Client_writeAttribute(client, &nodeId, UA_ATTRIBUTEID_ISABSTRACT,
  301. newIsAbstract, &UA_TYPES[UA_TYPES_BOOLEAN]);
  302. }
  303. static UA_INLINE UA_StatusCode
  304. UA_Client_writeSymmetricAttribute(UA_Client *client, const UA_NodeId nodeId,
  305. const UA_Boolean *newSymmetric) {
  306. return __UA_Client_writeAttribute(client, &nodeId, UA_ATTRIBUTEID_SYMMETRIC,
  307. newSymmetric, &UA_TYPES[UA_TYPES_BOOLEAN]);
  308. }
  309. static UA_INLINE UA_StatusCode
  310. UA_Client_writeInverseNameAttribute(UA_Client *client, const UA_NodeId nodeId,
  311. const UA_LocalizedText *newInverseName) {
  312. return __UA_Client_writeAttribute(client, &nodeId, UA_ATTRIBUTEID_INVERSENAME,
  313. newInverseName,
  314. &UA_TYPES[UA_TYPES_LOCALIZEDTEXT]);
  315. }
  316. static UA_INLINE UA_StatusCode
  317. UA_Client_writeContainsNoLoopsAttribute(UA_Client *client, const UA_NodeId nodeId,
  318. const UA_Boolean *newContainsNoLoops) {
  319. return __UA_Client_writeAttribute(client, &nodeId,
  320. UA_ATTRIBUTEID_CONTAINSNOLOOPS,
  321. newContainsNoLoops,
  322. &UA_TYPES[UA_TYPES_BOOLEAN]);
  323. }
  324. static UA_INLINE UA_StatusCode
  325. UA_Client_writeEventNotifierAttribute(UA_Client *client, const UA_NodeId nodeId,
  326. const UA_Byte *newEventNotifier) {
  327. return __UA_Client_writeAttribute(client, &nodeId,
  328. UA_ATTRIBUTEID_EVENTNOTIFIER,
  329. newEventNotifier,
  330. &UA_TYPES[UA_TYPES_BYTE]);
  331. }
  332. static UA_INLINE UA_StatusCode
  333. UA_Client_writeValueAttribute(UA_Client *client, const UA_NodeId nodeId,
  334. const UA_Variant *newValue) {
  335. return __UA_Client_writeAttribute(client, &nodeId, UA_ATTRIBUTEID_VALUE,
  336. newValue, &UA_TYPES[UA_TYPES_VARIANT]);
  337. }
  338. static UA_INLINE UA_StatusCode
  339. UA_Client_writeDataTypeAttribute(UA_Client *client, const UA_NodeId nodeId,
  340. const UA_NodeId *newDataType) {
  341. return __UA_Client_writeAttribute(client, &nodeId, UA_ATTRIBUTEID_DATATYPE,
  342. newDataType, &UA_TYPES[UA_TYPES_NODEID]);
  343. }
  344. static UA_INLINE UA_StatusCode
  345. UA_Client_writeValueRankAttribute(UA_Client *client, const UA_NodeId nodeId,
  346. const UA_Int32 *newValueRank) {
  347. return __UA_Client_writeAttribute(client, &nodeId, UA_ATTRIBUTEID_VALUERANK,
  348. newValueRank, &UA_TYPES[UA_TYPES_INT32]);
  349. }
  350. UA_StatusCode UA_EXPORT
  351. UA_Client_writeArrayDimensionsAttribute(UA_Client *client, const UA_NodeId nodeId,
  352. size_t newArrayDimensionsSize,
  353. const UA_UInt32 *newArrayDimensions);
  354. static UA_INLINE UA_StatusCode
  355. UA_Client_writeAccessLevelAttribute(UA_Client *client, const UA_NodeId nodeId,
  356. const UA_Byte *newAccessLevel) {
  357. return __UA_Client_writeAttribute(client, &nodeId, UA_ATTRIBUTEID_ACCESSLEVEL,
  358. newAccessLevel, &UA_TYPES[UA_TYPES_BYTE]);
  359. }
  360. static UA_INLINE UA_StatusCode
  361. UA_Client_writeUserAccessLevelAttribute(UA_Client *client, const UA_NodeId nodeId,
  362. const UA_Byte *newUserAccessLevel) {
  363. return __UA_Client_writeAttribute(client, &nodeId,
  364. UA_ATTRIBUTEID_USERACCESSLEVEL,
  365. newUserAccessLevel,
  366. &UA_TYPES[UA_TYPES_BYTE]);
  367. }
  368. static UA_INLINE UA_StatusCode
  369. UA_Client_writeMinimumSamplingIntervalAttribute(UA_Client *client,
  370. const UA_NodeId nodeId,
  371. const UA_Double *newMinInterval) {
  372. return __UA_Client_writeAttribute(client, &nodeId,
  373. UA_ATTRIBUTEID_MINIMUMSAMPLINGINTERVAL,
  374. newMinInterval, &UA_TYPES[UA_TYPES_DOUBLE]);
  375. }
  376. static UA_INLINE UA_StatusCode
  377. UA_Client_writeHistorizingAttribute(UA_Client *client, const UA_NodeId nodeId,
  378. const UA_Boolean *newHistorizing) {
  379. return __UA_Client_writeAttribute(client, &nodeId, UA_ATTRIBUTEID_HISTORIZING,
  380. newHistorizing, &UA_TYPES[UA_TYPES_BOOLEAN]);
  381. }
  382. static UA_INLINE UA_StatusCode
  383. UA_Client_writeExecutableAttribute(UA_Client *client, const UA_NodeId nodeId,
  384. const UA_Boolean *newExecutable) {
  385. return __UA_Client_writeAttribute(client, &nodeId, UA_ATTRIBUTEID_EXECUTABLE,
  386. newExecutable, &UA_TYPES[UA_TYPES_BOOLEAN]);
  387. }
  388. static UA_INLINE UA_StatusCode
  389. UA_Client_writeUserExecutableAttribute(UA_Client *client, const UA_NodeId nodeId,
  390. const UA_Boolean *newUserExecutable) {
  391. return __UA_Client_writeAttribute(client, &nodeId,
  392. UA_ATTRIBUTEID_USEREXECUTABLE,
  393. newUserExecutable,
  394. &UA_TYPES[UA_TYPES_BOOLEAN]);
  395. }
  396. /**
  397. * Method Calling
  398. * ^^^^^^^^^^^^^^ */
  399. #ifdef UA_ENABLE_METHODCALLS
  400. UA_StatusCode UA_EXPORT
  401. UA_Client_call(UA_Client *client, const UA_NodeId objectId,
  402. const UA_NodeId methodId, size_t inputSize, const UA_Variant *input,
  403. size_t *outputSize, UA_Variant **output);
  404. #endif
  405. /**
  406. * Node Management
  407. * ^^^^^^^^^^^^^^^
  408. * See the section on :ref:`server-side node management <addnodes>`. */
  409. UA_StatusCode UA_EXPORT
  410. UA_Client_addReference(UA_Client *client, const UA_NodeId sourceNodeId,
  411. const UA_NodeId referenceTypeId, UA_Boolean isForward,
  412. const UA_String targetServerUri,
  413. const UA_ExpandedNodeId targetNodeId,
  414. UA_NodeClass targetNodeClass);
  415. UA_StatusCode UA_EXPORT
  416. UA_Client_deleteReference(UA_Client *client, const UA_NodeId sourceNodeId,
  417. const UA_NodeId referenceTypeId, UA_Boolean isForward,
  418. const UA_ExpandedNodeId targetNodeId,
  419. UA_Boolean deleteBidirectional);
  420. UA_StatusCode UA_EXPORT
  421. UA_Client_deleteNode(UA_Client *client, const UA_NodeId nodeId,
  422. UA_Boolean deleteTargetReferences);
  423. /* Protect against redundant definitions for server/client */
  424. #ifndef UA_DEFAULT_ATTRIBUTES_DEFINED
  425. #define UA_DEFAULT_ATTRIBUTES_DEFINED
  426. /* The default for variables is "BaseDataType" for the datatype, -2 for the
  427. * valuerank and a read-accesslevel. */
  428. UA_EXPORT extern const UA_VariableAttributes UA_VariableAttributes_default;
  429. UA_EXPORT extern const UA_VariableTypeAttributes UA_VariableTypeAttributes_default;
  430. /* Methods are executable by default */
  431. UA_EXPORT extern const UA_MethodAttributes UA_MethodAttributes_default;
  432. /* The remaining attribute definitions are currently all zeroed out */
  433. UA_EXPORT extern const UA_ObjectAttributes UA_ObjectAttributes_default;
  434. UA_EXPORT extern const UA_ObjectTypeAttributes UA_ObjectTypeAttributes_default;
  435. UA_EXPORT extern const UA_ReferenceTypeAttributes UA_ReferenceTypeAttributes_default;
  436. UA_EXPORT extern const UA_DataTypeAttributes UA_DataTypeAttributes_default;
  437. UA_EXPORT extern const UA_ViewAttributes UA_ViewAttributes_default;
  438. #endif
  439. /* Don't call this function, use the typed versions */
  440. UA_StatusCode UA_EXPORT
  441. __UA_Client_addNode(UA_Client *client, const UA_NodeClass nodeClass,
  442. const UA_NodeId requestedNewNodeId,
  443. const UA_NodeId parentNodeId,
  444. const UA_NodeId referenceTypeId,
  445. const UA_QualifiedName browseName,
  446. const UA_NodeId typeDefinition, const UA_NodeAttributes *attr,
  447. const UA_DataType *attributeType, UA_NodeId *outNewNodeId);
  448. static UA_INLINE UA_StatusCode
  449. UA_Client_addVariableNode(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_NodeId typeDefinition,
  454. const UA_VariableAttributes attr,
  455. UA_NodeId *outNewNodeId) {
  456. return __UA_Client_addNode(client, UA_NODECLASS_VARIABLE, requestedNewNodeId,
  457. parentNodeId, referenceTypeId, browseName,
  458. typeDefinition, (const UA_NodeAttributes*)&attr,
  459. &UA_TYPES[UA_TYPES_VARIABLEATTRIBUTES],
  460. outNewNodeId);
  461. }
  462. static UA_INLINE UA_StatusCode
  463. UA_Client_addVariableTypeNode(UA_Client *client,
  464. const UA_NodeId requestedNewNodeId,
  465. const UA_NodeId parentNodeId,
  466. const UA_NodeId referenceTypeId,
  467. const UA_QualifiedName browseName,
  468. const UA_VariableTypeAttributes attr,
  469. UA_NodeId *outNewNodeId) {
  470. return __UA_Client_addNode(client, UA_NODECLASS_VARIABLETYPE,
  471. requestedNewNodeId,
  472. parentNodeId, referenceTypeId, browseName,
  473. UA_NODEID_NULL, (const UA_NodeAttributes*)&attr,
  474. &UA_TYPES[UA_TYPES_VARIABLETYPEATTRIBUTES],
  475. outNewNodeId);
  476. }
  477. static UA_INLINE UA_StatusCode
  478. UA_Client_addObjectNode(UA_Client *client, const UA_NodeId requestedNewNodeId,
  479. const UA_NodeId parentNodeId,
  480. const UA_NodeId referenceTypeId,
  481. const UA_QualifiedName browseName,
  482. const UA_NodeId typeDefinition,
  483. const UA_ObjectAttributes attr, UA_NodeId *outNewNodeId) {
  484. return __UA_Client_addNode(client, UA_NODECLASS_OBJECT, requestedNewNodeId,
  485. parentNodeId, referenceTypeId, browseName,
  486. typeDefinition, (const UA_NodeAttributes*)&attr,
  487. &UA_TYPES[UA_TYPES_OBJECTATTRIBUTES], outNewNodeId);
  488. }
  489. static UA_INLINE UA_StatusCode
  490. UA_Client_addObjectTypeNode(UA_Client *client, const UA_NodeId requestedNewNodeId,
  491. const UA_NodeId parentNodeId,
  492. const UA_NodeId referenceTypeId,
  493. const UA_QualifiedName browseName,
  494. const UA_ObjectTypeAttributes attr,
  495. UA_NodeId *outNewNodeId) {
  496. return __UA_Client_addNode(client, UA_NODECLASS_OBJECTTYPE, requestedNewNodeId,
  497. parentNodeId, referenceTypeId, browseName,
  498. UA_NODEID_NULL, (const UA_NodeAttributes*)&attr,
  499. &UA_TYPES[UA_TYPES_OBJECTTYPEATTRIBUTES],
  500. outNewNodeId);
  501. }
  502. static UA_INLINE UA_StatusCode
  503. UA_Client_addViewNode(UA_Client *client, const UA_NodeId requestedNewNodeId,
  504. const UA_NodeId parentNodeId,
  505. const UA_NodeId referenceTypeId,
  506. const UA_QualifiedName browseName,
  507. const UA_ViewAttributes attr,
  508. UA_NodeId *outNewNodeId) {
  509. return __UA_Client_addNode(client, UA_NODECLASS_VIEW, requestedNewNodeId,
  510. parentNodeId, referenceTypeId, browseName,
  511. UA_NODEID_NULL, (const UA_NodeAttributes*)&attr,
  512. &UA_TYPES[UA_TYPES_VIEWATTRIBUTES], outNewNodeId);
  513. }
  514. static UA_INLINE UA_StatusCode
  515. UA_Client_addReferenceTypeNode(UA_Client *client,
  516. const UA_NodeId requestedNewNodeId,
  517. const UA_NodeId parentNodeId,
  518. const UA_NodeId referenceTypeId,
  519. const UA_QualifiedName browseName,
  520. const UA_ReferenceTypeAttributes attr,
  521. UA_NodeId *outNewNodeId) {
  522. return __UA_Client_addNode(client, UA_NODECLASS_REFERENCETYPE,
  523. requestedNewNodeId,
  524. parentNodeId, referenceTypeId, browseName,
  525. UA_NODEID_NULL, (const UA_NodeAttributes*)&attr,
  526. &UA_TYPES[UA_TYPES_REFERENCETYPEATTRIBUTES],
  527. outNewNodeId);
  528. }
  529. static UA_INLINE UA_StatusCode
  530. UA_Client_addDataTypeNode(UA_Client *client, const UA_NodeId requestedNewNodeId,
  531. const UA_NodeId parentNodeId,
  532. const UA_NodeId referenceTypeId,
  533. const UA_QualifiedName browseName,
  534. const UA_DataTypeAttributes attr,
  535. UA_NodeId *outNewNodeId) {
  536. return __UA_Client_addNode(client, UA_NODECLASS_DATATYPE, requestedNewNodeId,
  537. parentNodeId, referenceTypeId, browseName,
  538. UA_NODEID_NULL, (const UA_NodeAttributes*)&attr,
  539. &UA_TYPES[UA_TYPES_DATATYPEATTRIBUTES],
  540. outNewNodeId);
  541. }
  542. static UA_INLINE UA_StatusCode
  543. UA_Client_addMethodNode(UA_Client *client, const UA_NodeId requestedNewNodeId,
  544. const UA_NodeId parentNodeId,
  545. const UA_NodeId referenceTypeId,
  546. const UA_QualifiedName browseName,
  547. const UA_MethodAttributes attr,
  548. UA_NodeId *outNewNodeId) {
  549. return __UA_Client_addNode(client, UA_NODECLASS_METHOD, requestedNewNodeId,
  550. parentNodeId, referenceTypeId, browseName,
  551. UA_NODEID_NULL, (const UA_NodeAttributes*)&attr,
  552. &UA_TYPES[UA_TYPES_METHODATTRIBUTES], outNewNodeId);
  553. }
  554. /**
  555. * Misc Highlevel Functionality
  556. * ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ */
  557. /* Get the namespace-index of a namespace-URI
  558. *
  559. * @param client The UA_Client struct for this connection
  560. * @param namespaceUri The interested namespace URI
  561. * @param namespaceIndex The namespace index of the URI. The value is unchanged
  562. * in case of an error
  563. * @return Indicates whether the operation succeeded or returns an error code */
  564. UA_StatusCode UA_EXPORT
  565. UA_Client_NamespaceGetIndex(UA_Client *client, UA_String *namespaceUri,
  566. UA_UInt16 *namespaceIndex);
  567. #ifndef HAVE_NODEITER_CALLBACK
  568. #define HAVE_NODEITER_CALLBACK
  569. /* Iterate over all nodes referenced by parentNodeId by calling the callback
  570. function for each child node */
  571. typedef UA_StatusCode (*UA_NodeIteratorCallback)(UA_NodeId childId, UA_Boolean isInverse,
  572. UA_NodeId referenceTypeId, void *handle);
  573. #endif
  574. UA_StatusCode UA_EXPORT
  575. UA_Client_forEachChildNodeCall(UA_Client *client, UA_NodeId parentNodeId,
  576. UA_NodeIteratorCallback callback, void *handle) ;
  577. _UA_END_DECLS
  578. #endif /* UA_CLIENT_HIGHLEVEL_H_ */