libiec61850  1.6.0
iec61850_common.h
Go to the documentation of this file.
1 /*
2  * iec61850_common.h
3  *
4  * Copyright 2013-2019 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 IEC61850_COMMON_H_
25 #define IEC61850_COMMON_H_
26 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 
31 
32 #include "libiec61850_common_api.h"
33 #include "logging_api.h"
34 #include "linked_list.h"
35 
42 #define IEC_61850_EDITION_1 0
43 
45 #define IEC_61850_EDITION_2 1
46 
48 #define IEC_61850_EDITION_2_1 2
49 
51 typedef struct {
52  uint8_t vlanPriority;
53  uint16_t vlanId;
54  uint16_t appId;
55  uint8_t dstAddress[6];
57 
59 typedef enum {
72 
76 typedef enum {
81 
87 
93 
98 
104 
112 #define TRG_OPT_DATA_CHANGED 1
113 
115 #define TRG_OPT_QUALITY_CHANGED 2
116 
118 #define TRG_OPT_DATA_UPDATE 4
119 
121 #define TRG_OPT_INTEGRITY 8
122 
124 #define TRG_OPT_GI 16
125 
127 #define TRG_OPT_TRANSIENT 128
139 #define RPT_OPT_SEQ_NUM 1
140 
142 #define RPT_OPT_TIME_STAMP 2
143 
145 #define RPT_OPT_REASON_FOR_INCLUSION 4
146 
148 #define RPT_OPT_DATA_SET 8
149 
151 #define RPT_OPT_DATA_REFERENCE 16
152 
154 #define RPT_OPT_BUFFER_OVERFLOW 32
155 
157 #define RPT_OPT_ENTRY_ID 64
158 
160 #define RPT_OPT_CONF_REV 128
170 #define CONTROL_ORCAT_NOT_SUPPORTED 0
171 
173 #define CONTROL_ORCAT_BAY_CONTROL 1
174 
176 #define CONTROL_ORCAT_STATION_CONTROL 2
177 
179 #define CONTROL_ORCAT_REMOTE_CONTROL 3
180 
182 #define CONTROL_ORCAT_AUTOMATIC_BAY 4
183 
185 #define CONTROL_ORCAT_AUTOMATIC_STATION 5
186 
188 #define CONTROL_ORCAT_AUTOMATIC_REMOTE 6
189 
191 #define CONTROL_ORCAT_MAINTENANCE 7
192 
194 #define CONTROL_ORCAT_PROCESS 8
195 
205 typedef enum {
235 
244 typedef enum {
250 
260 typedef enum eFunctionalConstraint {
299 
302  IEC61850_FC_NONE = -1
304 
308 LIB61850_API char*
310 
314 LIB61850_API FunctionalConstraint
315 FunctionalConstraint_fromString(const char* fcString);
316 
326 typedef uint16_t Quality;
327 typedef uint16_t Validity;
328 
329 #define QUALITY_VALIDITY_GOOD 0
330 #define QUALITY_VALIDITY_INVALID 2
331 #define QUALITY_VALIDITY_RESERVED 1
332 #define QUALITY_VALIDITY_QUESTIONABLE 3
333 
334 #define QUALITY_DETAIL_OVERFLOW 4
335 #define QUALITY_DETAIL_OUT_OF_RANGE 8
336 #define QUALITY_DETAIL_BAD_REFERENCE 16
337 #define QUALITY_DETAIL_OSCILLATORY 32
338 #define QUALITY_DETAIL_FAILURE 64
339 #define QUALITY_DETAIL_OLD_DATA 128
340 #define QUALITY_DETAIL_INCONSISTENT 256
341 #define QUALITY_DETAIL_INACCURATE 512
342 
343 #define QUALITY_SOURCE_SUBSTITUTED 1024
344 
345 #define QUALITY_TEST 2048
346 
347 #define QUALITY_OPERATOR_BLOCKED 4096
348 
349 #define QUALITY_DERIVED 8192
350 
351 LIB61850_API Validity
353 
354 LIB61850_API void
356 
357 LIB61850_API void
358 Quality_setFlag(Quality* self, int flag);
359 
360 LIB61850_API void
361 Quality_unsetFlag(Quality* self, int flag);
362 
363 LIB61850_API bool
364 Quality_isFlagSet(Quality* self, int flag);
365 
366 LIB61850_API Quality
368 
369 LIB61850_API MmsValue*
371 
380 typedef enum {
383  DBPOS_ON = 2,
384  DBPOS_BAD_STATE = 3
386 
387 
395 LIB61850_API Dbpos
396 Dbpos_fromMmsValue(const MmsValue* mmsValue);
397 
406 LIB61850_API MmsValue*
407 Dbpos_toMmsValue(MmsValue* mmsValue, Dbpos dbpos);
408 
417 typedef union {
418  uint8_t val[8];
419 } Timestamp;
420 
421 LIB61850_API Timestamp*
423 
424 LIB61850_API Timestamp*
425 Timestamp_createFromByteArray(const uint8_t* byteArray);
426 
427 LIB61850_API void
429 
430 LIB61850_API void
432 
433 LIB61850_API uint32_t
435 
436 LIB61850_API msSinceEpoch
438 
439 LIB61850_API nsSinceEpoch
441 
442 LIB61850_API bool
444 
445 LIB61850_API void
447 
448 LIB61850_API bool
450 
451 LIB61850_API void
453 
454 LIB61850_API bool
456 
457 LIB61850_API void
459 
460 LIB61850_API int
462 
463 LIB61850_API void
464 Timestamp_setFractionOfSecondPart(Timestamp* self, uint32_t fractionOfSecond);
465 
466 LIB61850_API uint32_t
468 
469 LIB61850_API float
471 
477 LIB61850_API void
478 Timestamp_setSubsecondPrecision(Timestamp* self, int subsecondPrecision);
479 
489 LIB61850_API void
490 Timestamp_setTimeInSeconds(Timestamp* self, uint32_t secondsSinceEpoch);
491 
500 LIB61850_API void
501 Timestamp_setTimeInMilliseconds(Timestamp* self, msSinceEpoch msTime);
502 
511 LIB61850_API void
512 Timestamp_setTimeInNanoseconds(Timestamp* self, nsSinceEpoch nsTime);
513 
514 LIB61850_API void
516 
523 LIB61850_API MmsValue*
525 
534 LIB61850_API Timestamp*
536 
542 LIB61850_API char*
544 
549 #ifdef __cplusplus
550 }
551 #endif
552 
553 #endif /* IEC61850_COMMON_H_ */
ControlAddCause
Definition: iec61850_common.h:205
@ ADD_CAUSE_ABORTION_BY_COMMUNICATION_LOSS
Definition: iec61850_common.h:229
@ ADD_CAUSE_BLOCKED_BY_INTERLOCKING
Definition: iec61850_common.h:216
@ ADD_CAUSE_UNKNOWN
Definition: iec61850_common.h:206
@ ADD_CAUSE_OBJECT_ALREADY_SELECTED
Definition: iec61850_common.h:225
@ ADD_CAUSE_SELECT_FAILED
Definition: iec61850_common.h:209
@ ADD_CAUSE_ABORTION_BY_CANCEL
Definition: iec61850_common.h:221
@ ADD_CAUSE_BLOCKED_BY_PROCESS
Definition: iec61850_common.h:215
@ ADD_CAUSE_COMMAND_ALREADY_IN_EXECUTION
Definition: iec61850_common.h:218
@ ADD_CAUSE_ABORTION_BY_TRIP
Definition: iec61850_common.h:223
@ ADD_CAUSE_OBJECT_NOT_SELECTED
Definition: iec61850_common.h:224
@ ADD_CAUSE_BLOCKED_BY_SYNCHROCHECK
Definition: iec61850_common.h:217
@ ADD_CAUSE_BLOCKED_BY_SWITCHING_HIERARCHY
Definition: iec61850_common.h:208
@ ADD_CAUSE_INVALID_POSITION
Definition: iec61850_common.h:210
@ ADD_CAUSE_STEP_LIMIT
Definition: iec61850_common.h:213
@ ADD_CAUSE_NO_ACCESS_AUTHORITY
Definition: iec61850_common.h:226
@ ADD_CAUSE_PARAMETER_CHANGE_IN_EXECUTION
Definition: iec61850_common.h:212
@ ADD_CAUSE_ENDED_WITH_OVERSHOOT
Definition: iec61850_common.h:227
@ ADD_CAUSE_ABORTION_BY_COMMAND
Definition: iec61850_common.h:230
@ ADD_CAUSE_TIME_LIMIT_OVER
Definition: iec61850_common.h:222
@ ADD_CAUSE_BLOCKED_BY_HEALTH
Definition: iec61850_common.h:219
@ ADD_CAUSE_LOCKED_BY_OTHER_CLIENT
Definition: iec61850_common.h:233
@ ADD_CAUSE_1_OF_N_CONTROL
Definition: iec61850_common.h:220
@ ADD_CAUSE_ABORTION_DUE_TO_DEVIATION
Definition: iec61850_common.h:228
@ ADD_CAUSE_NOT_SUPPORTED
Definition: iec61850_common.h:207
@ ADD_CAUSE_BLOCKED_BY_MODE
Definition: iec61850_common.h:214
@ ADD_CAUSE_NONE
Definition: iec61850_common.h:231
@ ADD_CAUSE_INCONSISTENT_PARAMETERS
Definition: iec61850_common.h:232
@ ADD_CAUSE_POSITION_REACHED
Definition: iec61850_common.h:211
ControlLastApplError
Definition: iec61850_common.h:244
@ CONTROL_ERROR_TIMEOUT_TEST
Definition: iec61850_common.h:247
@ CONTROL_ERROR_NO_ERROR
Definition: iec61850_common.h:245
@ CONTROL_ERROR_OPERATOR_TEST
Definition: iec61850_common.h:248
@ CONTROL_ERROR_UNKNOWN
Definition: iec61850_common.h:246
LIB61850_API Dbpos Dbpos_fromMmsValue(const MmsValue *mmsValue)
convert MMS bit string to Dbpos enumeration type
Dbpos
Definition: iec61850_common.h:380
LIB61850_API MmsValue * Dbpos_toMmsValue(MmsValue *mmsValue, Dbpos dbpos)
conver Dbpos to MMS bit string
@ DBPOS_BAD_STATE
Definition: iec61850_common.h:384
@ DBPOS_ON
Definition: iec61850_common.h:383
@ DBPOS_OFF
Definition: iec61850_common.h:382
@ DBPOS_INTERMEDIATE_STATE
Definition: iec61850_common.h:381
LIB61850_API char * FunctionalConstraint_toString(FunctionalConstraint fc)
convert a function constraint to a static string
LIB61850_API FunctionalConstraint FunctionalConstraint_fromString(const char *fcString)
parse a string treated as a functional constraint representation
FunctionalConstraint
Definition: iec61850_common.h:260
@ IEC61850_FC_BL
Definition: iec61850_common.h:282
@ IEC61850_FC_SE
Definition: iec61850_common.h:276
@ IEC61850_FC_US
Definition: iec61850_common.h:288
@ IEC61850_FC_SP
Definition: iec61850_common.h:266
@ IEC61850_FC_MX
Definition: iec61850_common.h:264
@ IEC61850_FC_LG
Definition: iec61850_common.h:296
@ IEC61850_FC_SV
Definition: iec61850_common.h:268
@ IEC61850_FC_BR
Definition: iec61850_common.h:294
@ IEC61850_FC_OR
Definition: iec61850_common.h:280
@ IEC61850_FC_SR
Definition: iec61850_common.h:278
@ IEC61850_FC_EX
Definition: iec61850_common.h:284
@ IEC61850_FC_ALL
Definition: iec61850_common.h:301
@ IEC61850_FC_SG
Definition: iec61850_common.h:274
@ IEC61850_FC_DC
Definition: iec61850_common.h:272
@ IEC61850_FC_MS
Definition: iec61850_common.h:290
@ IEC61850_FC_GO
Definition: iec61850_common.h:298
@ IEC61850_FC_NONE
Definition: iec61850_common.h:302
@ IEC61850_FC_CO
Definition: iec61850_common.h:286
@ IEC61850_FC_CF
Definition: iec61850_common.h:270
@ IEC61850_FC_ST
Definition: iec61850_common.h:262
@ IEC61850_FC_RP
Definition: iec61850_common.h:292
struct sMmsValue MmsValue
Definition: mms_value.h:68
uint16_t Validity
Definition: iec61850_common.h:327
LIB61850_API Quality Quality_fromMmsValue(const MmsValue *mmsValue)
LIB61850_API void Quality_setValidity(Quality *self, Validity validity)
uint16_t Quality
Definition: iec61850_common.h:326
LIB61850_API bool Quality_isFlagSet(Quality *self, int flag)
LIB61850_API void Quality_setFlag(Quality *self, int flag)
LIB61850_API void Quality_unsetFlag(Quality *self, int flag)
LIB61850_API Validity Quality_getValidity(Quality *self)
LIB61850_API MmsValue * Quality_toMmsValue(Quality *self, MmsValue *mmsValue)
LIB61850_API msSinceEpoch Timestamp_getTimeInMs(Timestamp *self)
LIB61850_API void Timestamp_setFractionOfSecondPart(Timestamp *self, uint32_t fractionOfSecond)
LIB61850_API void Timestamp_setSubsecondPrecision(Timestamp *self, int subsecondPrecision)
Set the subsecond precision value of the time stamp.
LIB61850_API void Timestamp_setClockFailure(Timestamp *self, bool value)
LIB61850_API Timestamp * Timestamp_create(void)
LIB61850_API void Timestamp_setByMmsUtcTime(Timestamp *self, const MmsValue *mmsValue)
LIB61850_API nsSinceEpoch Timestamp_getTimeInNs(Timestamp *self)
LIB61850_API int Timestamp_getSubsecondPrecision(Timestamp *self)
LIB61850_API void Timestamp_destroy(Timestamp *self)
LIB61850_API void Timestamp_setClockNotSynchronized(Timestamp *self, bool value)
LIB61850_API void Timestamp_setTimeInMilliseconds(Timestamp *self, msSinceEpoch msTime)
Set the time in milliseconds.
LIB61850_API Timestamp * Timestamp_fromMmsValue(Timestamp *self, MmsValue *mmsValue)
Get the Timestamp value from an MmsValue instance of type MMS_UTC_TIME.
LIB61850_API MmsValue * Timestamp_toMmsValue(Timestamp *self, MmsValue *mmsValue)
Set an MmsValue instance of type UTCTime to the timestamp value.
LIB61850_API float Timestamp_getFractionOfSecond(Timestamp *self)
LIB61850_API bool Timestamp_isClockNotSynchronized(Timestamp *self)
LIB61850_API bool Timestamp_hasClockFailure(Timestamp *self)
LIB61850_API uint32_t Timestamp_getFractionOfSecondPart(Timestamp *self)
LIB61850_API Timestamp * Timestamp_createFromByteArray(const uint8_t *byteArray)
LIB61850_API void Timestamp_setTimeInNanoseconds(Timestamp *self, nsSinceEpoch nsTime)
Set the time in nanoseconds.
LIB61850_API void Timestamp_setTimeInSeconds(Timestamp *self, uint32_t secondsSinceEpoch)
Set the time in seconds.
LIB61850_API void Timestamp_setLeapSecondKnown(Timestamp *self, bool value)
LIB61850_API char * LibIEC61850_getVersionString(void)
Get the version of the library as string.
LIB61850_API bool Timestamp_isLeapSecondKnown(Timestamp *self)
LIB61850_API uint32_t Timestamp_getTimeInSeconds(Timestamp *self)
LIB61850_API void Timestamp_clearFlags(Timestamp *self)
ACSIClass
Definition: iec61850_common.h:59
ControlModel
Control model (represented by "ctlModel" attribute)
Definition: iec61850_common.h:76
@ ACSI_CLASS_URCB
Definition: iec61850_common.h:63
@ ACSI_CLASS_DATA_SET
Definition: iec61850_common.h:61
@ ACSI_CLASS_BRCB
Definition: iec61850_common.h:62
@ ACSI_CLASS_MSVCB
Definition: iec61850_common.h:69
@ ACSI_CLASS_DATA_OBJECT
Definition: iec61850_common.h:60
@ ACSI_CLASS_GsCB
Definition: iec61850_common.h:68
@ ACSI_CLASS_LCB
Definition: iec61850_common.h:64
@ ACSI_CLASS_SGCB
Definition: iec61850_common.h:66
@ ACSI_CLASS_GoCB
Definition: iec61850_common.h:67
@ ACSI_CLASS_USVCB
Definition: iec61850_common.h:70
@ ACSI_CLASS_LOG
Definition: iec61850_common.h:65
@ CONTROL_MODEL_DIRECT_ENHANCED
Definition: iec61850_common.h:97
@ CONTROL_MODEL_STATUS_ONLY
Definition: iec61850_common.h:80
@ CONTROL_MODEL_DIRECT_NORMAL
Definition: iec61850_common.h:86
@ CONTROL_MODEL_SBO_ENHANCED
Definition: iec61850_common.h:102
@ CONTROL_MODEL_SBO_NORMAL
Definition: iec61850_common.h:92
Definition: iec61850_common.h:51
uint8_t vlanPriority
Definition: iec61850_common.h:52
uint16_t vlanId
Definition: iec61850_common.h:53
uint16_t appId
Definition: iec61850_common.h:54
Definition: iec61850_common.h:417