libiec61850  1.2.0
iec61850_common.h
Go to the documentation of this file.
1 /*
2  * iec61850_common.h
3  *
4  * Copyright 2013 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 
41 typedef struct {
42  uint8_t vlanPriority;
43  uint16_t vlanId;
44  uint16_t appId;
45  uint8_t dstAddress[6];
47 
55 #define TRG_OPT_DATA_CHANGED 1
56 
58 #define TRG_OPT_QUALITY_CHANGED 2
59 
61 #define TRG_OPT_DATA_UPDATE 4
62 
64 #define TRG_OPT_INTEGRITY 8
65 
67 #define TRG_OPT_GI 16
68 
77 #define RPT_OPT_SEQ_NUM 1
78 
80 #define RPT_OPT_TIME_STAMP 2
81 
83 #define RPT_OPT_REASON_FOR_INCLUSION 4
84 
86 #define RPT_OPT_DATA_SET 8
87 
89 #define RPT_OPT_DATA_REFERENCE 16
90 
92 #define RPT_OPT_BUFFER_OVERFLOW 32
93 
95 #define RPT_OPT_ENTRY_ID 64
96 
98 #define RPT_OPT_CONF_REV 128
99 
108 #define CONTROL_ORCAT_NOT_SUPPORTED 0
109 
111 #define CONTROL_ORCAT_BAY_CONTROL 1
112 
114 #define CONTROL_ORCAT_STATION_CONTROL 2
115 
117 #define CONTROL_ORCAT_REMOTE_CONTROL 3
118 
120 #define CONTROL_ORCAT_AUTOMATIC_BAY 4
121 
123 #define CONTROL_ORCAT_AUTOMATIC_STATION 5
124 
126 #define CONTROL_ORCAT_AUTOMATIC_REMOTE 6
127 
129 #define CONTROL_ORCAT_MAINTENANCE 7
130 
132 #define CONTROL_ORCAT_PROCESS 8
133 
143 typedef enum {
173 
182 #if (CONFIG_PROVIDE_OLD_FC_DEFINES == 1)
183 #define ST IEC61850_FC_ST
184 #define MX IEC61850_FC_MX
185 #define SP IEC61850_FC_SP
186 #define SV IEC61850_FC_SV
187 #define CF IEC61850_FC_CF
188 #define DC IEC61850_FC_DC
189 #define SG IEC61850_FC_SG
190 #define SE IEC61850_FC_SE
191 #define SR IEC61850_FC_SR
192 #define OR IEC61850_FC_OR
193 #define BL IEC61850_FC_BL
194 #define EX IEC61850_FC_EX
195 #define CO IEC61850_FC_CO
196 #define ALL IEC61850_FC_ALL
197 #define NONE IEC61850_FC_NONE
198 #endif /* (CONFIG_PROVIDE_OLD_FC_DEFINES == 1) */
199 
200 
202 typedef enum eFunctionalConstraint {
239 
244 
248 char*
250 
255 FunctionalConstraint_fromString(const char* fcString);
256 
266 typedef uint16_t Quality;
267 typedef uint16_t Validity;
268 
269 #define QUALITY_VALIDITY_GOOD 0
270 #define QUALITY_VALIDITY_INVALID 2
271 #define QUALITY_VALIDITY_RESERVED 1
272 #define QUALITY_VALIDITY_QUESTIONABLE 3
273 
274 #define QUALITY_DETAIL_OVERFLOW 4
275 #define QUALITY_DETAIL_OUT_OF_RANGE 8
276 #define QUALITY_DETAIL_BAD_REFERENCE 16
277 #define QUALITY_DETAIL_OSCILLATORY 32
278 #define QUALITY_DETAIL_FAILURE 64
279 #define QUALITY_DETAIL_OLD_DATA 128
280 #define QUALITY_DETAIL_INCONSISTENT 256
281 #define QUALITY_DETAIL_INACCURATE 512
282 
283 #define QUALITY_SOURCE_SUBSTITUTED 1024
284 
285 #define QUALITY_TEST 2048
286 
287 #define QUALITY_OPERATOR_BLOCKED 4096
288 
289 Validity
290 Quality_getValidity(Quality* self);
291 
292 void
293 Quality_setValidity(Quality* self, Validity validity);
294 
295 void
296 Quality_setFlag(Quality* self, int flag);
297 
298 void
299 Quality_unsetFlag(Quality* self, int flag);
300 
301 bool
302 Quality_isFlagSet(Quality* self, int flag);
303 
304 Quality
305 Quality_fromMmsValue(const MmsValue* mmsValue);
306 
315 typedef enum {
318  DBPOS_ON = 2,
320 } Dbpos;
321 
322 
330 Dbpos
331 Dbpos_fromMmsValue(const MmsValue* mmsValue);
332 
341 MmsValue*
342 Dbpos_toMmsValue(MmsValue* mmsValue, Dbpos dbpos);
343 
352 typedef union {
353  uint8_t val[8];
354 } Timestamp;
355 
356 Timestamp*
357 Timestamp_create(void);
358 
359 Timestamp*
360 Timestamp_createFromByteArray(uint8_t* byteArray);
361 
362 void
364 
365 void
367 
368 uint32_t
370 
371 uint64_t
373 
374 bool
376 
377 void
378 Timestamp_setLeapSecondKnown(Timestamp* self, bool value);
379 
380 bool
382 
383 void
384 Timestamp_setClockFailure(Timestamp* self, bool value);
385 
386 bool
388 
389 void
391 
392 int
394 
400 void
401 Timestamp_setSubsecondPrecision(Timestamp* self, int subsecondPrecision);
402 
403 void
404 Timestamp_setTimeInSeconds(Timestamp* self, uint32_t secondsSinceEpoch);
405 
406 void
407 Timestamp_setTimeInMilliseconds(Timestamp* self, uint64_t millisSinceEpoch);
408 
409 void
411 
418 MmsValue*
419 Timestamp_toMmsValue(Timestamp* self, MmsValue* mmsValue);
420 
426 char*
428 
429 
434 #ifdef __cplusplus
435 }
436 #endif
437 
438 #endif /* IEC61850_COMMON_H_ */
Definition: iec61850_common.h:155
Definition: iec61850_common.h:154
Definition: iec61850_common.h:158
Definition: iec61850_common.h:226
Definition: iec61850_common.h:230
uint64_t Timestamp_getTimeInMs(Timestamp *self)
void Timestamp_setTimeInSeconds(Timestamp *self, uint32_t secondsSinceEpoch)
Definition: iec61850_common.h:167
FunctionalConstraint FunctionalConstraint_fromString(const char *fcString)
parse a string treated as a functional constraint representation
Definition: iec61850_common.h:218
Definition: iec61850_common.h:41
uint16_t Quality
Definition: iec61850_common.h:266
Definition: iec61850_common.h:145
int Timestamp_getSubsecondPrecision(Timestamp *self)
void Timestamp_setClockFailure(Timestamp *self, bool value)
Definition: iec61850_common.h:214
Definition: iec61850_common.h:232
Timestamp * Timestamp_createFromByteArray(uint8_t *byteArray)
Definition: iec61850_common.h:208
Definition: iec61850_common.h:319
Dbpos Dbpos_fromMmsValue(const MmsValue *mmsValue)
convert MMS bit string to Dbpos enumeration type
Definition: iec61850_common.h:153
Definition: iec61850_common.h:316
bool Quality_isFlagSet(Quality *self, int flag)
Definition: iec61850_common.h:238
Definition: iec61850_common.h:144
Definition: iec61850_common.h:210
uint16_t appId
Definition: iec61850_common.h:44
Definition: iec61850_common.h:206
Definition: iec61850_common.h:162
Definition: iec61850_common.h:165
ControlAddCause
Definition: iec61850_common.h:143
Validity Quality_getValidity(Quality *self)
Definition: iec61850_common.h:166
Definition: iec61850_common.h:169
MmsValue * Dbpos_toMmsValue(MmsValue *mmsValue, Dbpos dbpos)
conver Dbpos to MMS bit string
void Timestamp_setSubsecondPrecision(Timestamp *self, int subsecondPrecision)
Set the subsecond precision value of the time stamp.
Definition: iec61850_common.h:352
Definition: iec61850_common.h:157
Definition: iec61850_common.h:204
Definition: iec61850_common.h:170
void Timestamp_clearFlags(Timestamp *self)
Definition: iec61850_common.h:164
Definition: iec61850_common.h:222
Definition: iec61850_common.h:147
void Quality_unsetFlag(Quality *self, int flag)
uint16_t vlanId
Definition: iec61850_common.h:43
Definition: iec61850_common.h:148
Definition: iec61850_common.h:171
void Timestamp_destroy(Timestamp *self)
Definition: iec61850_common.h:146
Timestamp * Timestamp_create(void)
Definition: iec61850_common.h:156
Definition: iec61850_common.h:212
uint32_t Timestamp_getTimeInSeconds(Timestamp *self)
Definition: iec61850_common.h:168
Definition: iec61850_common.h:241
uint8_t vlanPriority
Definition: iec61850_common.h:42
Definition: iec61850_common.h:161
void Timestamp_setTimeInMilliseconds(Timestamp *self, uint64_t millisSinceEpoch)
Definition: iec61850_common.h:228
void Timestamp_setClockNotSynchronized(Timestamp *self, bool value)
void Timestamp_setLeapSecondKnown(Timestamp *self, bool value)
Definition: iec61850_common.h:163
Definition: iec61850_common.h:234
Definition: iec61850_common.h:224
bool Timestamp_isLeapSecondKnown(Timestamp *self)
Definition: iec61850_common.h:216
MmsValue * Timestamp_toMmsValue(Timestamp *self, MmsValue *mmsValue)
Set an MmsValue instance of type UTCTime to the timestamp value.
Definition: iec61850_common.h:160
Definition: iec61850_common.h:317
void Quality_setFlag(Quality *self, int flag)
Definition: iec61850_common.h:242
Quality Quality_fromMmsValue(const MmsValue *mmsValue)
char * FunctionalConstraint_toString(FunctionalConstraint fc)
convert a function constraint to a static string
char * LibIEC61850_getVersionString(void)
Get the version of the library as string.
Definition: iec61850_common.h:149
Dbpos
Definition: iec61850_common.h:315
bool Timestamp_hasClockFailure(Timestamp *self)
void Timestamp_setByMmsUtcTime(Timestamp *self, MmsValue *mmsValue)
Definition: iec61850_common.h:318
Definition: iec61850_common.h:236
uint16_t Validity
Definition: iec61850_common.h:267
void Quality_setValidity(Quality *self, Validity validity)
Definition: iec61850_common.h:220
FunctionalConstraint
Definition: iec61850_common.h:202
Definition: iec61850_common.h:159
Definition: iec61850_common.h:151
bool Timestamp_isClockNotSynchronized(Timestamp *self)
Definition: iec61850_common.h:150
struct sMmsValue MmsValue
Definition: mms_value.h:68
Definition: iec61850_common.h:152