ua_client_highlevel.h 29 KB

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