client_highlevel.h 31 KB

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