libiec61850  1.5.3
sv_subscriber.h
Go to the documentation of this file.
1 /*
2  * sv_subscriber.h
3  *
4  * Copyright 2015-2018 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 
24 #ifndef SAMPLED_VALUES_SV_SUBSCRIBER_H_
25 #define SAMPLED_VALUES_SV_SUBSCRIBER_H_
26 
27 #include "libiec61850_common_api.h"
28 #include "iec61850_common.h"
29 #include "hal_ethernet.h"
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
96 typedef struct sSVSubscriber_ASDU* SVSubscriber_ASDU;
97 
105 typedef struct sSVSubscriber* SVSubscriber;
106 
116 typedef void (*SVUpdateListener)(SVSubscriber subscriber, void* parameter, SVSubscriber_ASDU asdu);
117 
121 typedef struct sSVReceiver* SVReceiver;
122 
132 LIB61850_API SVReceiver
134 
140 LIB61850_API void
142 
153 LIB61850_API void
155 
166 LIB61850_API void
167 SVReceiver_setInterfaceId(SVReceiver self, const char* interfaceId);
168 
177 LIB61850_API void
179 
186 LIB61850_API void
188 
196 LIB61850_API void
198 
204 LIB61850_API void
206 
216 LIB61850_API bool
218 
224 LIB61850_API void
226 
227 /***************************************
228  * Functions for non-threaded operation
229  ***************************************/
230 
231 LIB61850_API EthernetSocket
233 
234 LIB61850_API void
236 
246 LIB61850_API bool
248 
249 /*
250  * \brief Create a new SV subscriber instance
251  *
252  * \param ethAddr optional destination address (NULL to not specify the destination address)
253  * \param appID the APP-ID to identify matching SV messages
254  *
255  * \return the new subscriber instance
256  */
257 
258 LIB61850_API SVSubscriber
259 SVSubscriber_create(const uint8_t* ethAddr, uint16_t appID);
260 
272 LIB61850_API void
273 SVSubscriber_setListener(SVSubscriber self, SVUpdateListener listener, void* parameter);
274 
275 LIB61850_API void
277 
278 /*************************************************************************
279  * SVSubscriber_ASDU object methods
280  **************************************************************************/
281 
295 LIB61850_API uint16_t
297 
303 LIB61850_API const char*
305 
311 LIB61850_API const char*
313 
319 LIB61850_API uint32_t
321 
327 LIB61850_API uint8_t
329 
335 LIB61850_API uint16_t
337 
345 LIB61850_API bool
347 
355 LIB61850_API bool
357 
365 LIB61850_API bool
367 
375 LIB61850_API bool
377 
385 LIB61850_API uint64_t
387 
395 LIB61850_API nsSinceEpoch
397 
406 LIB61850_API int8_t
408 
417 LIB61850_API int16_t
419 
428 LIB61850_API int32_t
430 
439 LIB61850_API int64_t
441 
450 LIB61850_API uint8_t
452 
461 LIB61850_API uint16_t
463 
472 LIB61850_API uint32_t
474 
483 LIB61850_API uint64_t
485 
494 LIB61850_API float
496 
505 LIB61850_API double
507 
516 LIB61850_API Timestamp
518 
529 LIB61850_API Quality
531 
539 LIB61850_API int
541 
549 uint8_t
551 
552 #ifndef DEPRECATED
553 #if defined(__GNUC__) || defined(__clang__)
554  #define DEPRECATED __attribute__((deprecated))
555 #else
556  #define DEPRECATED
557 #endif
558 #endif
559 
567 typedef struct sSVSubscriberASDU* SVClientASDU;
568 
569 LIB61850_API DEPRECATED uint16_t
571 
572 LIB61850_API DEPRECATED const char*
574 
575 LIB61850_API DEPRECATED uint32_t
577 
578 LIB61850_API DEPRECATED bool
580 
581 LIB61850_API DEPRECATED uint64_t
583 
584 LIB61850_API DEPRECATED int8_t
586 
587 LIB61850_API DEPRECATED int16_t
589 
590 LIB61850_API DEPRECATED int32_t
592 
593 LIB61850_API DEPRECATED int64_t
595 
596 LIB61850_API DEPRECATED uint8_t
598 
599 LIB61850_API DEPRECATED uint16_t
601 
602 LIB61850_API DEPRECATED uint32_t
604 
605 LIB61850_API DEPRECATED uint64_t
607 
608 LIB61850_API DEPRECATED float
610 
611 LIB61850_API DEPRECATED double
613 
614 LIB61850_API DEPRECATED int
616 
619 #ifdef __cplusplus
620 }
621 #endif
622 
623 #endif /* SAMPLED_VALUES_SV_SUBSCRIBER_ */
uint16_t Quality
Definition: iec61850_common.h:330
struct sSVSubscriber_ASDU * SVSubscriber_ASDU
opaque handle to a SV ASDU (Application service data unit) instance.
Definition: sv_subscriber.h:96
LIB61850_API void SVReceiver_enableDestAddrCheck(SVReceiver self)
Enable check for destination address of the received SV messages.
LIB61850_API void SVReceiver_start(SVReceiver self)
Receiver starts listening for SV messages.
LIB61850_API SVReceiver SVReceiver_create(void)
Create a new SV receiver instance.
LIB61850_API void SVSubscriber_setListener(SVSubscriber self, SVUpdateListener listener, void *parameter)
Set a callback handler to process received SV messages.
struct sSVReceiver * SVReceiver
opaque handle to a SV receiver instance
Definition: sv_subscriber.h:121
LIB61850_API void SVReceiver_setInterfaceId(SVReceiver self, const char *interfaceId)
Set the Ethernet interface ID for the receiver instance.
LIB61850_API void SVSubscriber_destroy(SVSubscriber self)
LIB61850_API bool SVReceiver_tick(SVReceiver self)
Parse SV messages if they are available.
LIB61850_API void SVReceiver_disableDestAddrCheck(SVReceiver self)
Disable check for destination address of the received SV messages.
struct sSVSubscriber * SVSubscriber
opaque handle to a SV subscriber instance
Definition: sv_subscriber.h:105
LIB61850_API void SVReceiver_stop(SVReceiver self)
Receiver stops listening for SV messages.
LIB61850_API void SVReceiver_destroy(SVReceiver self)
Destroy receiver instance (cleanup resources)
LIB61850_API void SVReceiver_removeSubscriber(SVReceiver self, SVSubscriber subscriber)
Disconnect subscriber and receiver.
LIB61850_API EthernetSocket SVReceiver_startThreadless(SVReceiver self)
LIB61850_API SVSubscriber SVSubscriber_create(const uint8_t *ethAddr, uint16_t appID)
LIB61850_API void SVReceiver_addSubscriber(SVReceiver self, SVSubscriber subscriber)
Add a subscriber instance to the receiver.
LIB61850_API void SVReceiver_stopThreadless(SVReceiver self)
void(* SVUpdateListener)(SVSubscriber subscriber, void *parameter, SVSubscriber_ASDU asdu)
Callback function for received SV messages.
Definition: sv_subscriber.h:116
LIB61850_API bool SVReceiver_isRunning(SVReceiver self)
Check if SV receiver is running.
LIB61850_API uint64_t SVSubscriber_ASDU_getRefrTmAsMs(SVSubscriber_ASDU self)
Get the RefrTim value included in SV ASDU as milliseconds timestamp.
LIB61850_API int8_t SVSubscriber_ASDU_getINT8(SVSubscriber_ASDU self, int index)
Get an INT8 data value in the data part of the ASDU.
LIB61850_API bool SVSubscriber_ASDU_hasRefrTm(SVSubscriber_ASDU self)
Check if RefrTm value is included in the SV ASDU.
LIB61850_API bool SVSubscriber_ASDU_hasSmpRate(SVSubscriber_ASDU self)
Check if SmpRate value is included in the SV ASDU.
LIB61850_API bool SVSubscriber_ASDU_hasDatSet(SVSubscriber_ASDU self)
Check if DatSet value is included in the SV ASDU.
LIB61850_API Timestamp SVSubscriber_ASDU_getTimestamp(SVSubscriber_ASDU self, int index)
Get a timestamp data value in the data part of the ASDU.
LIB61850_API nsSinceEpoch SVSubscriber_ASDU_getRefrTmAsNs(SVSubscriber_ASDU self)
Get the RefrTim value included in SV ASDU as nanoseconds timestamp.
LIB61850_API uint32_t SVSubscriber_ASDU_getConfRev(SVSubscriber_ASDU self)
return the ConfRev value included in the SV ASDU
LIB61850_API const char * SVSubscriber_ASDU_getDatSet(SVSubscriber_ASDU self)
return the DatSet value included in the SV ASDU
LIB61850_API Quality SVSubscriber_ASDU_getQuality(SVSubscriber_ASDU self, int index)
Get a quality value in the data part of the ASDU.
LIB61850_API int SVSubscriber_ASDU_getDataSize(SVSubscriber_ASDU self)
Returns the size of the data part of the ASDU.
LIB61850_API uint64_t SVSubscriber_ASDU_getINT64U(SVSubscriber_ASDU self, int index)
Get an INT64U data value in the data part of the ASDU.
LIB61850_API int64_t SVSubscriber_ASDU_getINT64(SVSubscriber_ASDU self, int index)
Get an INT64 data value in the data part of the ASDU.
LIB61850_API int32_t SVSubscriber_ASDU_getINT32(SVSubscriber_ASDU self, int index)
Get an INT32 data value in the data part of the ASDU.
LIB61850_API bool SVSubscriber_ASDU_hasSmpMod(SVSubscriber_ASDU self)
Check if SmpMod value is included in the SV ASDU.
LIB61850_API uint8_t SVSubscriber_ASDU_getSmpMod(SVSubscriber_ASDU self)
return the SmpMod value included in the SV ASDU
LIB61850_API uint16_t SVSubscriber_ASDU_getINT16U(SVSubscriber_ASDU self, int index)
Get an INT16U data value in the data part of the ASDU.
LIB61850_API uint32_t SVSubscriber_ASDU_getINT32U(SVSubscriber_ASDU self, int index)
Get an INT32U data value in the data part of the ASDU.
#define DEPRECATED
Definition: sv_subscriber.h:556
uint8_t SVSubscriber_ASDU_getSmpSynch(SVSubscriber_ASDU self)
return the SmpSynch value included in the SV ASDU
LIB61850_API double SVSubscriber_ASDU_getFLOAT64(SVSubscriber_ASDU self, int index)
Get an FLOAT64 data value in the data part of the ASDU.
LIB61850_API uint16_t SVSubscriber_ASDU_getSmpCnt(SVSubscriber_ASDU self)
return the SmpCnt value included in the SV ASDU
LIB61850_API uint8_t SVSubscriber_ASDU_getINT8U(SVSubscriber_ASDU self, int index)
Get an INT8U data value in the data part of the ASDU.
LIB61850_API int16_t SVSubscriber_ASDU_getINT16(SVSubscriber_ASDU self, int index)
Get an INT16 data value in the data part of the ASDU.
LIB61850_API const char * SVSubscriber_ASDU_getSvId(SVSubscriber_ASDU self)
return the SvID value included in the SV ASDU
LIB61850_API float SVSubscriber_ASDU_getFLOAT32(SVSubscriber_ASDU self, int index)
Get an FLOAT32 data value in the data part of the ASDU.
LIB61850_API uint16_t SVSubscriber_ASDU_getSmpRate(SVSubscriber_ASDU self)
return the SmpRate value included in the SV ASDU
struct sSVSubscriberASDU * SVClientASDU
Definition: sv_subscriber.h:567
LIB61850_API DEPRECATED uint16_t SVClientASDU_getSmpCnt(SVSubscriber_ASDU self)
LIB61850_API DEPRECATED uint8_t SVClientASDU_getINT8U(SVSubscriber_ASDU self, int index)
LIB61850_API DEPRECATED uint64_t SVClientASDU_getRefrTmAsMs(SVSubscriber_ASDU self)
LIB61850_API DEPRECATED int8_t SVClientASDU_getINT8(SVSubscriber_ASDU self, int index)
LIB61850_API DEPRECATED uint32_t SVClientASDU_getConfRev(SVSubscriber_ASDU self)
LIB61850_API DEPRECATED int16_t SVClientASDU_getINT16(SVSubscriber_ASDU self, int index)
LIB61850_API DEPRECATED uint16_t SVClientASDU_getINT16U(SVSubscriber_ASDU self, int index)
LIB61850_API DEPRECATED int SVClientASDU_getDataSize(SVSubscriber_ASDU self)
LIB61850_API DEPRECATED const char * SVClientASDU_getSvId(SVSubscriber_ASDU self)
LIB61850_API DEPRECATED int64_t SVClientASDU_getINT64(SVSubscriber_ASDU self, int index)
LIB61850_API DEPRECATED uint32_t SVClientASDU_getINT32U(SVSubscriber_ASDU self, int index)
LIB61850_API DEPRECATED bool SVClientASDU_hasRefrTm(SVSubscriber_ASDU self)
LIB61850_API DEPRECATED int32_t SVClientASDU_getINT32(SVSubscriber_ASDU self, int index)
LIB61850_API DEPRECATED double SVClientASDU_getFLOAT64(SVSubscriber_ASDU self, int index)
LIB61850_API DEPRECATED float SVClientASDU_getFLOAT32(SVSubscriber_ASDU self, int index)
LIB61850_API DEPRECATED uint64_t SVClientASDU_getINT64U(SVSubscriber_ASDU self, int index)
Definition: iec61850_common.h:421