ua_client_highlevel.h 31 KB

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