libiec61850  1.2.0
sv_subscriber.h
Go to the documentation of this file.
1 /*
2  * sv_subscriber.h
3  *
4  * Copyright 2015 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 SVReceiver
133 SVReceiver_create(void);
134 
144 void
145 SVReceiver_disableDestAddrCheck(SVReceiver self);
146 
157 void
158 SVReceiver_setInterfaceId(SVReceiver self, const char* interfaceId);
159 
168 void
169 SVReceiver_addSubscriber(SVReceiver self, SVSubscriber subscriber);
170 
177 void
178 SVReceiver_removeSubscriber(SVReceiver self, SVSubscriber subscriber);
179 
187 void
188 SVReceiver_start(SVReceiver self);
189 
195 void
196 SVReceiver_stop(SVReceiver self);
197 
207 bool
208 SVReceiver_isRunning(SVReceiver self);
209 
215 void
216 SVReceiver_destroy(SVReceiver self);
217 
218 /***************************************
219  * Functions for non-threaded operation
220  ***************************************/
221 
223 SVReceiver_startThreadless(SVReceiver self);
224 
225 void
226 SVReceiver_stopThreadless(SVReceiver self);
227 
237 bool
238 SVReceiver_tick(SVReceiver self);
239 
240 /*
241  * Subscriber
242  */
243 
244 SVSubscriber
245 SVSubscriber_create(const uint8_t* ethAddr, uint16_t appID);
246 
259 void
260 SVSubscriber_setListener(SVSubscriber self, SVUpdateListener listener, void* parameter);
261 
262 void
263 SVSubscriber_destroy(SVSubscriber self);
264 
265 /*************************************************************************
266  * SVSubscriber_ASDU object methods
267  **************************************************************************/
268 
282 uint16_t
283 SVSubscriber_ASDU_getSmpCnt(SVSubscriber_ASDU self);
284 
290 const char*
291 SVSubscriber_ASDU_getSvId(SVSubscriber_ASDU self);
292 
298 const char*
299 SVSubscriber_ASDU_getDatSet(SVSubscriber_ASDU self);
300 
306 uint32_t
307 SVSubscriber_ASDU_getConfRev(SVSubscriber_ASDU self);
308 
314 uint8_t
315 SVSubscriber_ASDU_getSmpMod(SVSubscriber_ASDU self);
316 
322 uint16_t
323 SVSubscriber_ASDU_getSmpRate(SVSubscriber_ASDU self);
324 
332 bool
333 SVSubscriber_ASDU_hasDatSet(SVSubscriber_ASDU self);
334 
342 bool
343 SVSubscriber_ASDU_hasRefrTm(SVSubscriber_ASDU self);
344 
352 bool
353 SVSubscriber_ASDU_hasSmpMod(SVSubscriber_ASDU self);
354 
362 bool
363 SVSubscriber_ASDU_hasSmpRate(SVSubscriber_ASDU self);
364 
372 uint64_t
373 SVSubscriber_ASDU_getRefrTmAsMs(SVSubscriber_ASDU self);
374 
383 int8_t
384 SVSubscriber_ASDU_getINT8(SVSubscriber_ASDU self, int index);
385 
394 int16_t
395 SVSubscriber_ASDU_getINT16(SVSubscriber_ASDU self, int index);
396 
405 int32_t
406 SVSubscriber_ASDU_getINT32(SVSubscriber_ASDU self, int index);
407 
416 int64_t
417 SVSubscriber_ASDU_getINT64(SVSubscriber_ASDU self, int index);
418 
427 uint8_t
428 SVSubscriber_ASDU_getINT8U(SVSubscriber_ASDU self, int index);
429 
438 uint16_t
439 SVSubscriber_ASDU_getINT16U(SVSubscriber_ASDU self, int index);
440 
449 uint32_t
450 SVSubscriber_ASDU_getINT32U(SVSubscriber_ASDU self, int index);
451 
460 uint64_t
461 SVSubscriber_ASDU_getINT64U(SVSubscriber_ASDU self, int index);
462 
471 float
472 SVSubscriber_ASDU_getFLOAT32(SVSubscriber_ASDU self, int index);
473 
482 double
483 SVSubscriber_ASDU_getFLOAT64(SVSubscriber_ASDU self, int index);
484 
493 Timestamp
494 SVSubscriber_ASDU_getTimestamp(SVSubscriber_ASDU self, int index);
495 
506 Quality
507 SVSubscriber_ASDU_getQuality(SVSubscriber_ASDU self, int index);
508 
516 int
517 SVSubscriber_ASDU_getDataSize(SVSubscriber_ASDU self);
518 
519 #ifndef DEPRECATED
520 #if defined(__GNUC__) || defined(__clang__)
521  #define DEPRECATED __attribute__((deprecated))
522 #else
523  #define DEPRECATED
524 #endif
525 #endif
526 
534 typedef struct sSVSubscriberASDU* SVClientASDU;
535 
536 DEPRECATED uint16_t
537 SVClientASDU_getSmpCnt(SVSubscriber_ASDU self);
538 
539 DEPRECATED const char*
540 SVClientASDU_getSvId(SVSubscriber_ASDU self);
541 
542 DEPRECATED uint32_t
543 SVClientASDU_getConfRev(SVSubscriber_ASDU self);
544 
545 DEPRECATED bool
546 SVClientASDU_hasRefrTm(SVSubscriber_ASDU self);
547 
548 DEPRECATED uint64_t
549 SVClientASDU_getRefrTmAsMs(SVSubscriber_ASDU self);
550 
551 DEPRECATED int8_t
552 SVClientASDU_getINT8(SVSubscriber_ASDU self, int index);
553 
554 DEPRECATED int16_t
555 SVClientASDU_getINT16(SVSubscriber_ASDU self, int index);
556 
557 DEPRECATED int32_t
558 SVClientASDU_getINT32(SVSubscriber_ASDU self, int index);
559 
560 DEPRECATED int64_t
561 SVClientASDU_getINT64(SVSubscriber_ASDU self, int index);
562 
563 DEPRECATED uint8_t
564 SVClientASDU_getINT8U(SVSubscriber_ASDU self, int index);
565 
566 DEPRECATED uint16_t
567 SVClientASDU_getINT16U(SVSubscriber_ASDU self, int index);
568 
569 DEPRECATED uint32_t
570 SVClientASDU_getINT32U(SVSubscriber_ASDU self, int index);
571 
572 DEPRECATED uint64_t
573 SVClientASDU_getINT64U(SVSubscriber_ASDU self, int index);
574 
575 DEPRECATED float
576 SVClientASDU_getFLOAT32(SVSubscriber_ASDU self, int index);
577 
578 DEPRECATED double
579 SVClientASDU_getFLOAT64(SVSubscriber_ASDU self, int index);
580 
581 DEPRECATED int
582 SVClientASDU_getDataSize(SVSubscriber_ASDU self);
583 
586 #ifdef __cplusplus
587 }
588 #endif
589 
590 #endif /* SAMPLED_VALUES_SV_SUBSCRIBER_ */
DEPRECATED float SVClientASDU_getFLOAT32(SVSubscriber_ASDU self, int index)
uint16_t SVSubscriber_ASDU_getINT16U(SVSubscriber_ASDU self, int index)
Get an INT16U data value in the data part of the ASDU.
bool SVSubscriber_ASDU_hasSmpRate(SVSubscriber_ASDU self)
Check if SmpRate value is included in the SV ASDU.
uint16_t Quality
Definition: iec61850_common.h:266
uint32_t SVSubscriber_ASDU_getConfRev(SVSubscriber_ASDU self)
return the ConfRev value included in the SV ASDU
uint8_t SVSubscriber_ASDU_getINT8U(SVSubscriber_ASDU self, int index)
Get an INT8U data value in the data part of the ASDU.
DEPRECATED uint16_t SVClientASDU_getINT16U(SVSubscriber_ASDU self, int index)
int64_t SVSubscriber_ASDU_getINT64(SVSubscriber_ASDU self, int index)
Get an INT64 data value in the data part of the ASDU.
DEPRECATED uint16_t SVClientASDU_getSmpCnt(SVSubscriber_ASDU self)
bool SVReceiver_tick(SVReceiver self)
Parse SV messages if they are available.
void SVSubscriber_destroy(SVSubscriber self)
void SVReceiver_removeSubscriber(SVReceiver self, SVSubscriber subscriber)
Disconnect subscriber and receiver.
DEPRECATED uint64_t SVClientASDU_getRefrTmAsMs(SVSubscriber_ASDU self)
DEPRECATED int8_t SVClientASDU_getINT8(SVSubscriber_ASDU self, int index)
struct sEthernetSocket * EthernetSocket
Opaque handle that represents an Ethernet "socket".
Definition: hal_ethernet.h:49
int8_t SVSubscriber_ASDU_getINT8(SVSubscriber_ASDU self, int index)
Get an INT8 data value in the data part of the ASDU.
struct sSVSubscriber_ASDU * SVSubscriber_ASDU
opaque handle to a SV ASDU (Application service data unit) instance.
Definition: sv_subscriber.h:96
void(* SVUpdateListener)(SVSubscriber subscriber, void *parameter, SVSubscriber_ASDU asdu)
Callback function for received SV messages.
Definition: sv_subscriber.h:116
float SVSubscriber_ASDU_getFLOAT32(SVSubscriber_ASDU self, int index)
Get an FLOAT32 data value in the data part of the ASDU.
void SVReceiver_disableDestAddrCheck(SVReceiver self)
Disable check for destination address of the received SV messages.
DEPRECATED uint8_t SVClientASDU_getINT8U(SVSubscriber_ASDU self, int index)
int16_t SVSubscriber_ASDU_getINT16(SVSubscriber_ASDU self, int index)
Get an INT16 data value in the data part of the ASDU.
Definition: iec61850_common.h:352
DEPRECATED double SVClientASDU_getFLOAT64(SVSubscriber_ASDU self, int index)
DEPRECATED bool SVClientASDU_hasRefrTm(SVSubscriber_ASDU self)
DEPRECATED int32_t SVClientASDU_getINT32(SVSubscriber_ASDU self, int index)
void SVReceiver_destroy(SVReceiver self)
Destroy receiver instance (cleanup resources)
bool SVSubscriber_ASDU_hasSmpMod(SVSubscriber_ASDU self)
Check if SmpMod value is included in the SV ASDU.
uint64_t SVSubscriber_ASDU_getINT64U(SVSubscriber_ASDU self, int index)
Get an INT64U data value in the data part of the ASDU.
Quality SVSubscriber_ASDU_getQuality(SVSubscriber_ASDU self, int index)
Get a quality value in the data part of the ASDU.
const char * SVSubscriber_ASDU_getSvId(SVSubscriber_ASDU self)
return the SvID value included in the SV ASDU
void SVSubscriber_setListener(SVSubscriber self, SVUpdateListener listener, void *parameter)
Set a callback handler to process received SV messages.
uint16_t SVSubscriber_ASDU_getSmpCnt(SVSubscriber_ASDU self)
return the SmpCnt value included in the SV ASDU
struct sSVReceiver * SVReceiver
opaque handle to a SV receiver instance
Definition: sv_subscriber.h:121
int32_t SVSubscriber_ASDU_getINT32(SVSubscriber_ASDU self, int index)
Get an INT32 data value in the data part of the ASDU.
DEPRECATED uint32_t SVClientASDU_getConfRev(SVSubscriber_ASDU self)
struct sSVSubscriberASDU * SVClientASDU
Definition: sv_subscriber.h:534
void SVReceiver_stop(SVReceiver self)
Receiver stops listening for SV messages.
bool SVSubscriber_ASDU_hasRefrTm(SVSubscriber_ASDU self)
Check if RefrTm value is included in the SV ASDU.
SVReceiver SVReceiver_create(void)
Create a new SV receiver instance.
struct sSVSubscriber * SVSubscriber
opaque handle to a SV subscriber instance
Definition: sv_subscriber.h:105
EthernetSocket SVReceiver_startThreadless(SVReceiver self)
DEPRECATED uint64_t SVClientASDU_getINT64U(SVSubscriber_ASDU self, int index)
void SVReceiver_start(SVReceiver self)
Receiver starts listening for SV messages.
DEPRECATED const char * SVClientASDU_getSvId(SVSubscriber_ASDU self)
void SVReceiver_setInterfaceId(SVReceiver self, const char *interfaceId)
Set the Ethernet interface ID for the receiver instance.
#define DEPRECATED
Definition: sv_subscriber.h:523
Timestamp SVSubscriber_ASDU_getTimestamp(SVSubscriber_ASDU self, int index)
Get a timestamp data value in the data part of the ASDU.
double SVSubscriber_ASDU_getFLOAT64(SVSubscriber_ASDU self, int index)
Get an FLOAT64 data value in the data part of the ASDU.
int SVSubscriber_ASDU_getDataSize(SVSubscriber_ASDU self)
Returns the size of the data part of the ASDU.
bool SVSubscriber_ASDU_hasDatSet(SVSubscriber_ASDU self)
Check if DatSet value is included in the SV ASDU.
SVSubscriber SVSubscriber_create(const uint8_t *ethAddr, uint16_t appID)
DEPRECATED int16_t SVClientASDU_getINT16(SVSubscriber_ASDU self, int index)
DEPRECATED int64_t SVClientASDU_getINT64(SVSubscriber_ASDU self, int index)
void SVReceiver_addSubscriber(SVReceiver self, SVSubscriber subscriber)
Add a subscriber instance to the receiver.
DEPRECATED int SVClientASDU_getDataSize(SVSubscriber_ASDU self)
uint32_t SVSubscriber_ASDU_getINT32U(SVSubscriber_ASDU self, int index)
Get an INT32U data value in the data part of the ASDU.
uint16_t SVSubscriber_ASDU_getSmpRate(SVSubscriber_ASDU self)
return the SmpRate value included in the SV ASDU
DEPRECATED uint32_t SVClientASDU_getINT32U(SVSubscriber_ASDU self, int index)
uint64_t SVSubscriber_ASDU_getRefrTmAsMs(SVSubscriber_ASDU self)
Get the RefrTim value included in SV ASDU as ms timestamp.
void SVReceiver_stopThreadless(SVReceiver self)
uint8_t SVSubscriber_ASDU_getSmpMod(SVSubscriber_ASDU self)
return the SmpMod value included in the SV ASDU
const char * SVSubscriber_ASDU_getDatSet(SVSubscriber_ASDU self)
return the DatSet value included in the SV ASDU
bool SVReceiver_isRunning(SVReceiver self)
Check if SV receiver is running.