ua_client_highlevel.h 31 KB

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