iec61850_client.h 119 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079
  1. /*
  2. * iec61850_client.h
  3. *
  4. * Copyright 2013-2021 Michael Zillgith
  5. *
  6. * This file is part of libIEC61850.
  7. *
  8. * libIEC61850 is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * libIEC61850 is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with libIEC61850. If not, see <http://www.gnu.org/licenses/>.
  20. *
  21. * See COPYING file for the complete license text.
  22. */
  23. #ifndef IEC61850_CLIENT_H_
  24. #define IEC61850_CLIENT_H_
  25. #ifdef __cplusplus
  26. extern "C" {
  27. #endif
  28. #include "libiec61850_common_api.h"
  29. #include "iec61850_common.h"
  30. #include "mms_value.h"
  31. #include "mms_client_connection.h"
  32. #include "linked_list.h"
  33. /**
  34. * * \defgroup iec61850_client_api_group IEC 61850/MMS client API
  35. */
  36. /**@{*/
  37. /** an opaque handle to the instance data of a ClientDataSet object */
  38. typedef struct sClientDataSet* ClientDataSet;
  39. /** an opaque handle to the instance data of a ClientReport object */
  40. typedef struct sClientReport* ClientReport;
  41. /** an opaque handle to the instance data of a ClientReportControlBlock object */
  42. typedef struct sClientReportControlBlock* ClientReportControlBlock;
  43. /** an opaque handle to the instance data of a ClientGooseControlBlock object */
  44. typedef struct sClientGooseControlBlock* ClientGooseControlBlock;
  45. /**
  46. * @defgroup IEC61850_CLIENT_GENERAL General client side connection handling functions and data types
  47. *
  48. * @{
  49. */
  50. /** An opaque handle to the instance data of the IedConnection object */
  51. typedef struct sIedConnection* IedConnection;
  52. /** Detailed description of the last application error of the client connection instance */
  53. typedef struct
  54. {
  55. int ctlNum;
  56. ControlLastApplError error;
  57. ControlAddCause addCause;
  58. } LastApplError;
  59. /** Connection state of the IedConnection instance - either closed(idle), connecting, connected, or closing) */
  60. typedef enum
  61. {
  62. IED_STATE_CLOSED = 0,
  63. IED_STATE_CONNECTING,
  64. IED_STATE_CONNECTED,
  65. IED_STATE_CLOSING
  66. } IedConnectionState;
  67. /** used to describe the error reason for most client side service functions */
  68. typedef enum {
  69. /* general errors */
  70. /** No error occurred - service request has been successful */
  71. IED_ERROR_OK = 0,
  72. /** The service request can not be executed because the client is not yet connected */
  73. IED_ERROR_NOT_CONNECTED = 1,
  74. /** Connect service not execute because the client is already connected */
  75. IED_ERROR_ALREADY_CONNECTED = 2,
  76. /** The service request can not be executed caused by a loss of connection */
  77. IED_ERROR_CONNECTION_LOST = 3,
  78. /** The service or some given parameters are not supported by the client stack or by the server */
  79. IED_ERROR_SERVICE_NOT_SUPPORTED = 4,
  80. /** Connection rejected by server */
  81. IED_ERROR_CONNECTION_REJECTED = 5,
  82. /** Cannot send request because outstanding call limit is reached */
  83. IED_ERROR_OUTSTANDING_CALL_LIMIT_REACHED = 6,
  84. /* client side errors */
  85. /** API function has been called with an invalid argument */
  86. IED_ERROR_USER_PROVIDED_INVALID_ARGUMENT = 10,
  87. IED_ERROR_ENABLE_REPORT_FAILED_DATASET_MISMATCH = 11,
  88. /** The object provided object reference is invalid (there is a syntactical error). */
  89. IED_ERROR_OBJECT_REFERENCE_INVALID = 12,
  90. /** Received object is of unexpected type */
  91. IED_ERROR_UNEXPECTED_VALUE_RECEIVED = 13,
  92. /* service error - error reported by server */
  93. /** The communication to the server failed with a timeout */
  94. IED_ERROR_TIMEOUT = 20,
  95. /** The server rejected the access to the requested object/service due to access control */
  96. IED_ERROR_ACCESS_DENIED = 21,
  97. /** The server reported that the requested object does not exist (returned by server) */
  98. IED_ERROR_OBJECT_DOES_NOT_EXIST = 22,
  99. /** The server reported that the requested object already exists */
  100. IED_ERROR_OBJECT_EXISTS = 23,
  101. /** The server does not support the requested access method (returned by server) */
  102. IED_ERROR_OBJECT_ACCESS_UNSUPPORTED = 24,
  103. /** The server expected an object of another type (returned by server) */
  104. IED_ERROR_TYPE_INCONSISTENT = 25,
  105. /** The object or service is temporarily unavailable (returned by server) */
  106. IED_ERROR_TEMPORARILY_UNAVAILABLE = 26,
  107. /** The specified object is not defined in the server (returned by server) */
  108. IED_ERROR_OBJECT_UNDEFINED = 27,
  109. /** The specified address is invalid (returned by server) */
  110. IED_ERROR_INVALID_ADDRESS = 28,
  111. /** Service failed due to a hardware fault (returned by server) */
  112. IED_ERROR_HARDWARE_FAULT = 29,
  113. /** The requested data type is not supported by the server (returned by server) */
  114. IED_ERROR_TYPE_UNSUPPORTED = 30,
  115. /** The provided attributes are inconsistent (returned by server) */
  116. IED_ERROR_OBJECT_ATTRIBUTE_INCONSISTENT = 31,
  117. /** The provided object value is invalid (returned by server) */
  118. IED_ERROR_OBJECT_VALUE_INVALID = 32,
  119. /** The object is invalidated (returned by server) */
  120. IED_ERROR_OBJECT_INVALIDATED = 33,
  121. /** Received an invalid response message from the server */
  122. IED_ERROR_MALFORMED_MESSAGE = 34,
  123. /** Service not implemented */
  124. IED_ERROR_SERVICE_NOT_IMPLEMENTED = 98,
  125. /** unknown error */
  126. IED_ERROR_UNKNOWN = 99
  127. } IedClientError;
  128. /**************************************************
  129. * Connection creation and destruction
  130. **************************************************/
  131. /**
  132. * \brief create a new IedConnection instance
  133. *
  134. * This function creates a new IedConnection instance that is used to handle a connection to an IED.
  135. * It allocated all required resources. The new connection is in the "CLOSED" state. Before it can be used
  136. * the connect method has to be called. The connection will be in non-TLS and thread mode.
  137. *
  138. * \return the new IedConnection instance
  139. */
  140. LIB61850_API IedConnection
  141. IedConnection_create(void);
  142. /**
  143. * \brief create a new IedConnection instance (extended version)
  144. *
  145. * This function creates a new IedConnection instance that is used to handle a connection to an IED.
  146. * It allocated all required resources. The new connection is in the "CLOSED" state. Before it can be used
  147. * the \ref IedConnection_connect or \ref IedConnection_connectAsync method has to be called.
  148. * The connection will use TLS when a TLSConfiguration object is provided. The useThread is false the
  149. * IedConnection is in non-thread mode and the IedConnection_tick function has to be called periodically to
  150. * receive messages and perform the house-keeping tasks.
  151. *
  152. * \param tlsConfig the TLS configuration to be used, or NULL for non-TLS connection
  153. * \param useThreads when true, the IedConnection is in thread mode
  154. *
  155. * \return the new IedConnection instance
  156. */
  157. LIB61850_API IedConnection
  158. IedConnection_createEx(TLSConfiguration tlsConfig, bool useThreads);
  159. /**
  160. * \brief create a new IedConnection instance that has support for TLS
  161. *
  162. * This function creates a new IedConnection instance that is used to handle a connection to an IED.
  163. * It allocated all required resources. The new connection is in the "CLOSED" state. Before it can be used
  164. * the \ref IedConnection_connect or \ref IedConnection_connectAsync method has to be called.
  165. * The connection will use TLS when a TLSConfiguration object is provided. The connection will be in thread mode.
  166. *
  167. * \deprecated Use \ref IedConnection_createEx instead
  168. *
  169. * \param tlsConfig the TLS configuration to be used
  170. *
  171. * \return the new IedConnection instance
  172. */
  173. LIB61850_API IedConnection
  174. IedConnection_createWithTlsSupport(TLSConfiguration tlsConfig);
  175. /**
  176. * \brief destroy an IedConnection instance.
  177. *
  178. * The connection will be closed if it is in "connected" state. All allocated resources of the connection
  179. * will be freed.
  180. *
  181. * \param self the connection object
  182. */
  183. LIB61850_API void
  184. IedConnection_destroy(IedConnection self);
  185. /**
  186. * \brief set the connect timeout in ms
  187. *
  188. * Set the connect timeout for this connection. This function has to be called before IedConnection_connect
  189. * is called.
  190. *
  191. * \param self the connection object
  192. * \param timoutInMs the connection timeout in ms
  193. */
  194. LIB61850_API void
  195. IedConnection_setConnectTimeout(IedConnection self, uint32_t timeoutInMs);
  196. /**
  197. * \brief set the request timeout in ms
  198. *
  199. * Set the request timeout for this connection. You can call this function any time to adjust
  200. * timeout behavior.
  201. *
  202. * \param self the connection object
  203. * \param timoutInMs the connection timeout in ms
  204. */
  205. LIB61850_API void
  206. IedConnection_setRequestTimeout(IedConnection self, uint32_t timeoutInMs);
  207. /**
  208. * \brief get the request timeout in ms for this connection
  209. *
  210. * \param self the connection object
  211. *
  212. * \return request timeout in milliseconds
  213. */
  214. LIB61850_API uint32_t
  215. IedConnection_getRequestTimeout(IedConnection self);
  216. /**
  217. * \brief Set the time quality for all timestamps generated by this IedConnection instance
  218. *
  219. * \param self the connection object
  220. * \param leapSecondKnown set/unset leap seconds known flag
  221. * \param clockFailure set/unset clock failure flag
  222. * \param clockNotSynchronized set/unset clock not synchronized flag
  223. * \param subsecondPrecision set the subsecond precision (number of significant bits of the fractionOfSecond part of the time stamp)
  224. */
  225. LIB61850_API void
  226. IedConnection_setTimeQuality(IedConnection self, bool leapSecondKnown, bool clockFailure, bool clockNotSynchronized, int subsecondPrecision);
  227. /**
  228. * \brief Perform MMS message handling and house-keeping tasks (for non-thread mode only)
  229. *
  230. * This function has to be called periodically by the user application in non-thread mode. The return
  231. * value helps to decide when the stack has nothing to do and other tasks can be executed.
  232. *
  233. * NOTE: When using non-thread mode you should NOT use the synchronous (blocking) API functions. The
  234. * synchronous functions will block forever when IedConnection_tick is not called in a separate thread.
  235. *
  236. * \return true when connection is currently waiting and calling thread can be suspended, false means
  237. * connection is busy and the tick function should be called again as soon as possible.
  238. */
  239. LIB61850_API bool
  240. IedConnection_tick(IedConnection self);
  241. /**
  242. * \brief Generic serivce callback handler
  243. *
  244. * NOTE: This callback handler is used by several asynchronous service functions that require
  245. * only a simple feedback in form of a success (IED_ERROR_OK) or failure (other \ref err value).
  246. *
  247. * \param invokeId the invoke ID used by the related service request
  248. * \param parameter user provided parameter
  249. * \param err the result code. IED_ERROR_OK indicates success.
  250. */
  251. typedef void
  252. (*IedConnection_GenericServiceHandler) (uint32_t invokeId, void* parameter, IedClientError err);
  253. /**************************************************
  254. * Association service
  255. **************************************************/
  256. /**
  257. * \brief Connect to a server
  258. *
  259. * NOTE: Function will block until connection is up or timeout happened.
  260. *
  261. * \param self the connection object
  262. * \param error the error code if an error occurs
  263. * \param hostname the host name or IP address of the server to connect to
  264. * \param tcpPort the TCP port number of the server to connect to
  265. */
  266. LIB61850_API void
  267. IedConnection_connect(IedConnection self, IedClientError* error, const char* hostname, int tcpPort);
  268. /**
  269. * \brief Asynchronously connect to a server
  270. *
  271. * The function will return immediately. No error doesn't indicate that the
  272. * connection is established. The current connection state has to be tracked
  273. * by polling the \ref IedConnection_getState function or by using
  274. * \ref IedConnection_StateChangedHandler
  275. *
  276. * \param self the connection object
  277. * \param error the error code if an error occurs
  278. * \param hostname the host name or IP address of the server to connect to
  279. * \param tcpPort the TCP port number of the server to connect to
  280. */
  281. LIB61850_API void
  282. IedConnection_connectAsync(IedConnection self, IedClientError* error, const char* hostname, int tcpPort);
  283. /**
  284. * \brief Abort the connection
  285. *
  286. * This will close the MMS association by sending an ACSE abort message to the server.
  287. * After sending the abort message the connection is closed immediately.
  288. * The client can assume the connection to be closed when the function returns and the
  289. * destroy method can be called. If the connection is not in "connected" state an
  290. * IED_ERROR_NOT_CONNECTED error will be reported.
  291. *
  292. * \param self the connection object
  293. * \param error the error code if an error occurs
  294. */
  295. LIB61850_API void
  296. IedConnection_abort(IedConnection self, IedClientError* error);
  297. /**
  298. * \brief Asynchronously abort the connection
  299. *
  300. * This will close the MMS association by sending an ACSE abort message to the server.
  301. * After sending the abort message the connection is closed immediately.
  302. * If the connection is not in "connected" state an IED_ERROR_NOT_CONNECTED error will be reported.
  303. *
  304. * NOTE: This function works asynchronously. The IedConnection object should not be destroyed before the
  305. * connection state changes to IED_STATE_CLOSED.
  306. *
  307. * \param self the connection object
  308. * \param error the error code if an error occurs
  309. */
  310. LIB61850_API void
  311. IedConnection_abortAsync(IedConnection self, IedClientError* error);
  312. /**
  313. * \brief Release the connection
  314. *
  315. * This will release the MMS association by sending an MMS conclude message to the server.
  316. * The client can NOT assume the connection to be closed when the function returns, It can
  317. * also fail if the server returns with a negative response. To be sure that the connection
  318. * will be close the close or abort methods should be used. If the connection is not in "connected" state an
  319. * IED_ERROR_NOT_CONNECTED error will be reported.
  320. *
  321. * \param self the connection object
  322. * \param error the error code if an error occurs
  323. */
  324. LIB61850_API void
  325. IedConnection_release(IedConnection self, IedClientError* error);
  326. /**
  327. * \brief Asynchronously release the connection
  328. *
  329. * This will release the MMS association by sending an MMS conclude message to the server.
  330. * The client can NOT assume the connection to be closed when the function returns, It can
  331. * also fail if the server returns with a negative response. To be sure that the connection
  332. * will be close the close or abort methods should be used. If the connection is not in "connected" state an
  333. * IED_ERROR_NOT_CONNECTED error will be reported.
  334. *
  335. * \param self the connection object
  336. * \param error the error code if an error occurs
  337. */
  338. LIB61850_API void
  339. IedConnection_releaseAsync(IedConnection self, IedClientError* error);
  340. /**
  341. * \brief Close the connection
  342. *
  343. * This will close the MMS association and the underlying TCP connection.
  344. *
  345. * \param self the connection object
  346. */
  347. LIB61850_API void
  348. IedConnection_close(IedConnection self);
  349. /**
  350. * \brief return the state of the connection.
  351. *
  352. * This function can be used to determine if the connection is established or closed.
  353. *
  354. * \param self the connection object
  355. *
  356. * \return the connection state
  357. */
  358. LIB61850_API IedConnectionState
  359. IedConnection_getState(IedConnection self);
  360. /**
  361. * \brief Access to last application error received by the client connection
  362. *
  363. * \param self the connection object
  364. *
  365. * \return the LastApplError value
  366. */
  367. LIB61850_API LastApplError
  368. IedConnection_getLastApplError(IedConnection self);
  369. /**
  370. * \brief Callback handler that is invoked when the connection is closed
  371. *
  372. * \deprecated Use \ref IedConnection_StateChangedHandler instead
  373. *
  374. * \param user provided parameter
  375. * \param connection the connection object of the closed connection
  376. */
  377. typedef void
  378. (*IedConnectionClosedHandler) (void* parameter, IedConnection connection);
  379. /**
  380. * \brief Install a handler function that is called when the connection is lost/closed.
  381. *
  382. * \deprecated Use \ref IedConnection_StateChangedHandler instead
  383. *
  384. * \param self the connection object
  385. * \param handler that callback function
  386. * \param parameter the user provided parameter that is handed over to the callback function
  387. */
  388. LIB61850_API void
  389. IedConnection_installConnectionClosedHandler(IedConnection self, IedConnectionClosedHandler handler,
  390. void* parameter);
  391. /**
  392. * \brief Callback handler that is invoked whenever the connection state (\ref IedConnectionState) changes
  393. *
  394. * \param user provided parameter
  395. * \param connection the related connection
  396. * \param newState the new state of the connection
  397. */
  398. typedef void
  399. (*IedConnection_StateChangedHandler) (void* parameter, IedConnection connection, IedConnectionState newState);
  400. /**
  401. * \brief Install a handler function that is called when the connection state changes
  402. *
  403. * \param self the connection object
  404. * \param handler that callback function
  405. * \param parameter the user provided parameter that is handed over to the callback function
  406. */
  407. LIB61850_API void
  408. IedConnection_installStateChangedHandler(IedConnection self, IedConnection_StateChangedHandler handler, void* parameter);
  409. /**
  410. * \brief get a handle to the underlying MmsConnection
  411. *
  412. * Get access to the underlying MmsConnection instance used by this IedConnection.
  413. * This can be used to set/change specific MmsConnection parameters or to call low-level MMS services/functions.
  414. *
  415. * \param self the connection object
  416. *
  417. * \return the MmsConnection instance used by this IedConnection.
  418. */
  419. LIB61850_API MmsConnection
  420. IedConnection_getMmsConnection(IedConnection self);
  421. /** @} */
  422. /**
  423. * @defgroup IEC61850_CLIENT_SV Client side SV control block handling functions
  424. *
  425. * @{
  426. */
  427. /** SV ASDU contains attribute RefrTm */
  428. #define IEC61850_SV_OPT_REFRESH_TIME 1
  429. /** SV ASDU contains attribute SmpSynch */
  430. #define IEC61850_SV_OPT_SAMPLE_SYNC 2
  431. /** SV ASDU contains attribute SmpRate */
  432. #define IEC61850_SV_OPT_SAMPLE_RATE 4
  433. /** SV ASDU contains attribute DatSet */
  434. #define IEC61850_SV_OPT_DATA_SET 8
  435. /** SV ASDU contains attribute Security */
  436. #define IEC61850_SV_OPT_SECURITY 16
  437. #define IEC61850_SV_SMPMOD_SAMPLES_PER_PERIOD 0
  438. #define IEC61850_SV_SMPMOD_SAMPLES_PER_SECOND 1
  439. #define IEC61850_SV_SMPMOD_SECONDS_PER_SAMPLE 2
  440. /** an opaque handle to the instance data of a ClientSVControlBlock object */
  441. typedef struct sClientSVControlBlock* ClientSVControlBlock;
  442. /**
  443. * \brief Create a new ClientSVControlBlock instance
  444. *
  445. * This function simplifies client side access to server MSV/USV control blocks
  446. * NOTE: Do not use the functions after the IedConnection object is invalidated!
  447. *
  448. * The access functions cause synchronous read/write calls to the server. For asynchronous
  449. * access use the \ref IedConnection_readObjectAsync and \ref IedConnection_writeObjectAsync
  450. * functions.
  451. *
  452. * \param connection the IedConnection object with a valid connection to the server.
  453. * \param reference the object reference of the control block
  454. *
  455. * \return the new instance
  456. */
  457. LIB61850_API ClientSVControlBlock
  458. ClientSVControlBlock_create(IedConnection connection, const char* reference);
  459. /**
  460. * \brief Free all resources related to the ClientSVControlBlock instance.
  461. *
  462. * \param self the ClientSVControlBlock instance to operate on
  463. */
  464. LIB61850_API void
  465. ClientSVControlBlock_destroy(ClientSVControlBlock self);
  466. /**
  467. * \brief Test if this SVCB is multicast
  468. *
  469. * \param self the ClientSVControlBlock instance to operate on
  470. *
  471. * \return true if multicast SCVB, false otherwise (unicast)
  472. */
  473. LIB61850_API bool
  474. ClientSVControlBlock_isMulticast(ClientSVControlBlock self);
  475. /**
  476. * \brief Return the error code of the last write or write acccess to the SVCB
  477. *
  478. * \param self the ClientSVControlBlock instance to operate on
  479. *
  480. * \return the error code of the last read or write access
  481. */
  482. LIB61850_API IedClientError
  483. ClientSVControlBlock_getLastComError(ClientSVControlBlock self);
  484. LIB61850_API bool
  485. ClientSVControlBlock_setSvEna(ClientSVControlBlock self, bool value);
  486. LIB61850_API bool
  487. ClientSVControlBlock_getSvEna(ClientSVControlBlock self);
  488. LIB61850_API bool
  489. ClientSVControlBlock_setResv(ClientSVControlBlock self, bool value);
  490. LIB61850_API bool
  491. ClientSVControlBlock_getResv(ClientSVControlBlock self);
  492. LIB61850_API char*
  493. ClientSVControlBlock_getMsvID(ClientSVControlBlock self);
  494. /**
  495. * \brief Get the (MMS) reference to the data set
  496. *
  497. * NOTE: the returned string is dynamically allocated with the
  498. * GLOBAL_MALLOC macro. The application is responsible to release
  499. * the memory when the string is no longer needed.
  500. *
  501. * \param self the ClientSVControlBlock instance to operate on
  502. *
  503. * \return the data set reference as a NULL terminated string
  504. */
  505. LIB61850_API char*
  506. ClientSVControlBlock_getDatSet(ClientSVControlBlock self);
  507. LIB61850_API uint32_t
  508. ClientSVControlBlock_getConfRev(ClientSVControlBlock self);
  509. LIB61850_API uint16_t
  510. ClientSVControlBlock_getSmpRate(ClientSVControlBlock self);
  511. /**
  512. * \brief returns the destination address of the SV publisher
  513. *
  514. * \param self the ClientSVControlBlock instance to operate on
  515. */
  516. LIB61850_API PhyComAddress
  517. ClientSVControlBlock_getDstAddress(ClientSVControlBlock self);
  518. /**
  519. * \brief Gets the OptFlds parameter of the RCB (decides what information to include in a report)
  520. *
  521. * \param self the RCB instance
  522. * \return bit field representing the optional fields of a report (uses flags from \ref REPORT_OPTIONS)
  523. */
  524. LIB61850_API int
  525. ClientSVControlBlock_getOptFlds(ClientSVControlBlock self);
  526. /**
  527. * \brief returns number of sample mode of the SV publisher
  528. *
  529. * \param self the ClientSVControlBlock instance to operate on
  530. */
  531. LIB61850_API uint8_t
  532. ClientSVControlBlock_getSmpMod(ClientSVControlBlock self);
  533. /**
  534. * \brief returns number of ASDUs included in the SV message
  535. *
  536. * \param self the ClientSVControlBlock instance to operate on
  537. *
  538. * \return the number of ASDU included in a single SV message
  539. */
  540. LIB61850_API int
  541. ClientSVControlBlock_getNoASDU(ClientSVControlBlock self);
  542. /** @} */
  543. /**
  544. * @defgroup IEC61850_CLIENT_GOOSE Client side GOOSE control block handling functions
  545. *
  546. * @{
  547. */
  548. /*********************************************************
  549. * GOOSE services handling (MMS part)
  550. ********************************************************/
  551. /** Enable GOOSE publisher GoCB block element */
  552. #define GOCB_ELEMENT_GO_ENA 1
  553. /** GOOSE ID GoCB block element */
  554. #define GOCB_ELEMENT_GO_ID 2
  555. /** Data set GoCB block element */
  556. #define GOCB_ELEMENT_DATSET 4
  557. /** Configuration revision GoCB block element (this is usually read-only) */
  558. #define GOCB_ELEMENT_CONF_REV 8
  559. /** Need commission GoCB block element (read-only according to 61850-7-2) */
  560. #define GOCB_ELEMENT_NDS_COMM 16
  561. /** Destination address GoCB block element (read-only according to 61850-7-2) */
  562. #define GOCB_ELEMENT_DST_ADDRESS 32
  563. /** Minimum time GoCB block element (read-only according to 61850-7-2) */
  564. #define GOCB_ELEMENT_MIN_TIME 64
  565. /** Maximum time GoCB block element (read-only according to 61850-7-2) */
  566. #define GOCB_ELEMENT_MAX_TIME 128
  567. /** Fixed offsets GoCB block element (read-only according to 61850-7-2) */
  568. #define GOCB_ELEMENT_FIXED_OFFS 256
  569. /** select all elements of the GoCB */
  570. #define GOCB_ELEMENT_ALL 511
  571. /**************************************************
  572. * ClientGooseControlBlock class
  573. **************************************************/
  574. LIB61850_API ClientGooseControlBlock
  575. ClientGooseControlBlock_create(const char* dataAttributeReference);
  576. LIB61850_API void
  577. ClientGooseControlBlock_destroy(ClientGooseControlBlock self);
  578. LIB61850_API bool
  579. ClientGooseControlBlock_getGoEna(ClientGooseControlBlock self);
  580. LIB61850_API void
  581. ClientGooseControlBlock_setGoEna(ClientGooseControlBlock self, bool goEna);
  582. LIB61850_API const char*
  583. ClientGooseControlBlock_getGoID(ClientGooseControlBlock self);
  584. LIB61850_API void
  585. ClientGooseControlBlock_setGoID(ClientGooseControlBlock self, const char* goID);
  586. LIB61850_API const char*
  587. ClientGooseControlBlock_getDatSet(ClientGooseControlBlock self);
  588. LIB61850_API void
  589. ClientGooseControlBlock_setDatSet(ClientGooseControlBlock self, const char* datSet);
  590. LIB61850_API uint32_t
  591. ClientGooseControlBlock_getConfRev(ClientGooseControlBlock self);
  592. LIB61850_API bool
  593. ClientGooseControlBlock_getNdsComm(ClientGooseControlBlock self);
  594. LIB61850_API uint32_t
  595. ClientGooseControlBlock_getMinTime(ClientGooseControlBlock self);
  596. LIB61850_API uint32_t
  597. ClientGooseControlBlock_getMaxTime(ClientGooseControlBlock self);
  598. LIB61850_API bool
  599. ClientGooseControlBlock_getFixedOffs(ClientGooseControlBlock self);
  600. LIB61850_API PhyComAddress
  601. ClientGooseControlBlock_getDstAddress(ClientGooseControlBlock self);
  602. LIB61850_API void
  603. ClientGooseControlBlock_setDstAddress(ClientGooseControlBlock self, PhyComAddress value);
  604. LIB61850_API DEPRECATED MmsValue* /* MMS_OCTET_STRING */
  605. ClientGooseControlBlock_getDstAddress_addr(ClientGooseControlBlock self);
  606. LIB61850_API DEPRECATED void
  607. ClientGooseControlBlock_setDstAddress_addr(ClientGooseControlBlock self, MmsValue* macAddr);
  608. LIB61850_API DEPRECATED uint8_t
  609. ClientGooseControlBlock_getDstAddress_priority(ClientGooseControlBlock self);
  610. LIB61850_API DEPRECATED void
  611. ClientGooseControlBlock_setDstAddress_priority(ClientGooseControlBlock self, uint8_t priorityValue);
  612. LIB61850_API DEPRECATED uint16_t
  613. ClientGooseControlBlock_getDstAddress_vid(ClientGooseControlBlock self);
  614. LIB61850_API DEPRECATED void
  615. ClientGooseControlBlock_setDstAddress_vid(ClientGooseControlBlock self, uint16_t vidValue);
  616. LIB61850_API DEPRECATED uint16_t
  617. ClientGooseControlBlock_getDstAddress_appid(ClientGooseControlBlock self);
  618. LIB61850_API DEPRECATED void
  619. ClientGooseControlBlock_setDstAddress_appid(ClientGooseControlBlock self, uint16_t appidValue);
  620. /*********************************************************
  621. * GOOSE services (access to GOOSE Control Blocks (GoCB))
  622. ********************************************************/
  623. /**
  624. * \brief Read access to attributes of a GOOSE control block (GoCB) at the connected server. A GoCB contains
  625. * the configuration values for a single GOOSE publisher.
  626. *
  627. * The requested GoCB has to be specified by its object IEC 61850 ACSI object reference. E.g.
  628. *
  629. * "simpleIOGernericIO/LLN0.gcbEvents"
  630. *
  631. * This function is used to perform the actual read service for the GoCB values.
  632. * To access the received values the functions of ClientGooseControlBlock have to be used.
  633. *
  634. * If called with a NULL argument for the updateGoCB parameter a new ClientGooseControlBlock instance is created
  635. * and populated with the values received by the server. It is up to the user to release this object by
  636. * calling the ClientGooseControlBlock_destroy function when the object is no longer needed. If called with a reference
  637. * to an existing ClientGooseControlBlock instance the values of the attributes will be updated and no new instance
  638. * will be created.
  639. *
  640. * Note: This function maps to a single MMS read request to retrieve the complete GoCB at once.
  641. *
  642. * \param connection the connection object
  643. * \param error the error code if an error occurs
  644. * \param goCBReference IEC 61850-7-2 ACSI object reference of the GOOSE control block
  645. * \param updateRcb a reference to an existing ClientGooseControlBlock instance or NULL
  646. *
  647. * \return new ClientGooseControlBlock instance or the instance provided by the user with
  648. * the updateRcb parameter.
  649. */
  650. LIB61850_API ClientGooseControlBlock
  651. IedConnection_getGoCBValues(IedConnection self, IedClientError* error, const char* goCBReference, ClientGooseControlBlock updateGoCB);
  652. /**
  653. * \brief Write access to attributes of a GOOSE control block (GoCB) at the connected server
  654. *
  655. * The GoCB and the values to be written are specified with the goCB parameter.
  656. *
  657. * The parametersMask parameter specifies which attributes of the remote GoCB have to be set by this request.
  658. * You can specify multiple attributes by ORing the defined bit values. If all attributes have to be written
  659. * GOCB_ELEMENT_ALL can be used.
  660. *
  661. * The singleRequest parameter specifies the mapping to the corresponding MMS write request. Standard compliant
  662. * servers should accept both variants. But some server accept only one variant. Then the value of this parameter
  663. * will be of relevance.
  664. *
  665. * \param connection the connection object
  666. * \param error the error code if an error occurs
  667. * \param goCB ClientGooseControlBlock instance that actually holds the parameter
  668. * values to be written.
  669. * \param parametersMask specifies the parameters contained in the setGoCBValues request.
  670. * \param singleRequest specifies if the seGoCBValues services is mapped to a single MMS write request containing
  671. * multiple variables or to multiple MMS write requests.
  672. */
  673. LIB61850_API void
  674. IedConnection_setGoCBValues(IedConnection self, IedClientError* error, ClientGooseControlBlock goCB,
  675. uint32_t parametersMask, bool singleRequest);
  676. /** @} */
  677. /****************************************
  678. * Data model access services
  679. ****************************************/
  680. /**
  681. * @defgroup IEC61850_CLIENT_DATA_ACCESS Client side data access (read/write) service functions
  682. *
  683. * @{
  684. */
  685. /**
  686. * \brief read a functional constrained data attribute (FCDA) or functional constrained data (FCD).
  687. *
  688. * \param self the connection object to operate on
  689. * \param error the error code if an error occurs
  690. * \param object reference of the object/attribute to read
  691. * \param fc the functional constraint of the data attribute or data object to read
  692. *
  693. * \return the MmsValue instance of the received value or NULL if the request failed
  694. */
  695. LIB61850_API MmsValue*
  696. IedConnection_readObject(IedConnection self, IedClientError* error, const char* dataAttributeReference, FunctionalConstraint fc);
  697. typedef void
  698. (*IedConnection_ReadObjectHandler) (uint32_t invokeId, void* parameter, IedClientError err, MmsValue* value);
  699. /**
  700. * \brief read a functional constrained data attribute (FCDA) or functional constrained data (FCD) - async version
  701. *
  702. * \param self the connection object to operate on
  703. * \param error the error code if an error occurs
  704. * \param object reference of the object/attribute to read
  705. * \param fc the functional constraint of the data attribute or data object to read
  706. * \param handler the user provided callback handler
  707. * \param parameter user provided parameter that is passed to the callback handler
  708. *
  709. * \return the invoke ID of the request
  710. */
  711. LIB61850_API uint32_t
  712. IedConnection_readObjectAsync(IedConnection self, IedClientError* error, const char* objRef, FunctionalConstraint fc,
  713. IedConnection_ReadObjectHandler handler, void* parameter);
  714. /**
  715. * \brief write a functional constrained data attribute (FCDA) or functional constrained data (FCD).
  716. *
  717. * \param self the connection object to operate on
  718. * \param error the error code if an error occurs
  719. * \param object reference of the object/attribute to write
  720. * \param fc the functional constraint of the data attribute or data object to write
  721. * \param value the MmsValue to write (has to be of the correct type - MMS_STRUCTURE for FCD)
  722. */
  723. LIB61850_API void
  724. IedConnection_writeObject(IedConnection self, IedClientError* error, const char* dataAttributeReference, FunctionalConstraint fc,
  725. MmsValue* value);
  726. /**
  727. * \brief write a functional constrained data attribute (FCDA) or functional constrained data (FCD) - async version
  728. *
  729. * \param self the connection object to operate on
  730. * \param error the error code if an error occurs
  731. * \param object reference of the object/attribute to write
  732. * \param fc the functional constraint of the data attribute or data object to write
  733. * \param value the MmsValue to write (has to be of the correct type - MMS_STRUCTURE for FCD)
  734. * \param handler the user provided callback handler
  735. * \param parameter user provided parameter that is passed to the callback handler
  736. *
  737. * \return the invoke ID of the request
  738. */
  739. LIB61850_API uint32_t
  740. IedConnection_writeObjectAsync(IedConnection self, IedClientError* error, const char* objectReference,
  741. FunctionalConstraint fc, MmsValue* value, IedConnection_GenericServiceHandler handler, void* parameter);
  742. /**
  743. * \brief read a functional constrained data attribute (FCDA) of type boolean
  744. *
  745. * \param self the connection object to operate on
  746. * \param error the error code if an error occurs
  747. * \param object reference of the data attribute to read
  748. * \param fc the functional constraint of the data attribute to read
  749. */
  750. LIB61850_API bool
  751. IedConnection_readBooleanValue(IedConnection self, IedClientError* error, const char* objectReference, FunctionalConstraint fc);
  752. /**
  753. * \brief read a functional constrained data attribute (FCDA) of type float
  754. *
  755. * \param self the connection object to operate on
  756. * \param error the error code if an error occurs
  757. * \param object reference of the data attribute to read
  758. * \param fc the functional constraint of the data attribute to read
  759. */
  760. LIB61850_API float
  761. IedConnection_readFloatValue(IedConnection self, IedClientError* error, const char* objectReference, FunctionalConstraint fc);
  762. /**
  763. * \brief read a functional constrained data attribute (FCDA) of type VisibleString or MmsString
  764. *
  765. * NOTE: the returned char buffer is dynamically allocated and has to be freed by the caller!
  766. *
  767. * \param self the connection object to operate on
  768. * \param error the error code if an error occurs
  769. * \param object reference of the data attribute to read
  770. * \param fc the functional constraint of the data attribute to read
  771. *
  772. * \return a C string representation of the value. Has to be freed by the caller!
  773. */
  774. LIB61850_API char*
  775. IedConnection_readStringValue(IedConnection self, IedClientError* error, const char* objectReference, FunctionalConstraint fc);
  776. /**
  777. * \brief read a functional constrained data attribute (FCDA) of type Integer or Unsigned and return the result as int32_t
  778. *
  779. * \param self the connection object to operate on
  780. * \param error the error code if an error occurs
  781. * \param object reference of the data attribute to read
  782. * \param fc the functional constraint of the data attribute to read
  783. *
  784. * \return an int32_t value of the read data attributes
  785. */
  786. LIB61850_API int32_t
  787. IedConnection_readInt32Value(IedConnection self, IedClientError* error, const char* objectReference, FunctionalConstraint fc);
  788. /**
  789. * \brief read a functional constrained data attribute (FCDA) of type Integer or Unsigned and return the result as int64_t
  790. *
  791. * \param self the connection object to operate on
  792. * \param error the error code if an error occurs
  793. * \param object reference of the data attribute to read
  794. * \param fc the functional constraint of the data attribute to read
  795. *
  796. * \return an int64_t value of the read data attributes
  797. */
  798. LIB61850_API int64_t
  799. IedConnection_readInt64Value(IedConnection self, IedClientError* error, const char* objectReference, FunctionalConstraint fc);
  800. /**
  801. * \brief read a functional constrained data attribute (FCDA) of type Integer or Unsigned and return the result as uint32_t
  802. *
  803. * \param self the connection object to operate on
  804. * \param error the error code if an error occurs
  805. * \param object reference of the data attribute to read
  806. * \param fc the functional constraint of the data attribute to read
  807. *
  808. * \return an uint32_t value of the read data attributes
  809. */
  810. LIB61850_API uint32_t
  811. IedConnection_readUnsigned32Value(IedConnection self, IedClientError* error, const char* objectReference, FunctionalConstraint fc);
  812. /**
  813. * \brief read a functional constrained data attribute (FCDA) of type Timestamp (UTC Time)
  814. *
  815. * NOTE: If the timestamp parameter is set to NULL the function allocates a new timestamp instance. Otherwise the
  816. * return value is a pointer to the user provided timestamp instance. The new timestamp instance has to be freed by
  817. * the caller of the function.
  818. *
  819. * \param self the connection object to operate on
  820. * \param error the error code if an error occurs
  821. * \param object reference of the data attribute to read
  822. * \param fc the functional constraint of the data attribute to read
  823. * \param timestamp a pointer to a user provided timestamp instance or NULL
  824. *
  825. * \return the timestamp value
  826. */
  827. LIB61850_API Timestamp*
  828. IedConnection_readTimestampValue(IedConnection self, IedClientError* error, const char* objectReference, FunctionalConstraint fc,
  829. Timestamp* timeStamp);
  830. /**
  831. * \brief read a functional constrained data attribute (FCDA) of type Quality
  832. *
  833. * \param self the connection object to operate on
  834. * \param error the error code if an error occurs
  835. * \param object reference of the data attribute to read
  836. * \param fc the functional constraint of the data attribute to read
  837. *
  838. * \return the timestamp value
  839. */
  840. LIB61850_API Quality
  841. IedConnection_readQualityValue(IedConnection self, IedClientError* error, const char* objectReference, FunctionalConstraint fc);
  842. /**
  843. * \brief write a functional constrained data attribute (FCDA) of type boolean
  844. *
  845. * \param self the connection object to operate on
  846. * \param error the error code if an error occurs
  847. * \param object reference of the data attribute to read
  848. * \param fc the functional constraint of the data attribute or data object to write
  849. * \param value the boolean value to write
  850. */
  851. LIB61850_API void
  852. IedConnection_writeBooleanValue(IedConnection self, IedClientError* error, const char* objectReference,
  853. FunctionalConstraint fc, bool value);
  854. /**
  855. * \brief write a functional constrained data attribute (FCDA) of type integer
  856. *
  857. * \param self the connection object to operate on
  858. * \param error the error code if an error occurs
  859. * \param object reference of the data attribute to read
  860. * \param fc the functional constraint of the data attribute or data object to write
  861. * \param value the int32_t value to write
  862. */
  863. LIB61850_API void
  864. IedConnection_writeInt32Value(IedConnection self, IedClientError* error, const char* objectReference,
  865. FunctionalConstraint fc, int32_t value);
  866. /**
  867. * \brief write a functional constrained data attribute (FCDA) of type unsigned (integer)
  868. *
  869. * \param self the connection object to operate on
  870. * \param error the error code if an error occurs
  871. * \param object reference of the data attribute to read
  872. * \param fc the functional constraint of the data attribute or data object to write
  873. * \param value the uint32_t value to write
  874. */
  875. LIB61850_API void
  876. IedConnection_writeUnsigned32Value(IedConnection self, IedClientError* error, const char* objectReference,
  877. FunctionalConstraint fc, uint32_t value);
  878. /**
  879. * \brief write a functional constrained data attribute (FCDA) of type float
  880. *
  881. * \param self the connection object to operate on
  882. * \param error the error code if an error occurs
  883. * \param object reference of the data attribute to read
  884. * \param fc the functional constraint of the data attribute or data object to write
  885. * \param value the float value to write
  886. */
  887. LIB61850_API void
  888. IedConnection_writeFloatValue(IedConnection self, IedClientError* error, const char* objectReference,
  889. FunctionalConstraint fc, float value);
  890. LIB61850_API void
  891. IedConnection_writeVisibleStringValue(IedConnection self, IedClientError* error, const char* objectReference,
  892. FunctionalConstraint fc, char* value);
  893. LIB61850_API void
  894. IedConnection_writeOctetString(IedConnection self, IedClientError* error, const char* objectReference,
  895. FunctionalConstraint fc, uint8_t* value, int valueLength);
  896. /** @} */
  897. /********************************************
  898. * Reporting services
  899. ********************************************/
  900. /**
  901. * @defgroup IEC61850_CLIENT_REPORTS Client side report handling services, functions, and data types
  902. *
  903. * @{
  904. */
  905. /**
  906. * \brief Read access to attributes of a report control block (RCB) at the connected server
  907. *
  908. * The requested RCB has to be specified by its object reference. E.g.
  909. *
  910. * "simpleIOGenericIO/LLN0.RP.EventsRCB01"
  911. *
  912. * or
  913. *
  914. * "simpleIOGenericIO/LLN0.BR.EventsBRCB01"
  915. *
  916. * Report control blocks have either "RP" or "BR" as part of their name following the logical node part.
  917. * "RP" is part of the name of unbuffered RCBs whilst "BR" is part of the name of buffered RCBs.
  918. *
  919. * This function is used to perform the actual read service. To access the received values the functions
  920. * of ClientReportControlBlock have to be used.
  921. *
  922. * If called with a NULL argument for the updateRcb parameter a new ClientReportControlBlock instance is created
  923. * and populated with the values received by the server. It is up to the user to release this object by
  924. * calling the ClientReportControlBlock_destroy function when the object is no longer needed. If called with a reference
  925. * to an existing ClientReportControlBlock instance the values of the attributes will be updated and no new instance
  926. * will be created.
  927. *
  928. * Note: This function maps to a single MMS read request to retrieve the complete RCB at once.
  929. *
  930. * \param connection the connection object
  931. * \param error the error code if an error occurs
  932. * \param rcbReference object reference of the report control block
  933. * \param updateRcb a reference to an existing ClientReportControlBlock instance or NULL
  934. *
  935. * \return new ClientReportControlBlock instance or the instance provided by the user with
  936. * the updateRcb parameter.
  937. */
  938. LIB61850_API ClientReportControlBlock
  939. IedConnection_getRCBValues(IedConnection self, IedClientError* error, const char* rcbReference,
  940. ClientReportControlBlock updateRcb);
  941. typedef void
  942. (*IedConnection_GetRCBValuesHandler) (uint32_t invokeId, void* parameter, IedClientError err, ClientReportControlBlock rcb);
  943. LIB61850_API uint32_t
  944. IedConnection_getRCBValuesAsync(IedConnection self, IedClientError* error, const char* rcbReference, ClientReportControlBlock updateRcb,
  945. IedConnection_GetRCBValuesHandler handler, void* parameter);
  946. /** Describes the reason for the inclusion of the element in the report */
  947. typedef int ReasonForInclusion;
  948. /** the element is not included in the received report */
  949. #define IEC61850_REASON_NOT_INCLUDED 0
  950. /** the element is included due to a change of the data value */
  951. #define IEC61850_REASON_DATA_CHANGE 1
  952. /** the element is included due to a change in the quality of data */
  953. #define IEC61850_REASON_QUALITY_CHANGE 2
  954. /** the element is included due to an update of the data value */
  955. #define IEC61850_REASON_DATA_UPDATE 4
  956. /** the element is included due to a periodic integrity report task */
  957. #define IEC61850_REASON_INTEGRITY 8
  958. /** the element is included due to a general interrogation by the client */
  959. #define IEC61850_REASON_GI 16
  960. /** the reason for inclusion is unknown (e.g. report is not configured to include reason-for-inclusion) */
  961. #define IEC61850_REASON_UNKNOWN 32
  962. #define REASON_NOT_INCLUDED IEC61850_REASON_NOT_INCLUDED
  963. #define REASON_DATA_CHANGE IEC61850_REASON_DATA_CHANGE
  964. #define REASON_QUALITY_CHANGE IEC61850_REASON_QUALITY_CHANGE
  965. #define REASON_DATA_UPDATE IEC61850_REASON_DATA_UPDATE
  966. #define REASON_INTEGRITY IEC61850_REASON_INTEGRITY
  967. #define REASON_GI IEC61850_REASON_GI
  968. #define REASON_UNKNOWN IEC61850_REASON_UNKNOWN
  969. /* Element encoding mask values for ClientReportControlBlock */
  970. /** include the report ID into the setRCB request */
  971. #define RCB_ELEMENT_RPT_ID 1
  972. /** include the report enable element into the setRCB request */
  973. #define RCB_ELEMENT_RPT_ENA 2
  974. /** include the reservation element into the setRCB request (only available in unbuffered RCBs!) */
  975. #define RCB_ELEMENT_RESV 4
  976. /** include the data set element into the setRCB request */
  977. #define RCB_ELEMENT_DATSET 8
  978. /** include the configuration revision element into the setRCB request */
  979. #define RCB_ELEMENT_CONF_REV 16
  980. /** include the option fields element into the setRCB request */
  981. #define RCB_ELEMENT_OPT_FLDS 32
  982. /** include the bufTm (event buffering time) element into the setRCB request */
  983. #define RCB_ELEMENT_BUF_TM 64
  984. /** include the sequence number element into the setRCB request (should be used!) */
  985. #define RCB_ELEMENT_SQ_NUM 128
  986. /** include the trigger options element into the setRCB request */
  987. #define RCB_ELEMENT_TRG_OPS 256
  988. /** include the integrity period element into the setRCB request */
  989. #define RCB_ELEMENT_INTG_PD 512
  990. /** include the GI (general interrogation) element into the setRCB request */
  991. #define RCB_ELEMENT_GI 1024
  992. /** include the purge buffer element into the setRCB request (only available in buffered RCBs) */
  993. #define RCB_ELEMENT_PURGE_BUF 2048
  994. /** include the entry ID element into the setRCB request (only available in buffered RCBs) */
  995. #define RCB_ELEMENT_ENTRY_ID 4096
  996. /** include the time of entry element into the setRCB request (only available in buffered RCBs) */
  997. #define RCB_ELEMENT_TIME_OF_ENTRY 8192
  998. /** include the reservation time element into the setRCB request (only available in buffered RCBs) */
  999. #define RCB_ELEMENT_RESV_TMS 16384
  1000. /** include the owner element into the setRCB request */
  1001. #define RCB_ELEMENT_OWNER 32768
  1002. /**
  1003. * \brief Write access to attributes of a report control block (RCB) at the connected server
  1004. *
  1005. * The requested RCB has to be specified by its object reference (see also IedConnection_getRCBValues).
  1006. * The object reference for the referenced RCB is contained in the provided ClientReportControlBlock instance.
  1007. *
  1008. * The parametersMask parameter specifies which attributes of the remote RCB have to be set by this request.
  1009. * You can specify multiple attributes by ORing the defined bit values.
  1010. *
  1011. * The singleRequest parameter specifies the mapping to the corresponding MMS write request. Standard compliant
  1012. * servers should accept both variants. But some server accept only one variant. Then the value of this parameter
  1013. * will be of relevance.
  1014. *
  1015. * \param connection the connection object
  1016. * \param error the error code if an error occurs
  1017. * \param rcb object reference of the ClientReportControlBlock instance that actually holds the parameter
  1018. * values to be written.
  1019. * \param parametersMask specifies the parameters contained in the setRCBValues request.
  1020. * \param singleRequest specifies if the setRCBValues services is mapped to a single MMS write request containing
  1021. * multiple variables or to multiple MMS write requests.
  1022. */
  1023. LIB61850_API void
  1024. IedConnection_setRCBValues(IedConnection self, IedClientError* error, ClientReportControlBlock rcb,
  1025. uint32_t parametersMask, bool singleRequest);
  1026. LIB61850_API uint32_t
  1027. IedConnection_setRCBValuesAsync(IedConnection self, IedClientError* error, ClientReportControlBlock rcb,
  1028. uint32_t parametersMask, bool singleRequest, IedConnection_GenericServiceHandler handler, void* parameter);
  1029. /**
  1030. * \brief Callback function for receiving reports
  1031. *
  1032. * \param parameter a user provided parameter that is handed to the callback function
  1033. * \param report a ClientReport instance that holds the informations contained in the received report
  1034. */
  1035. typedef void (*ReportCallbackFunction) (void* parameter, ClientReport report);
  1036. /**
  1037. * \brief Install a report handler function for the specified report control block (RCB)
  1038. *
  1039. * This function will replace a report handler set earlier for the specified RCB. The report handler
  1040. * will be called whenever a report for the specified RCB is received.
  1041. * Please note that this function should be called whenever the RCB data set is changed or updated.
  1042. * Otherwise the internal data structures storing the received data set values will not be updated
  1043. * correctly.
  1044. *
  1045. * When replacing a report handler you only have to call this function. There is no separate call to
  1046. * IedConnection_uninstallReportHandler() required.
  1047. *
  1048. * \param self the connection object
  1049. * \param rcbReference object reference of the report control block
  1050. * \param rptId a string that identifies the report. If the rptId is not available then the
  1051. * rcbReference is used to identify the report.
  1052. * \param handler user provided callback function to be invoked when a report is received.
  1053. * \param handlerParameter user provided parameter that will be passed to the callback function
  1054. */
  1055. LIB61850_API void
  1056. IedConnection_installReportHandler(IedConnection self, const char* rcbReference, const char* rptId, ReportCallbackFunction handler,
  1057. void* handlerParameter);
  1058. /**
  1059. * \brief uninstall a report handler function for the specified report control block (RCB)
  1060. *
  1061. * \param self the connection object
  1062. * \param rcbReference object reference of the report control block
  1063. */
  1064. LIB61850_API void
  1065. IedConnection_uninstallReportHandler(IedConnection self, const char* rcbReference);
  1066. /**
  1067. * \brief trigger a general interrogation (GI) report for the specified report control block (RCB)
  1068. *
  1069. * The RCB must have been enabled and GI set as trigger option before this command can be performed.
  1070. *
  1071. * \deprecated Use ClientReportControlBlock_setGI instead
  1072. *
  1073. * \param connection the connection object
  1074. * \param error the error code if an error occurs
  1075. * \param rcbReference object reference of the report control block
  1076. */
  1077. LIB61850_API void
  1078. IedConnection_triggerGIReport(IedConnection self, IedClientError* error, const char* rcbReference);
  1079. /****************************************
  1080. * Access to received reports
  1081. ****************************************/
  1082. /**
  1083. * \brief get the name of the report data set
  1084. *
  1085. * NOTE: the returned string is only valid as long as the ClientReport instance exists!
  1086. *
  1087. * \param self the ClientReport instance
  1088. * \return report data set name as 0 terminated string
  1089. */
  1090. LIB61850_API const char*
  1091. ClientReport_getDataSetName(ClientReport self);
  1092. /**
  1093. * \brief return the received data set values of the report
  1094. *
  1095. * NOTE: The returned MmsValue instance is handled by the library and only valid as long as the
  1096. * ClientReport instance exists! It should not be used outside the report callback handler to
  1097. * avoid concurrency issues.
  1098. *
  1099. * \param self the ClientReport instance
  1100. * \return an MmsValue array instance containing the data set values
  1101. */
  1102. LIB61850_API MmsValue*
  1103. ClientReport_getDataSetValues(ClientReport self);
  1104. /**
  1105. * \brief return reference (name) of the server RCB associated with this ClientReport object
  1106. *
  1107. * \param self the ClientReport instance
  1108. * \return report control block reference as string
  1109. */
  1110. LIB61850_API char*
  1111. ClientReport_getRcbReference(ClientReport self);
  1112. /**
  1113. * \brief return RptId of the server RCB associated with this ClientReport object
  1114. *
  1115. * \param self the ClientReport instance
  1116. * \return report control block reference as string
  1117. */
  1118. LIB61850_API char*
  1119. ClientReport_getRptId(ClientReport self);
  1120. /**
  1121. * \brief get the reason code (reason for inclusion) for a specific report data set element
  1122. *
  1123. * \param self the ClientReport instance
  1124. * \param elementIndex index of the data set element (starting with 0)
  1125. *
  1126. * \return reason code for the inclusion of the specified element
  1127. */
  1128. LIB61850_API ReasonForInclusion
  1129. ClientReport_getReasonForInclusion(ClientReport self, int elementIndex);
  1130. /**
  1131. * \brief get the entry ID of the report
  1132. *
  1133. * Returns the entryId of the report if included in the report. Otherwise returns NULL.
  1134. *
  1135. * \param self the ClientReport instance
  1136. *
  1137. * \return entryId or NULL
  1138. */
  1139. LIB61850_API MmsValue*
  1140. ClientReport_getEntryId(ClientReport self);
  1141. /**
  1142. * \brief determine if the last received report contains a timestamp
  1143. *
  1144. * \param self the ClientReport instance
  1145. *
  1146. * \return true if the report contains a timestamp, false otherwise
  1147. */
  1148. LIB61850_API bool
  1149. ClientReport_hasTimestamp(ClientReport self);
  1150. /**
  1151. * \brief determine if the last received report contains a sequence number
  1152. *
  1153. * \param self the ClientReport instance
  1154. *
  1155. * \return true if the report contains a sequence number, false otherwise
  1156. */
  1157. LIB61850_API bool
  1158. ClientReport_hasSeqNum(ClientReport self);
  1159. /**
  1160. * \brief get the value of the sequence number
  1161. *
  1162. * NOTE: The returned value is undefined if the sequence number is not present in report
  1163. *
  1164. * \param self the ClientReport instance
  1165. *
  1166. * \returns the number of the sequence number when present
  1167. */
  1168. LIB61850_API uint16_t
  1169. ClientReport_getSeqNum(ClientReport self);
  1170. /**
  1171. * \brief determine if the last received report contains the data set name
  1172. *
  1173. * \param self the ClientReport instance
  1174. *
  1175. * \return true if the report contains the data set name, false otherwise
  1176. */
  1177. LIB61850_API bool
  1178. ClientReport_hasDataSetName(ClientReport self);
  1179. /**
  1180. * \brief determine if the last received report contains reason-for-inclusion information
  1181. *
  1182. * \param self the ClientReport instance
  1183. *
  1184. * \return true if the report contains reason-for-inclusion information, false otherwise
  1185. */
  1186. LIB61850_API bool
  1187. ClientReport_hasReasonForInclusion(ClientReport self);
  1188. /**
  1189. * \brief determine if the last received report contains the configuration revision
  1190. *
  1191. * \param self the ClientReport instance
  1192. *
  1193. * \return true if the report contains the configuration revision, false otherwise
  1194. */
  1195. LIB61850_API bool
  1196. ClientReport_hasConfRev(ClientReport self);
  1197. /**
  1198. * \brief get the value of the configuration revision
  1199. *
  1200. * NOTE: The returned value is undefined if configuration revision is not present in report
  1201. *
  1202. * \param self the ClientReport instance
  1203. *
  1204. * \returns the number of the configuration revision
  1205. */
  1206. LIB61850_API uint32_t
  1207. ClientReport_getConfRev(ClientReport self);
  1208. /**
  1209. * \brief indicates if the report contains the bufOvfl (buffer overflow) flag
  1210. *
  1211. * \param self the ClientReport instance
  1212. *
  1213. * \returns true if the report contains the bufOvfl flag, false otherwise
  1214. */
  1215. LIB61850_API bool
  1216. ClientReport_hasBufOvfl(ClientReport self);
  1217. /**
  1218. * \brief get the value of the bufOvfl flag
  1219. *
  1220. * \param self the ClientReport instance
  1221. *
  1222. * \returns true if bufOvfl is set, false otherwise
  1223. */
  1224. LIB61850_API bool
  1225. ClientReport_getBufOvfl(ClientReport self);
  1226. /**
  1227. * \brief indicates if the report contains data references for the reported data set members
  1228. *
  1229. * \param self the ClientReport instance
  1230. *
  1231. * \returns true if the report contains data-references, false otherwise
  1232. */
  1233. LIB61850_API bool
  1234. ClientReport_hasDataReference(ClientReport self);
  1235. /**
  1236. * \brief get the data-reference of the element of the report data set
  1237. *
  1238. * This function will only return a non-NULL value if the received report contains data-references.
  1239. * This can be determined by the ClientReport_hasDataReference function.
  1240. * NOTE: The returned string is allocated and hold by the ClientReport instance and is only valid until
  1241. * the ClientReport instance exists!
  1242. *
  1243. * \param self the ClientReport instance
  1244. * \param elementIndex index of the data set element (starting with 0)
  1245. *
  1246. * \param the data reference as string as provided by the report or NULL if the data reference is not available
  1247. */
  1248. LIB61850_API const char*
  1249. ClientReport_getDataReference(ClientReport self, int elementIndex);
  1250. /**
  1251. * \brief get the timestamp of the report
  1252. *
  1253. * Returns the timestamp of the report if included in the report. Otherwise the value is undefined.
  1254. * Use the ClientReport_hasTimestamp function first to figure out if the timestamp is valid
  1255. *
  1256. * \param self the ClientReport instance
  1257. *
  1258. * \return the timestamp as milliseconds since 1.1.1970 UTC
  1259. */
  1260. LIB61850_API uint64_t
  1261. ClientReport_getTimestamp(ClientReport self);
  1262. /**
  1263. * \brief indicates if the report contains a sub sequence number and a more segments follow flags (for segmented reporting)
  1264. *
  1265. * \param self the ClientReport instance
  1266. *
  1267. * \returns true if the report contains sub-sequence-number and more-follows-flag, false otherwise
  1268. */
  1269. LIB61850_API bool
  1270. ClientReport_hasSubSeqNum(ClientReport self);
  1271. /**
  1272. * \brief get the sub sequence number of the report (for segmented reporting)
  1273. *
  1274. * Returns the sub sequence number of the report. This is 0 for the first report of a segmented report and
  1275. * will be increased by one for each report segment.
  1276. *
  1277. * \param self the ClientReport instance
  1278. *
  1279. * \return the sub sequence number of the last received report message.
  1280. */
  1281. LIB61850_API uint16_t
  1282. ClientReport_getSubSeqNum(ClientReport self);
  1283. /**
  1284. * \brief get the more segments follow flag of the received report segment (for segmented reporting)
  1285. *
  1286. * Will return true in case this is part of a segmented report and more report segments will follow or false, if
  1287. * the current report is not a segmented report or is the last segment of a segmented report.
  1288. *
  1289. * \param self the ClientReport instance
  1290. *
  1291. * \return true when more segments of the current report will follow, false otherwise
  1292. */
  1293. LIB61850_API bool
  1294. ClientReport_getMoreSeqmentsFollow(ClientReport self);
  1295. /**
  1296. * \brief get the reason for inclusion of as a human readable string
  1297. *
  1298. * \param reasonCode
  1299. *
  1300. * \return the reason for inclusion as static human readable string
  1301. */
  1302. LIB61850_API char*
  1303. ReasonForInclusion_getValueAsString(ReasonForInclusion reasonCode);
  1304. /**************************************************
  1305. * ClientReportControlBlock access class
  1306. **************************************************/
  1307. LIB61850_API ClientReportControlBlock
  1308. ClientReportControlBlock_create(const char* rcbReference);
  1309. LIB61850_API void
  1310. ClientReportControlBlock_destroy(ClientReportControlBlock self);
  1311. LIB61850_API char*
  1312. ClientReportControlBlock_getObjectReference(ClientReportControlBlock self);
  1313. LIB61850_API bool
  1314. ClientReportControlBlock_isBuffered(ClientReportControlBlock self);
  1315. LIB61850_API const char*
  1316. ClientReportControlBlock_getRptId(ClientReportControlBlock self);
  1317. LIB61850_API void
  1318. ClientReportControlBlock_setRptId(ClientReportControlBlock self, const char* rptId);
  1319. LIB61850_API bool
  1320. ClientReportControlBlock_getRptEna(ClientReportControlBlock self);
  1321. LIB61850_API void
  1322. ClientReportControlBlock_setRptEna(ClientReportControlBlock self, bool rptEna);
  1323. LIB61850_API bool
  1324. ClientReportControlBlock_getResv(ClientReportControlBlock self);
  1325. LIB61850_API void
  1326. ClientReportControlBlock_setResv(ClientReportControlBlock self, bool resv);
  1327. LIB61850_API const char*
  1328. ClientReportControlBlock_getDataSetReference(ClientReportControlBlock self);
  1329. /**
  1330. * \brief set the data set to be observed by the RCB
  1331. *
  1332. * The data set reference is a mixture of MMS and IEC 61850 syntax! In general the reference has
  1333. * the form:
  1334. * LDName/LNName$DataSetName
  1335. *
  1336. * e.g. "simpleIOGenericIO/LLN0$Events"
  1337. *
  1338. * It is standard that data sets are defined in LN0 logical nodes. But this is not mandatory.
  1339. *
  1340. * Note: As a result of changing the data set the server will increase the confRev attribute of the RCB.
  1341. *
  1342. * \param self the RCB instance
  1343. * \param dataSetReference the reference of the data set
  1344. */
  1345. LIB61850_API void
  1346. ClientReportControlBlock_setDataSetReference(ClientReportControlBlock self, const char* dataSetReference);
  1347. LIB61850_API uint32_t
  1348. ClientReportControlBlock_getConfRev(ClientReportControlBlock self);
  1349. /**
  1350. * \brief Gets the OptFlds parameter of the RCB (decides what information to include in a report)
  1351. *
  1352. * \param self the RCB instance
  1353. *
  1354. * \return bit field representing the optional fields of a report (uses flags from \ref REPORT_OPTIONS)
  1355. */
  1356. LIB61850_API int
  1357. ClientReportControlBlock_getOptFlds(ClientReportControlBlock self);
  1358. /**
  1359. * \brief Set the OptFlds parameter of the RCB (decides what information to include in a report)
  1360. *
  1361. * \param self the RCB instance
  1362. * \param optFlds bit field representing the optional fields of a report (use flags from \ref REPORT_OPTIONS)
  1363. */
  1364. LIB61850_API void
  1365. ClientReportControlBlock_setOptFlds(ClientReportControlBlock self, int optFlds);
  1366. /**
  1367. * \brief Get the BufTm (buffer time) parameter of the RCB
  1368. *
  1369. * The buffer time is the time to wait after a triggering event before the report is actually sent.
  1370. * It is used to be able to collect events that happen in a short time period and send them in a single report.
  1371. *
  1372. * \param self the RCB instance
  1373. */
  1374. LIB61850_API uint32_t
  1375. ClientReportControlBlock_getBufTm(ClientReportControlBlock self);
  1376. /**
  1377. * \brief Set the BufTm (buffer time) parameter of the RCB
  1378. *
  1379. * The buffer time is the time to wait after a triggering event before the report is actually sent.
  1380. * It is used to be able to collect events that happen in a short time period and send them in a single report.
  1381. *
  1382. * \param self the RCB instance
  1383. * \param bufTm the buffer time in ms
  1384. */
  1385. LIB61850_API void
  1386. ClientReportControlBlock_setBufTm(ClientReportControlBlock self, uint32_t bufTm);
  1387. LIB61850_API uint16_t
  1388. ClientReportControlBlock_getSqNum(ClientReportControlBlock self);
  1389. LIB61850_API int
  1390. ClientReportControlBlock_getTrgOps(ClientReportControlBlock self);
  1391. LIB61850_API void
  1392. ClientReportControlBlock_setTrgOps(ClientReportControlBlock self, int trgOps);
  1393. LIB61850_API uint32_t
  1394. ClientReportControlBlock_getIntgPd(ClientReportControlBlock self);
  1395. LIB61850_API void
  1396. ClientReportControlBlock_setIntgPd(ClientReportControlBlock self, uint32_t intgPd);
  1397. LIB61850_API bool
  1398. ClientReportControlBlock_getGI(ClientReportControlBlock self);
  1399. LIB61850_API void
  1400. ClientReportControlBlock_setGI(ClientReportControlBlock self, bool gi);
  1401. LIB61850_API bool
  1402. ClientReportControlBlock_getPurgeBuf(ClientReportControlBlock self);
  1403. /**
  1404. * \brief Set the "PurgeBuf" attribute value (only BRCB)
  1405. *
  1406. * When set to true the report buffer will be cleared.
  1407. *
  1408. * \param purgeBuf attribute value
  1409. */
  1410. LIB61850_API void
  1411. ClientReportControlBlock_setPurgeBuf(ClientReportControlBlock self, bool purgeBuf);
  1412. /**
  1413. * \brief Check if optional attribute "ResvTms" is present in BRCB
  1414. *
  1415. * \return true when present, false otherwise
  1416. */
  1417. LIB61850_API bool
  1418. ClientReportControlBlock_hasResvTms(ClientReportControlBlock self);
  1419. LIB61850_API int16_t
  1420. ClientReportControlBlock_getResvTms(ClientReportControlBlock self);
  1421. LIB61850_API void
  1422. ClientReportControlBlock_setResvTms(ClientReportControlBlock self, int16_t resvTms);
  1423. LIB61850_API MmsValue* /* <MMS_OCTET_STRING> */
  1424. ClientReportControlBlock_getEntryId(ClientReportControlBlock self);
  1425. LIB61850_API void
  1426. ClientReportControlBlock_setEntryId(ClientReportControlBlock self, MmsValue* entryId);
  1427. LIB61850_API uint64_t
  1428. ClientReportControlBlock_getEntryTime(ClientReportControlBlock self);
  1429. LIB61850_API MmsValue* /* <MMS_OCTET_STRING> */
  1430. ClientReportControlBlock_getOwner(ClientReportControlBlock self);
  1431. /** @} */
  1432. /****************************************
  1433. * Data set handling
  1434. ****************************************/
  1435. /**
  1436. * @defgroup IEC61850_CLIENT_DATA_SET Client side data set service functions and data types
  1437. *
  1438. * @{
  1439. */
  1440. /**
  1441. * \brief get data set values from the server
  1442. *
  1443. * The parameter dataSetReference is the name of the data set to read. It is either in the form LDName/LNodeName.dataSetName
  1444. * for permanent domain or VMD scope data sets or @dataSetName for an association specific data set.
  1445. * If the LDName part of the reference is missing the resulting data set will be of VMD scope.
  1446. * The received data set values are stored in a container object of type ClientDataSet that can be reused in a further
  1447. * read request.
  1448. *
  1449. * \param connection the connection object
  1450. * \param error the error code if an error occurs
  1451. * \param dataSetReference object reference of the data set
  1452. * \param dataSet a data set instance where to store the retrieved values or NULL if a new instance
  1453. * shall be created.
  1454. *
  1455. * \return data set instance with retrieved values of NULL if an error occurred.
  1456. */
  1457. LIB61850_API ClientDataSet
  1458. IedConnection_readDataSetValues(IedConnection self, IedClientError* error, const char* dataSetReference, ClientDataSet dataSet);
  1459. typedef void
  1460. (*IedConnection_ReadDataSetHandler) (uint32_t invokeId, void* parameter, IedClientError err, ClientDataSet dataSet);
  1461. /**
  1462. * \brief get data set values from the server - async version
  1463. *
  1464. * The parameter dataSetReference is the name of the data set to read. It is either in the form LDName/LNodeName.dataSetName
  1465. * for permanent domain or VMD scope data sets or @dataSetName for an association specific data set.
  1466. * If the LDName part of the reference is missing the resulting data set will be of VMD scope.
  1467. * The received data set values are stored in a container object of type ClientDataSet that can be reused in a further
  1468. * service request.
  1469. *
  1470. * \param connection the connection object
  1471. * \param error the error code if an error occurs
  1472. * \param dataSetReference object reference of the data set
  1473. * \param dataSet a data set instance where to store the retrieved values or NULL if a new instance
  1474. * shall be created.
  1475. * \param handler the user provided callback handler
  1476. * \param parameter user provided parameter that is passed to the callback handler
  1477. *
  1478. * \return the invoke ID of the request
  1479. */
  1480. LIB61850_API uint32_t
  1481. IedConnection_readDataSetValuesAsync(IedConnection self, IedClientError* error, const char* dataSetReference, ClientDataSet dataSet,
  1482. IedConnection_ReadDataSetHandler handler, void* parameter);
  1483. /**
  1484. * \brief create a new data set at the connected server device
  1485. *
  1486. * This function creates a new data set at the server. The parameter dataSetReference is the name of the new data set
  1487. * to create. It is either in the form LDName/LNodeName.dataSetName for permanent domain or VMD scope data sets or
  1488. * @dataSetName for an association specific data set. If the LDName part of the reference is missing the resulting
  1489. * data set will be of VMD scope.
  1490. *
  1491. * The dataSetElements parameter contains a linked list containing the object references of FCDs or FCDAs. The format of
  1492. * this object references is LDName/LNodeName.item(arrayIndex)component[FC].
  1493. *
  1494. * \param connection the connection object
  1495. * \param error the error code if an error occurs
  1496. * \param dataSetReference object reference of the data set
  1497. * \param dataSetElements a list of object references defining the members of the new data set
  1498. *
  1499. */
  1500. LIB61850_API void
  1501. IedConnection_createDataSet(IedConnection self, IedClientError* error, const char* dataSetReference, LinkedList /* char* */ dataSetElements);
  1502. /**
  1503. * \brief create a new data set at the connected server device
  1504. *
  1505. * This function creates a new data set at the server. The parameter dataSetReference is the name of the new data set
  1506. * to create. It is either in the form LDName/LNodeName.dataSetName for permanent domain or VMD scope data sets or
  1507. * @dataSetName for an association specific data set. If the LDName part of the reference is missing the resulting
  1508. * data set will be of VMD scope.
  1509. *
  1510. * The dataSetElements parameter contains a linked list containing the object references of FCDs or FCDAs. The format of
  1511. * this object references is LDName/LNodeName.item(arrayIndex)component[FC].
  1512. *
  1513. * \param connection the connection object
  1514. * \param error the error code if an error occurs
  1515. * \param dataSetReference object reference of the data set
  1516. * \param dataSetElements a list of object references defining the members of the new data set
  1517. *
  1518. * \param handler the callback handler that is called when the response is received or timeout
  1519. * \param parameter user provided parameter that is passed to the callback handler
  1520. *
  1521. * \return the invoke ID of the request
  1522. */
  1523. LIB61850_API uint32_t
  1524. IedConnection_createDataSetAsync(IedConnection self, IedClientError* error, const char* dataSetReference, LinkedList /* char* */ dataSetElements,
  1525. IedConnection_GenericServiceHandler handler, void* parameter);
  1526. /**
  1527. * \brief delete a deletable data set at the connected server device
  1528. *
  1529. * This function deletes a data set at the server. The parameter dataSetReference is the name of the data set
  1530. * to delete. It is either in the form LDName/LNodeName.dataSetName or @dataSetName for an association specific data set.
  1531. *
  1532. *
  1533. * \param connection the connection object
  1534. * \param error the error code if an error occurs
  1535. * \param dataSetReference object reference of the data set
  1536. *
  1537. * \return true if data set has been deleted, false otherwise
  1538. */
  1539. LIB61850_API bool
  1540. IedConnection_deleteDataSet(IedConnection self, IedClientError* error, const char* dataSetReference);
  1541. /**
  1542. * \brief delete a deletable data set at the connected server device - asynchronous version
  1543. *
  1544. * This function deletes a data set at the server. The parameter dataSetReference is the name of the data set
  1545. * to delete. It is either in the form LDName/LNodeName.dataSetName or @dataSetName for an association specific data set.
  1546. *
  1547. * The data set was deleted successfully when the callback parameter "error" is IED_ERROR_OK. Otherwise the "error"
  1548. * parameter contains a particular error code.
  1549. *
  1550. * \param connection the connection object
  1551. * \param error the error code if an error occurs
  1552. * \param dataSetReference object reference of the data set
  1553. * \param handler the callback handler that is called when the response is received or timeout
  1554. * \param parameter user provided parameter that is passed to the callback handler
  1555. *
  1556. * \return the invoke ID of the request
  1557. */
  1558. LIB61850_API uint32_t
  1559. IedConnection_deleteDataSetAsync(IedConnection self, IedClientError* error, const char* dataSetReference,
  1560. IedConnection_GenericServiceHandler handler, void* parameter);
  1561. /**
  1562. * \brief read the data set directory
  1563. *
  1564. * The return value contains a linked list containing the object references of FCDs or FCDAs. The format of
  1565. * this object references is LDName/LNodeName.item(arrayIndex)component[FC].
  1566. *
  1567. * \param connection the connection object
  1568. * \param[out] error the error code if an error occurs
  1569. * \param dataSetReference object reference of the data set
  1570. * \param[out] isDeletable this is an output parameter indicating that the requested data set is deletable by clients.
  1571. * If this information is not required a NULL pointer can be used.
  1572. *
  1573. * \return LinkedList containing the data set elements as char* strings.
  1574. */
  1575. LIB61850_API LinkedList /* <char*> */
  1576. IedConnection_getDataSetDirectory(IedConnection self, IedClientError* error, const char* dataSetReference, bool* isDeletable);
  1577. /**
  1578. * \brief GetDataSetDirectory response or timeout callback
  1579. *
  1580. * \param dataSetDirectory a linked list containing the object references of FCDs or FCDAs. The format of
  1581. * this object references is LDName/LNodeName.item(arrayIndex)component[FC].
  1582. * \param isDeletable this is an output parameter indicating that the requested data set is deletable by clients.
  1583. */
  1584. typedef void
  1585. (*IedConnection_GetDataSetDirectoryHandler) (uint32_t invokeId, void* parameter, IedClientError err, LinkedList /* <char*> */ dataSetDirectory, bool isDeletable);
  1586. /**
  1587. * \brief read the data set directory - asynchronous version
  1588. *
  1589. * The result data is a linked list containing the object references of FCDs or FCDAs. The format of
  1590. * this object references is LDName/LNodeName.item(arrayIndex)component[FC].
  1591. *
  1592. * \param connection the connection object
  1593. * \param[out] error the error code if an error occurs
  1594. * \param dataSetReference object reference of the data set
  1595. * \param handler the callback handler that is called when the response is received or timeout
  1596. * \param parameter user provided parameter that is passed to the callback handler
  1597. *
  1598. * \return the invoke ID of the request
  1599. */
  1600. LIB61850_API uint32_t
  1601. IedConnection_getDataSetDirectoryAsync(IedConnection self, IedClientError* error, const char* dataSetReference,
  1602. IedConnection_GetDataSetDirectoryHandler handler, void* parameter);
  1603. /**
  1604. * \brief Write the data set values to the server
  1605. *
  1606. * The parameter dataSetReference is the name of the data set to write. It is either in the form LDName/LNodeName.dataSetName
  1607. * for permanent domain or VMD scope data sets or @dataSetName for an association specific data set.
  1608. * If the LDName part of the reference is missing the resulting data set will be of VMD scope.
  1609. * The values parameter has to be the same number of elements as are members in the data set. The accessResult return parameter
  1610. * contains a value for each data set member.
  1611. *
  1612. * \param connection the connection object
  1613. * \param[out] error the error code if an error occurs
  1614. * \param dataSetReference object reference of the data set
  1615. * \param values the new data set values
  1616. * \param[out] accessResults the access results for each data set member
  1617. */
  1618. LIB61850_API void
  1619. IedConnection_writeDataSetValues(IedConnection self, IedClientError* error, const char* dataSetReference,
  1620. LinkedList/*<MmsValue*>*/ values, /* OUTPUT */LinkedList* /* <MmsValue*> */accessResults);
  1621. /**
  1622. * \brief Callback handler for asynchronous write data set values services (set data set)
  1623. *
  1624. * \param invokeId the invoke ID of the service request
  1625. * \param parameter used provided parameter
  1626. * \param err the error code if an error occurs
  1627. * \param accessResults the list of access results for the data set entries.
  1628. */
  1629. typedef void
  1630. (*IedConnection_WriteDataSetHandler) (uint32_t invokeId, void* parameter, IedClientError err, LinkedList /* <MmsValue*> */accessResults);
  1631. /**
  1632. * \brief Write the data set values to the server - async version
  1633. *
  1634. * The parameter dataSetReference is the name of the data set to write. It is either in the form LDName/LNodeName.dataSetName
  1635. * for permanent domain or VMD scope data sets or @dataSetName for an association specific data set.
  1636. * If the LDName part of the reference is missing the resulting data set will be of VMD scope.
  1637. * The values parameter has to be the same number of elements as are members in the data set.
  1638. *
  1639. * When the service call had been successful the \ref IedConnection_WriteDataSetHandler is called with an error value of
  1640. * IED_ERROR_OK and a list of MmsValue instances of type data access error. These describe the access results of the individual
  1641. * data set entries.
  1642. *
  1643. * \param connection the connection object
  1644. * \param[out] error the error code if an error occurs
  1645. * \param dataSetReference object reference of the data set
  1646. * \param values the new data set values
  1647. * \param handler the user provided callback handler
  1648. * \param parameter user provided parameter that is passed to the callback handler
  1649. *
  1650. * \return the invoke ID of the request
  1651. */
  1652. LIB61850_API uint32_t
  1653. IedConnection_writeDataSetValuesAsync(IedConnection self, IedClientError* error, const char* dataSetReference,
  1654. LinkedList/*<MmsValue*>*/ values, IedConnection_WriteDataSetHandler handler, void* parameter);
  1655. /********************************************************
  1656. * Data set object (local representation of a data set)
  1657. *******************************************************/
  1658. /**
  1659. * \brief destroy an ClientDataSet instance. Has to be called by the application.
  1660. *
  1661. * Note: A ClientDataSet cannot be created directly by the application but only by the IedConnection_readDataSetValues
  1662. * function. Therefore there is no public ClientDataSet_create function.
  1663. *
  1664. * \param self the ClientDataSet instance
  1665. */
  1666. LIB61850_API void
  1667. ClientDataSet_destroy(ClientDataSet self);
  1668. /**
  1669. * \brief get the data set values locally stored in the ClientDataSet instance.
  1670. *
  1671. * This function returns a pointer to the locally stored MmsValue instance of this
  1672. * ClientDataSet instance. The MmsValue instance is of type MMS_ARRAY and contains one
  1673. * array element for each data set member.
  1674. * Note: This call does not invoke any interaction with the associated server. It will
  1675. * only provide access to already stored value. To update the values with the current values
  1676. * of the server the IecConnection_readDataSetValues function has to be called!
  1677. *
  1678. * \param self the ClientDataSet instance
  1679. *
  1680. * \return the locally stored data set values as MmsValue object of type MMS_ARRAY.
  1681. */
  1682. LIB61850_API MmsValue*
  1683. ClientDataSet_getValues(ClientDataSet self);
  1684. /**
  1685. * \brief Get the object reference of the data set.
  1686. *
  1687. * \param self the ClientDataSet instance
  1688. *
  1689. * \return the object reference of the data set.
  1690. */
  1691. LIB61850_API char*
  1692. ClientDataSet_getReference(ClientDataSet self);
  1693. /**
  1694. * \brief get the size of the data set (number of members)
  1695. *
  1696. * \param self the ClientDataSet instance
  1697. *
  1698. * \return the number of member contained in the data set.
  1699. */
  1700. LIB61850_API int
  1701. ClientDataSet_getDataSetSize(ClientDataSet self);
  1702. /** @} */
  1703. /************************************
  1704. * Control service functions
  1705. ************************************/
  1706. /**
  1707. * @defgroup IEC61850_CLIENT_CONTROL Client side control service functions
  1708. *
  1709. * @{
  1710. */
  1711. typedef struct sControlObjectClient* ControlObjectClient;
  1712. /**
  1713. * \brief Create a new client control object
  1714. *
  1715. * A client control object is used to handle all client side functions of a controllable
  1716. * data object. A controllable data object is an instance of a controllable CDC like e.g.
  1717. * SPC, DPC, APC, ...
  1718. *
  1719. * NOTE: This function will synchronously request information about the control object
  1720. * (like ctlModel) from the server. The function will block until these requests return
  1721. * or time-out.
  1722. *
  1723. * \param objectReference the reference of the controllable data object
  1724. * \param connection the connection instance where the control object has to be reached
  1725. *
  1726. * \return the newly created instance or NULL if the creation failed
  1727. */
  1728. LIB61850_API ControlObjectClient
  1729. ControlObjectClient_create(const char* objectReference, IedConnection connection);
  1730. /**
  1731. * \brief Create a new client control object - doesn't send requests to the server (doesn't block)
  1732. *
  1733. * A client control object is used to handle all client side functions of a controllable
  1734. * data object. A controllable data object is an instance of a controllable CDC like e.g.
  1735. * SPC, DPC, APC, ...
  1736. *
  1737. * \param objectReference the reference of the controllable data object
  1738. * \param connection the connection instance where the control object has to be reached
  1739. * \param ctlModel the control model used by the controllable data object
  1740. * \param controlObjectSpec specification of the controllable data objects - used to derive required information to handle the control object
  1741. */
  1742. LIB61850_API ControlObjectClient
  1743. ControlObjectClient_createEx(const char* objectReference, IedConnection connection, ControlModel ctlModel, MmsVariableSpecification* controlObjectSpec);
  1744. /**
  1745. * \brief Destroy the client control object instance and release all related resources
  1746. *
  1747. * \param self the control object instance to use
  1748. */
  1749. LIB61850_API void
  1750. ControlObjectClient_destroy(ControlObjectClient self);
  1751. /**
  1752. * Cause of the \ref ControlObjectClient_ControlActionHandler invocation
  1753. */
  1754. typedef enum
  1755. {
  1756. CONTROL_ACTION_TYPE_SELECT = 0, /** < callback was invoked because of a select command */
  1757. CONTROL_ACTION_TYPE_OPERATE = 1, /** < callback was invoked because of an operate command */
  1758. CONTROL_ACTION_TYPE_CANCEL = 2 /** < callback was invoked because of a cancel command */
  1759. } ControlActionType;
  1760. /**
  1761. * \brief A callback handler that is invoked when a command termination message is received.
  1762. *
  1763. * This callback is invoked whenever a CommandTermination+ or CommandTermination- message is received.
  1764. * To distinguish between a CommandTermination+ and CommandTermination- please use the
  1765. * ControlObjectClient_getLastApplError function.
  1766. *
  1767. * NOTE: Do not call \ref ControlObjectClient_destroy inside of this callback! Doing so will cause a dead-lock.
  1768. *
  1769. * \param invokeId invoke ID of the command sent by the client
  1770. * \param parameter the user parameter that is passed to the callback function
  1771. * \param err the error code when an error occurred, or IED_ERROR_OK
  1772. * \param type control action type that caused the callback
  1773. * \param success true, when the command was successful, false otherwise
  1774. *
  1775. */
  1776. typedef void
  1777. (*ControlObjectClient_ControlActionHandler) (uint32_t invokeId, void* parameter, IedClientError err, ControlActionType type, bool success);
  1778. /**
  1779. * \brief Get the object reference of the control data object
  1780. *
  1781. * \param self the control object instance to use
  1782. *
  1783. * \return the object reference (string is valid only as long as the \ref ControlObjectClient instance exists).
  1784. */
  1785. LIB61850_API const char*
  1786. ControlObjectClient_getObjectReference(ControlObjectClient self);
  1787. /**
  1788. * \brief Get the current control model (local representation) applied to the control object
  1789. *
  1790. * \param self the control object instance to use
  1791. *
  1792. * \return the current applied control model (\ref ControlModel)
  1793. */
  1794. LIB61850_API ControlModel
  1795. ControlObjectClient_getControlModel(ControlObjectClient self);
  1796. /**
  1797. * \brief Set the applied control model
  1798. *
  1799. * NOTE: This function call will not change the server control model.
  1800. *
  1801. * \param self the control object instance to use
  1802. * \param ctlModel the new control model to apply
  1803. */
  1804. LIB61850_API void
  1805. ControlObjectClient_setControlModel(ControlObjectClient self, ControlModel ctlModel);
  1806. /**
  1807. * \brief Change the control model of the server.
  1808. *
  1809. * NOTE: Not supported by all servers. Information can be found in the PIXIT of the server.
  1810. * Also sets the applied control model for this client control instance.
  1811. *
  1812. * \param self the control object instance to use
  1813. * \param ctlModel the new control model
  1814. */
  1815. LIB61850_API void
  1816. ControlObjectClient_changeServerControlModel(ControlObjectClient self, ControlModel ctlModel);
  1817. /**
  1818. * \brief Get the type of ctlVal.
  1819. *
  1820. * This type is required for the ctlVal parameter of the \ref ControlObjectClient_operate
  1821. * and \ref ControlObjectClient_selectWithValue functions.
  1822. *
  1823. * \param self the control object instance to use
  1824. *
  1825. * \return MmsType required for the ctlVal value.
  1826. */
  1827. LIB61850_API MmsType
  1828. ControlObjectClient_getCtlValType(ControlObjectClient self);
  1829. /**
  1830. * \brief Get the error code of the last synchronous control action (operate, select, select-with-value, cancel)
  1831. *
  1832. * \param self the control object instance to use
  1833. *
  1834. * \return the client error code
  1835. */
  1836. LIB61850_API IedClientError
  1837. ControlObjectClient_getLastError(ControlObjectClient self);
  1838. /**
  1839. * \brief Send an operate command to the server
  1840. *
  1841. * \param self the control object instance to use
  1842. * \param ctlVal the control value (for APC the value may be either AnalogueValue (MMS_STRUCT) or MMS_FLOAT/MMS_INTEGER
  1843. * \param operTime the time when the command has to be executed (for time activated control). The value represents the local time of the
  1844. * server in milliseconds since epoch. If this value is 0 the command will be executed instantly.
  1845. *
  1846. * \return true if operation has been successful, false otherwise.
  1847. */
  1848. LIB61850_API bool
  1849. ControlObjectClient_operate(ControlObjectClient self, MmsValue* ctlVal, uint64_t operTime);
  1850. /**
  1851. * \brief Send a select command to the server
  1852. *
  1853. * The select command is only used for the control model "select-before-operate with normal security"
  1854. * (CONTROL_MODEL_SBO_NORMAL). The select command has to be sent before the operate command can be used.
  1855. *
  1856. * \param self the control object instance to use
  1857. *
  1858. * \return true if operation has been successful, false otherwise.
  1859. */
  1860. LIB61850_API bool
  1861. ControlObjectClient_select(ControlObjectClient self);
  1862. /**
  1863. * \brief Send an select with value command to the server
  1864. *
  1865. * The select-with-value command is only used for the control model "select-before-operate with enhanced security"
  1866. * (CONTROL_MODEL_SBO_ENHANCED). The select-with-value command has to be sent before the operate command can be used.
  1867. *
  1868. * \param self the control object instance to use
  1869. * \param ctlVal the control value (for APC the value may be either AnalogueValue (MMS_STRUCT) or MMS_FLOAT/MMS_INTEGER
  1870. *
  1871. * \return true if select has been successful, false otherwise.
  1872. */
  1873. LIB61850_API bool
  1874. ControlObjectClient_selectWithValue(ControlObjectClient self, MmsValue* ctlVal);
  1875. /**
  1876. * \brief Send a cancel command to the server
  1877. *
  1878. * The cancel command can be used to stop an ongoing operation (when the server and application
  1879. * support this) and to cancel a former select command.
  1880. *
  1881. * \param self the control object instance to use
  1882. *
  1883. * \return true if operation has been successful, false otherwise.
  1884. */
  1885. LIB61850_API bool
  1886. ControlObjectClient_cancel(ControlObjectClient self);
  1887. /**
  1888. * \brief Send an operate command to the server - async version
  1889. *
  1890. * \param self the control object instance to use
  1891. * \param[out] err error code
  1892. * \param ctlVal the control value (for APC the value may be either AnalogueValue (MMS_STRUCT) or MMS_FLOAT/MMS_INTEGER
  1893. * \param operTime the time when the command has to be executed (for time activated control). The value represents the local time of the
  1894. * server in milliseconds since epoch. If this value is 0 the command will be executed instantly.
  1895. * \param handler the user provided callback handler
  1896. * \param parameter user provided parameter that is passed to the callback handler
  1897. *
  1898. * \return the invoke ID of the request
  1899. */
  1900. LIB61850_API uint32_t
  1901. ControlObjectClient_operateAsync(ControlObjectClient self, IedClientError* err, MmsValue* ctlVal, uint64_t operTime,
  1902. ControlObjectClient_ControlActionHandler handler, void* parameter);
  1903. /**
  1904. * \brief Send a select command to the server - async version
  1905. *
  1906. * The select command is only used for the control model "select-before-operate with normal security"
  1907. * (CONTROL_MODEL_SBO_NORMAL). The select command has to be sent before the operate command can be used.
  1908. *
  1909. * \param self the control object instance to use
  1910. * \param[out] err error code
  1911. * \param handler the user provided callback handler
  1912. * \param parameter user provided parameter that is passed to the callback handler
  1913. *
  1914. * \return the invoke ID of the request
  1915. */
  1916. LIB61850_API uint32_t
  1917. ControlObjectClient_selectAsync(ControlObjectClient self, IedClientError* err, ControlObjectClient_ControlActionHandler handler, void* parameter);
  1918. /**
  1919. * \brief Send a select-with-value command to the server - async version
  1920. *
  1921. * The select-with-value command is only used for the control model "select-before-operate with enhanced security"
  1922. * (CONTROL_MODEL_SBO_ENHANCED). The select-with-value command has to be sent before the operate command can be used.
  1923. *
  1924. * \param self the control object instance to use
  1925. * \param[out] err error code
  1926. * \param ctlVal the control value (for APC the value may be either AnalogueValue (MMS_STRUCT) or MMS_FLOAT/MMS_INTEGER
  1927. * \param handler the user provided callback handler
  1928. * \param parameter user provided parameter that is passed to the callback handler
  1929. *
  1930. * \return the invoke ID of the request
  1931. */
  1932. LIB61850_API uint32_t
  1933. ControlObjectClient_selectWithValueAsync(ControlObjectClient self, IedClientError* err, MmsValue* ctlVal,
  1934. ControlObjectClient_ControlActionHandler handler, void* parameter);
  1935. /**
  1936. * \brief Send a cancel command to the server - async version
  1937. *
  1938. * The cancel command can be used to stop an ongoing operation (when the server and application
  1939. * support this) and to cancel a former select command.
  1940. *
  1941. * \param self the control object instance to use
  1942. * \param[out] err error code
  1943. * \param handler the user provided callback handler
  1944. * \param parameter user provided parameter that is passed to the callback handler
  1945. *
  1946. * \return the invoke ID of the request
  1947. */
  1948. LIB61850_API uint32_t
  1949. ControlObjectClient_cancelAsync(ControlObjectClient self, IedClientError* err, ControlObjectClient_ControlActionHandler handler, void* parameter);
  1950. /**
  1951. * \brief Get the last received control application error
  1952. *
  1953. * NOTE: this is the content of the "LastApplError" message received from the server.
  1954. *
  1955. * \return the value of the last received application error
  1956. */
  1957. LIB61850_API LastApplError
  1958. ControlObjectClient_getLastApplError(ControlObjectClient self);
  1959. /**
  1960. * \brief Send commands in test mode.
  1961. *
  1962. * When the server supports test mode the commands that are sent with the test flag set
  1963. * are not executed (will have no effect on the attached physical process).
  1964. *
  1965. * \param self the control object instance to use
  1966. * \param value value if the test flag (true = test mode).
  1967. */
  1968. LIB61850_API void
  1969. ControlObjectClient_setTestMode(ControlObjectClient self, bool value);
  1970. /**
  1971. * \brief Set the origin parameter for control commands
  1972. *
  1973. * The origin parameter is used to identify the client/application that sent a control
  1974. * command. It is intended for later analysis.
  1975. *
  1976. * \param self the ControlObjectClient instance
  1977. * \param orIdent originator identification can be an arbitrary string
  1978. * \param orCat originator category (see \ref ORIGINATOR_CATEGORIES)
  1979. */
  1980. LIB61850_API void
  1981. ControlObjectClient_setOrigin(ControlObjectClient self, const char* orIdent, int orCat);
  1982. /**
  1983. * \brief Use a constant T parameter for all command (select, operate, cancel) of a single control sequence
  1984. *
  1985. * NOTE: Some non-standard compliant servers may require this to accept oper/cancel requests
  1986. *
  1987. * \param self the ControlObjectClient instance
  1988. * \param useContantT enable this behavior with true, disable with false
  1989. */
  1990. LIB61850_API void
  1991. ControlObjectClient_useConstantT(ControlObjectClient self, bool useConstantT);
  1992. /**
  1993. * \deprecated use ControlObjectClient_setInterlockCheck instead
  1994. */
  1995. LIB61850_API DEPRECATED void
  1996. ControlObjectClient_enableInterlockCheck(ControlObjectClient self);
  1997. /**
  1998. * \deprecated use ControlObjectClient_setSynchroCheck instead
  1999. */
  2000. LIB61850_API DEPRECATED void
  2001. ControlObjectClient_enableSynchroCheck(ControlObjectClient self);
  2002. /**
  2003. * \deprecated Do not use (ctlNum is handled automatically by the library)! Intended for test purposes only.
  2004. */
  2005. LIB61850_API DEPRECATED void
  2006. ControlObjectClient_setCtlNum(ControlObjectClient self, uint8_t ctlNum);
  2007. /**
  2008. * \brief Set the value of the interlock check flag when a control command is sent
  2009. *
  2010. * \param self the ControlObjectClient instance
  2011. * \param value if true the server will perform a interlock check if supported
  2012. */
  2013. LIB61850_API void
  2014. ControlObjectClient_setInterlockCheck(ControlObjectClient self, bool value);
  2015. /**
  2016. * \brief Set the value of the synchro check flag when a control command is sent
  2017. *
  2018. * \param self the ControlObjectClient instance
  2019. * \param value if true the server will perform a synchro check if supported
  2020. */
  2021. LIB61850_API void
  2022. ControlObjectClient_setSynchroCheck(ControlObjectClient self, bool value);
  2023. /**
  2024. * \brief A callback handler that is invoked when a command termination message is received.
  2025. *
  2026. * This callback is invoked whenever a CommandTermination+ or CommandTermination- message is received.
  2027. * To distinguish between a CommandTermination+ and CommandTermination- please use the
  2028. * \ref ControlObjectClient_getLastApplError function.
  2029. *
  2030. * In case of CommandTermination+ the return value
  2031. * of \ref ControlObjectClient_getLastApplError has error=CONTROL_ERROR_NO_ERROR and
  2032. * addCause=ADD_CAUSE_UNKNOWN set. When addCause is different from ADD_CAUSE_UNKNOWN then the client
  2033. * received a CommandTermination- message.
  2034. *
  2035. * NOTE: Do not call \ref ControlObjectClient_destroy inside of this callback! Doing so will cause a dead-lock.
  2036. *
  2037. * \param parameter the user parameter that is passed to the callback function
  2038. * \param controlClient the ControlObjectClient instance
  2039. */
  2040. typedef void (*CommandTerminationHandler) (void* parameter, ControlObjectClient controlClient);
  2041. /**
  2042. * \brief Set the command termination callback handler for this control object
  2043. *
  2044. * This callback is invoked whenever a CommandTermination+ or CommandTermination- message is received.
  2045. * To distinguish between a CommandTermination+ and CommandTermination- please use the
  2046. * \ref ControlObjectClient_getLastApplError function. In case of CommandTermination+ the return value
  2047. * of \ref ControlObjectClient_getLastApplError has error=CONTROL_ERROR_NO_ERROR and
  2048. * addCause=ADD_CAUSE_UNKNOWN set. When addCause is different from ADD_CAUSE_UNKNOWN then the client
  2049. * received a CommandTermination- message.
  2050. *
  2051. * \param self the ControlObjectClient instance
  2052. * \param handler the callback function to be used
  2053. * \param handlerParameter a user parameter that is passed to the handler
  2054. */
  2055. LIB61850_API void
  2056. ControlObjectClient_setCommandTerminationHandler(ControlObjectClient self, CommandTerminationHandler handler,
  2057. void* handlerParameter);
  2058. /** @} */
  2059. /*************************************
  2060. * Model discovery services
  2061. ************************************/
  2062. /**
  2063. * @defgroup IEC61850_CLIENT_MODEL_DISCOVERY Model discovery services
  2064. *
  2065. * @{
  2066. */
  2067. /**
  2068. * \brief Retrieve the device model from the server
  2069. *
  2070. * This function retrieves the complete device model from the server. The model is buffered an can be browsed
  2071. * by subsequent API calls. This API call is mapped to multiple ACSI services.
  2072. *
  2073. * \param self the connection object
  2074. * \param error the error code if an error occurs
  2075. *
  2076. */
  2077. LIB61850_API void
  2078. IedConnection_getDeviceModelFromServer(IedConnection self, IedClientError* error);
  2079. /**
  2080. * \brief Get the list of logical devices available at the server (DEPRECATED)
  2081. *
  2082. * This function is mapped to the GetServerDirectory(LD) ACSI service.
  2083. *
  2084. * NOTE: This function will call \ref IedConnection_getDeviceModelFromServer if no buffered data model
  2085. * information is available. Otherwise it will use the buffered information.
  2086. *
  2087. * \param self the connection object
  2088. * \param error the error code if an error occurs
  2089. *
  2090. * \return LinkedList with string elements representing the logical device names
  2091. */
  2092. LIB61850_API LinkedList /*<char*>*/
  2093. IedConnection_getLogicalDeviceList(IedConnection self, IedClientError* error);
  2094. /**
  2095. * \brief Get the list of logical devices or files available at the server
  2096. *
  2097. * GetServerDirectory ACSI service implementation. This function will either return the list of
  2098. * logical devices (LD) present at the server or the list of available files.
  2099. *
  2100. * NOTE: When getFIleNames is false zhis function will call
  2101. * \ref IedConnection_getDeviceModelFromServer if no buffered data model
  2102. * information is available. Otherwise it will use the buffered information.
  2103. *
  2104. * \param self the connection object
  2105. * \param error the error code if an error occurs
  2106. * \param getFileNames get list of files instead of logical device names (TO BE IMPLEMENTED)
  2107. *
  2108. * \return LinkedList with string elements representing the logical device names or file names
  2109. */
  2110. LIB61850_API LinkedList /*<char*>*/
  2111. IedConnection_getServerDirectory(IedConnection self, IedClientError* error, bool getFileNames);
  2112. /**
  2113. * \brief Get the list of logical nodes (LN) of a logical device
  2114. *
  2115. * GetLogicalDeviceDirectory ACSI service implementation. Returns the list of logical nodes names present
  2116. * in a logical device. The list is returned as a linked list of type LinkedList with c style string elements.
  2117. *
  2118. * NOTE: This function will call \ref IedConnection_getDeviceModelFromServer if no buffered data model
  2119. * information is available. Otherwise it will use the buffered information.
  2120. *
  2121. * \param self the connection object
  2122. * \param error the error code if an error occurs
  2123. * \param logicalDeviceName the name of the logical device (LD) of interest
  2124. *
  2125. * \return LinkedList with string elements representing the logical node names
  2126. */
  2127. LIB61850_API LinkedList /*<char*>*/
  2128. IedConnection_getLogicalDeviceDirectory(IedConnection self, IedClientError* error, const char* logicalDeviceName);
  2129. typedef enum {
  2130. ACSI_CLASS_DATA_OBJECT,
  2131. ACSI_CLASS_DATA_SET,
  2132. ACSI_CLASS_BRCB,
  2133. ACSI_CLASS_URCB,
  2134. ACSI_CLASS_LCB,
  2135. ACSI_CLASS_LOG,
  2136. ACSI_CLASS_SGCB,
  2137. ACSI_CLASS_GoCB,
  2138. ACSI_CLASS_GsCB,
  2139. ACSI_CLASS_MSVCB,
  2140. ACSI_CLASS_USVCB
  2141. } ACSIClass;
  2142. /**
  2143. * \brief returns a list of all MMS variables that are children of the given logical node
  2144. *
  2145. * This function cannot be mapped to any ACSI service. It is a convenience function for generic clients that
  2146. * wants to show a list of all available children of the MMS named variable representing the logical node.
  2147. *
  2148. * NOTE: This function will call \ref IedConnection_getDeviceModelFromServer if no buffered data model
  2149. * information is available. Otherwise it will use the buffered information.
  2150. *
  2151. * \param self the connection object
  2152. * \param error the error code if an error occurs
  2153. * \param logicalNodeReference string that represents the LN reference
  2154. *
  2155. * \return the list of all MMS named variables as C strings in a LinkedList type
  2156. */
  2157. LIB61850_API LinkedList /*<char*>*/
  2158. IedConnection_getLogicalNodeVariables(IedConnection self, IedClientError* error,
  2159. const char* logicalNodeReference);
  2160. /**
  2161. * \brief returns the directory of the given logical node (LN) containing elements of the specified ACSI class
  2162. *
  2163. * Implementation of the GetLogicalNodeDirectory ACSI service. In contrast to the ACSI description this
  2164. * function does not always creates a request to the server. For most ACSI classes it simply accesses the
  2165. * data model that was retrieved before or calls \ref IedConnection_getDeviceModelFromServer if no buffered data model
  2166. * information is available. An exception to this rule are the ACSI classes ACSI_CLASS_DATASET and
  2167. * ACSI_CLASS_LOG. Both always perform a request to the server.
  2168. *
  2169. * \param self the connection object
  2170. * \param error the error code if an error occurs
  2171. * \param logicalNodeReference string that represents the LN reference
  2172. * \param acsiClass specifies the ACSI class
  2173. *
  2174. * \return list of all logical node elements of the specified ACSI class type as C strings in a LinkedList
  2175. */
  2176. LIB61850_API LinkedList /*<char*>*/
  2177. IedConnection_getLogicalNodeDirectory(IedConnection self, IedClientError* error,
  2178. const char* logicalNodeReference, ACSIClass acsiClass);
  2179. /**
  2180. * \brief returns the directory of the given data object (DO)
  2181. *
  2182. * Implementation of the GetDataDirectory ACSI service. This will return the list of
  2183. * all data attributes or sub data objects.
  2184. *
  2185. * NOTE: This function will call \ref IedConnection_getDeviceModelFromServer if no buffered data model
  2186. * information is available. Otherwise it will use the buffered information.
  2187. *
  2188. * \param self the connection object
  2189. * \param error the error code if an error occurs
  2190. * \param dataReference string that represents the DO reference
  2191. *
  2192. * \return list of all data attributes or sub data objects as C strings in a LinkedList
  2193. */
  2194. LIB61850_API LinkedList /*<char*>*/
  2195. IedConnection_getDataDirectory(IedConnection self, IedClientError* error, const char* dataReference);
  2196. /**
  2197. * \brief returns the directory of the given data object (DO)
  2198. *
  2199. * Implementation of the GetDataDirectory ACSI service. This will return the list of
  2200. * C strings with all data attributes or sub data objects as elements. The returned
  2201. * strings will contain the functional constraint appended in square brackets when appropriate.
  2202. *
  2203. * NOTE: This function will call \ref IedConnection_getDeviceModelFromServer if no buffered data model
  2204. * information is available. Otherwise it will use the buffered information.
  2205. *
  2206. * \param self the connection object
  2207. * \param error the error code if an error occurs
  2208. * \param dataReference string that represents the DO reference
  2209. *
  2210. * \return list of all data attributes or sub data objects as C strings in a LinkedList
  2211. */
  2212. LIB61850_API LinkedList /*<char*>*/
  2213. IedConnection_getDataDirectoryFC(IedConnection self, IedClientError* error, const char* dataReference);
  2214. /**
  2215. * \brief returns the directory of the given data object/data attribute with the given FC
  2216. *
  2217. * Implementation of the GetDataDirectory ACSI service. This will return the list of
  2218. * C strings with all data attributes or sub data objects as elements.
  2219. *
  2220. * NOTE: This function will call \ref IedConnection_getDeviceModelFromServer if no buffered data model
  2221. * information is available. Otherwise it will use the buffered information.
  2222. *
  2223. * WARNING: Starting with version 1.0.3 the functional constraint will no longer be appended to
  2224. * the name string.
  2225. *
  2226. * \param self the connection object
  2227. * \param error the error code if an error occurs
  2228. * \param dataReference string that represents the DO reference
  2229. * \param fc the functional constraint
  2230. *
  2231. * \return list of all data attributes or sub data objects as C strings in a LinkedList
  2232. */
  2233. LIB61850_API LinkedList
  2234. IedConnection_getDataDirectoryByFC(IedConnection self, IedClientError* error, const char* dataReference, FunctionalConstraint fc);
  2235. /**
  2236. * \brief return the MMS variable type specification of the data attribute referenced by dataAttributeReference and function constraint fc.
  2237. *
  2238. * This function can be used to get the MMS variable type specification for an IEC 61850 data attribute. It is an extension
  2239. * of the ACSI that may be required by generic client applications.
  2240. *
  2241. * NOTE: API user is responsible to free the resources (see \ref MmsVariableSpecification_destroy)
  2242. *
  2243. * \param self the connection object
  2244. * \param error the error code if an error occurs
  2245. * \param dataAttributeReference string that represents the DA reference
  2246. * \param fc functional constraint of the DA
  2247. *
  2248. * \return MmsVariableSpecification of the data attribute.
  2249. */
  2250. LIB61850_API MmsVariableSpecification*
  2251. IedConnection_getVariableSpecification(IedConnection self, IedClientError* error, const char* dataAttributeReference,
  2252. FunctionalConstraint fc);
  2253. /**
  2254. * \brief Get all variables of the logical device
  2255. *
  2256. * NOTE: This function will return all MMS variables of the logical device (MMS domain). The result will be in the
  2257. * MMS notation (like "GGIO1$ST$Ind1$stVal") and also contain the variables of control blocks.
  2258. *
  2259. * \param[in] self the connection object
  2260. * \param[out] error the error code if an error occurs
  2261. * \param[in] ldName the logical device name
  2262. *
  2263. * \return a \ref LinkedList with the MMS variable names as string. Has to be released by the caller
  2264. */
  2265. LIB61850_API LinkedList
  2266. IedConnection_getLogicalDeviceVariables(IedConnection self, IedClientError* error, const char* ldName);
  2267. /**
  2268. * \brief Get the data set names of the logical device
  2269. *
  2270. * NOTE: This function will return all data set names (MMS named variable lists) of the logical device (MMS domain). The result will be in the
  2271. * MMS notation (like "LLN0$dataset1").
  2272. *
  2273. * \param[in] self the connection object
  2274. * \param[out] error the error code if an error occurs
  2275. * \param[in] ldName the logical device name
  2276. *
  2277. * \return a \ref LinkedList with data set names as string. Has to be released by the caller.
  2278. */
  2279. LIB61850_API LinkedList
  2280. IedConnection_getLogicalDeviceDataSets(IedConnection self, IedClientError* error, const char* ldName);
  2281. /*****************************************
  2282. * Asynchronous model discovery functions
  2283. *****************************************/
  2284. typedef void
  2285. (*IedConnection_GetNameListHandler) (uint32_t invokeId, void* parameter, IedClientError err, LinkedList nameList, bool moreFollows);
  2286. /**
  2287. * \brief Get the server directory (logical devices name) - asynchronous version
  2288. *
  2289. * \param[in] self the connection object
  2290. * \param[out] error the error code if an error occurs
  2291. * \param[in] continueAfter the name of the last received element when the call is a continuation, or NULL for the first call
  2292. * \param[in] result list to store (append) the response names, or NULL to create a new list for the response names
  2293. * \param[in] handler will be called when response is received or timed out.
  2294. * \param[in] parameter
  2295. *
  2296. * \return the invoke ID of the request
  2297. */
  2298. LIB61850_API uint32_t
  2299. IedConnection_getServerDirectoryAsync(IedConnection self, IedClientError* error, const char* continueAfter, LinkedList result,
  2300. IedConnection_GetNameListHandler handler, void* parameter);
  2301. /**
  2302. * \brief Get the variables in the logical device - asynchronous version
  2303. *
  2304. * NOTE: This function will return all MMS variables of the logical device (MMS domain). The result will be in the
  2305. * MMS notation (like "GGIO1$ST$Ind1$stVal") and also contain the variables of control blocks.
  2306. *
  2307. * \param[in] self the connection object
  2308. * \param[out] error the error code if an error occurs
  2309. * \param[in] ldName the logical device name
  2310. * \param[in] continueAfter the name of the last received element when the call is a continuation, or NULL for the first call
  2311. * \param[in] result list to store (append) the response names, or NULL to create a new list for the response names
  2312. * \param[in] handler will be called when response is received or timed out.
  2313. * \param[in] parameter
  2314. *
  2315. * \return the invoke ID of the request
  2316. */
  2317. LIB61850_API uint32_t
  2318. IedConnection_getLogicalDeviceVariablesAsync(IedConnection self, IedClientError* error, const char* ldName, const char* continueAfter, LinkedList result,
  2319. IedConnection_GetNameListHandler handler, void* parameter);
  2320. /**
  2321. * \brief Get the data set names in the logical device - asynchronous version
  2322. *
  2323. * NOTE: This function will return all data set names (MMS named variable lists) of the logical device (MMS domain). The result will be in the
  2324. * MMS notation (like "LLN0$dataset1").
  2325. *
  2326. * \param[in] self the connection object
  2327. * \param[out] error the error code if an error occurs
  2328. * \param[in] ldName the logical device name
  2329. * \param[in] continueAfter the name of the last received element when the call is a continuation, or NULL for the first call
  2330. * \param[in] result list to store (append) the response names, or NULL to create a new list for the response names
  2331. * \param[in] handler will be called when response is received or timed out.
  2332. * \param[in] parameter
  2333. *
  2334. * \return the invoke ID of the request
  2335. */
  2336. LIB61850_API uint32_t
  2337. IedConnection_getLogicalDeviceDataSetsAsync(IedConnection self, IedClientError* error, const char* ldName, const char* continueAfter, LinkedList result,
  2338. IedConnection_GetNameListHandler handler, void* parameter);
  2339. typedef void
  2340. (*IedConnection_GetVariableSpecificationHandler) (uint32_t invokeId, void* parameter, IedClientError err, MmsVariableSpecification* spec);
  2341. /**
  2342. * \brief Get the specification of a variable (data attribute or functional constraint data object) - asynchronous version
  2343. *
  2344. * \param[in] self the connection object
  2345. * \param[out] error the error code if an error occurs
  2346. * \param[in] dataAttributeReference the data attribute reference (FCDA or FCDO)
  2347. * \param[in] handler will be called when response is received or timed out.
  2348. * \param[in] parameter
  2349. *
  2350. * \return the invoke ID of the request
  2351. */
  2352. LIB61850_API uint32_t
  2353. IedConnection_getVariableSpecificationAsync(IedConnection self, IedClientError* error, const char* dataAttributeReference,
  2354. FunctionalConstraint fc, IedConnection_GetVariableSpecificationHandler handler, void* parameter);
  2355. /** @} */
  2356. /**
  2357. * @defgroup IEC61850_CLIENT_LOG_SERVICE Log service related functions, data types, and definitions
  2358. *
  2359. * @{
  2360. */
  2361. /**
  2362. * \brief Implementation of the QueryLogByTime ACSI service
  2363. *
  2364. * Read log entries from a log at the server. The log entries to read are specified by
  2365. * a starting time and an end time. If the complete range does not fit in a single MMS message
  2366. * the moreFollows flag will be set to true, to indicate that more entries are available for the
  2367. * specified time range.
  2368. *
  2369. * \param self the connection object
  2370. * \param error the error code if an error occurs
  2371. * \param logReference log object reference in the form <LD name>/<LN name>$<log name>
  2372. * \param startTime as millisecond UTC timestamp
  2373. * \param endTime as millisecond UTC timestamp
  2374. * \param moreFollows (output value) indicates that more entries are available that match the specification.
  2375. *
  2376. * \return list of MmsJournalEntry objects matching the specification
  2377. */
  2378. LIB61850_API LinkedList /* <MmsJournalEntry> */
  2379. IedConnection_queryLogByTime(IedConnection self, IedClientError* error, const char* logReference,
  2380. uint64_t startTime, uint64_t endTime, bool* moreFollows);
  2381. /**
  2382. * \brief Implementation of the QueryLogAfter ACSI service
  2383. *
  2384. * Read log entries from a log at the server following the entry with the specified entryID and timestamp.
  2385. * If the complete range does not fit in a single MMS message
  2386. * the moreFollows flag will be set to true, to indicate that more entries are available for the
  2387. * specified time range.
  2388. *
  2389. * \param self the connection object
  2390. * \param error the error code if an error occurs
  2391. * \param logReference log object reference in the form <LD name>/<LN name>$<log name>
  2392. * \param entryID usually the entryID of the last received entry
  2393. * \param timeStamp as millisecond UTC timestamp
  2394. * \param moreFollows (output value) indicates that more entries are available that match the specification.
  2395. *
  2396. * \return list of MmsJournalEntry objects matching the specification
  2397. */
  2398. LIB61850_API LinkedList /* <MmsJournalEntry> */
  2399. IedConnection_queryLogAfter(IedConnection self, IedClientError* error, const char* logReference,
  2400. MmsValue* entryID, uint64_t timeStamp, bool* moreFollows);
  2401. typedef void
  2402. (*IedConnection_QueryLogHandler) (uint32_t invokeId, void* parameter, IedClientError mmsError, LinkedList /* <MmsJournalEntry> */ journalEntries, bool moreFollows);
  2403. LIB61850_API uint32_t
  2404. IedConnection_queryLogByTimeAsync(IedConnection self, IedClientError* error, const char* logReference,
  2405. uint64_t startTime, uint64_t endTime, IedConnection_QueryLogHandler handler, void* parameter);
  2406. LIB61850_API uint32_t
  2407. IedConnection_queryLogAfterAsync(IedConnection self, IedClientError* error, const char* logReference,
  2408. MmsValue* entryID, uint64_t timeStamp, IedConnection_QueryLogHandler handler, void* parameter);
  2409. /** @} */
  2410. /**
  2411. * @defgroup IEC61850_CLIENT_FILE_SERVICE File service related functions, data types, and definitions
  2412. *
  2413. * @{
  2414. */
  2415. typedef struct sFileDirectoryEntry* FileDirectoryEntry;
  2416. /**
  2417. * @deprecated Will be removed from API
  2418. */
  2419. LIB61850_API FileDirectoryEntry
  2420. FileDirectoryEntry_create(const char* fileName, uint32_t fileSize, uint64_t lastModified);
  2421. /**
  2422. * \brief Destroy a FileDirectoryEntry object (free all resources)
  2423. *
  2424. * NOTE: Usually is called as a parameter of the \ref LinkedList_destroyDeep function.
  2425. *
  2426. * \param self the FileDirectoryEntry object
  2427. */
  2428. LIB61850_API void
  2429. FileDirectoryEntry_destroy(FileDirectoryEntry self);
  2430. /**
  2431. * \brief Get the name of the file
  2432. *
  2433. * \param self the FileDirectoryEntry object
  2434. *
  2435. * \return name of the file as null terminated string
  2436. */
  2437. LIB61850_API const char*
  2438. FileDirectoryEntry_getFileName(FileDirectoryEntry self);
  2439. /**
  2440. * \brief Get the file size in bytes
  2441. *
  2442. * \param self the FileDirectoryEntry object
  2443. *
  2444. * \return size of the file in bytes, or 0 if file size is unknown
  2445. */
  2446. LIB61850_API uint32_t
  2447. FileDirectoryEntry_getFileSize(FileDirectoryEntry self);
  2448. /**
  2449. * \brief Get the timestamp of last modification of the file
  2450. *
  2451. * \param self the FileDirectoryEntry object
  2452. *
  2453. * \return UTC timestamp in milliseconds
  2454. */
  2455. LIB61850_API uint64_t
  2456. FileDirectoryEntry_getLastModified(FileDirectoryEntry self);
  2457. /**
  2458. * \brief returns the directory entries of the specified file directory.
  2459. *
  2460. * Requires the server to support file services.
  2461. *
  2462. * NOTE: the returned linked list has to be freed by the user. You can user the following statement
  2463. * to free the list of directory entries:
  2464. *
  2465. * LinkedList_destroyDeep(fileNames, (LinkedListValueDeleteFunction) FileDirectoryEntry_destroy);
  2466. *
  2467. * where fileNames is the return value of this function.
  2468. *
  2469. * \param self the connection object
  2470. * \param error the error code if an error occurs
  2471. * \param directoryName the name of the directory or NULL to get the entries of the root directory
  2472. *
  2473. * \return the list of directory entries. The return type is a LinkedList with FileDirectoryEntry elements
  2474. */
  2475. LIB61850_API LinkedList /*<FileDirectoryEntry>*/
  2476. IedConnection_getFileDirectory(IedConnection self, IedClientError* error, const char* directoryName);
  2477. /**
  2478. * \brief returns the directory entries of the specified file directory returned by a single file directory request.
  2479. *
  2480. * This function will only create a single request and the result may only be the directory that fits
  2481. * into a single MMS PDU. If the server contains more directory entries, this will be indicated by setting
  2482. * the moreFollows variable (if provided by the caller). If the directory entry does not fit into a single MMS
  2483. * PDU the next part of the directory list can be requested by setting the continueAfter parameter with the value
  2484. * of the last filename of the received list.
  2485. *
  2486. * Requires the server to support file services.
  2487. *
  2488. * NOTE: the returned linked list has to be freed by the user. You can user the following statement
  2489. * to free the list of directory entries:
  2490. *
  2491. * LinkedList_destroyDeep(fileNames, (LinkedListValueDeleteFunction) FileDirectoryEntry_destroy);
  2492. *
  2493. * where fileNames is the return value of this function.
  2494. *
  2495. * \param self the connection object
  2496. * \param error the error code if an error occurs
  2497. * \param directoryName the name of the directory or NULL to get the entries of the root directory
  2498. * \param continueAfter last received filename to continue after, or NULL for the first request
  2499. * \param moreFollows if provided by the caller (non NULL) the function will indicate if more directory entries
  2500. * are available.
  2501. *
  2502. * \return the list of directory entries. The return type is a LinkedList with FileDirectoryEntry elements
  2503. */
  2504. LIB61850_API LinkedList /*<FileDirectoryEntry>*/
  2505. IedConnection_getFileDirectoryEx(IedConnection self, IedClientError* error, const char* directoryName, const char* continueAfter,
  2506. bool* moreFollows);
  2507. /**
  2508. * \brief Callback handler for the get file directory service
  2509. *
  2510. * Will be called once for each file directory entry and after the last entry with \ref moreFollows = false to indicate
  2511. * to indicate that no more data will follow. In case of an error the callback will be called with
  2512. * \ref err != IED_ERROR_OK and moreFollows = false.
  2513. */
  2514. /**
  2515. * \brief Callback handler for the get file directory service
  2516. *
  2517. * Will be called once for each file directory entry and after the last entry with \ref filename = NULL to indicate
  2518. * with \ref moreFollows set to true if more data is available at the server (can only happen when using the \ref IedConnection_getFileDirectoryAsyncEx
  2519. * function). In case of an error the callback will be called with \ref err != IED_ERROR_OK and moreFollows = false.
  2520. *
  2521. * \param invokeId invoke ID of the request
  2522. * \param parameter user provided parameter
  2523. * \param err error code in case of a problem, otherwise IED_ERROR_OK
  2524. * \param filename the filename of the current file directory entry or NULL if no more entries are available
  2525. * \param size the file size in byte of the current file directory entry
  2526. * \param lastModified the last modified timestamp of the current file directory entry
  2527. *
  2528. * \return return false when the request has to be stopped (no further callback invokations), true otherwise
  2529. */
  2530. typedef bool
  2531. (*IedConnection_FileDirectoryEntryHandler) (uint32_t invokeId, void* parameter, IedClientError err, char* filename, uint32_t size, uint64_t lastModfified,
  2532. bool moreFollows);
  2533. /**
  2534. * \brief Get file directory (single request) - asynchronous version
  2535. *
  2536. * The provided handler will be called for each received file directory entry.
  2537. *
  2538. * NOTE: This will only cause a single MMS request. When the resulting file directory doesn't fit into
  2539. * a single MMS PDU another request has to be sent indicating a continuation point with the continueAfter
  2540. * parameter.
  2541. *
  2542. * \param self the connection object
  2543. * \param error the error code if an error occurs
  2544. * \param directoryName the name of the directory or NULL to get the entries of the root directory
  2545. * \param continueAfter last received filename to continue after, or NULL for the first request
  2546. * \param handler the callback handler
  2547. * \param parameter user provided callback parameter
  2548. *
  2549. * \return the invokeId of the first file directory request
  2550. */
  2551. LIB61850_API uint32_t
  2552. IedConnection_getFileDirectoryAsyncEx(IedConnection self, IedClientError* error, const char* directoryName, const char* continueAfter,
  2553. IedConnection_FileDirectoryEntryHandler handler, void* parameter);
  2554. /**
  2555. * \brief user provided handler to receive the data of the GetFile request
  2556. *
  2557. * This handler will be invoked whenever the clients receives a data block from
  2558. * the server. The API user has to copy the data to another location before returning.
  2559. * The other location could for example be a file in the clients file system.
  2560. *
  2561. * \param parameter user provided parameter
  2562. * \param buffer pointer to the buffer containing the received data
  2563. * \param bytesRead number of bytes available in the buffer
  2564. *
  2565. * \return true if the client implementation shall continue to download data false if the download
  2566. * should be stopped. E.g. if the file cannot be stored client side due to missing resources.
  2567. */
  2568. typedef bool
  2569. (*IedClientGetFileHandler) (void* parameter, uint8_t* buffer, uint32_t bytesRead);
  2570. /**
  2571. * \brief Implementation of the GetFile ACSI service
  2572. *
  2573. * Download a file from the server.
  2574. *
  2575. * \param self the connection object
  2576. * \param error the error code if an error occurs
  2577. * \param fileName the name of the file to be read from the server
  2578. *
  2579. * \return number of bytes received
  2580. */
  2581. LIB61850_API uint32_t
  2582. IedConnection_getFile(IedConnection self, IedClientError* error, const char* fileName, IedClientGetFileHandler handler,
  2583. void* handlerParameter);
  2584. /**
  2585. * \brief User provided handler to receive the data of the asynchronous GetFile request
  2586. *
  2587. * This handler will be invoked whenever the clients receives a data block from
  2588. * the server. The API user has to copy the data to another location before returning.
  2589. * The other location could for example be a file in the clients file system. When the
  2590. * last data block is received the moreFollows parameter will be set to false.
  2591. *
  2592. * \param invokeId invoke ID of the message containing the received data
  2593. * \param parameter user provided parameter passed to the callback
  2594. * \param err error code in case of an error or IED_ERROR_OK
  2595. * \param originalInvokeId the invoke ID of the original (first) request. This is usually the request to open the file.
  2596. * \param buffer the buffer that contains the received file data
  2597. * \param bytesRead the number of bytes read into the buffer
  2598. * \param moreFollows indicates that more file data is following
  2599. *
  2600. * \return true, continue the file download when moreFollows is true, false, stop file download
  2601. */
  2602. typedef bool
  2603. (*IedConnection_GetFileAsyncHandler) (uint32_t invokeId, void* parameter, IedClientError err, uint32_t originalInvokeId,
  2604. uint8_t* buffer, uint32_t bytesRead, bool moreFollows);
  2605. /**
  2606. * \brief Implementation of the GetFile ACSI service - asynchronous version
  2607. *
  2608. * Download a file from the server.
  2609. *
  2610. * NOTE: This function can cause several request messages to be sent until the complete file is received
  2611. * or the file transfer is canceled. It allocates a background task and an outstanding call slot.
  2612. *
  2613. * \param self the connection object
  2614. * \param error the error code if an error occurs
  2615. * \param fileName the name of the file to be read from the server
  2616. * \param hander callback handler that is called for each received data or error message
  2617. * \param parameter user provided callback parameter
  2618. *
  2619. * \return invokeId of the first sent request
  2620. */
  2621. LIB61850_API uint32_t
  2622. IedConnection_getFileAsync(IedConnection self, IedClientError* error, const char* fileName, IedConnection_GetFileAsyncHandler handler,
  2623. void* parameter);
  2624. /**
  2625. * \brief Set the virtual filestore basepath for the setFile service
  2626. *
  2627. * All external file service accesses will be mapped to paths relative to the base directory.
  2628. * NOTE: This function is only available when the CONFIG_SET_FILESTORE_BASEPATH_AT_RUNTIME
  2629. * option in stack_config.h is set.
  2630. *
  2631. * \param self the connection object
  2632. * \param basepath the new virtual filestore basepath
  2633. */
  2634. LIB61850_API void
  2635. IedConnection_setFilestoreBasepath(IedConnection, const char* basepath);
  2636. /**
  2637. * \brief Implementation of the SetFile ACSI service
  2638. *
  2639. * Upload a file to the server. The file has to be available in the local VMD filestore.
  2640. *
  2641. * \param self the connection object
  2642. * \param error the error code if an error occurs
  2643. * \param sourceFilename the filename of the local (client side) file
  2644. * \param destinationFilename the filename of the remote (service side) file
  2645. */
  2646. LIB61850_API void
  2647. IedConnection_setFile(IedConnection self, IedClientError* error, const char* sourceFilename, const char* destinationFilename);
  2648. /**
  2649. * \brief Implementation of the SetFile ACSI service - asynchronous version
  2650. *
  2651. * Upload a file to the server. The file has to be available in the local VMD filestore.
  2652. *
  2653. * \param self the connection object
  2654. * \param error the error code if an error occurs
  2655. * \param sourceFilename the filename of the local (client side) file
  2656. * \param destinationFilename the filename of the remote (service side) file
  2657. * \param handler callback handler that is called when the obtain file response has been received
  2658. * \param parameter user provided callback parameter
  2659. */
  2660. LIB61850_API uint32_t
  2661. IedConnection_setFileAsync(IedConnection self, IedClientError* error, const char* sourceFilename, const char* destinationFilename,
  2662. IedConnection_GenericServiceHandler handler, void* parameter);
  2663. /**
  2664. * \brief Implementation of the DeleteFile ACSI service
  2665. *
  2666. * Delete a file at the server.
  2667. *
  2668. * \param self the connection object
  2669. * \param error the error code if an error occurs
  2670. * \param fileName the name of the file to delete
  2671. */
  2672. LIB61850_API void
  2673. IedConnection_deleteFile(IedConnection self, IedClientError* error, const char* fileName);
  2674. /**
  2675. * \brief Implementation of the DeleteFile ACSI service - asynchronous version
  2676. *
  2677. * Delete a file at the server.
  2678. *
  2679. * \param self the connection object
  2680. * \param error the error code if an error occurs
  2681. * \param fileName the name of the file to delete
  2682. * \param handler callback handler that is called when the obtain file response has been received
  2683. * \param parameter user provided callback parameter
  2684. */
  2685. LIB61850_API uint32_t
  2686. IedConnection_deleteFileAsync(IedConnection self, IedClientError* error, const char* fileName,
  2687. IedConnection_GenericServiceHandler handler, void* parameter);
  2688. /** @} */
  2689. /**@}*/
  2690. #ifdef __cplusplus
  2691. }
  2692. #endif
  2693. #endif /* IEC61850_CLIENT_H_ */