iec61850_client.h 123 KB

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