server.h 67 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462
  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 2014-2017 (c) Fraunhofer IOSB (Author: Julius Pfrommer)
  6. * Copyright 2015-2016 (c) Sten Grüner
  7. * Copyright 2014-2015, 2017 (c) Florian Palm
  8. * Copyright 2015-2016 (c) Chris Iatrou
  9. * Copyright 2015-2016 (c) Oleksiy Vasylyev
  10. * Copyright 2016-2017 (c) Stefan Profanter, fortiss GmbH
  11. */
  12. #ifndef UA_SERVER_H_
  13. #define UA_SERVER_H_
  14. #include <open62541/nodeids.h>
  15. #include <open62541/types.h>
  16. #include <open62541/types_generated.h>
  17. #include <open62541/types_generated_handling.h>
  18. _UA_BEGIN_DECLS
  19. /* Forward declarations */
  20. struct UA_ServerConfig;
  21. typedef struct UA_ServerConfig UA_ServerConfig;
  22. struct UA_Server;
  23. typedef struct UA_Server UA_Server;
  24. struct UA_Client;
  25. /**
  26. * .. _server:
  27. *
  28. * Server
  29. * ======
  30. *
  31. * .. include:: server_config.rst
  32. *
  33. * .. _server-lifecycle:
  34. *
  35. * Server Lifecycle
  36. * ---------------- */
  37. /* The method UA_Server_new is defined in server_config_default.h. So default
  38. * plugins outside of the core library (for logging, etc) are already available
  39. * during the initialization.
  40. *
  41. * UA_Server UA_EXPORT * UA_Server_new(void);
  42. */
  43. /* Creates a new server. Moves the config into the server with a shallow copy.
  44. * The config content is cleared together with the server. */
  45. UA_Server UA_EXPORT *
  46. UA_Server_newWithConfig(const UA_ServerConfig *config);
  47. void UA_EXPORT UA_Server_delete(UA_Server *server);
  48. UA_ServerConfig UA_EXPORT *
  49. UA_Server_getConfig(UA_Server *server);
  50. /* Runs the main loop of the server. In each iteration, this calls into the
  51. * networklayers to see if messages have arrived.
  52. *
  53. * @param server The server object.
  54. * @param running The loop is run as long as *running is true.
  55. * Otherwise, the server shuts down.
  56. * @return Returns the statuscode of the UA_Server_run_shutdown method */
  57. UA_StatusCode UA_EXPORT
  58. UA_Server_run(UA_Server *server, const volatile UA_Boolean *running);
  59. /* The prologue part of UA_Server_run (no need to use if you call
  60. * UA_Server_run) */
  61. UA_StatusCode UA_EXPORT
  62. UA_Server_run_startup(UA_Server *server);
  63. /* Executes a single iteration of the server's main loop.
  64. *
  65. * @param server The server object.
  66. * @param waitInternal Should we wait for messages in the networklayer?
  67. * Otherwise, the timouts for the networklayers are set to zero.
  68. * The default max wait time is 50millisec.
  69. * @return Returns how long we can wait until the next scheduled
  70. * callback (in ms) */
  71. UA_UInt16 UA_EXPORT
  72. UA_Server_run_iterate(UA_Server *server, UA_Boolean waitInternal);
  73. /* The epilogue part of UA_Server_run (no need to use if you call
  74. * UA_Server_run) */
  75. UA_StatusCode UA_EXPORT
  76. UA_Server_run_shutdown(UA_Server *server);
  77. /**
  78. * Timed Callbacks
  79. * --------------- */
  80. typedef void (*UA_ServerCallback)(UA_Server *server, void *data);
  81. /* Add a callback for execution at a specified time. If the indicated time lies
  82. * in the past, then the callback is executed at the next iteration of the
  83. * server's main loop.
  84. *
  85. * @param server The server object.
  86. * @param callback The callback that shall be added.
  87. * @param data Data that is forwarded to the callback.
  88. * @param date The timestamp for the execution time.
  89. * @param callbackId Set to the identifier of the repeated callback . This can
  90. * be used to cancel the callback later on. If the pointer is null, the
  91. * identifier is not set.
  92. * @return Upon success, UA_STATUSCODE_GOOD is returned. An error code
  93. * otherwise. */
  94. UA_StatusCode UA_EXPORT UA_THREADSAFE
  95. UA_Server_addTimedCallback(UA_Server *server, UA_ServerCallback callback,
  96. void *data, UA_DateTime date, UA_UInt64 *callbackId);
  97. /* Add a callback for cyclic repetition to the server.
  98. *
  99. * @param server The server object.
  100. * @param callback The callback that shall be added.
  101. * @param data Data that is forwarded to the callback.
  102. * @param interval_ms The callback shall be repeatedly executed with the given
  103. * interval (in ms). The interval must be positive. The first execution
  104. * occurs at now() + interval at the latest.
  105. * @param callbackId Set to the identifier of the repeated callback . This can
  106. * be used to cancel the callback later on. If the pointer is null, the
  107. * identifier is not set.
  108. * @return Upon success, UA_STATUSCODE_GOOD is returned. An error code
  109. * otherwise. */
  110. UA_StatusCode UA_EXPORT UA_THREADSAFE
  111. UA_Server_addRepeatedCallback(UA_Server *server, UA_ServerCallback callback,
  112. void *data, UA_Double interval_ms, UA_UInt64 *callbackId);
  113. UA_StatusCode UA_EXPORT UA_THREADSAFE
  114. UA_Server_changeRepeatedCallbackInterval(UA_Server *server, UA_UInt64 callbackId,
  115. UA_Double interval_ms);
  116. /* Remove a repeated callback. Does nothing if the callback is not found.
  117. *
  118. * @param server The server object.
  119. * @param callbackId The id of the callback */
  120. void UA_EXPORT UA_THREADSAFE
  121. UA_Server_removeCallback(UA_Server *server, UA_UInt64 callbackId);
  122. #define UA_Server_removeRepeatedCallback(server, callbackId) \
  123. UA_Server_removeCallback(server, callbackId);
  124. /**
  125. * Reading and Writing Node Attributes
  126. * -----------------------------------
  127. * The functions for reading and writing node attributes call the regular read
  128. * and write service in the background that are also used over the network.
  129. *
  130. * The following attributes cannot be read, since the local "admin" user always
  131. * has full rights.
  132. *
  133. * - UserWriteMask
  134. * - UserAccessLevel
  135. * - UserExecutable */
  136. /* Read an attribute of a node. The specialized functions below provide a more
  137. * concise syntax.
  138. *
  139. * @param server The server object.
  140. * @param item ReadValueIds contain the NodeId of the target node, the id of the
  141. * attribute to read and (optionally) an index range to read parts
  142. * of an array only. See the section on NumericRange for the format
  143. * used for array ranges.
  144. * @param timestamps Which timestamps to return for the attribute.
  145. * @return Returns a DataValue that contains either an error code, or a variant
  146. * with the attribute value and the timestamps. */
  147. UA_DataValue UA_EXPORT UA_THREADSAFE
  148. UA_Server_read(UA_Server *server, const UA_ReadValueId *item,
  149. UA_TimestampsToReturn timestamps);
  150. /* Don't use this function. There are typed versions for every supported
  151. * attribute. */
  152. UA_StatusCode UA_EXPORT UA_THREADSAFE
  153. __UA_Server_read(UA_Server *server, const UA_NodeId *nodeId,
  154. UA_AttributeId attributeId, void *v);
  155. static UA_INLINE UA_THREADSAFE UA_StatusCode
  156. UA_Server_readNodeId(UA_Server *server, const UA_NodeId nodeId,
  157. UA_NodeId *outNodeId) {
  158. return __UA_Server_read(server, &nodeId, UA_ATTRIBUTEID_NODEID, outNodeId);
  159. }
  160. static UA_INLINE UA_THREADSAFE UA_StatusCode
  161. UA_Server_readNodeClass(UA_Server *server, const UA_NodeId nodeId,
  162. UA_NodeClass *outNodeClass) {
  163. return __UA_Server_read(server, &nodeId, UA_ATTRIBUTEID_NODECLASS,
  164. outNodeClass);
  165. }
  166. static UA_INLINE UA_THREADSAFE UA_StatusCode
  167. UA_Server_readBrowseName(UA_Server *server, const UA_NodeId nodeId,
  168. UA_QualifiedName *outBrowseName) {
  169. return __UA_Server_read(server, &nodeId, UA_ATTRIBUTEID_BROWSENAME,
  170. outBrowseName);
  171. }
  172. static UA_INLINE UA_THREADSAFE UA_StatusCode
  173. UA_Server_readDisplayName(UA_Server *server, const UA_NodeId nodeId,
  174. UA_LocalizedText *outDisplayName) {
  175. return __UA_Server_read(server, &nodeId, UA_ATTRIBUTEID_DISPLAYNAME,
  176. outDisplayName);
  177. }
  178. static UA_INLINE UA_THREADSAFE UA_StatusCode
  179. UA_Server_readDescription(UA_Server *server, const UA_NodeId nodeId,
  180. UA_LocalizedText *outDescription) {
  181. return __UA_Server_read(server, &nodeId, UA_ATTRIBUTEID_DESCRIPTION,
  182. outDescription);
  183. }
  184. static UA_INLINE UA_THREADSAFE UA_StatusCode
  185. UA_Server_readWriteMask(UA_Server *server, const UA_NodeId nodeId,
  186. UA_UInt32 *outWriteMask) {
  187. return __UA_Server_read(server, &nodeId, UA_ATTRIBUTEID_WRITEMASK,
  188. outWriteMask);
  189. }
  190. static UA_INLINE UA_THREADSAFE UA_StatusCode
  191. UA_Server_readIsAbstract(UA_Server *server, const UA_NodeId nodeId,
  192. UA_Boolean *outIsAbstract) {
  193. return __UA_Server_read(server, &nodeId, UA_ATTRIBUTEID_ISABSTRACT,
  194. outIsAbstract);
  195. }
  196. static UA_INLINE UA_THREADSAFE UA_StatusCode
  197. UA_Server_readSymmetric(UA_Server *server, const UA_NodeId nodeId,
  198. UA_Boolean *outSymmetric) {
  199. return __UA_Server_read(server, &nodeId, UA_ATTRIBUTEID_SYMMETRIC,
  200. outSymmetric);
  201. }
  202. static UA_INLINE UA_THREADSAFE UA_StatusCode
  203. UA_Server_readInverseName(UA_Server *server, const UA_NodeId nodeId,
  204. UA_LocalizedText *outInverseName) {
  205. return __UA_Server_read(server, &nodeId, UA_ATTRIBUTEID_INVERSENAME,
  206. outInverseName);
  207. }
  208. static UA_INLINE UA_THREADSAFE UA_StatusCode
  209. UA_Server_readContainsNoLoop(UA_Server *server, const UA_NodeId nodeId,
  210. UA_Boolean *outContainsNoLoops) {
  211. return __UA_Server_read(server, &nodeId, UA_ATTRIBUTEID_CONTAINSNOLOOPS,
  212. outContainsNoLoops);
  213. }
  214. static UA_INLINE UA_THREADSAFE UA_StatusCode
  215. UA_Server_readEventNotifier(UA_Server *server, const UA_NodeId nodeId,
  216. UA_Byte *outEventNotifier) {
  217. return __UA_Server_read(server, &nodeId, UA_ATTRIBUTEID_EVENTNOTIFIER,
  218. outEventNotifier);
  219. }
  220. static UA_INLINE UA_THREADSAFE UA_StatusCode
  221. UA_Server_readValue(UA_Server *server, const UA_NodeId nodeId,
  222. UA_Variant *outValue) {
  223. return __UA_Server_read(server, &nodeId, UA_ATTRIBUTEID_VALUE, outValue);
  224. }
  225. static UA_INLINE UA_THREADSAFE UA_StatusCode
  226. UA_Server_readDataType(UA_Server *server, const UA_NodeId nodeId,
  227. UA_NodeId *outDataType) {
  228. return __UA_Server_read(server, &nodeId, UA_ATTRIBUTEID_DATATYPE,
  229. outDataType);
  230. }
  231. static UA_INLINE UA_THREADSAFE UA_StatusCode
  232. UA_Server_readValueRank(UA_Server *server, const UA_NodeId nodeId,
  233. UA_Int32 *outValueRank) {
  234. return __UA_Server_read(server, &nodeId, UA_ATTRIBUTEID_VALUERANK,
  235. outValueRank);
  236. }
  237. /* Returns a variant with an int32 array */
  238. static UA_INLINE UA_THREADSAFE UA_StatusCode
  239. UA_Server_readArrayDimensions(UA_Server *server, const UA_NodeId nodeId,
  240. UA_Variant *outArrayDimensions) {
  241. return __UA_Server_read(server, &nodeId, UA_ATTRIBUTEID_ARRAYDIMENSIONS,
  242. outArrayDimensions);
  243. }
  244. static UA_INLINE UA_THREADSAFE UA_StatusCode
  245. UA_Server_readAccessLevel(UA_Server *server, const UA_NodeId nodeId,
  246. UA_Byte *outAccessLevel) {
  247. return __UA_Server_read(server, &nodeId, UA_ATTRIBUTEID_ACCESSLEVEL,
  248. outAccessLevel);
  249. }
  250. static UA_INLINE UA_THREADSAFE UA_StatusCode
  251. UA_Server_readMinimumSamplingInterval(UA_Server *server, const UA_NodeId nodeId,
  252. UA_Double *outMinimumSamplingInterval) {
  253. return __UA_Server_read(server, &nodeId,
  254. UA_ATTRIBUTEID_MINIMUMSAMPLINGINTERVAL,
  255. outMinimumSamplingInterval);
  256. }
  257. static UA_INLINE UA_THREADSAFE UA_StatusCode
  258. UA_Server_readHistorizing(UA_Server *server, const UA_NodeId nodeId,
  259. UA_Boolean *outHistorizing) {
  260. return __UA_Server_read(server, &nodeId, UA_ATTRIBUTEID_HISTORIZING,
  261. outHistorizing);
  262. }
  263. static UA_INLINE UA_THREADSAFE UA_StatusCode
  264. UA_Server_readExecutable(UA_Server *server, const UA_NodeId nodeId,
  265. UA_Boolean *outExecutable) {
  266. return __UA_Server_read(server, &nodeId, UA_ATTRIBUTEID_EXECUTABLE,
  267. outExecutable);
  268. }
  269. /**
  270. * The following node attributes cannot be changed once a node has been created:
  271. *
  272. * - NodeClass
  273. * - NodeId
  274. * - Symmetric
  275. * - ContainsNoLoop
  276. *
  277. * The following attributes cannot be written from the server, as they are
  278. * specific to the different users and set by the access control callback:
  279. *
  280. * - UserWriteMask
  281. * - UserAccessLevel
  282. * - UserExecutable
  283. */
  284. /* Overwrite an attribute of a node. The specialized functions below provide a
  285. * more concise syntax.
  286. *
  287. * @param server The server object.
  288. * @param value WriteValues contain the NodeId of the target node, the id of the
  289. * attribute to overwritten, the actual value and (optionally) an
  290. * index range to replace parts of an array only. of an array only.
  291. * See the section on NumericRange for the format used for array
  292. * ranges.
  293. * @return Returns a status code. */
  294. UA_StatusCode UA_EXPORT UA_THREADSAFE
  295. UA_Server_write(UA_Server *server, const UA_WriteValue *value);
  296. /* Don't use this function. There are typed versions with no additional
  297. * overhead. */
  298. UA_StatusCode UA_EXPORT UA_THREADSAFE
  299. __UA_Server_write(UA_Server *server, const UA_NodeId *nodeId,
  300. const UA_AttributeId attributeId,
  301. const UA_DataType *attr_type, const void *attr);
  302. static UA_INLINE UA_THREADSAFE UA_StatusCode
  303. UA_Server_writeBrowseName(UA_Server *server, const UA_NodeId nodeId,
  304. const UA_QualifiedName browseName) {
  305. return __UA_Server_write(server, &nodeId, UA_ATTRIBUTEID_BROWSENAME,
  306. &UA_TYPES[UA_TYPES_QUALIFIEDNAME], &browseName);
  307. }
  308. static UA_INLINE UA_THREADSAFE UA_StatusCode
  309. UA_Server_writeDisplayName(UA_Server *server, const UA_NodeId nodeId,
  310. const UA_LocalizedText displayName) {
  311. return __UA_Server_write(server, &nodeId, UA_ATTRIBUTEID_DISPLAYNAME,
  312. &UA_TYPES[UA_TYPES_LOCALIZEDTEXT], &displayName);
  313. }
  314. static UA_INLINE UA_THREADSAFE UA_StatusCode
  315. UA_Server_writeDescription(UA_Server *server, const UA_NodeId nodeId,
  316. const UA_LocalizedText description) {
  317. return __UA_Server_write(server, &nodeId, UA_ATTRIBUTEID_DESCRIPTION,
  318. &UA_TYPES[UA_TYPES_LOCALIZEDTEXT], &description);
  319. }
  320. static UA_INLINE UA_THREADSAFE UA_StatusCode
  321. UA_Server_writeWriteMask(UA_Server *server, const UA_NodeId nodeId,
  322. const UA_UInt32 writeMask) {
  323. return __UA_Server_write(server, &nodeId, UA_ATTRIBUTEID_WRITEMASK,
  324. &UA_TYPES[UA_TYPES_UINT32], &writeMask);
  325. }
  326. static UA_INLINE UA_THREADSAFE UA_StatusCode
  327. UA_Server_writeIsAbstract(UA_Server *server, const UA_NodeId nodeId,
  328. const UA_Boolean isAbstract) {
  329. return __UA_Server_write(server, &nodeId, UA_ATTRIBUTEID_ISABSTRACT,
  330. &UA_TYPES[UA_TYPES_BOOLEAN], &isAbstract);
  331. }
  332. static UA_INLINE UA_THREADSAFE UA_StatusCode
  333. UA_Server_writeInverseName(UA_Server *server, const UA_NodeId nodeId,
  334. const UA_LocalizedText inverseName) {
  335. return __UA_Server_write(server, &nodeId, UA_ATTRIBUTEID_INVERSENAME,
  336. &UA_TYPES[UA_TYPES_LOCALIZEDTEXT], &inverseName);
  337. }
  338. static UA_INLINE UA_THREADSAFE UA_StatusCode
  339. UA_Server_writeEventNotifier(UA_Server *server, const UA_NodeId nodeId,
  340. const UA_Byte eventNotifier) {
  341. return __UA_Server_write(server, &nodeId, UA_ATTRIBUTEID_EVENTNOTIFIER,
  342. &UA_TYPES[UA_TYPES_BYTE], &eventNotifier);
  343. }
  344. static UA_INLINE UA_THREADSAFE UA_StatusCode
  345. UA_Server_writeValue(UA_Server *server, const UA_NodeId nodeId,
  346. const UA_Variant value) {
  347. return __UA_Server_write(server, &nodeId, UA_ATTRIBUTEID_VALUE,
  348. &UA_TYPES[UA_TYPES_VARIANT], &value);
  349. }
  350. static UA_INLINE UA_THREADSAFE UA_StatusCode
  351. UA_Server_writeDataType(UA_Server *server, const UA_NodeId nodeId,
  352. const UA_NodeId dataType) {
  353. return __UA_Server_write(server, &nodeId, UA_ATTRIBUTEID_DATATYPE,
  354. &UA_TYPES[UA_TYPES_NODEID], &dataType);
  355. }
  356. static UA_INLINE UA_THREADSAFE UA_StatusCode
  357. UA_Server_writeValueRank(UA_Server *server, const UA_NodeId nodeId,
  358. const UA_Int32 valueRank) {
  359. return __UA_Server_write(server, &nodeId, UA_ATTRIBUTEID_VALUERANK,
  360. &UA_TYPES[UA_TYPES_INT32], &valueRank);
  361. }
  362. static UA_INLINE UA_THREADSAFE UA_StatusCode
  363. UA_Server_writeArrayDimensions(UA_Server *server, const UA_NodeId nodeId,
  364. const UA_Variant arrayDimensions) {
  365. return __UA_Server_write(server, &nodeId, UA_ATTRIBUTEID_ARRAYDIMENSIONS,
  366. &UA_TYPES[UA_TYPES_VARIANT], &arrayDimensions);
  367. }
  368. static UA_INLINE UA_THREADSAFE UA_StatusCode
  369. UA_Server_writeAccessLevel(UA_Server *server, const UA_NodeId nodeId,
  370. const UA_Byte accessLevel) {
  371. return __UA_Server_write(server, &nodeId, UA_ATTRIBUTEID_ACCESSLEVEL,
  372. &UA_TYPES[UA_TYPES_BYTE], &accessLevel);
  373. }
  374. static UA_INLINE UA_THREADSAFE UA_StatusCode
  375. UA_Server_writeMinimumSamplingInterval(UA_Server *server, const UA_NodeId nodeId,
  376. const UA_Double miniumSamplingInterval) {
  377. return __UA_Server_write(server, &nodeId,
  378. UA_ATTRIBUTEID_MINIMUMSAMPLINGINTERVAL,
  379. &UA_TYPES[UA_TYPES_DOUBLE],
  380. &miniumSamplingInterval);
  381. }
  382. static UA_INLINE UA_THREADSAFE UA_StatusCode
  383. UA_Server_writeHistorizing(UA_Server *server, const UA_NodeId nodeId,
  384. const UA_Boolean historizing) {
  385. return __UA_Server_write(server, &nodeId,
  386. UA_ATTRIBUTEID_HISTORIZING,
  387. &UA_TYPES[UA_TYPES_BOOLEAN],
  388. &historizing);
  389. }
  390. static UA_INLINE UA_THREADSAFE UA_StatusCode
  391. UA_Server_writeExecutable(UA_Server *server, const UA_NodeId nodeId,
  392. const UA_Boolean executable) {
  393. return __UA_Server_write(server, &nodeId, UA_ATTRIBUTEID_EXECUTABLE,
  394. &UA_TYPES[UA_TYPES_BOOLEAN], &executable); }
  395. /**
  396. * Browsing
  397. * -------- */
  398. /* Browse the references of a particular node. See the definition of
  399. * BrowseDescription structure for details. */
  400. UA_BrowseResult UA_EXPORT UA_THREADSAFE
  401. UA_Server_browse(UA_Server *server, UA_UInt32 maxReferences,
  402. const UA_BrowseDescription *bd);
  403. UA_BrowseResult UA_EXPORT UA_THREADSAFE
  404. UA_Server_browseNext(UA_Server *server, UA_Boolean releaseContinuationPoint,
  405. const UA_ByteString *continuationPoint);
  406. /* Nonstandard version of the browse service that recurses into child nodes.
  407. * Possible loops (that can occur for non-hierarchical references) are handled
  408. * by adding every target node at most once to the results array. */
  409. UA_StatusCode UA_EXPORT UA_THREADSAFE
  410. UA_Server_browseRecursive(UA_Server *server, const UA_BrowseDescription *bd,
  411. size_t *resultsSize, UA_ExpandedNodeId **results);
  412. UA_BrowsePathResult UA_EXPORT UA_THREADSAFE
  413. UA_Server_translateBrowsePathToNodeIds(UA_Server *server,
  414. const UA_BrowsePath *browsePath);
  415. /* A simplified TranslateBrowsePathsToNodeIds based on the
  416. * SimpleAttributeOperand type (Part 4, 7.4.4.5).
  417. *
  418. * This specifies a relative path using a list of BrowseNames instead of the
  419. * RelativePath structure. The list of BrowseNames is equivalent to a
  420. * RelativePath that specifies forward references which are subtypes of the
  421. * HierarchicalReferences ReferenceType. All Nodes followed by the browsePath
  422. * shall be of the NodeClass Object or Variable. */
  423. UA_BrowsePathResult UA_EXPORT UA_THREADSAFE
  424. UA_Server_browseSimplifiedBrowsePath(UA_Server *server, const UA_NodeId origin,
  425. size_t browsePathSize,
  426. const UA_QualifiedName *browsePath);
  427. #ifndef HAVE_NODEITER_CALLBACK
  428. #define HAVE_NODEITER_CALLBACK
  429. /* Iterate over all nodes referenced by parentNodeId by calling the callback
  430. * function for each child node (in ifdef because GCC/CLANG handle include order
  431. * differently) */
  432. typedef UA_StatusCode
  433. (*UA_NodeIteratorCallback)(UA_NodeId childId, UA_Boolean isInverse,
  434. UA_NodeId referenceTypeId, void *handle);
  435. #endif
  436. UA_StatusCode UA_EXPORT UA_THREADSAFE
  437. UA_Server_forEachChildNodeCall(UA_Server *server, UA_NodeId parentNodeId,
  438. UA_NodeIteratorCallback callback, void *handle);
  439. #ifdef UA_ENABLE_DISCOVERY
  440. /**
  441. * Discovery
  442. * --------- */
  443. /* Register the given server instance at the discovery server.
  444. * This should be called periodically.
  445. * The semaphoreFilePath is optional. If the given file is deleted,
  446. * the server will automatically be unregistered. This could be
  447. * for example a pid file which is deleted if the server crashes.
  448. *
  449. * When the server shuts down you need to call unregister.
  450. *
  451. * @param server
  452. * @param client the client which is used to call the RegisterServer. It must
  453. * already be connected to the correct endpoint
  454. * @param semaphoreFilePath optional parameter pointing to semaphore file. */
  455. UA_StatusCode UA_EXPORT UA_THREADSAFE
  456. UA_Server_register_discovery(UA_Server *server, struct UA_Client *client,
  457. const char* semaphoreFilePath);
  458. /* Unregister the given server instance from the discovery server.
  459. * This should only be called when the server is shutting down.
  460. * @param server
  461. * @param client the client which is used to call the RegisterServer. It must
  462. * already be connected to the correct endpoint */
  463. UA_StatusCode UA_EXPORT UA_THREADSAFE
  464. UA_Server_unregister_discovery(UA_Server *server, struct UA_Client *client);
  465. /* Adds a periodic callback to register the server with the LDS (local discovery server)
  466. * periodically. The interval between each register call is given as second parameter.
  467. * It should be 10 minutes by default (= 10*60*1000).
  468. *
  469. * The delayFirstRegisterMs parameter indicates the delay for the first register call.
  470. * If it is 0, the first register call will be after intervalMs milliseconds,
  471. * otherwise the server's first register will be after delayFirstRegisterMs.
  472. *
  473. * When you manually unregister the server, you also need to cancel the
  474. * periodic callback, otherwise it will be automatically be registered again.
  475. *
  476. * If you call this method multiple times for the same discoveryServerUrl, the older
  477. * periodic callback will be removed.
  478. *
  479. * @param server
  480. * @param client the client which is used to call the RegisterServer.
  481. * It must not yet be connected and will be connected for every register call
  482. * to the given discoveryServerUrl.
  483. * @param discoveryServerUrl where this server should register itself.
  484. * The string will be copied internally. Therefore you can free it after calling this method.
  485. * @param intervalMs
  486. * @param delayFirstRegisterMs
  487. * @param periodicCallbackId */
  488. UA_StatusCode UA_EXPORT UA_THREADSAFE
  489. UA_Server_addPeriodicServerRegisterCallback(UA_Server *server, struct UA_Client *client,
  490. const char* discoveryServerUrl,
  491. UA_Double intervalMs,
  492. UA_Double delayFirstRegisterMs,
  493. UA_UInt64 *periodicCallbackId);
  494. /* Callback for RegisterServer. Data is passed from the register call */
  495. typedef void (*UA_Server_registerServerCallback)(const UA_RegisteredServer *registeredServer,
  496. void* data);
  497. /* Set the callback which is called if another server registeres or unregisters
  498. * with this instance. This callback is called every time the server gets a register
  499. * call. This especially means that for every periodic server register the callback will
  500. * be called.
  501. *
  502. * @param server
  503. * @param cb the callback
  504. * @param data data passed to the callback
  505. * @return UA_STATUSCODE_SUCCESS on success */
  506. void UA_EXPORT UA_THREADSAFE
  507. UA_Server_setRegisterServerCallback(UA_Server *server, UA_Server_registerServerCallback cb,
  508. void* data);
  509. #ifdef UA_ENABLE_DISCOVERY_MULTICAST
  510. /* Callback for server detected through mDNS. Data is passed from the register
  511. * call
  512. *
  513. * @param isServerAnnounce indicates if the server has just been detected. If
  514. * set to false, this means the server is shutting down.
  515. * @param isTxtReceived indicates if we already received the corresponding TXT
  516. * record with the path and caps data */
  517. typedef void (*UA_Server_serverOnNetworkCallback)(const UA_ServerOnNetwork *serverOnNetwork,
  518. UA_Boolean isServerAnnounce,
  519. UA_Boolean isTxtReceived, void* data);
  520. /* Set the callback which is called if another server is found through mDNS or
  521. * deleted. It will be called for any mDNS message from the remote server, thus
  522. * it may be called multiple times for the same instance. Also the SRV and TXT
  523. * records may arrive later, therefore for the first call the server
  524. * capabilities may not be set yet. If called multiple times, previous data will
  525. * be overwritten.
  526. *
  527. * @param server
  528. * @param cb the callback
  529. * @param data data passed to the callback
  530. * @return UA_STATUSCODE_SUCCESS on success */
  531. void UA_EXPORT UA_THREADSAFE
  532. UA_Server_setServerOnNetworkCallback(UA_Server *server,
  533. UA_Server_serverOnNetworkCallback cb,
  534. void* data);
  535. #endif /* UA_ENABLE_DISCOVERY_MULTICAST */
  536. #endif /* UA_ENABLE_DISCOVERY */
  537. /**
  538. * Information Model Callbacks
  539. * ---------------------------
  540. *
  541. * There are three places where a callback from an information model to
  542. * user-defined code can happen.
  543. *
  544. * - Custom node constructors and destructors
  545. * - Linking VariableNodes with an external data source
  546. * - MethodNode callbacks
  547. *
  548. * .. _node-lifecycle:
  549. *
  550. * Node Lifecycle: Constructors, Destructors and Node Contexts
  551. * ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  552. *
  553. * To finalize the instantiation of a node, a (user-defined) constructor
  554. * callback is executed. There can be both a global constructor for all nodes
  555. * and node-type constructor specific to the TypeDefinition of the new node
  556. * (attached to an ObjectTypeNode or VariableTypeNode).
  557. *
  558. * In the hierarchy of ObjectTypes and VariableTypes, only the constructor of
  559. * the (lowest) type defined for the new node is executed. Note that every
  560. * Object and Variable can have only one ``isTypeOf`` reference. But type-nodes
  561. * can technically have several ``hasSubType`` references to implement multiple
  562. * inheritance. Issues of (multiple) inheritance in the constructor need to be
  563. * solved by the user.
  564. *
  565. * When a node is destroyed, the node-type destructor is called before the
  566. * global destructor. So the overall node lifecycle is as follows:
  567. *
  568. * 1. Global Constructor (set in the server config)
  569. * 2. Node-Type Constructor (for VariableType or ObjectTypes)
  570. * 3. (Usage-period of the Node)
  571. * 4. Node-Type Destructor
  572. * 5. Global Destructor
  573. *
  574. * The constructor and destructor callbacks can be set to ``NULL`` and are not
  575. * used in that case. If the node-type constructor fails, the global destructor
  576. * will be called before removing the node. The destructors are assumed to never
  577. * fail.
  578. *
  579. * Every node carries a user-context and a constructor-context pointer. The
  580. * user-context is used to attach custom data to a node. But the (user-defined)
  581. * constructors and destructors may replace the user-context pointer if they
  582. * wish to do so. The initial value for the constructor-context is ``NULL``.
  583. * When the ``AddNodes`` service is used over the network, the user-context
  584. * pointer of the new node is also initially set to ``NULL``. */
  585. /* To be set in the server config. */
  586. typedef struct {
  587. /* Can be NULL. May replace the nodeContext */
  588. UA_StatusCode (*constructor)(UA_Server *server,
  589. const UA_NodeId *sessionId, void *sessionContext,
  590. const UA_NodeId *nodeId, void **nodeContext);
  591. /* Can be NULL. The context cannot be replaced since the node is destroyed
  592. * immediately afterwards anyway. */
  593. void (*destructor)(UA_Server *server,
  594. const UA_NodeId *sessionId, void *sessionContext,
  595. const UA_NodeId *nodeId, void *nodeContext);
  596. /* Can be NULL. Called during recursive node instantiation. While mandatory
  597. * child nodes are automatically created if not already present, optional child
  598. * nodes are not. This callback can be used to define whether an optional child
  599. * node should be created.
  600. *
  601. * @param server The server executing the callback
  602. * @param sessionId The identifier of the session
  603. * @param sessionContext Additional data attached to the session in the
  604. * access control layer
  605. * @param sourceNodeId Source node from the type definition. If the new node
  606. * shall be created, it will be a copy of this node.
  607. * @param targetParentNodeId Parent of the potential new child node
  608. * @param referenceTypeId Identifies the reference type which that the parent
  609. * node has to the new node.
  610. * @return Return UA_TRUE if the child node shall be instantiatet,
  611. * UA_FALSE otherwise. */
  612. UA_Boolean (*createOptionalChild)(UA_Server *server,
  613. const UA_NodeId *sessionId,
  614. void *sessionContext,
  615. const UA_NodeId *sourceNodeId,
  616. const UA_NodeId *targetParentNodeId,
  617. const UA_NodeId *referenceTypeId);
  618. /* Can be NULL. Called when a node is to be copied during recursive
  619. * node instantiation. Allows definition of the NodeId for the new node.
  620. * If the callback is set to NULL or the resulting NodeId is UA_NODEID_NULL,
  621. * then a random NodeId will be generated.
  622. *
  623. * @param server The server executing the callback
  624. * @param sessionId The identifier of the session
  625. * @param sessionContext Additional data attached to the session in the
  626. * access control layer
  627. * @param sourceNodeId Source node of the copy operation
  628. * @param targetParentNodeId Parent node of the new node
  629. * @param referenceTypeId Identifies the reference type which that the parent
  630. * node has to the new node. */
  631. UA_StatusCode (*generateChildNodeId)(UA_Server *server,
  632. const UA_NodeId *sessionId, void *sessionContext,
  633. const UA_NodeId *sourceNodeId,
  634. const UA_NodeId *targetParentNodeId,
  635. const UA_NodeId *referenceTypeId,
  636. UA_NodeId *targetNodeId);
  637. } UA_GlobalNodeLifecycle;
  638. typedef struct {
  639. /* Can be NULL. May replace the nodeContext */
  640. UA_StatusCode (*constructor)(UA_Server *server,
  641. const UA_NodeId *sessionId, void *sessionContext,
  642. const UA_NodeId *typeNodeId, void *typeNodeContext,
  643. const UA_NodeId *nodeId, void **nodeContext);
  644. /* Can be NULL. May replace the nodeContext. */
  645. void (*destructor)(UA_Server *server,
  646. const UA_NodeId *sessionId, void *sessionContext,
  647. const UA_NodeId *typeNodeId, void *typeNodeContext,
  648. const UA_NodeId *nodeId, void **nodeContext);
  649. } UA_NodeTypeLifecycle;
  650. UA_StatusCode UA_EXPORT UA_THREADSAFE
  651. UA_Server_setNodeTypeLifecycle(UA_Server *server, UA_NodeId nodeId,
  652. UA_NodeTypeLifecycle lifecycle);
  653. UA_StatusCode UA_EXPORT UA_THREADSAFE
  654. UA_Server_getNodeContext(UA_Server *server, UA_NodeId nodeId,
  655. void **nodeContext);
  656. /* Careful! The user has to ensure that the destructor callbacks still work. */
  657. UA_StatusCode UA_EXPORT UA_THREADSAFE
  658. UA_Server_setNodeContext(UA_Server *server, UA_NodeId nodeId,
  659. void *nodeContext);
  660. /**
  661. * .. _datasource:
  662. *
  663. * Data Source Callback
  664. * ^^^^^^^^^^^^^^^^^^^^
  665. *
  666. * The server has a unique way of dealing with the content of variables. Instead
  667. * of storing a variant attached to the variable node, the node can point to a
  668. * function with a local data provider. Whenever the value attribute is read,
  669. * the function will be called and asked to provide a UA_DataValue return value
  670. * that contains the value content and additional timestamps.
  671. *
  672. * It is expected that the read callback is implemented. The write callback can
  673. * be set to a null-pointer. */
  674. typedef struct {
  675. /* Copies the data from the source into the provided value.
  676. *
  677. * !! ZERO-COPY OPERATIONS POSSIBLE !!
  678. * It is not required to return a copy of the actual content data. You can
  679. * return a pointer to memory owned by the user. Memory can be reused
  680. * between read callbacks of a DataSource, as the result is already encoded
  681. * on the network buffer between each read operation.
  682. *
  683. * To use zero-copy reads, set the value of the `value->value` Variant
  684. * without copying, e.g. with `UA_Variant_setScalar`. Then, also set
  685. * `value->value.storageType` to `UA_VARIANT_DATA_NODELETE` to prevent the
  686. * memory being cleaned up. Don't forget to also set `value->hasValue` to
  687. * true to indicate the presence of a value.
  688. *
  689. * @param server The server executing the callback
  690. * @param sessionId The identifier of the session
  691. * @param sessionContext Additional data attached to the session in the
  692. * access control layer
  693. * @param nodeId The identifier of the node being read from
  694. * @param nodeContext Additional data attached to the node by the user
  695. * @param includeSourceTimeStamp If true, then the datasource is expected to
  696. * set the source timestamp in the returned value
  697. * @param range If not null, then the datasource shall return only a
  698. * selection of the (nonscalar) data. Set
  699. * UA_STATUSCODE_BADINDEXRANGEINVALID in the value if this does not
  700. * apply
  701. * @param value The (non-null) DataValue that is returned to the client. The
  702. * data source sets the read data, the result status and optionally a
  703. * sourcetimestamp.
  704. * @return Returns a status code for logging. Error codes intended for the
  705. * original caller are set in the value. If an error is returned,
  706. * then no releasing of the value is done
  707. */
  708. UA_StatusCode (*read)(UA_Server *server, const UA_NodeId *sessionId,
  709. void *sessionContext, const UA_NodeId *nodeId,
  710. void *nodeContext, UA_Boolean includeSourceTimeStamp,
  711. const UA_NumericRange *range, UA_DataValue *value);
  712. /* Write into a data source. This method pointer can be NULL if the
  713. * operation is unsupported.
  714. *
  715. * @param server The server executing the callback
  716. * @param sessionId The identifier of the session
  717. * @param sessionContext Additional data attached to the session in the
  718. * access control layer
  719. * @param nodeId The identifier of the node being written to
  720. * @param nodeContext Additional data attached to the node by the user
  721. * @param range If not NULL, then the datasource shall return only a
  722. * selection of the (nonscalar) data. Set
  723. * UA_STATUSCODE_BADINDEXRANGEINVALID in the value if this does not
  724. * apply
  725. * @param value The (non-NULL) DataValue that has been written by the client.
  726. * The data source contains the written data, the result status and
  727. * optionally a sourcetimestamp
  728. * @return Returns a status code for logging. Error codes intended for the
  729. * original caller are set in the value. If an error is returned,
  730. * then no releasing of the value is done
  731. */
  732. UA_StatusCode (*write)(UA_Server *server, const UA_NodeId *sessionId,
  733. void *sessionContext, const UA_NodeId *nodeId,
  734. void *nodeContext, const UA_NumericRange *range,
  735. const UA_DataValue *value);
  736. } UA_DataSource;
  737. UA_StatusCode UA_EXPORT UA_THREADSAFE
  738. UA_Server_setVariableNode_dataSource(UA_Server *server, const UA_NodeId nodeId,
  739. const UA_DataSource dataSource);
  740. /**
  741. * .. _value-callback:
  742. *
  743. * Value Callback
  744. * ^^^^^^^^^^^^^^
  745. * Value Callbacks can be attached to variable and variable type nodes. If
  746. * not ``NULL``, they are called before reading and after writing respectively. */
  747. typedef struct {
  748. /* Called before the value attribute is read. It is possible to write into the
  749. * value attribute during onRead (using the write service). The node is
  750. * re-opened afterwards so that changes are considered in the following read
  751. * operation.
  752. *
  753. * @param handle Points to user-provided data for the callback.
  754. * @param nodeid The identifier of the node.
  755. * @param data Points to the current node value.
  756. * @param range Points to the numeric range the client wants to read from
  757. * (or NULL). */
  758. void (*onRead)(UA_Server *server, const UA_NodeId *sessionId,
  759. void *sessionContext, const UA_NodeId *nodeid,
  760. void *nodeContext, const UA_NumericRange *range,
  761. const UA_DataValue *value);
  762. /* Called after writing the value attribute. The node is re-opened after
  763. * writing so that the new value is visible in the callback.
  764. *
  765. * @param server The server executing the callback
  766. * @sessionId The identifier of the session
  767. * @sessionContext Additional data attached to the session
  768. * in the access control layer
  769. * @param nodeid The identifier of the node.
  770. * @param nodeUserContext Additional data attached to the node by
  771. * the user.
  772. * @param nodeConstructorContext Additional data attached to the node
  773. * by the type constructor(s).
  774. * @param range Points to the numeric range the client wants to write to (or
  775. * NULL). */
  776. void (*onWrite)(UA_Server *server, const UA_NodeId *sessionId,
  777. void *sessionContext, const UA_NodeId *nodeId,
  778. void *nodeContext, const UA_NumericRange *range,
  779. const UA_DataValue *data);
  780. } UA_ValueCallback;
  781. UA_StatusCode UA_EXPORT UA_THREADSAFE
  782. UA_Server_setVariableNode_valueCallback(UA_Server *server,
  783. const UA_NodeId nodeId,
  784. const UA_ValueCallback callback);
  785. /**
  786. * .. _local-monitoreditems:
  787. *
  788. * Local MonitoredItems
  789. * ^^^^^^^^^^^^^^^^^^^^
  790. *
  791. * MonitoredItems are used with the Subscription mechanism of OPC UA to
  792. * transported notifications for data changes and events. MonitoredItems can
  793. * also be registered locally. Notifications are then forwarded to a
  794. * user-defined callback instead of a remote client. */
  795. #ifdef UA_ENABLE_SUBSCRIPTIONS
  796. typedef void (*UA_Server_DataChangeNotificationCallback)
  797. (UA_Server *server, UA_UInt32 monitoredItemId, void *monitoredItemContext,
  798. const UA_NodeId *nodeId, void *nodeContext, UA_UInt32 attributeId,
  799. const UA_DataValue *value);
  800. typedef void (*UA_Server_EventNotificationCallback)
  801. (UA_Server *server, UA_UInt32 monId, void *monContext,
  802. size_t nEventFields, const UA_Variant *eventFields);
  803. /* Create a local MonitoredItem with a sampling interval that detects data
  804. * changes.
  805. *
  806. * @param server The server executing the MonitoredItem
  807. * @timestampsToReturn Shall timestamps be added to the value for the callback?
  808. * @item The parameters of the new MonitoredItem. Note that the attribute of the
  809. * ReadValueId (the node that is monitored) can not be
  810. * ``UA_ATTRIBUTEID_EVENTNOTIFIER``. A different callback type needs to be
  811. * registered for event notifications.
  812. * @monitoredItemContext A pointer that is forwarded with the callback
  813. * @callback The callback that is executed on detected data changes
  814. *
  815. * @return Returns a description of the created MonitoredItem. The structure
  816. * also contains a StatusCode (in case of an error) and the identifier of the
  817. * new MonitoredItem. */
  818. UA_MonitoredItemCreateResult UA_EXPORT UA_THREADSAFE
  819. UA_Server_createDataChangeMonitoredItem(UA_Server *server,
  820. UA_TimestampsToReturn timestampsToReturn,
  821. const UA_MonitoredItemCreateRequest item,
  822. void *monitoredItemContext,
  823. UA_Server_DataChangeNotificationCallback callback);
  824. /* UA_MonitoredItemCreateResult UA_EXPORT */
  825. /* UA_Server_createEventMonitoredItem(UA_Server *server, */
  826. /* UA_TimestampsToReturn timestampsToReturn, */
  827. /* const UA_MonitoredItemCreateRequest item, void *context, */
  828. /* UA_Server_EventNotificationCallback callback); */
  829. UA_StatusCode UA_EXPORT UA_THREADSAFE
  830. UA_Server_deleteMonitoredItem(UA_Server *server, UA_UInt32 monitoredItemId);
  831. #endif
  832. /**
  833. * Method Callbacks
  834. * ^^^^^^^^^^^^^^^^
  835. * Method callbacks are set to `NULL` (not executable) when a method node is
  836. * added over the network. In theory, it is possible to add a callback via
  837. * ``UA_Server_setMethodNode_callback`` within the global constructor when
  838. * adding methods over the network is really wanted. See the Section
  839. * :ref:`object-interaction` for calling methods on an object. */
  840. typedef UA_StatusCode
  841. (*UA_MethodCallback)(UA_Server *server, const UA_NodeId *sessionId,
  842. void *sessionContext, const UA_NodeId *methodId,
  843. void *methodContext, const UA_NodeId *objectId,
  844. void *objectContext, size_t inputSize,
  845. const UA_Variant *input, size_t outputSize,
  846. UA_Variant *output);
  847. #ifdef UA_ENABLE_METHODCALLS
  848. UA_StatusCode UA_EXPORT UA_THREADSAFE
  849. UA_Server_setMethodNode_callback(UA_Server *server,
  850. const UA_NodeId methodNodeId,
  851. UA_MethodCallback methodCallback);
  852. #endif
  853. /**
  854. * .. _object-interaction:
  855. *
  856. * Interacting with Objects
  857. * ------------------------
  858. * Objects in the information model are represented as ObjectNodes. Some
  859. * convenience functions are provided to simplify the interaction with objects.
  860. */
  861. /* Write an object property. The property is represented as a VariableNode with
  862. * a ``HasProperty`` reference from the ObjectNode. The VariableNode is
  863. * identified by its BrowseName. Writing the property sets the value attribute
  864. * of the VariableNode.
  865. *
  866. * @param server The server object
  867. * @param objectId The identifier of the object (node)
  868. * @param propertyName The name of the property
  869. * @param value The value to be set for the event attribute
  870. * @return The StatusCode for setting the event attribute */
  871. UA_StatusCode UA_EXPORT UA_THREADSAFE
  872. UA_Server_writeObjectProperty(UA_Server *server, const UA_NodeId objectId,
  873. const UA_QualifiedName propertyName,
  874. const UA_Variant value);
  875. /* Directly point to the scalar value instead of a variant */
  876. UA_StatusCode UA_EXPORT UA_THREADSAFE
  877. UA_Server_writeObjectProperty_scalar(UA_Server *server, const UA_NodeId objectId,
  878. const UA_QualifiedName propertyName,
  879. const void *value, const UA_DataType *type);
  880. /* Read an object property.
  881. *
  882. * @param server The server object
  883. * @param objectId The identifier of the object (node)
  884. * @param propertyName The name of the property
  885. * @param value Contains the property value after reading. Must not be NULL.
  886. * @return The StatusCode for setting the event attribute */
  887. UA_StatusCode UA_EXPORT UA_THREADSAFE
  888. UA_Server_readObjectProperty(UA_Server *server, const UA_NodeId objectId,
  889. const UA_QualifiedName propertyName,
  890. UA_Variant *value);
  891. #ifdef UA_ENABLE_METHODCALLS
  892. UA_CallMethodResult UA_EXPORT UA_THREADSAFE
  893. UA_Server_call(UA_Server *server, const UA_CallMethodRequest *request);
  894. #endif
  895. /**
  896. * .. _addnodes:
  897. *
  898. * Node Addition and Deletion
  899. * --------------------------
  900. * When creating dynamic node instances at runtime, chances are that you will
  901. * not care about the specific NodeId of the new node, as long as you can
  902. * reference it later. When passing numeric NodeIds with a numeric identifier 0,
  903. * the stack evaluates this as "select a random unassigned numeric NodeId in
  904. * that namespace". To find out which NodeId was actually assigned to the new
  905. * node, you may pass a pointer `outNewNodeId`, which will (after a successful
  906. * node insertion) contain the nodeId of the new node. You may also pass a
  907. * ``NULL`` pointer if this result is not needed.
  908. *
  909. * See the Section :ref:`node-lifecycle` on constructors and on attaching
  910. * user-defined data to nodes.
  911. *
  912. * The methods for node addition and deletion take mostly const arguments that
  913. * are not modified. When creating a node, a deep copy of the node identifier,
  914. * node attributes, etc. is created. Therefore, it is possible to call for
  915. * example ``UA_Server_addVariablenode`` with a value attribute (a
  916. * :ref:`variant`) pointing to a memory location on the stack. If you need
  917. * changes to a variable value to manifest at a specific memory location, please
  918. * use a :ref:`datasource` or a :ref:`value-callback`. */
  919. /* Protect against redundant definitions for server/client */
  920. #ifndef UA_DEFAULT_ATTRIBUTES_DEFINED
  921. #define UA_DEFAULT_ATTRIBUTES_DEFINED
  922. /* The default for variables is "BaseDataType" for the datatype, -2 for the
  923. * valuerank and a read-accesslevel. */
  924. UA_EXPORT extern const UA_VariableAttributes UA_VariableAttributes_default;
  925. UA_EXPORT extern const UA_VariableTypeAttributes UA_VariableTypeAttributes_default;
  926. /* Methods are executable by default */
  927. UA_EXPORT extern const UA_MethodAttributes UA_MethodAttributes_default;
  928. /* The remaining attribute definitions are currently all zeroed out */
  929. UA_EXPORT extern const UA_ObjectAttributes UA_ObjectAttributes_default;
  930. UA_EXPORT extern const UA_ObjectTypeAttributes UA_ObjectTypeAttributes_default;
  931. UA_EXPORT extern const UA_ReferenceTypeAttributes UA_ReferenceTypeAttributes_default;
  932. UA_EXPORT extern const UA_DataTypeAttributes UA_DataTypeAttributes_default;
  933. UA_EXPORT extern const UA_ViewAttributes UA_ViewAttributes_default;
  934. #endif
  935. /* Don't use this function. There are typed versions as inline functions. */
  936. UA_StatusCode UA_EXPORT UA_THREADSAFE
  937. __UA_Server_addNode(UA_Server *server, const UA_NodeClass nodeClass,
  938. const UA_NodeId *requestedNewNodeId,
  939. const UA_NodeId *parentNodeId,
  940. const UA_NodeId *referenceTypeId,
  941. const UA_QualifiedName browseName,
  942. const UA_NodeId *typeDefinition,
  943. const UA_NodeAttributes *attr,
  944. const UA_DataType *attributeType,
  945. void *nodeContext, UA_NodeId *outNewNodeId);
  946. static UA_INLINE UA_THREADSAFE UA_StatusCode
  947. UA_Server_addVariableNode(UA_Server *server, const UA_NodeId requestedNewNodeId,
  948. const UA_NodeId parentNodeId,
  949. const UA_NodeId referenceTypeId,
  950. const UA_QualifiedName browseName,
  951. const UA_NodeId typeDefinition,
  952. const UA_VariableAttributes attr,
  953. void *nodeContext, UA_NodeId *outNewNodeId) {
  954. return __UA_Server_addNode(server, UA_NODECLASS_VARIABLE, &requestedNewNodeId,
  955. &parentNodeId, &referenceTypeId, browseName,
  956. &typeDefinition, (const UA_NodeAttributes*)&attr,
  957. &UA_TYPES[UA_TYPES_VARIABLEATTRIBUTES],
  958. nodeContext, outNewNodeId);
  959. }
  960. static UA_INLINE UA_THREADSAFE UA_StatusCode
  961. UA_Server_addVariableTypeNode(UA_Server *server,
  962. const UA_NodeId requestedNewNodeId,
  963. const UA_NodeId parentNodeId,
  964. const UA_NodeId referenceTypeId,
  965. const UA_QualifiedName browseName,
  966. const UA_NodeId typeDefinition,
  967. const UA_VariableTypeAttributes attr,
  968. void *nodeContext, UA_NodeId *outNewNodeId) {
  969. return __UA_Server_addNode(server, UA_NODECLASS_VARIABLETYPE,
  970. &requestedNewNodeId, &parentNodeId, &referenceTypeId,
  971. browseName, &typeDefinition,
  972. (const UA_NodeAttributes*)&attr,
  973. &UA_TYPES[UA_TYPES_VARIABLETYPEATTRIBUTES],
  974. nodeContext, outNewNodeId);
  975. }
  976. static UA_INLINE UA_THREADSAFE UA_StatusCode
  977. UA_Server_addObjectNode(UA_Server *server, const UA_NodeId requestedNewNodeId,
  978. const UA_NodeId parentNodeId,
  979. const UA_NodeId referenceTypeId,
  980. const UA_QualifiedName browseName,
  981. const UA_NodeId typeDefinition,
  982. const UA_ObjectAttributes attr,
  983. void *nodeContext, UA_NodeId *outNewNodeId) {
  984. return __UA_Server_addNode(server, UA_NODECLASS_OBJECT, &requestedNewNodeId,
  985. &parentNodeId, &referenceTypeId, browseName,
  986. &typeDefinition, (const UA_NodeAttributes*)&attr,
  987. &UA_TYPES[UA_TYPES_OBJECTATTRIBUTES],
  988. nodeContext, outNewNodeId);
  989. }
  990. static UA_INLINE UA_THREADSAFE UA_StatusCode
  991. UA_Server_addObjectTypeNode(UA_Server *server, const UA_NodeId requestedNewNodeId,
  992. const UA_NodeId parentNodeId,
  993. const UA_NodeId referenceTypeId,
  994. const UA_QualifiedName browseName,
  995. const UA_ObjectTypeAttributes attr,
  996. void *nodeContext, UA_NodeId *outNewNodeId) {
  997. return __UA_Server_addNode(server, UA_NODECLASS_OBJECTTYPE, &requestedNewNodeId,
  998. &parentNodeId, &referenceTypeId, browseName,
  999. &UA_NODEID_NULL, (const UA_NodeAttributes*)&attr,
  1000. &UA_TYPES[UA_TYPES_OBJECTTYPEATTRIBUTES],
  1001. nodeContext, outNewNodeId);
  1002. }
  1003. static UA_INLINE UA_THREADSAFE UA_StatusCode
  1004. UA_Server_addViewNode(UA_Server *server, const UA_NodeId requestedNewNodeId,
  1005. const UA_NodeId parentNodeId,
  1006. const UA_NodeId referenceTypeId,
  1007. const UA_QualifiedName browseName,
  1008. const UA_ViewAttributes attr,
  1009. void *nodeContext, UA_NodeId *outNewNodeId) {
  1010. return __UA_Server_addNode(server, UA_NODECLASS_VIEW, &requestedNewNodeId,
  1011. &parentNodeId, &referenceTypeId, browseName,
  1012. &UA_NODEID_NULL, (const UA_NodeAttributes*)&attr,
  1013. &UA_TYPES[UA_TYPES_VIEWATTRIBUTES],
  1014. nodeContext, outNewNodeId);
  1015. }
  1016. static UA_INLINE UA_THREADSAFE UA_StatusCode
  1017. UA_Server_addReferenceTypeNode(UA_Server *server,
  1018. const UA_NodeId requestedNewNodeId,
  1019. const UA_NodeId parentNodeId,
  1020. const UA_NodeId referenceTypeId,
  1021. const UA_QualifiedName browseName,
  1022. const UA_ReferenceTypeAttributes attr,
  1023. void *nodeContext, UA_NodeId *outNewNodeId) {
  1024. return __UA_Server_addNode(server, UA_NODECLASS_REFERENCETYPE,
  1025. &requestedNewNodeId, &parentNodeId, &referenceTypeId,
  1026. browseName, &UA_NODEID_NULL,
  1027. (const UA_NodeAttributes*)&attr,
  1028. &UA_TYPES[UA_TYPES_REFERENCETYPEATTRIBUTES],
  1029. nodeContext, outNewNodeId);
  1030. }
  1031. static UA_INLINE UA_THREADSAFE UA_StatusCode
  1032. UA_Server_addDataTypeNode(UA_Server *server,
  1033. const UA_NodeId requestedNewNodeId,
  1034. const UA_NodeId parentNodeId,
  1035. const UA_NodeId referenceTypeId,
  1036. const UA_QualifiedName browseName,
  1037. const UA_DataTypeAttributes attr,
  1038. void *nodeContext, UA_NodeId *outNewNodeId) {
  1039. return __UA_Server_addNode(server, UA_NODECLASS_DATATYPE, &requestedNewNodeId,
  1040. &parentNodeId, &referenceTypeId, browseName,
  1041. &UA_NODEID_NULL, (const UA_NodeAttributes*)&attr,
  1042. &UA_TYPES[UA_TYPES_DATATYPEATTRIBUTES],
  1043. nodeContext, outNewNodeId);
  1044. }
  1045. UA_StatusCode UA_EXPORT UA_THREADSAFE
  1046. UA_Server_addDataSourceVariableNode(UA_Server *server,
  1047. const UA_NodeId requestedNewNodeId,
  1048. const UA_NodeId parentNodeId,
  1049. const UA_NodeId referenceTypeId,
  1050. const UA_QualifiedName browseName,
  1051. const UA_NodeId typeDefinition,
  1052. const UA_VariableAttributes attr,
  1053. const UA_DataSource dataSource,
  1054. void *nodeContext, UA_NodeId *outNewNodeId);
  1055. #ifdef UA_ENABLE_METHODCALLS
  1056. UA_StatusCode UA_EXPORT UA_THREADSAFE
  1057. UA_Server_addMethodNodeEx(UA_Server *server, const UA_NodeId requestedNewNodeId,
  1058. const UA_NodeId parentNodeId,
  1059. const UA_NodeId referenceTypeId,
  1060. const UA_QualifiedName browseName,
  1061. const UA_MethodAttributes attr, UA_MethodCallback method,
  1062. size_t inputArgumentsSize, const UA_Argument *inputArguments,
  1063. const UA_NodeId inputArgumentsRequestedNewNodeId,
  1064. UA_NodeId *inputArgumentsOutNewNodeId,
  1065. size_t outputArgumentsSize, const UA_Argument *outputArguments,
  1066. const UA_NodeId outputArgumentsRequestedNewNodeId,
  1067. UA_NodeId *outputArgumentsOutNewNodeId,
  1068. void *nodeContext, UA_NodeId *outNewNodeId);
  1069. static UA_INLINE UA_THREADSAFE UA_StatusCode
  1070. UA_Server_addMethodNode(UA_Server *server, const UA_NodeId requestedNewNodeId,
  1071. const UA_NodeId parentNodeId, const UA_NodeId referenceTypeId,
  1072. const UA_QualifiedName browseName, const UA_MethodAttributes attr,
  1073. UA_MethodCallback method,
  1074. size_t inputArgumentsSize, const UA_Argument *inputArguments,
  1075. size_t outputArgumentsSize, const UA_Argument *outputArguments,
  1076. void *nodeContext, UA_NodeId *outNewNodeId) {
  1077. return UA_Server_addMethodNodeEx(server, requestedNewNodeId, parentNodeId,
  1078. referenceTypeId, browseName, attr, method,
  1079. inputArgumentsSize, inputArguments, UA_NODEID_NULL, NULL,
  1080. outputArgumentsSize, outputArguments, UA_NODEID_NULL, NULL,
  1081. nodeContext, outNewNodeId);
  1082. }
  1083. #endif
  1084. /**
  1085. * The method pair UA_Server_addNode_begin and _finish splits the AddNodes
  1086. * service in two parts. This is useful if the node shall be modified before
  1087. * finish the instantiation. For example to add children with specific NodeIds.
  1088. * Otherwise, mandatory children (e.g. of an ObjectType) are added with
  1089. * pseudo-random unique NodeIds. Existing children are detected during the
  1090. * _finish part via their matching BrowseName.
  1091. *
  1092. * The _begin method:
  1093. * - prepares the node and adds it to the nodestore
  1094. * - copies some unassigned attributes from the TypeDefinition node internally
  1095. * - adds the references to the parent (and the TypeDefinition if applicable)
  1096. * - performs type-checking of variables.
  1097. *
  1098. * You can add an object node without a parent if you set the parentNodeId and
  1099. * referenceTypeId to UA_NODE_ID_NULL. Then you need to add the parent reference
  1100. * and hasTypeDef reference yourself before calling the _finish method.
  1101. * Not that this is only allowed for object nodes.
  1102. *
  1103. * The _finish method:
  1104. * - copies mandatory children
  1105. * - calls the node constructor(s) at the end
  1106. * - may remove the node if it encounters an error.
  1107. *
  1108. * The special UA_Server_addMethodNode_finish method needs to be used for
  1109. * method nodes, since there you need to explicitly specifiy the input
  1110. * and output arguments which are added in the finish step (if not yet already there)
  1111. **/
  1112. /* The ``attr`` argument must have a type according to the NodeClass.
  1113. * ``VariableAttributes`` for variables, ``ObjectAttributes`` for objects, and
  1114. * so on. Missing attributes are taken from the TypeDefinition node if
  1115. * applicable. */
  1116. UA_StatusCode UA_EXPORT UA_THREADSAFE
  1117. UA_Server_addNode_begin(UA_Server *server, const UA_NodeClass nodeClass,
  1118. const UA_NodeId requestedNewNodeId,
  1119. const UA_NodeId parentNodeId,
  1120. const UA_NodeId referenceTypeId,
  1121. const UA_QualifiedName browseName,
  1122. const UA_NodeId typeDefinition,
  1123. const void *attr, const UA_DataType *attributeType,
  1124. void *nodeContext, UA_NodeId *outNewNodeId);
  1125. UA_StatusCode UA_EXPORT UA_THREADSAFE
  1126. UA_Server_addNode_finish(UA_Server *server, const UA_NodeId nodeId);
  1127. #ifdef UA_ENABLE_METHODCALLS
  1128. UA_StatusCode UA_EXPORT UA_THREADSAFE
  1129. UA_Server_addMethodNode_finish(UA_Server *server, const UA_NodeId nodeId,
  1130. UA_MethodCallback method,
  1131. size_t inputArgumentsSize, const UA_Argument* inputArguments,
  1132. size_t outputArgumentsSize, const UA_Argument* outputArguments);
  1133. #endif
  1134. /* Deletes a node and optionally all references leading to the node. */
  1135. UA_StatusCode UA_EXPORT UA_THREADSAFE
  1136. UA_Server_deleteNode(UA_Server *server, const UA_NodeId nodeId,
  1137. UA_Boolean deleteReferences);
  1138. /**
  1139. * Reference Management
  1140. * -------------------- */
  1141. UA_StatusCode UA_EXPORT UA_THREADSAFE
  1142. UA_Server_addReference(UA_Server *server, const UA_NodeId sourceId,
  1143. const UA_NodeId refTypeId,
  1144. const UA_ExpandedNodeId targetId, UA_Boolean isForward);
  1145. UA_StatusCode UA_EXPORT UA_THREADSAFE
  1146. UA_Server_deleteReference(UA_Server *server, const UA_NodeId sourceNodeId,
  1147. const UA_NodeId referenceTypeId, UA_Boolean isForward,
  1148. const UA_ExpandedNodeId targetNodeId,
  1149. UA_Boolean deleteBidirectional);
  1150. /**
  1151. * .. _events:
  1152. *
  1153. * Events
  1154. * ------
  1155. * The method ``UA_Server_createEvent`` creates an event and represents it as node. The node receives a unique `EventId`
  1156. * which is automatically added to the node.
  1157. * The method returns a `NodeId` to the object node which represents the event through ``outNodeId``. The `NodeId` can
  1158. * be used to set the attributes of the event. The generated `NodeId` is always numeric. ``outNodeId`` cannot be
  1159. * ``NULL``.
  1160. *
  1161. * Note: In order to see an event in UAExpert, the field `Time` must be given a value!
  1162. *
  1163. * The method ``UA_Server_triggerEvent`` "triggers" an event by adding it to all monitored items of the specified
  1164. * origin node and those of all its parents. Any filters specified by the monitored items are automatically applied.
  1165. * Using this method deletes the node generated by ``UA_Server_createEvent``. The `EventId` for the new event is
  1166. * generated automatically and is returned through ``outEventId``. ``NULL`` can be passed if the `EventId` is not
  1167. * needed. ``deleteEventNode`` specifies whether the node representation of the event should be deleted after invoking
  1168. * the method. This can be useful if events with the similar attributes are triggered frequently. ``UA_TRUE`` would
  1169. * cause the node to be deleted. */
  1170. #ifdef UA_ENABLE_SUBSCRIPTIONS_EVENTS
  1171. /* The EventQueueOverflowEventType is defined as abstract, therefore we can not
  1172. * create an instance of that type directly, but need to create a subtype. The
  1173. * following is an arbitrary number which shall refer to our internal overflow
  1174. * type. This is already posted on the OPC Foundation bug tracker under the
  1175. * following link for clarification:
  1176. * https://opcfoundation-onlineapplications.org/mantis/view.php?id=4206 */
  1177. # define UA_NS0ID_SIMPLEOVERFLOWEVENTTYPE 4035
  1178. /* Creates a node representation of an event
  1179. *
  1180. * @param server The server object
  1181. * @param eventType The type of the event for which a node should be created
  1182. * @param outNodeId The NodeId of the newly created node for the event
  1183. * @return The StatusCode of the UA_Server_createEvent method */
  1184. UA_StatusCode UA_EXPORT UA_THREADSAFE
  1185. UA_Server_createEvent(UA_Server *server, const UA_NodeId eventType,
  1186. UA_NodeId *outNodeId);
  1187. /* Triggers a node representation of an event by applying EventFilters and
  1188. adding the event to the appropriate queues.
  1189. * @param server The server object
  1190. * @param eventNodeId The NodeId of the node representation of the event which should be triggered
  1191. * @param outEvent the EventId of the new event
  1192. * @param deleteEventNode Specifies whether the node representation of the event should be deleted
  1193. * @return The StatusCode of the UA_Server_triggerEvent method */
  1194. UA_StatusCode UA_EXPORT UA_THREADSAFE
  1195. UA_Server_triggerEvent(UA_Server *server, const UA_NodeId eventNodeId, const UA_NodeId originId,
  1196. UA_ByteString *outEventId, const UA_Boolean deleteEventNode);
  1197. #endif /* UA_ENABLE_SUBSCRIPTIONS_EVENTS */
  1198. UA_StatusCode UA_EXPORT
  1199. UA_Server_updateCertificate(UA_Server *server,
  1200. const UA_ByteString *oldCertificate,
  1201. const UA_ByteString *newCertificate,
  1202. const UA_ByteString *newPrivateKey,
  1203. UA_Boolean closeSessions,
  1204. UA_Boolean closeSecureChannels);
  1205. /**
  1206. * Utility Functions
  1207. * ----------------- */
  1208. /* Add a new namespace to the server. Returns the index of the new namespace */
  1209. UA_UInt16 UA_EXPORT UA_THREADSAFE UA_Server_addNamespace(UA_Server *server, const char* name);
  1210. /* Get namespace by name from the server. */
  1211. UA_StatusCode UA_EXPORT UA_THREADSAFE
  1212. UA_Server_getNamespaceByName(UA_Server *server, const UA_String namespaceUri,
  1213. size_t* foundIndex);
  1214. #ifdef UA_ENABLE_HISTORIZING
  1215. UA_Boolean UA_EXPORT UA_THREADSAFE
  1216. UA_Server_AccessControl_allowHistoryUpdateUpdateData(UA_Server *server,
  1217. const UA_NodeId *sessionId, void *sessionContext,
  1218. const UA_NodeId *nodeId,
  1219. UA_PerformUpdateType performInsertReplace,
  1220. const UA_DataValue *value);
  1221. UA_Boolean UA_EXPORT UA_THREADSAFE
  1222. UA_Server_AccessControl_allowHistoryUpdateDeleteRawModified(UA_Server *server,
  1223. const UA_NodeId *sessionId, void *sessionContext,
  1224. const UA_NodeId *nodeId,
  1225. UA_DateTime startTimestamp,
  1226. UA_DateTime endTimestamp,
  1227. bool isDeleteModified);
  1228. #endif // UA_ENABLE_HISTORIZING
  1229. /**
  1230. * .. _async_operations:
  1231. *
  1232. * Async Operations
  1233. * ----------------
  1234. * Some operations (such as reading out a sensor that needs to warm up) can take
  1235. * quite some time. In order not to block the server during such an operation, it
  1236. * can be "outsourced" to a worker thread.
  1237. *
  1238. * Take the example of a CallRequest. It is split into the individual method call
  1239. * operations. If the method is marked as async, then the operation is put into a
  1240. * queue where it is be retrieved by a worker. The worker returns the result when
  1241. * ready. See the examples in ``/examples/tutorial_server_method_async.c`` for
  1242. * the usage.
  1243. *
  1244. * Note that the operation can time out (see the asyncOperationTimeout setting in
  1245. * the server config) also when it has been retrieved by the worker. */
  1246. #if UA_MULTITHREADING >= 100
  1247. /* Set the async flag in a method node */
  1248. UA_StatusCode UA_EXPORT
  1249. UA_Server_setMethodNodeAsync(UA_Server *server, const UA_NodeId id,
  1250. UA_Boolean isAsync);
  1251. typedef enum {
  1252. UA_ASYNCOPERATIONTYPE_INVALID, /* 0, the default */
  1253. UA_ASYNCOPERATIONTYPE_CALL
  1254. /* UA_ASYNCOPERATIONTYPE_READ, */
  1255. /* UA_ASYNCOPERATIONTYPE_WRITE, */
  1256. } UA_AsyncOperationType;
  1257. typedef union {
  1258. UA_CallMethodRequest callMethodRequest;
  1259. /* UA_ReadValueId readValueId; */
  1260. /* UA_WriteValue writeValue; */
  1261. } UA_AsyncOperationRequest;
  1262. typedef union {
  1263. UA_CallMethodResult callMethodResult;
  1264. /* UA_DataValue readResult; */
  1265. /* UA_StatusCode writeResult; */
  1266. } UA_AsyncOperationResponse;
  1267. /* Get the next async operation without blocking
  1268. *
  1269. * @param server The server object
  1270. * @param type The type of the async operation
  1271. * @param request Receives pointer to the operation
  1272. * @param context Receives the pointer to the operation context
  1273. * @param timeout The timestamp when the operation times out and can
  1274. * no longer be returned to the client. The response has to
  1275. * be set in UA_Server_setAsyncOperationResult in any case.
  1276. * @return false if queue is empty, true else */
  1277. UA_Boolean UA_EXPORT
  1278. UA_Server_getAsyncOperationNonBlocking(UA_Server *server, UA_AsyncOperationType *type,
  1279. const UA_AsyncOperationRequest **request,
  1280. void **context, UA_DateTime *timeout);
  1281. /* UA_Boolean UA_EXPORT */
  1282. /* UA_Server_getAsyncOperationBlocking(UA_Server *server, UA_AsyncOperationType *type, */
  1283. /* const UA_AsyncOperationRequest **request, */
  1284. /* void **context, UA_DateTime *timeout); */
  1285. /* Submit an async operation result
  1286. *
  1287. * @param server The server object
  1288. * @param response Pointer to the operation result
  1289. * @param context Pointer to the operation context */
  1290. void UA_EXPORT
  1291. UA_Server_setAsyncOperationResult(UA_Server *server,
  1292. const UA_AsyncOperationResponse *response,
  1293. void *context);
  1294. /* Get the next async operation. Attention! This method is deprecated and has
  1295. * been replaced by UA_Server_getAsyncOperationNonBlocking! */
  1296. UA_DEPRECATED UA_Boolean UA_EXPORT
  1297. UA_Server_getAsyncOperation(UA_Server *server, UA_AsyncOperationType *type,
  1298. const UA_AsyncOperationRequest **request,
  1299. void **context);
  1300. #endif /* !UA_MULTITHREADING >= 100 */
  1301. _UA_END_DECLS
  1302. #endif /* UA_SERVER_H_ */