dnp3 (C++ API) 1.1.0
dnp3.hpp
Go to the documentation of this file.
1// This library is provided under the terms of a non-commercial license.
2//
3// Please refer to the source repository for details:
4//
5// https://github.com/stepfunc/dnp3/blob/master/LICENSE.txt
6//
7// Please contact Step Function I/O if you are interested in commercial license:
8//
9// info@stepfunc.io
10#pragma once
11
12#include <cstdint>
13#include <stdexcept>
14#include <chrono>
15#include <memory>
16#include <vector>
17
37
39namespace dnp3 {
40
42constexpr uint64_t dnp3_version_major = 1;
44constexpr uint64_t dnp3_version_minor = 1;
46constexpr uint64_t dnp3_version_patch = 0;
48constexpr char const* dnp3_version_string = "1.1.0";
49
50
52enum class ParamError {
54 ok = 0,
60 no_support = 3,
98 other_tls_error = 22,
99};
100
104const char* to_string(ParamError value);
105
107class ParamException : public std::logic_error {
108public:
113};
114
116namespace flag {
118 constexpr uint8_t online = 0x01;
120 constexpr uint8_t restart = 0x02;
122 constexpr uint8_t comm_lost = 0x04;
124 constexpr uint8_t remote_forced = 0x08;
126 constexpr uint8_t local_forced = 0x10;
128 constexpr uint8_t chatter_filter = 0x20;
130 constexpr uint8_t over_range = 0x20;
132 constexpr uint8_t discontinuity = 0x40;
134 constexpr uint8_t reference_err = 0x40;
135}
136
140enum class LogLevel {
142 error = 0,
144 warn = 1,
146 info = 2,
148 debug = 3,
150 trace = 4,
151};
152
156const char* to_string(LogLevel value);
157
158struct LoggingConfig;
159
161enum class LogOutputFormat {
163 text = 0,
165 json = 1,
166};
167
171const char* to_string(LogOutputFormat value);
172
174enum class TimeFormat {
176 none = 0,
178 rfc_3339 = 1,
180 system = 2,
181};
182
186const char* to_string(TimeFormat value);
187
190 friend class CppLoggingConfigFriend;
191
192private:
201
202public:
203
215
216
227};
228
231class Logger {
232public:
233 virtual ~Logger() = default;
234
239 virtual void on_message(LogLevel level, const char* message) = 0;
240};
241
243namespace functional {
244
247template <class T>
248class LoggerLambda final : public Logger
249{
250 static_assert(std::is_copy_constructible<T>::value, "Lambda expression must be copy constructible. Does it contain something that is move-only?");
251
252 T lambda;
253
254public:
257 LoggerLambda(const T& lambda) : lambda(lambda) {}
258
260 void on_message(LogLevel level, const char* message) override
261 {
262 lambda(level, message);
263 }
264};
265
270template <class T>
271std::unique_ptr<Logger> logger(const T& lambda)
272{
273 return std::make_unique<LoggerLambda<T>>(lambda); ;
274}
275
276} // end namespace functional
277
279class Logging {
280 Logging() = delete;
281public:
291 static void configure(const LoggingConfig& config, std::unique_ptr<Logger> logger);
292};
293
295enum class AppDecodeLevel {
297 nothing = 0,
299 header = 1,
301 object_headers = 2,
303 object_values = 3,
304};
305
309const char* to_string(AppDecodeLevel value);
310
314 nothing = 0,
316 header = 1,
318 payload = 2,
319};
320
325
327enum class LinkDecodeLevel {
329 nothing = 0,
331 header = 1,
333 payload = 2,
334};
335
339const char* to_string(LinkDecodeLevel value);
340
342enum class PhysDecodeLevel {
344 nothing = 0,
346 length = 1,
348 data = 2,
349};
350
354const char* to_string(PhysDecodeLevel value);
355
356struct DecodeLevel;
357
360 friend class CppDecodeLevelFriend;
361
362private:
370
371public:
372
383
384
395
396
405};
406
407class Runtime;
408
409struct RuntimeConfig;
410
413 friend class CppRuntimeConfigFriend;
414
415private:
420
421public:
422
430
431
436};
437
439class Runtime {
440 friend class CppRuntimeFriend;
441 // pointer to the underlying C type
442 void* self;
443 // constructor only accessible internally
444 Runtime(void* self): self(self) {}
445 // non-copyable
446 Runtime(const Runtime&) = delete;
447 Runtime& operator=(const Runtime&) = delete;
448 // no move assignment
449 Runtime& operator=(Runtime&& other) = delete;
450
451public:
455 Runtime(Runtime&& other) noexcept : self(other.self) { other.self = nullptr; }
456
463 Runtime(const RuntimeConfig& config);
464
469};
470
471struct ControlField;
472
475 friend class CppControlFieldFriend;
476
477private:
485 ControlField(bool fir, bool fin, bool con, bool uns, uint8_t seq);
486
487public:
488 ControlField() = delete;
489
491 bool fir;
493 bool fin;
495 bool con;
497 bool uns;
499 uint8_t seq;
500};
501
503enum class TripCloseCode {
505 nul = 0,
507 close = 1,
509 trip = 2,
511 reserved = 3,
512};
513
517const char* to_string(TripCloseCode value);
518
520enum class OpType {
522 nul = 0,
524 pulse_on = 1,
526 pulse_off = 2,
528 latch_on = 3,
530 latch_off = 4,
531};
532
536const char* to_string(OpType value);
537
538struct ControlCode;
539
542 friend class CppControlCodeFriend;
543
544private:
552
553public:
554 ControlCode() = delete;
555
566
567
580
581
594
595
599 bool clear;
601 bool queue;
604};
605
606struct Group12Var1;
607
610 friend class CppGroup12Var1Friend;
611
612 Group12Var1() = delete;
613
620 Group12Var1(const ControlCode& code, uint8_t count, uint32_t on_time, uint32_t off_time);
621
622
635
636
640 uint8_t count;
642 uint32_t on_time;
644 uint32_t off_time;
645};
646
647struct Flags;
648
650struct Flags {
651 friend class CppFlagsFriend;
652
653 Flags() = delete;
654
658 Flags(uint8_t value);
659
660
662 uint8_t value;
663};
664
666enum class TimeQuality {
672 invalid_time = 2,
673};
674
678const char* to_string(TimeQuality value);
679
680struct Timestamp;
681
683struct Timestamp {
684 friend class CppTimestampFriend;
685
686private:
692
693public:
694 Timestamp() = delete;
695
704
705
714
715
724
725
727 uint64_t value;
730};
731
733enum class DoubleBit {
735 intermediate = 0,
737 determined_off = 1,
739 determined_on = 2,
741 indeterminate = 3,
742};
743
747const char* to_string(DoubleBit value);
748
749struct BinaryInput;
750
753 friend class CppBinaryInputFriend;
754
755 BinaryInput() = delete;
756
763 BinaryInput(uint16_t index, bool value, const Flags& flags, const Timestamp& time);
764
765
767 uint16_t index;
769 bool value;
774};
775
777
790
791 friend class CppBinaryInputIteratorFriend;
792
793 // underlying opaque c type
794 void* iter;
795 // pointer to the last retrieved c value
796 void* current;
797
798 // internal constructor
799 BinaryInputIterator(void* iter) : iter(iter), current(nullptr) {}
800
801 BinaryInputIterator() = delete; // no default construction
802 BinaryInputIterator(const BinaryInputIterator&) = delete; // no copies
803 BinaryInputIterator& operator=(const BinaryInputIterator&) = delete; // no self-assignment
804 BinaryInputIterator& operator=(BinaryInputIterator&&) = delete; // no move self-assignment
805
806public:
807
810
813 bool next();
814
819};
820
822
825 friend class CppDoubleBitBinaryInputFriend;
826
827 DoubleBitBinaryInput() = delete;
828
836
837
839 uint16_t index;
846};
847
849
862
863 friend class CppDoubleBitBinaryInputIteratorFriend;
864
865 // underlying opaque c type
866 void* iter;
867 // pointer to the last retrieved c value
868 void* current;
869
870 // internal constructor
871 DoubleBitBinaryInputIterator(void* iter) : iter(iter), current(nullptr) {}
872
873 DoubleBitBinaryInputIterator() = delete; // no default construction
875 DoubleBitBinaryInputIterator& operator=(const DoubleBitBinaryInputIterator&) = delete; // no self-assignment
876 DoubleBitBinaryInputIterator& operator=(DoubleBitBinaryInputIterator&&) = delete; // no move self-assignment
877
878public:
879
882
885 bool next();
886
891};
892
893struct BinaryOutputStatus;
894
897 friend class CppBinaryOutputStatusFriend;
898
899 BinaryOutputStatus() = delete;
900
907 BinaryOutputStatus(uint16_t index, bool value, const Flags& flags, const Timestamp& time);
908
909
911 uint16_t index;
913 bool value;
918};
919
921
934
935 friend class CppBinaryOutputStatusIteratorFriend;
936
937 // underlying opaque c type
938 void* iter;
939 // pointer to the last retrieved c value
940 void* current;
941
942 // internal constructor
943 BinaryOutputStatusIterator(void* iter) : iter(iter), current(nullptr) {}
944
945 BinaryOutputStatusIterator() = delete; // no default construction
946 BinaryOutputStatusIterator(const BinaryOutputStatusIterator&) = delete; // no copies
947 BinaryOutputStatusIterator& operator=(const BinaryOutputStatusIterator&) = delete; // no self-assignment
948 BinaryOutputStatusIterator& operator=(BinaryOutputStatusIterator&&) = delete; // no move self-assignment
949
950public:
951
954
957 bool next();
958
963};
964
965struct Counter;
966
968struct Counter {
969 friend class CppCounterFriend;
970
971 Counter() = delete;
972
979 Counter(uint16_t index, uint32_t value, const Flags& flags, const Timestamp& time);
980
981
983 uint16_t index;
985 uint32_t value;
990};
991
992class CounterIterator;
993
1005class CounterIterator final {
1006
1007 friend class CppCounterIteratorFriend;
1008
1009 // underlying opaque c type
1010 void* iter;
1011 // pointer to the last retrieved c value
1012 void* current;
1013
1014 // internal constructor
1015 CounterIterator(void* iter) : iter(iter), current(nullptr) {}
1016
1017 CounterIterator() = delete; // no default construction
1018 CounterIterator(const CounterIterator&) = delete; // no copies
1019 CounterIterator& operator=(const CounterIterator&) = delete; // no self-assignment
1020 CounterIterator& operator=(CounterIterator&&) = delete; // no move self-assignment
1021
1022public:
1023
1026
1029 bool next();
1030
1035};
1036
1037struct FrozenCounter;
1038
1041 friend class CppFrozenCounterFriend;
1042
1043 FrozenCounter() = delete;
1044
1051 FrozenCounter(uint16_t index, uint32_t value, const Flags& flags, const Timestamp& time);
1052
1053
1055 uint16_t index;
1057 uint32_t value;
1062};
1063
1065
1078
1079 friend class CppFrozenCounterIteratorFriend;
1080
1081 // underlying opaque c type
1082 void* iter;
1083 // pointer to the last retrieved c value
1084 void* current;
1085
1086 // internal constructor
1087 FrozenCounterIterator(void* iter) : iter(iter), current(nullptr) {}
1088
1089 FrozenCounterIterator() = delete; // no default construction
1090 FrozenCounterIterator(const FrozenCounterIterator&) = delete; // no copies
1091 FrozenCounterIterator& operator=(const FrozenCounterIterator&) = delete; // no self-assignment
1092 FrozenCounterIterator& operator=(FrozenCounterIterator&&) = delete; // no move self-assignment
1093
1094public:
1095
1098
1101 bool next();
1102
1107};
1108
1109struct AnalogInput;
1110
1113 friend class CppAnalogInputFriend;
1114
1115 AnalogInput() = delete;
1116
1123 AnalogInput(uint16_t index, double value, const Flags& flags, const Timestamp& time);
1124
1125
1127 uint16_t index;
1129 double value;
1134};
1135
1137
1150
1151 friend class CppAnalogInputIteratorFriend;
1152
1153 // underlying opaque c type
1154 void* iter;
1155 // pointer to the last retrieved c value
1156 void* current;
1157
1158 // internal constructor
1159 AnalogInputIterator(void* iter) : iter(iter), current(nullptr) {}
1160
1161 AnalogInputIterator() = delete; // no default construction
1162 AnalogInputIterator(const AnalogInputIterator&) = delete; // no copies
1163 AnalogInputIterator& operator=(const AnalogInputIterator&) = delete; // no self-assignment
1164 AnalogInputIterator& operator=(AnalogInputIterator&&) = delete; // no move self-assignment
1165
1166public:
1167
1170
1173 bool next();
1174
1179};
1180
1181struct AnalogOutputStatus;
1182
1185 friend class CppAnalogOutputStatusFriend;
1186
1187 AnalogOutputStatus() = delete;
1188
1195 AnalogOutputStatus(uint16_t index, double value, const Flags& flags, const Timestamp& time);
1196
1197
1199 uint16_t index;
1201 double value;
1206};
1207
1209
1222
1223 friend class CppAnalogOutputStatusIteratorFriend;
1224
1225 // underlying opaque c type
1226 void* iter;
1227 // pointer to the last retrieved c value
1228 void* current;
1229
1230 // internal constructor
1231 AnalogOutputStatusIterator(void* iter) : iter(iter), current(nullptr) {}
1232
1233 AnalogOutputStatusIterator() = delete; // no default construction
1234 AnalogOutputStatusIterator(const AnalogOutputStatusIterator&) = delete; // no copies
1235 AnalogOutputStatusIterator& operator=(const AnalogOutputStatusIterator&) = delete; // no self-assignment
1236 AnalogOutputStatusIterator& operator=(AnalogOutputStatusIterator&&) = delete; // no move self-assignment
1237
1238public:
1239
1242
1245 bool next();
1246
1251};
1252
1253class ByteIterator;
1254
1266class ByteIterator final {
1267
1268 friend class CppByteIteratorFriend;
1269
1270 // underlying opaque c type
1271 void* iter;
1272 // pointer to the last retrieved c value
1273 void* current;
1274
1275 // internal constructor
1276 ByteIterator(void* iter) : iter(iter), current(nullptr) {}
1277
1278 ByteIterator() = delete; // no default construction
1279 ByteIterator(const ByteIterator&) = delete; // no copies
1280 ByteIterator& operator=(const ByteIterator&) = delete; // no self-assignment
1281 ByteIterator& operator=(ByteIterator&&) = delete; // no move self-assignment
1282
1283public:
1284
1287
1290 bool next();
1291
1295 uint8_t get();
1296};
1297
1298struct OctetString;
1299
1302 friend class CppOctetStringFriend;
1303
1304private:
1310
1311public:
1312 OctetString() = delete;
1313
1315 uint16_t index;
1318};
1319
1321
1334
1335 friend class CppOctetStringIteratorFriend;
1336
1337 // underlying opaque c type
1338 void* iter;
1339 // pointer to the last retrieved c value
1340 void* current;
1341
1342 // internal constructor
1343 OctetStringIterator(void* iter) : iter(iter), current(nullptr) {}
1344
1345 OctetStringIterator() = delete; // no default construction
1346 OctetStringIterator(const OctetStringIterator&) = delete; // no copies
1347 OctetStringIterator& operator=(const OctetStringIterator&) = delete; // no self-assignment
1348 OctetStringIterator& operator=(OctetStringIterator&&) = delete; // no move self-assignment
1349
1350public:
1351
1354
1357 bool next();
1358
1363};
1364
1366enum class PortState {
1368 disabled = 0,
1370 wait = 1,
1372 open = 2,
1374 shutdown = 3,
1375};
1376
1380const char* to_string(PortState value);
1381
1385public:
1386 virtual ~PortStateListener() = default;
1387
1391 virtual void on_change(PortState state) = 0;
1392};
1393
1394namespace functional {
1395
1398template <class T>
1400{
1401 static_assert(std::is_copy_constructible<T>::value, "Lambda expression must be copy constructible. Does it contain something that is move-only?");
1402
1403 T lambda;
1404
1405public:
1408 PortStateListenerLambda(const T& lambda) : lambda(lambda) {}
1409
1411 void on_change(PortState state) override
1412 {
1413 lambda(state);
1414 }
1415};
1416
1421template <class T>
1422std::unique_ptr<PortStateListener> port_state_listener(const T& lambda)
1423{
1424 return std::make_unique<PortStateListenerLambda<T>>(lambda); ;
1425}
1426
1427} // end namespace functional
1428
1430enum class Variation {
1432 group1_var0 = 0,
1434 group1_var1 = 1,
1436 group1_var2 = 2,
1438 group2_var0 = 3,
1440 group2_var1 = 4,
1442 group2_var2 = 5,
1444 group2_var3 = 6,
1446 group3_var0 = 7,
1448 group3_var1 = 8,
1450 group3_var2 = 9,
1452 group4_var0 = 10,
1454 group4_var1 = 11,
1456 group4_var2 = 12,
1458 group4_var3 = 13,
1460 group10_var0 = 14,
1462 group10_var1 = 15,
1464 group10_var2 = 16,
1466 group11_var0 = 17,
1468 group11_var1 = 18,
1470 group11_var2 = 19,
1472 group12_var0 = 20,
1474 group12_var1 = 21,
1476 group20_var0 = 22,
1478 group20_var1 = 23,
1480 group20_var2 = 24,
1482 group20_var5 = 25,
1484 group20_var6 = 26,
1486 group21_var0 = 27,
1488 group21_var1 = 28,
1490 group21_var2 = 29,
1492 group21_var5 = 30,
1494 group21_var6 = 31,
1496 group21_var9 = 32,
1498 group21_var10 = 33,
1500 group22_var0 = 34,
1502 group22_var1 = 35,
1504 group22_var2 = 36,
1506 group22_var5 = 37,
1508 group22_var6 = 38,
1510 group23_var0 = 39,
1512 group23_var1 = 40,
1514 group23_var2 = 41,
1516 group23_var5 = 42,
1518 group23_var6 = 43,
1520 group30_var0 = 44,
1522 group30_var1 = 45,
1524 group30_var2 = 46,
1526 group30_var3 = 47,
1528 group30_var4 = 48,
1530 group30_var5 = 49,
1532 group30_var6 = 50,
1534 group32_var0 = 51,
1536 group32_var1 = 52,
1538 group32_var2 = 53,
1540 group32_var3 = 54,
1542 group32_var4 = 55,
1544 group32_var5 = 56,
1546 group32_var6 = 57,
1548 group32_var7 = 58,
1550 group32_var8 = 59,
1552 group40_var0 = 60,
1554 group40_var1 = 61,
1556 group40_var2 = 62,
1558 group40_var3 = 63,
1560 group40_var4 = 64,
1562 group41_var0 = 65,
1564 group41_var1 = 66,
1566 group41_var2 = 67,
1568 group41_var3 = 68,
1570 group41_var4 = 69,
1572 group42_var0 = 70,
1574 group42_var1 = 71,
1576 group42_var2 = 72,
1578 group42_var3 = 73,
1580 group42_var4 = 74,
1582 group42_var5 = 75,
1584 group42_var6 = 76,
1586 group42_var7 = 77,
1588 group42_var8 = 78,
1590 group50_var1 = 79,
1592 group50_var3 = 80,
1594 group50_var4 = 81,
1596 group51_var1 = 82,
1598 group51_var2 = 83,
1600 group52_var1 = 84,
1602 group52_var2 = 85,
1604 group60_var1 = 86,
1606 group60_var2 = 87,
1608 group60_var3 = 88,
1610 group60_var4 = 89,
1612 group80_var1 = 90,
1614 group110 = 91,
1616 group111 = 92,
1617};
1618
1622const char* to_string(Variation value);
1623
1624struct RetryStrategy;
1625
1630 friend class CppRetryStrategyFriend;
1631
1632private:
1637 RetryStrategy(std::chrono::steady_clock::duration min_delay, std::chrono::steady_clock::duration max_delay);
1638
1639public:
1640
1649
1650
1652 std::chrono::steady_clock::duration min_delay;
1654 std::chrono::steady_clock::duration max_delay;
1655};
1656
1658enum class DataBits {
1660 five = 0,
1662 six = 1,
1664 seven = 2,
1666 eight = 3,
1667};
1668
1672const char* to_string(DataBits value);
1673
1675enum class FlowControl {
1677 none = 0,
1679 software = 1,
1681 hardware = 2,
1682};
1683
1687const char* to_string(FlowControl value);
1688
1690enum class Parity {
1692 none = 0,
1694 odd = 1,
1696 even = 2,
1697};
1698
1702const char* to_string(Parity value);
1703
1705enum class StopBits {
1707 one = 0,
1709 two = 1,
1710};
1711
1715const char* to_string(StopBits value);
1716
1717struct SerialSettings;
1718
1721 friend class CppSerialSettingsFriend;
1722
1723private:
1732
1733public:
1734
1746
1747
1749 uint32_t baud_rate;
1758};
1759
1761enum class LinkErrorMode {
1763 discard = 0,
1765 close = 1,
1766};
1767
1771const char* to_string(LinkErrorMode value);
1772
1774enum class MinTlsVersion {
1776 v12 = 0,
1778 v13 = 1,
1779};
1780
1784const char* to_string(MinTlsVersion value);
1785
1795 authority_based = 0,
1799 self_signed = 1,
1800};
1801
1805const char* to_string(CertificateMode value);
1806
1808enum class FunctionCode {
1810 confirm = 0,
1812 read = 1,
1814 write = 2,
1816 select = 3,
1818 operate = 4,
1820 direct_operate = 5,
1824 immediate_freeze = 7,
1828 freeze_clear = 9,
1832 freeze_at_time = 11,
1836 cold_restart = 13,
1838 warm_restart = 14,
1840 initialize_data = 15,
1844 start_application = 17,
1846 stop_application = 18,
1848 save_configuration = 19,
1850 enable_unsolicited = 20,
1854 assign_class = 22,
1856 delay_measure = 23,
1860 open_file = 25,
1862 close_file = 26,
1864 delete_file = 27,
1866 get_file_info = 28,
1868 authenticate_file = 29,
1870 abort_file = 30,
1872 response = 31,
1875};
1876
1880const char* to_string(FunctionCode value);
1881
1885 response = 0,
1888};
1889
1893const char* to_string(ResponseFunction value);
1894
1895struct Iin1;
1896
1898struct Iin1 {
1899 friend class CppIin1Friend;
1900
1901private:
1913
1914public:
1915 Iin1() = delete;
1916
1933};
1934
1935struct Iin2;
1936
1938struct Iin2 {
1939 friend class CppIin2Friend;
1940
1941private:
1953
1954public:
1955 Iin2() = delete;
1956
1973};
1974
1975struct Iin;
1976
1978struct Iin {
1979 friend class CppIinFriend;
1980
1981private:
1986 Iin(const Iin1& iin1, const Iin2& iin2);
1987
1988public:
1989 Iin() = delete;
1990
1995};
1996
1997struct ResponseHeader;
1998
2001 friend class CppResponseHeaderFriend;
2002
2003private:
2010
2011public:
2012 ResponseHeader() = delete;
2013
2020};
2021
2023enum class QualifierCode {
2025 range8 = 0,
2027 range16 = 1,
2029 all_objects = 2,
2031 count8 = 3,
2033 count16 = 4,
2039 free_format_16 = 7,
2040};
2041
2045const char* to_string(QualifierCode value);
2046
2047struct HeaderInfo;
2048
2051 friend class CppHeaderInfoFriend;
2052
2053private:
2061
2062public:
2063 HeaderInfo() = delete;
2064
2073};
2074
2076enum class ReadType {
2080 unsolicited = 1,
2082 single_poll = 2,
2084 periodic_poll = 3,
2085};
2086
2090const char* to_string(ReadType value);
2091
2095public:
2096 virtual ~ReadHandler() = default;
2097
2102 virtual void begin_fragment(ReadType read_type, const ResponseHeader& header) = 0;
2107 virtual void end_fragment(ReadType read_type, const ResponseHeader& header) = 0;
2112 virtual void handle_binary_input(const HeaderInfo& info, BinaryInputIterator& it) = 0;
2127 virtual void handle_counter(const HeaderInfo& info, CounterIterator& it) = 0;
2132 virtual void handle_frozen_counter(const HeaderInfo& info, FrozenCounterIterator& it) = 0;
2137 virtual void handle_analog_input(const HeaderInfo& info, AnalogInputIterator& it) = 0;
2147 virtual void handle_octet_string(const HeaderInfo& info, OctetStringIterator& it) = 0;
2148};
2149
2150class EndpointList;
2151
2156 friend class CppEndpointListFriend;
2157 // pointer to the underlying C type
2158 void* self;
2159 // constructor only accessible internally
2160 EndpointList(void* self): self(self) {}
2161 // non-copyable
2162 EndpointList(const EndpointList&) = delete;
2163 EndpointList& operator=(const EndpointList&) = delete;
2164 // no move assignment
2165 EndpointList& operator=(EndpointList&& other) = delete;
2166
2167public:
2171 EndpointList(EndpointList&& other) noexcept : self(other.self) { other.self = nullptr; }
2172
2178 EndpointList(const std::string& main_endpoint);
2179
2182
2188 void add(const std::string& endpoint);
2189};
2190
2191struct MasterChannelConfig;
2192
2195 friend class CppMasterChannelConfigFriend;
2196
2197private:
2205
2206public:
2207 MasterChannelConfig() = delete;
2208
2219
2220
2222 uint16_t address;
2233};
2234
2238enum class ClientState {
2240 disabled = 0,
2242 connecting = 1,
2244 connected = 2,
2250 shutdown = 5,
2251};
2252
2256const char* to_string(ClientState value);
2257
2261public:
2262 virtual ~ClientStateListener() = default;
2263
2267 virtual void on_change(ClientState state) = 0;
2268};
2269
2270namespace functional {
2271
2274template <class T>
2276{
2277 static_assert(std::is_copy_constructible<T>::value, "Lambda expression must be copy constructible. Does it contain something that is move-only?");
2278
2279 T lambda;
2280
2281public:
2284 ClientStateListenerLambda(const T& lambda) : lambda(lambda) {}
2285
2287 void on_change(ClientState state) override
2288 {
2289 lambda(state);
2290 }
2291};
2292
2297template <class T>
2298std::unique_ptr<ClientStateListener> client_state_listener(const T& lambda)
2299{
2300 return std::make_unique<ClientStateListenerLambda<T>>(lambda); ;
2301}
2302
2303} // end namespace functional
2304
2305class MasterChannel;
2306
2307struct TlsClientConfig;
2308
2311 friend class CppTlsClientConfigFriend;
2312
2313private:
2323 TlsClientConfig(const std::string& dns_name, const std::string& peer_cert_path, const std::string& local_cert_path, const std::string& private_key_path, const std::string& password, MinTlsVersion min_tls_version, CertificateMode certificate_mode);
2324
2325public:
2326 TlsClientConfig() = delete;
2327
2340 TlsClientConfig(const std::string& dns_name, const std::string& peer_cert_path, const std::string& local_cert_path, const std::string& private_key_path, const std::string& password);
2341
2342
2344 std::string dns_name;
2346 std::string peer_cert_path;
2348 std::string local_cert_path;
2350 std::string private_key_path;
2356 std::string password;
2361};
2362
2363struct ConnectStrategy;
2364
2367 friend class CppConnectStrategyFriend;
2368
2369private:
2375 ConnectStrategy(std::chrono::steady_clock::duration min_connect_delay, std::chrono::steady_clock::duration max_connect_delay, std::chrono::steady_clock::duration reconnect_delay);
2376
2377public:
2378
2388
2389
2391 std::chrono::steady_clock::duration min_connect_delay;
2393 std::chrono::steady_clock::duration max_connect_delay;
2395 std::chrono::steady_clock::duration reconnect_delay;
2396};
2397
2399enum class Nothing {
2401 nothing = 0,
2402};
2403
2407const char* to_string(Nothing value);
2408
2409struct AssociationId;
2410
2413 friend class CppAssociationIdFriend;
2414
2415private:
2416
2420 AssociationId(uint16_t address);
2421
2422 AssociationId() = delete;
2423
2425 uint16_t address;
2426};
2427
2428struct PollId;
2429
2431struct PollId {
2432 friend class CppPollIdFriend;
2433
2434private:
2435
2440 PollId(uint16_t association_id, uint64_t id);
2441
2442 PollId() = delete;
2443
2445 uint16_t association_id;
2447 uint64_t id;
2448};
2449
2450struct EventClasses;
2451
2454 friend class CppEventClassesFriend;
2455
2456 EventClasses() = delete;
2457
2464
2465
2475
2476
2486
2487
2494};
2495
2496struct Classes;
2497
2499struct Classes {
2500 friend class CppClassesFriend;
2501
2502 Classes() = delete;
2503
2510 Classes(bool class0, bool class1, bool class2, bool class3);
2511
2512
2522 static Classes all();
2523
2524
2534 static Classes none();
2535
2536
2545};
2546
2548enum class AutoTimeSync {
2550 none = 0,
2552 lan = 1,
2554 non_lan = 2,
2555};
2556
2560const char* to_string(AutoTimeSync value);
2561
2562struct AssociationConfig;
2563
2566 friend class CppAssociationConfigFriend;
2567
2568private:
2582
2583public:
2584 AssociationConfig() = delete;
2585
2602
2603
2605 std::chrono::steady_clock::duration response_timeout;
2621 std::chrono::steady_clock::duration keep_alive_timeout;
2628};
2629
2630struct UtcTimestamp;
2631
2636 friend class CppUtcTimestampFriend;
2637
2638private:
2643 UtcTimestamp(uint64_t value, bool is_valid);
2644
2645public:
2646 UtcTimestamp() = delete;
2647
2655 static UtcTimestamp valid(uint64_t value);
2656
2657
2666
2667
2671 uint64_t value;
2674};
2675
2679public:
2680 virtual ~AssociationHandler() = default;
2681
2690};
2691
2692namespace functional {
2693
2696template <class T>
2698{
2699 static_assert(std::is_copy_constructible<T>::value, "Lambda expression must be copy constructible. Does it contain something that is move-only?");
2700
2701 T lambda;
2702
2703public:
2706 AssociationHandlerLambda(const T& lambda) : lambda(lambda) {}
2707
2710 {
2711 return lambda();
2712 }
2713};
2714
2719template <class T>
2720std::unique_ptr<AssociationHandler> association_handler(const T& lambda)
2721{
2722 return std::make_unique<AssociationHandlerLambda<T>>(lambda); ;
2723}
2724
2725} // end namespace functional
2726
2728enum class TaskType {
2730 user_read = 0,
2732 periodic_poll = 1,
2736 auto_event_scan = 3,
2738 command = 4,
2746 time_sync = 8,
2748 restart = 9,
2749};
2750
2754const char* to_string(TaskType value);
2755
2757enum class TaskError {
2761 bad_response = 1,
2763 response_timeout = 2,
2765 write_error = 3,
2767 no_connection = 4,
2769 shutdown = 5,
2772};
2773
2777const char* to_string(TaskError value);
2778
2782public:
2783 virtual ~AssociationInformation() = default;
2784
2790 virtual void task_start(TaskType task_type, FunctionCode function_code, uint8_t seq) = 0;
2796 virtual void task_success(TaskType task_type, FunctionCode function_code, uint8_t seq) = 0;
2801 virtual void task_fail(TaskType task_type, TaskError error) = 0;
2806 virtual void unsolicited_response(bool is_duplicate, uint8_t seq) = 0;
2807};
2808
2809class Request;
2810
2814class Request {
2815 friend class CppRequestFriend;
2816 // pointer to the underlying C type
2817 void* self;
2818 // constructor only accessible internally
2819 Request(void* self): self(self) {}
2820 // non-copyable
2821 Request(const Request&) = delete;
2822 Request& operator=(const Request&) = delete;
2823 // no move assignment
2824 Request& operator=(Request&& other) = delete;
2825
2826public:
2830 Request(Request&& other) noexcept : self(other.self) { other.self = nullptr; }
2831
2835
2838
2844 void add_one_byte_range_header(Variation variation, uint8_t start, uint8_t stop);
2845
2851 void add_two_byte_range_header(Variation variation, uint16_t start, uint16_t stop);
2852
2857
2862 void add_one_byte_limited_count_header(Variation variation, uint8_t count);
2863
2868 void add_two_byte_limited_count_header(Variation variation, uint16_t count);
2869
2879 static Request class_request(bool class0, bool class1, bool class2, bool class3);
2880
2887 static Request all_objects(Variation variation);
2888
2897 static Request one_byte_range(Variation variation, uint8_t start, uint8_t stop);
2898
2907 static Request two_byte_range(Variation variation, uint16_t start, uint16_t stop);
2908
2916 static Request one_byte_limited_count(Variation variation, uint8_t count);
2917
2925 static Request two_byte_limited_count(Variation variation, uint16_t count);
2926};
2927
2929enum class ReadError {
2931 ok = 0,
2935 bad_response = 2,
2937 response_timeout = 3,
2939 write_error = 4,
2941 no_connection = 5,
2943 shutdown = 6,
2946};
2947
2951const char* to_string(ReadError value);
2952
2954class ReadException : public std::logic_error {
2955public:
2960};
2961
2965public:
2966 virtual ~ReadTaskCallback() = default;
2967
2971 virtual void on_complete(Nothing result) = 0;
2975 virtual void on_failure(ReadError error) = 0;
2976};
2977
2978class CommandSet;
2979
2982 friend class CppCommandSetFriend;
2983 // pointer to the underlying C type
2984 void* self;
2985 // constructor only accessible internally
2986 CommandSet(void* self): self(self) {}
2987 // non-copyable
2988 CommandSet(const CommandSet&) = delete;
2989 CommandSet& operator=(const CommandSet&) = delete;
2990 // no move assignment
2991 CommandSet& operator=(CommandSet&& other) = delete;
2992
2993public:
2997 CommandSet(CommandSet&& other) noexcept : self(other.self) { other.self = nullptr; }
2998
3002
3005
3010 void add_g12_v1_u8(uint8_t idx, const Group12Var1& header);
3011
3016 void add_g12_v1_u16(uint16_t idx, const Group12Var1& header);
3017
3022 void add_g41_v1_u8(uint8_t idx, int32_t value);
3023
3028 void add_g41_v1_u16(uint16_t idx, int32_t value);
3029
3034 void add_g41_v2_u8(uint8_t idx, int16_t value);
3035
3040 void add_g41_v2_u16(uint16_t idx, int16_t value);
3041
3046 void add_g41_v3_u8(uint8_t idx, float value);
3047
3052 void add_g41_v3_u16(uint16_t idx, float value);
3053
3058 void add_g41_v4_u8(uint8_t idx, double value);
3059
3064 void add_g41_v4_u16(uint16_t idx, double value);
3065
3069};
3070
3072enum class CommandMode {
3074 direct_operate = 0,
3077};
3078
3082const char* to_string(CommandMode value);
3083
3085enum class CommandError {
3087 ok = 0,
3089 bad_status = 1,
3091 header_mismatch = 2,
3095 bad_response = 4,
3097 response_timeout = 5,
3099 write_error = 6,
3101 no_connection = 7,
3103 shutdown = 8,
3106};
3107
3111const char* to_string(CommandError value);
3112
3114class CommandException : public std::logic_error {
3115public:
3120};
3121
3125public:
3126 virtual ~CommandTaskCallback() = default;
3127
3131 virtual void on_complete(Nothing result) = 0;
3135 virtual void on_failure(CommandError error) = 0;
3136};
3137
3139enum class TimeSyncMode {
3141 lan = 0,
3143 non_lan = 1,
3144};
3145
3149const char* to_string(TimeSyncMode value);
3150
3152enum class TimeSyncError {
3154 ok = 0,
3156 clock_rollback = 1,
3162 overflow = 4,
3164 still_needs_time = 5,
3168 iin_error = 7,
3172 bad_response = 9,
3174 response_timeout = 10,
3176 write_error = 11,
3178 no_connection = 12,
3180 shutdown = 13,
3183};
3184
3188const char* to_string(TimeSyncError value);
3189
3191class TimeSyncException : public std::logic_error {
3192public:
3197};
3198
3202public:
3203 virtual ~TimeSyncTaskCallback() = default;
3204
3208 virtual void on_complete(Nothing result) = 0;
3212 virtual void on_failure(TimeSyncError error) = 0;
3213};
3214
3216enum class RestartError {
3218 ok = 0,
3222 bad_response = 2,
3224 response_timeout = 3,
3226 write_error = 4,
3228 no_connection = 5,
3230 shutdown = 6,
3233};
3234
3238const char* to_string(RestartError value);
3239
3241class RestartException : public std::logic_error {
3242public:
3247};
3248
3252public:
3253 virtual ~RestartTaskCallback() = default;
3254
3258 virtual void on_complete(std::chrono::steady_clock::duration result) = 0;
3262 virtual void on_failure(RestartError error) = 0;
3263};
3264
3268 ok = 0,
3274 bad_response = 3,
3276 response_timeout = 4,
3278 write_error = 5,
3280 no_connection = 6,
3282 shutdown = 7,
3285};
3286
3290const char* to_string(LinkStatusError value);
3291
3293class LinkStatusException : public std::logic_error {
3294public:
3299};
3300
3304public:
3305 virtual ~LinkStatusCallback() = default;
3306
3310 virtual void on_complete(Nothing result) = 0;
3314 virtual void on_failure(LinkStatusError error) = 0;
3315};
3316
3323 friend class CppMasterChannelFriend;
3324 // pointer to the underlying C type
3325 void* self;
3326 // constructor only accessible internally
3327 MasterChannel(void* self): self(self) {}
3328 // non-copyable
3329 MasterChannel(const MasterChannel&) = delete;
3330 MasterChannel& operator=(const MasterChannel&) = delete;
3331 // no move assignment
3332 MasterChannel& operator=(MasterChannel&& other) = delete;
3333
3334public:
3338 MasterChannel(MasterChannel&& other) noexcept : self(other.self) { other.self = nullptr; }
3339
3342
3346 void enable();
3347
3351 void disable();
3352
3362 AssociationId add_association(uint16_t address, const AssociationConfig& config, std::unique_ptr<ReadHandler> read_handler, std::unique_ptr<AssociationHandler> association_handler, std::unique_ptr<AssociationInformation> association_information);
3363
3369
3374 void set_decode_level(const DecodeLevel& decode_level);
3375
3381
3391 PollId add_poll(const AssociationId& id, Request& request, std::chrono::steady_clock::duration period);
3392
3399 void remove_poll(const PollId& poll_id);
3400
3409 void demand_poll(const PollId& poll_id);
3410
3421 static MasterChannel create_tcp_channel(Runtime& runtime, LinkErrorMode link_error_mode, const MasterChannelConfig& config, EndpointList& endpoints, const ConnectStrategy& connect_strategy, std::unique_ptr<ClientStateListener> listener);
3422
3434 static MasterChannel create_tls_channel(Runtime& runtime, LinkErrorMode link_error_mode, const MasterChannelConfig& config, EndpointList& endpoints, const ConnectStrategy& connect_strategy, std::unique_ptr<ClientStateListener> listener, const TlsClientConfig& tls_config);
3435
3448 static MasterChannel create_serial_channel(Runtime& runtime, const MasterChannelConfig& config, const std::string& path, const SerialSettings& serial_params, std::chrono::steady_clock::duration open_retry_delay, std::unique_ptr<PortStateListener> listener);
3449
3458 void read(const AssociationId& association, Request& request, std::unique_ptr<ReadTaskCallback> callback);
3459
3460
3470 void read_with_handler(const AssociationId& association, Request& request, std::unique_ptr<ReadHandler> handler, std::unique_ptr<ReadTaskCallback> callback);
3471
3472
3480 void operate(const AssociationId& association, CommandMode mode, CommandSet& command, std::unique_ptr<CommandTaskCallback> callback);
3481
3482
3489 void synchronize_time(const AssociationId& association, TimeSyncMode mode, std::unique_ptr<TimeSyncTaskCallback> callback);
3490
3491
3497 void cold_restart(const AssociationId& association, std::unique_ptr<RestartTaskCallback> callback);
3498
3499
3505 void warm_restart(const AssociationId& association, std::unique_ptr<RestartTaskCallback> callback);
3506
3507
3513 void check_link_status(const AssociationId& association, std::unique_ptr<LinkStatusCallback> callback);
3514
3515};
3516
3517class Database;
3518
3520enum class EventClass {
3522 none = 0,
3524 class1 = 1,
3526 class2 = 2,
3528 class3 = 3,
3529};
3530
3534const char* to_string(EventClass value);
3535
3537enum class EventMode {
3541 detect = 0,
3543 force = 1,
3545 suppress = 2,
3546};
3547
3551const char* to_string(EventMode value);
3552
3553struct UpdateOptions;
3554
3559 friend class CppUpdateOptionsFriend;
3560
3561private:
3567
3568public:
3569 UpdateOptions() = delete;
3570
3579
3580
3589
3590
3595};
3596
3600 group1_var1 = 0,
3602 group1_var2 = 1,
3603};
3604
3609
3613 group2_var1 = 0,
3615 group2_var2 = 1,
3617 group2_var3 = 2,
3618};
3619
3624
3625struct BinaryInputConfig;
3626
3629 friend class CppBinaryInputConfigFriend;
3630
3631private:
3637
3638public:
3639
3648
3649
3654};
3655
3659 group3_var1 = 0,
3661 group3_var2 = 1,
3662};
3663
3668
3672 group4_var1 = 0,
3674 group4_var2 = 1,
3676 group4_var3 = 2,
3677};
3678
3683
3685
3688 friend class CppDoubleBitBinaryInputConfigFriend;
3689
3690private:
3696
3697public:
3698
3707
3708
3713};
3714
3718 group10_var1 = 0,
3720 group10_var2 = 1,
3721};
3722
3727
3731 group11_var1 = 0,
3733 group11_var2 = 1,
3734};
3735
3740
3742
3745 friend class CppBinaryOutputStatusConfigFriend;
3746
3747private:
3753
3754public:
3755
3764
3765
3770};
3771
3775 group20_var1 = 0,
3777 group20_var2 = 1,
3779 group20_var5 = 2,
3781 group20_var6 = 3,
3782};
3783
3788
3792 group22_var1 = 0,
3794 group22_var2 = 1,
3796 group22_var5 = 2,
3798 group22_var6 = 3,
3799};
3800
3805
3806struct CounterConfig;
3807
3810 friend class CppCounterConfigFriend;
3811
3812private:
3819
3820public:
3821
3831
3832
3838 uint32_t deadband;
3839};
3840
3844 group21_var1 = 0,
3846 group21_var2 = 1,
3848 group21_var5 = 2,
3850 group21_var6 = 3,
3852 group21_var9 = 4,
3854 group21_var10 = 5,
3855};
3856
3861
3865 group23_var1 = 0,
3867 group23_var2 = 1,
3869 group23_var5 = 2,
3871 group23_var6 = 3,
3872};
3873
3878
3879struct FrozenCounterConfig;
3880
3883 friend class CppFrozenCounterConfigFriend;
3884
3885private:
3892
3893public:
3894
3904
3905
3911 uint32_t deadband;
3912};
3913
3917 group30_var1 = 0,
3919 group30_var2 = 1,
3921 group30_var3 = 2,
3923 group30_var4 = 3,
3925 group30_var5 = 4,
3927 group30_var6 = 5,
3928};
3929
3934
3938 group32_var1 = 0,
3940 group32_var2 = 1,
3942 group32_var3 = 2,
3944 group32_var4 = 3,
3946 group32_var5 = 4,
3948 group32_var6 = 5,
3950 group32_var7 = 6,
3952 group32_var8 = 7,
3953};
3954
3959
3960struct AnalogInputConfig;
3961
3964 friend class CppAnalogInputConfigFriend;
3965
3966private:
3973
3974public:
3975
3985
3986
3992 double deadband;
3993};
3994
3998 group40_var1 = 0,
4000 group40_var2 = 1,
4002 group40_var3 = 2,
4004 group40_var4 = 3,
4005};
4006
4011
4015 group42_var1 = 0,
4017 group42_var2 = 1,
4019 group42_var3 = 2,
4021 group42_var4 = 3,
4023 group42_var5 = 4,
4025 group42_var6 = 5,
4027 group42_var7 = 6,
4029 group42_var8 = 7,
4030};
4031
4036
4038
4041 friend class CppAnalogOutputStatusConfigFriend;
4042
4043private:
4050
4051public:
4052
4062
4063
4069 double deadband;
4070};
4071
4076 friend class CppDatabaseFriend;
4077 // pointer to the underlying C type
4078 void* self;
4079 // constructor only accessible internally
4080 Database(void* self): self(self) {}
4081 // non-copyable
4082 Database(const Database&) = delete;
4083 Database& operator=(const Database&) = delete;
4084 // no move assignment
4085 Database& operator=(Database&& other) = delete;
4086
4087public:
4091 Database(Database&& other) noexcept : self(other.self) { other.self = nullptr; }
4092
4099 bool add_binary_input(uint16_t index, EventClass point_class, const BinaryInputConfig& config);
4100
4105 bool remove_binary_input(uint16_t index);
4106
4112 bool update_binary_input(const BinaryInput& value, const UpdateOptions& options);
4113
4120
4127 bool add_double_bit_binary_input(uint16_t index, EventClass point_class, const DoubleBitBinaryInputConfig& config);
4128
4134
4141
4148
4155 bool add_binary_output_status(uint16_t index, EventClass point_class, const BinaryOutputStatusConfig& config);
4156
4161 bool remove_binary_output_status(uint16_t index);
4162
4169
4176
4183 bool add_counter(uint16_t index, EventClass point_class, const CounterConfig& config);
4184
4189 bool remove_counter(uint16_t index);
4190
4196 bool update_counter(const Counter& value, const UpdateOptions& options);
4197
4203 Counter get_counter(uint16_t index);
4204
4211 bool add_frozen_counter(uint16_t index, EventClass point_class, const FrozenCounterConfig& config);
4212
4217 bool remove_frozen_counter(uint16_t index);
4218
4224 bool update_frozen_counter(const FrozenCounter& value, const UpdateOptions& options);
4225
4232
4239 bool add_analog_input(uint16_t index, EventClass point_class, const AnalogInputConfig& config);
4240
4245 bool remove_analog_input(uint16_t index);
4246
4252 bool update_analog_input(const AnalogInput& value, const UpdateOptions& options);
4253
4260
4267 bool add_analog_output_status(uint16_t index, EventClass point_class, const AnalogOutputStatusConfig& config);
4268
4273 bool remove_analog_output_status(uint16_t index);
4274
4281
4288
4294 bool add_octet_string(uint16_t index, EventClass point_class);
4295
4300 bool remove_octet_string(uint16_t index);
4301
4308 bool update_octet_string(uint16_t index, const std::vector<uint8_t>& value, const UpdateOptions& options);
4309};
4310
4314public:
4315 virtual ~DatabaseTransaction() = default;
4316
4320 virtual void execute(Database& database) = 0;
4321};
4322
4323namespace functional {
4324
4327template <class T>
4329{
4330 static_assert(std::is_copy_constructible<T>::value, "Lambda expression must be copy constructible. Does it contain something that is move-only?");
4331
4332 T lambda;
4333
4334public:
4337 DatabaseTransactionLambda(const T& lambda) : lambda(lambda) {}
4338
4340 void execute(Database& database) override
4341 {
4342 lambda(database);
4343 }
4344};
4345
4350template <class T>
4352{
4353 return DatabaseTransactionLambda<T>(lambda);
4354}
4355
4356} // end namespace functional
4357
4358class DatabaseHandle;
4359
4362 friend class CppDatabaseHandleFriend;
4363 // pointer to the underlying C type
4364 void* self;
4365 // constructor only accessible internally
4366 DatabaseHandle(void* self): self(self) {}
4367 // non-copyable
4368 DatabaseHandle(const DatabaseHandle&) = delete;
4369 DatabaseHandle& operator=(const DatabaseHandle&) = delete;
4370 // no move assignment
4371 DatabaseHandle& operator=(DatabaseHandle&& other) = delete;
4372
4373public:
4377 DatabaseHandle(DatabaseHandle&& other) noexcept : self(other.self) { other.self = nullptr; }
4378
4383};
4384
4385struct EventBufferConfig;
4386
4391 friend class CppEventBufferConfigFriend;
4392
4393 EventBufferConfig() = delete;
4394
4406
4407
4422
4423
4425 uint16_t max_binary;
4431 uint16_t max_counter;
4435 uint16_t max_analog;
4440};
4441
4442struct ClassZeroConfig;
4443
4446 friend class CppClassZeroConfigFriend;
4447
4448private:
4460
4461public:
4462
4477
4478
4497};
4498
4499struct OutstationFeatures;
4500
4503 friend class CppOutstationFeaturesFriend;
4504
4505private:
4512
4513public:
4514
4524
4525
4532};
4533
4534struct OutstationConfig;
4535
4538 friend class CppOutstationConfigFriend;
4539
4540private:
4559 OutstationConfig(uint16_t outstation_address, uint16_t master_address, const EventBufferConfig& event_buffer_config, uint16_t solicited_buffer_size, uint16_t unsolicited_buffer_size, uint16_t rx_buffer_size, const DecodeLevel& decode_level, std::chrono::steady_clock::duration confirm_timeout, std::chrono::steady_clock::duration select_timeout, const OutstationFeatures& features, uint32_t max_unsolicited_retries, std::chrono::steady_clock::duration unsolicited_retry_delay, std::chrono::steady_clock::duration keep_alive_timeout, uint16_t max_read_request_headers, uint16_t max_controls_per_request, const ClassZeroConfig& class_zero);
4560
4561public:
4562 OutstationConfig() = delete;
4563
4586
4587
4609 std::chrono::steady_clock::duration confirm_timeout;
4611 std::chrono::steady_clock::duration select_timeout;
4617 std::chrono::steady_clock::duration unsolicited_retry_delay;
4621 std::chrono::steady_clock::duration keep_alive_timeout;
4630};
4631
4635 not_supported = 0,
4637 seconds = 1,
4639 milli_seconds = 2,
4640};
4641
4645const char* to_string(RestartDelayType value);
4646
4647struct RestartDelay;
4648
4653 friend class CppRestartDelayFriend;
4654
4655private:
4661
4662public:
4663 RestartDelay() = delete;
4664
4673
4674
4682 static RestartDelay seconds(uint16_t value);
4683
4684
4693
4694
4698 uint16_t value;
4699};
4700
4704 ok = 0,
4706 parameter_error = 1,
4708 not_supported = 2,
4709};
4710
4714const char* to_string(WriteTimeResult value);
4715
4717enum class FreezeType {
4719 immediate_freeze = 0,
4721 freeze_and_clear = 1,
4722};
4723
4727const char* to_string(FreezeType value);
4728
4730enum class FreezeResult {
4732 ok = 0,
4734 parameter_error = 1,
4736 not_supported = 2,
4737};
4738
4742const char* to_string(FreezeResult value);
4743
4744struct ApplicationIin;
4745
4748 friend class CppApplicationIinFriend;
4749
4750private:
4758
4759public:
4760
4771
4772
4781};
4782
4786public:
4787 virtual ~OutstationApplication() = default;
4788
4798 virtual uint16_t get_processing_delay_ms() = 0;
4803 virtual WriteTimeResult write_absolute_time(uint64_t time) = 0;
4825 virtual FreezeResult freeze_counters_all(FreezeType freeze_type, DatabaseHandle& database_handle) = 0;
4833 virtual FreezeResult freeze_counters_range(uint16_t start, uint16_t stop, FreezeType freeze_type, DatabaseHandle& database_handle) = 0;
4834};
4835
4836struct RequestHeader;
4837
4840 friend class CppRequestHeaderFriend;
4841
4842private:
4848
4849public:
4850 RequestHeader() = delete;
4851
4856};
4857
4861 processed = 0,
4868};
4869
4873const char* to_string(BroadcastAction value);
4874
4880public:
4881 virtual ~OutstationInformation() = default;
4882
4886 virtual void process_request_from_idle(const RequestHeader& header) = 0;
4891 virtual void broadcast_received(FunctionCode function_code, BroadcastAction action) = 0;
4895 virtual void enter_solicited_confirm_wait(uint8_t ecsn) = 0;
4899 virtual void solicited_confirm_timeout(uint8_t ecsn) = 0;
4903 virtual void solicited_confirm_received(uint8_t ecsn) = 0;
4911 virtual void wrong_solicited_confirm_seq(uint8_t ecsn, uint8_t seq) = 0;
4916 virtual void unexpected_confirm(bool unsolicited, uint8_t seq) = 0;
4920 virtual void enter_unsolicited_confirm_wait(uint8_t ecsn) = 0;
4925 virtual void unsolicited_confirm_timeout(uint8_t ecsn, bool retry) = 0;
4929 virtual void unsolicited_confirmed(uint8_t ecsn) = 0;
4932 virtual void clear_restart_iin() = 0;
4933};
4934
4936enum class CommandStatus {
4938 success = 0,
4940 timeout = 1,
4942 no_select = 2,
4944 format_error = 3,
4946 not_supported = 4,
4948 already_active = 5,
4950 hardware_error = 6,
4952 local = 7,
4954 too_many_ops = 8,
4956 not_authorized = 9,
4958 automation_inhibit = 10,
4960 processing_limited = 11,
4962 out_of_range = 12,
4964 downstream_local = 13,
4966 already_complete = 14,
4968 blocked = 15,
4970 canceled = 16,
4974 downstream_fail = 18,
4976 non_participating = 19,
4978 unknown = 20,
4979};
4980
4984const char* to_string(CommandStatus value);
4985
4987enum class OperateType {
4991 direct_operate = 1,
4994};
4995
4999const char* to_string(OperateType value);
5000
5004public:
5005 virtual ~ControlHandler() = default;
5006
5009 virtual void begin_fragment() = 0;
5013 virtual void end_fragment(DatabaseHandle& database) = 0;
5024 virtual CommandStatus select_g12v1(const Group12Var1& value, uint16_t index, DatabaseHandle& database_handle) = 0;
5032 virtual CommandStatus operate_g12v1(const Group12Var1& value, uint16_t index, OperateType op_type, DatabaseHandle& database_handle) = 0;
5043 virtual CommandStatus select_g41v1(int32_t value, uint16_t index, DatabaseHandle& database_handle) = 0;
5051 virtual CommandStatus operate_g41v1(int32_t value, uint16_t index, OperateType op_type, DatabaseHandle& database_handle) = 0;
5062 virtual CommandStatus select_g41v2(int16_t value, uint16_t index, DatabaseHandle& database_handle) = 0;
5070 virtual CommandStatus operate_g41v2(int16_t value, uint16_t index, OperateType op_type, DatabaseHandle& database_handle) = 0;
5081 virtual CommandStatus select_g41v3(float value, uint16_t index, DatabaseHandle& database_handle) = 0;
5089 virtual CommandStatus operate_g41v3(float value, uint16_t index, OperateType op_type, DatabaseHandle& database_handle) = 0;
5100 virtual CommandStatus select_g41v4(double value, uint16_t index, DatabaseHandle& database_handle) = 0;
5108 virtual CommandStatus operate_g41v4(double value, uint16_t index, OperateType op_type, DatabaseHandle& database_handle) = 0;
5109};
5110
5114 connected = 0,
5116 disconnected = 1,
5117};
5118
5122const char* to_string(ConnectionState value);
5123
5127public:
5128 virtual ~ConnectionStateListener() = default;
5129
5133 virtual void on_change(ConnectionState state) = 0;
5134};
5135
5136namespace functional {
5137
5140template <class T>
5142{
5143 static_assert(std::is_copy_constructible<T>::value, "Lambda expression must be copy constructible. Does it contain something that is move-only?");
5144
5145 T lambda;
5146
5147public:
5150 ConnectionStateListenerLambda(const T& lambda) : lambda(lambda) {}
5151
5153 void on_change(ConnectionState state) override
5154 {
5155 lambda(state);
5156 }
5157};
5158
5163template <class T>
5164std::unique_ptr<ConnectionStateListener> connection_state_listener(const T& lambda)
5165{
5166 return std::make_unique<ConnectionStateListenerLambda<T>>(lambda); ;
5167}
5168
5169} // end namespace functional
5170
5171class Outstation;
5172
5177 friend class CppOutstationFriend;
5178 // pointer to the underlying C type
5179 void* self;
5180 // constructor only accessible internally
5181 Outstation(void* self): self(self) {}
5182 // non-copyable
5183 Outstation(const Outstation&) = delete;
5184 Outstation& operator=(const Outstation&) = delete;
5185 // no move assignment
5186 Outstation& operator=(Outstation&& other) = delete;
5187
5188public:
5192 Outstation(Outstation&& other) noexcept : self(other.self) { other.self = nullptr; }
5193
5198
5203
5208 void set_decode_level(const DecodeLevel& level);
5209
5225 static Outstation create_serial_session(Runtime& runtime, const std::string& serial_path, const SerialSettings& settings, const OutstationConfig& config, std::unique_ptr<OutstationApplication> application, std::unique_ptr<OutstationInformation> information, std::unique_ptr<ControlHandler> control_handler);
5226
5239 static Outstation create_serial_session_fault_tolerant(Runtime& runtime, const std::string& serial_path, const SerialSettings& settings, std::chrono::steady_clock::duration open_retry_delay, const OutstationConfig& config, std::unique_ptr<OutstationApplication> application, std::unique_ptr<OutstationInformation> information, std::unique_ptr<ControlHandler> control_handler);
5240};
5241
5242class AddressFilter;
5243
5246 friend class CppAddressFilterFriend;
5247 // pointer to the underlying C type
5248 void* self;
5249 // constructor only accessible internally
5250 AddressFilter(void* self): self(self) {}
5251 // non-copyable
5252 AddressFilter(const AddressFilter&) = delete;
5253 AddressFilter& operator=(const AddressFilter&) = delete;
5254 // no move assignment
5255 AddressFilter& operator=(AddressFilter&& other) = delete;
5256
5257public:
5261 AddressFilter(AddressFilter&& other) noexcept : self(other.self) { other.self = nullptr; }
5262
5271 AddressFilter(const std::string& address);
5272
5275
5280 void add(const std::string& address);
5281
5286};
5287
5288struct TlsServerConfig;
5289
5292 friend class CppTlsServerConfigFriend;
5293
5294private:
5304 TlsServerConfig(const std::string& dns_name, const std::string& peer_cert_path, const std::string& local_cert_path, const std::string& private_key_path, const std::string& password, MinTlsVersion min_tls_version, CertificateMode certificate_mode);
5305
5306public:
5307 TlsServerConfig() = delete;
5308
5321 TlsServerConfig(const std::string& dns_name, const std::string& peer_cert_path, const std::string& local_cert_path, const std::string& private_key_path, const std::string& password);
5322
5323
5325 std::string dns_name;
5327 std::string peer_cert_path;
5329 std::string local_cert_path;
5331 std::string private_key_path;
5337 std::string password;
5342};
5343
5344class OutstationServer;
5345
5352 friend class CppOutstationServerFriend;
5353 // pointer to the underlying C type
5354 void* self;
5355 // constructor only accessible internally
5356 OutstationServer(void* self): self(self) {}
5357 // non-copyable
5358 OutstationServer(const OutstationServer&) = delete;
5359 OutstationServer& operator=(const OutstationServer&) = delete;
5360 // no move assignment
5361 OutstationServer& operator=(OutstationServer&& other) = delete;
5362
5363public:
5367 OutstationServer(OutstationServer&& other) noexcept : self(other.self) { other.self = nullptr; }
5368
5371
5386 Outstation add_outstation(const OutstationConfig& config, std::unique_ptr<OutstationApplication> application, std::unique_ptr<OutstationInformation> information, std::unique_ptr<ControlHandler> control_handler, std::unique_ptr<ConnectionStateListener> listener, AddressFilter& filter);
5387
5391 void bind();
5392
5402 static OutstationServer create_tcp_server(Runtime& runtime, LinkErrorMode link_error_mode, const std::string& address);
5403
5414 static OutstationServer create_tls_server(Runtime& runtime, LinkErrorMode link_error_mode, const std::string& address, const TlsServerConfig& tls_config);
5415};
5416
5417} // end namespace dnp3
Outstation address filter.
Definition: dnp3.hpp:5245
static AddressFilter any()
Create an address filter that accepts any IP address.
AddressFilter(const std::string &address)
Create an address filter that matches a specific address or wildcards.
AddressFilter(AddressFilter &&other) noexcept
Transfer ownership of the underlying C-type to this instance and invalidate the other instance.
Definition: dnp3.hpp:5261
~AddressFilter()
Destroy an address filter.
void add(const std::string &address)
Add an accepted IP address to the filter.
Iterator over AnalogInput instances.
Definition: dnp3.hpp:1149
AnalogInputIterator(AnalogInputIterator &&)=default
move constructor for the iterator
AnalogInput get()
retrieve the current value
bool next()
move the iterator to the next value
Iterator over AnalogOutputStatus instances.
Definition: dnp3.hpp:1221
AnalogOutputStatus get()
retrieve the current value
bool next()
move the iterator to the next value
AnalogOutputStatusIterator(AnalogOutputStatusIterator &&)=default
move constructor for the iterator
Callbacks for a particular outstation association.
Definition: dnp3.hpp:2678
virtual UtcTimestamp get_current_time()=0
Returns the current time or an invalid time if none is available.
Informational callbacks about the current state of an outstation association.
Definition: dnp3.hpp:2781
virtual void task_success(TaskType task_type, FunctionCode function_code, uint8_t seq)=0
Called when a task successfully completes.
virtual void task_start(TaskType task_type, FunctionCode function_code, uint8_t seq)=0
Called when a new task is started.
virtual void unsolicited_response(bool is_duplicate, uint8_t seq)=0
Called when an unsolicited response is received.
virtual void task_fail(TaskType task_type, TaskError error)=0
Called when a task fails.
Iterator over BinaryInput instances.
Definition: dnp3.hpp:789
bool next()
move the iterator to the next value
BinaryInput get()
retrieve the current value
BinaryInputIterator(BinaryInputIterator &&)=default
move constructor for the iterator
Iterator over BinaryOutputStatus instances.
Definition: dnp3.hpp:933
bool next()
move the iterator to the next value
BinaryOutputStatus get()
retrieve the current value
BinaryOutputStatusIterator(BinaryOutputStatusIterator &&)=default
move constructor for the iterator
Iterator over uint8_t instances.
Definition: dnp3.hpp:1266
ByteIterator(ByteIterator &&)=default
move constructor for the iterator
uint8_t get()
retrieve the current value
bool next()
move the iterator to the next value
Callback for monitoring the client TCP connection state.
Definition: dnp3.hpp:2260
virtual void on_change(ClientState state)=0
Called when the client state changed.
Exception type corresponding to the underlying error enum CommandError.
Definition: dnp3.hpp:3114
CommandException(CommandError error)
construct the exception with an instance of the enum
Definition: dnp3.hpp:3119
CommandError error
underlying error enum
Definition: dnp3.hpp:3117
Builder type used to construct command requests.
Definition: dnp3.hpp:2981
~CommandSet()
Destroy a set of commands.
void add_g41_v1_u16(uint16_t idx, int32_t value)
Add a Analog Output command (signed 32-bit integer) with 2-byte prefix index.
void add_g12_v1_u16(uint16_t idx, const Group12Var1 &header)
Add a CROB with 2-byte prefix index.
void add_g41_v3_u8(uint8_t idx, float value)
Add a Analog Output command (single-precision float) with 1-byte prefix index.
CommandSet(CommandSet &&other) noexcept
Transfer ownership of the underlying C-type to this instance and invalidate the other instance.
Definition: dnp3.hpp:2997
void add_g41_v4_u16(uint16_t idx, double value)
Add a Analog Output command (double-precision float) with 2-byte prefix index.
void add_g12_v1_u8(uint8_t idx, const Group12Var1 &header)
Add a CROB with 1-byte prefix index.
CommandSet()
Create a new set of commands.
void add_g41_v1_u8(uint8_t idx, int32_t value)
Add a Analog Output command (signed 32-bit integer) with 1-byte prefix index.
void add_g41_v3_u16(uint16_t idx, float value)
Add a Analog Output command (single-precision float) with 2-byte prefix index.
void add_g41_v2_u8(uint8_t idx, int16_t value)
Add a Analog Output command (signed 16-bit integer) with 1-byte prefix index.
void finish_header()
Finish any partially completed header. This allows for the construction of two headers with the same ...
void add_g41_v4_u8(uint8_t idx, double value)
Add a Analog Output command (double-precision float) with 1-byte prefix index.
void add_g41_v2_u16(uint16_t idx, int16_t value)
Add a Analog Output command (signed 16-bit integer) with 2-byte prefix index.
Handler for command tasks.
Definition: dnp3.hpp:3124
virtual void on_failure(CommandError error)=0
Invoked when the asynchronous operation fails.
virtual void on_complete(Nothing result)=0
Invoked when the asynchronous operation completes successfully.
Callback interface for connection state events.
Definition: dnp3.hpp:5126
virtual void on_change(ConnectionState state)=0
Called when the connection state changes.
Callbacks for handling controls.
Definition: dnp3.hpp:5003
virtual CommandStatus select_g41v4(double value, uint16_t index, DatabaseHandle &database_handle)=0
Select an analog output, but do not operate.
virtual void end_fragment(DatabaseHandle &database)=0
Notifies the end of a command fragment.
virtual CommandStatus operate_g41v1(int32_t value, uint16_t index, OperateType op_type, DatabaseHandle &database_handle)=0
Operate a control point.
virtual CommandStatus operate_g12v1(const Group12Var1 &value, uint16_t index, OperateType op_type, DatabaseHandle &database_handle)=0
Operate a control point.
virtual CommandStatus operate_g41v2(int16_t value, uint16_t index, OperateType op_type, DatabaseHandle &database_handle)=0
Operate a control point.
virtual CommandStatus select_g41v2(int16_t value, uint16_t index, DatabaseHandle &database_handle)=0
Select an analog output, but do not operate.
virtual CommandStatus select_g41v3(float value, uint16_t index, DatabaseHandle &database_handle)=0
Select an analog output, but do not operate.
virtual CommandStatus operate_g41v3(float value, uint16_t index, OperateType op_type, DatabaseHandle &database_handle)=0
Operate a control point.
virtual CommandStatus operate_g41v4(double value, uint16_t index, OperateType op_type, DatabaseHandle &database_handle)=0
Operate a control point.
virtual CommandStatus select_g12v1(const Group12Var1 &value, uint16_t index, DatabaseHandle &database_handle)=0
Select a CROB, but do not operate.
virtual void begin_fragment()=0
Notifies the start of a command fragment.
virtual CommandStatus select_g41v1(int32_t value, uint16_t index, DatabaseHandle &database_handle)=0
Select an analog output, but do not operate.
Iterator over Counter instances.
Definition: dnp3.hpp:1005
CounterIterator(CounterIterator &&)=default
move constructor for the iterator
Counter get()
retrieve the current value
bool next()
move the iterator to the next value
handle used to perform transactions on the database
Definition: dnp3.hpp:4361
void transaction(DatabaseTransaction &callback)
Acquire a mutex on the underlying database and apply a set of changes as a transaction.
DatabaseHandle(DatabaseHandle &&other) noexcept
Transfer ownership of the underlying C-type to this instance and invalidate the other instance.
Definition: dnp3.hpp:4377
Database transaction interface.
Definition: dnp3.hpp:4313
virtual void execute(Database &database)=0
Execute a transaction on the provided database.
Internal database access.
Definition: dnp3.hpp:4075
bool remove_frozen_counter(uint16_t index)
Remove a Frozen Counter point.
bool add_analog_output_status(uint16_t index, EventClass point_class, const AnalogOutputStatusConfig &config)
Add a new Analog Output Status point.
Counter get_counter(uint16_t index)
Get a Counter point.
bool remove_binary_output_status(uint16_t index)
Remove a Binary Output Status point.
BinaryOutputStatus get_binary_output_status(uint16_t index)
Get a Binary Output Status point.
DoubleBitBinaryInput get_double_bit_binary_input(uint16_t index)
Get a Double-Bit Binary Input point.
bool update_binary_output_status(const BinaryOutputStatus &value, const UpdateOptions &options)
Update a Binary Output Status point.
bool remove_octet_string(uint16_t index)
Remove an Octet String point.
bool update_double_bit_binary_input(const DoubleBitBinaryInput &value, const UpdateOptions &options)
Update a Double-Bit Binary Input point.
bool update_frozen_counter(const FrozenCounter &value, const UpdateOptions &options)
Update an Frozen Counter point.
bool add_double_bit_binary_input(uint16_t index, EventClass point_class, const DoubleBitBinaryInputConfig &config)
Add a new Double-Bit Binary Input point.
bool update_analog_input(const AnalogInput &value, const UpdateOptions &options)
Update a AnalogInput point.
bool add_analog_input(uint16_t index, EventClass point_class, const AnalogInputConfig &config)
Add a new AnalogInput point.
bool add_binary_input(uint16_t index, EventClass point_class, const BinaryInputConfig &config)
Add a new BinaryInput point.
bool add_counter(uint16_t index, EventClass point_class, const CounterConfig &config)
Add a new Counter point.
bool add_binary_output_status(uint16_t index, EventClass point_class, const BinaryOutputStatusConfig &config)
Add a new Binary Output Status point.
bool update_binary_input(const BinaryInput &value, const UpdateOptions &options)
Update a BinaryInput point.
bool remove_analog_input(uint16_t index)
Remove an AnalogInput point.
bool add_octet_string(uint16_t index, EventClass point_class)
Add a new Octet String point.
AnalogOutputStatus get_analog_output_status(uint16_t index)
Get a Analog Output Status point.
FrozenCounter get_frozen_counter(uint16_t index)
Get a Frozen Counter point.
bool update_counter(const Counter &value, const UpdateOptions &options)
Update a Counter point.
bool remove_counter(uint16_t index)
Remove a Counter point.
Database(Database &&other) noexcept
Transfer ownership of the underlying C-type to this instance and invalidate the other instance.
Definition: dnp3.hpp:4091
bool update_octet_string(uint16_t index, const std::vector< uint8_t > &value, const UpdateOptions &options)
Update an Octet String point.
bool remove_double_bit_binary_input(uint16_t index)
Remove a Double-Bit Binary Input point.
BinaryInput get_binary_input(uint16_t index)
Get a BinaryInput point.
AnalogInput get_analog_input(uint16_t index)
Get a AnalogInput point.
bool update_analog_output_status(const AnalogOutputStatus &value, const UpdateOptions &options)
Update a Analog Output Status point.
bool remove_analog_output_status(uint16_t index)
Remove an Analog Output Status point.
bool remove_binary_input(uint16_t index)
Remove a BinaryInput point.
bool add_frozen_counter(uint16_t index, EventClass point_class, const FrozenCounterConfig &config)
Add a new Frozen Counter point.
Iterator over DoubleBitBinaryInput instances.
Definition: dnp3.hpp:861
DoubleBitBinaryInput get()
retrieve the current value
bool next()
move the iterator to the next value
DoubleBitBinaryInputIterator(DoubleBitBinaryInputIterator &&)=default
move constructor for the iterator
List of IP endpoints.
Definition: dnp3.hpp:2155
EndpointList(EndpointList &&other) noexcept
Transfer ownership of the underlying C-type to this instance and invalidate the other instance.
Definition: dnp3.hpp:2171
~EndpointList()
Destroy a previously allocated endpoint list.
void add(const std::string &endpoint)
Add an IP endpoint to the list.
EndpointList(const std::string &main_endpoint)
Create a new list of IP endpoints.
Iterator over FrozenCounter instances.
Definition: dnp3.hpp:1077
FrozenCounter get()
retrieve the current value
bool next()
move the iterator to the next value
FrozenCounterIterator(FrozenCounterIterator &&)=default
move constructor for the iterator
Handler for link status check.
Definition: dnp3.hpp:3303
virtual void on_complete(Nothing result)=0
Invoked when the asynchronous operation completes successfully.
virtual void on_failure(LinkStatusError error)=0
Invoked when the asynchronous operation fails.
Exception type corresponding to the underlying error enum LinkStatusError.
Definition: dnp3.hpp:3293
LinkStatusError error
underlying error enum
Definition: dnp3.hpp:3296
LinkStatusException(LinkStatusError error)
construct the exception with an instance of the enum
Definition: dnp3.hpp:3298
Logging interface that receives the log messages and writes them somewhere.
Definition: dnp3.hpp:231
virtual void on_message(LogLevel level, const char *message)=0
Called when a log message was received and should be logged.
Provides a static method for configuring logging.
Definition: dnp3.hpp:279
static void configure(const LoggingConfig &config, std::unique_ptr< Logger > logger)
Set the callback that will receive all the log messages.
Represents a communication channel for a master station.
Definition: dnp3.hpp:3322
void read(const AssociationId &association, Request &request, std::unique_ptr< ReadTaskCallback > callback)
Perform a read on the association.
void warm_restart(const AssociationId &association, std::unique_ptr< RestartTaskCallback > callback)
Asynchronously perform a warm restart operation to the association.
void cold_restart(const AssociationId &association, std::unique_ptr< RestartTaskCallback > callback)
Asynchronously perform a cold restart operation to the association.
void remove_poll(const PollId &poll_id)
Add a periodic poll to an association.
void enable()
start communications
void demand_poll(const PollId &poll_id)
Demand the immediate execution of a poll previously created with MasterChannel::add_poll().
void synchronize_time(const AssociationId &association, TimeSyncMode mode, std::unique_ptr< TimeSyncTaskCallback > callback)
Asynchronously perform a time sync operation to the association.
void disable()
stop communications
PollId add_poll(const AssociationId &id, Request &request, std::chrono::steady_clock::duration period)
Add a periodic poll to an association.
DecodeLevel get_decode_level()
Get the decoding level for the channel.
static MasterChannel create_tls_channel(Runtime &runtime, LinkErrorMode link_error_mode, const MasterChannelConfig &config, EndpointList &endpoints, const ConnectStrategy &connect_strategy, std::unique_ptr< ClientStateListener > listener, const TlsClientConfig &tls_config)
Create a master channel that connects to the specified TCP endpoint(s) and establish a TLS session wi...
void read_with_handler(const AssociationId &association, Request &request, std::unique_ptr< ReadHandler > handler, std::unique_ptr< ReadTaskCallback > callback)
Perform a read on the association.
AssociationId add_association(uint16_t address, const AssociationConfig &config, std::unique_ptr< ReadHandler > read_handler, std::unique_ptr< AssociationHandler > association_handler, std::unique_ptr< AssociationInformation > association_information)
Add an association to the channel.
void operate(const AssociationId &association, CommandMode mode, CommandSet &command, std::unique_ptr< CommandTaskCallback > callback)
Asynchronously perform a command operation on the association.
~MasterChannel()
Shutdown a MasterChannel and release all resources.
static MasterChannel create_tcp_channel(Runtime &runtime, LinkErrorMode link_error_mode, const MasterChannelConfig &config, EndpointList &endpoints, const ConnectStrategy &connect_strategy, std::unique_ptr< ClientStateListener > listener)
Create a master channel that connects to the specified TCP endpoint(s)
void remove_association(const AssociationId &id)
Remove an association from the channel.
MasterChannel(MasterChannel &&other) noexcept
Transfer ownership of the underlying C-type to this instance and invalidate the other instance.
Definition: dnp3.hpp:3338
void check_link_status(const AssociationId &association, std::unique_ptr< LinkStatusCallback > callback)
Asynchronously perform a link status check.
void set_decode_level(const DecodeLevel &decode_level)
Set the decoding level for the channel.
static MasterChannel create_serial_channel(Runtime &runtime, const MasterChannelConfig &config, const std::string &path, const SerialSettings &serial_params, std::chrono::steady_clock::duration open_retry_delay, std::unique_ptr< PortStateListener > listener)
Create a master channel on the specified serial port.
Iterator over OctetString instances.
Definition: dnp3.hpp:1333
OctetString get()
retrieve the current value
OctetStringIterator(OctetStringIterator &&)=default
move constructor for the iterator
bool next()
move the iterator to the next value
Dynamic information required by the outstation from the user application.
Definition: dnp3.hpp:4785
virtual RestartDelay warm_restart()=0
Request that the outstation perform a warm restart (IEEE-1815 2012, p. 58)
virtual FreezeResult freeze_counters_range(uint16_t start, uint16_t stop, FreezeType freeze_type, DatabaseHandle &database_handle)=0
Freeze a range of counters.
virtual RestartDelay cold_restart()=0
Request that the outstation perform a cold restart (IEEE-1815 2012, p. 58)
virtual FreezeResult freeze_counters_all(FreezeType freeze_type, DatabaseHandle &database_handle)=0
Freeze all the counters.
virtual ApplicationIin get_application_iin()=0
Returns the application-controlled IIN bits.
virtual uint16_t get_processing_delay_ms()=0
Returns the DELAY_MEASUREMENT delay.
virtual WriteTimeResult write_absolute_time(uint64_t time)=0
Handle a write of the absolute time during time synchronization procedures.
Informational callbacks that the outstation doesn't rely on to function.
Definition: dnp3.hpp:4879
virtual void solicited_confirm_received(uint8_t ecsn)=0
Received the expected confirm.
virtual void enter_unsolicited_confirm_wait(uint8_t ecsn)=0
Outstation has begun waiting for an unsolicited confirm.
virtual void unsolicited_confirm_timeout(uint8_t ecsn, bool retry)=0
Failed to receive an unsolicited confirm before the timeout occurred.
virtual void broadcast_received(FunctionCode function_code, BroadcastAction action)=0
Called when a broadcast request is received by the outstation.
virtual void enter_solicited_confirm_wait(uint8_t ecsn)=0
Outstation has begun waiting for a solicited confirm.
virtual void unsolicited_confirmed(uint8_t ecsn)=0
Master confirmed an unsolicited message.
virtual void wrong_solicited_confirm_seq(uint8_t ecsn, uint8_t seq)=0
Received a solicited confirm with the wrong sequence number.
virtual void unexpected_confirm(bool unsolicited, uint8_t seq)=0
Received a confirm when not expecting one.
virtual void process_request_from_idle(const RequestHeader &header)=0
Called when a request is processed from the IDLE state.
virtual void solicited_confirm_wait_new_request()=0
Received a new request while waiting for a solicited confirm, aborting the response series.
virtual void clear_restart_iin()=0
Master cleared the restart IIN bit.
virtual void solicited_confirm_timeout(uint8_t ecsn)=0
Failed to receive a solicited confirm before the timeout occurred.
TCP server that listens for connections and routes the messages to outstations.
Definition: dnp3.hpp:5351
Outstation add_outstation(const OutstationConfig &config, std::unique_ptr< OutstationApplication > application, std::unique_ptr< OutstationInformation > information, std::unique_ptr< ControlHandler > control_handler, std::unique_ptr< ConnectionStateListener > listener, AddressFilter &filter)
Add an outstation to the server.
~OutstationServer()
Gracefully shutdown all the outstations associated to this server, stops the server and release resou...
void bind()
Bind the server to the port and starts listening. Also starts all the outstations associated to it.
OutstationServer(OutstationServer &&other) noexcept
Transfer ownership of the underlying C-type to this instance and invalidate the other instance.
Definition: dnp3.hpp:5367
static OutstationServer create_tls_server(Runtime &runtime, LinkErrorMode link_error_mode, const std::string &address, const TlsServerConfig &tls_config)
Create a new TLS server.
static OutstationServer create_tcp_server(Runtime &runtime, LinkErrorMode link_error_mode, const std::string &address)
Create a new TCP server.
Outstation handle.
Definition: dnp3.hpp:5176
void set_decode_level(const DecodeLevel &level)
Set decoding log level.
~Outstation()
Free resources of the outstation.
static Outstation create_serial_session(Runtime &runtime, const std::string &serial_path, const SerialSettings &settings, const OutstationConfig &config, std::unique_ptr< OutstationApplication > application, std::unique_ptr< OutstationInformation > information, std::unique_ptr< ControlHandler > control_handler)
Create an outstation instance running on a serial port.
static Outstation create_serial_session_fault_tolerant(Runtime &runtime, const std::string &serial_path, const SerialSettings &settings, std::chrono::steady_clock::duration open_retry_delay, const OutstationConfig &config, std::unique_ptr< OutstationApplication > application, std::unique_ptr< OutstationInformation > information, std::unique_ptr< ControlHandler > control_handler)
Create an outstation instance running on a serial port which is tolerant to the serial port being add...
void transaction(DatabaseTransaction &callback)
Acquire a mutex on the underlying database and apply a set of changes as a transaction.
Outstation(Outstation &&other) noexcept
Transfer ownership of the underlying C-type to this instance and invalidate the other instance.
Definition: dnp3.hpp:5192
Exception type corresponding to the underlying error enum ParamError.
Definition: dnp3.hpp:107
ParamError error
underlying error enum
Definition: dnp3.hpp:110
ParamException(ParamError error)
construct the exception with an instance of the enum
Definition: dnp3.hpp:112
Callback interface for receiving updates about the state of a serial port.
Definition: dnp3.hpp:1384
virtual void on_change(PortState state)=0
Invoked when the serial port changes state.
Exception type corresponding to the underlying error enum ReadError.
Definition: dnp3.hpp:2954
ReadException(ReadError error)
construct the exception with an instance of the enum
Definition: dnp3.hpp:2959
ReadError error
underlying error enum
Definition: dnp3.hpp:2957
General handler that will receive all values read from the outstation.
Definition: dnp3.hpp:2094
virtual void handle_analog_input(const HeaderInfo &info, AnalogInputIterator &it)=0
Handle analog input data.
virtual void end_fragment(ReadType read_type, const ResponseHeader &header)=0
Marks the end of a fragment.
virtual void handle_frozen_counter(const HeaderInfo &info, FrozenCounterIterator &it)=0
Handle frozen counter input data.
virtual void handle_analog_output_status(const HeaderInfo &info, AnalogOutputStatusIterator &it)=0
Handle analog output status data.
virtual void handle_binary_input(const HeaderInfo &info, BinaryInputIterator &it)=0
Handle binary input data.
virtual void begin_fragment(ReadType read_type, const ResponseHeader &header)=0
Marks the beginning of a fragment.
virtual void handle_double_bit_binary_input(const HeaderInfo &info, DoubleBitBinaryInputIterator &it)=0
Handle double-bit binary input data.
virtual void handle_octet_string(const HeaderInfo &info, OctetStringIterator &it)=0
Handle octet string data.
virtual void handle_binary_output_status(const HeaderInfo &info, BinaryOutputStatusIterator &it)=0
Handle binary output status data.
virtual void handle_counter(const HeaderInfo &info, CounterIterator &it)=0
Handle counter data.
Handler for read tasks.
Definition: dnp3.hpp:2964
virtual void on_complete(Nothing result)=0
Invoked when the asynchronous operation completes successfully.
virtual void on_failure(ReadError error)=0
Invoked when the asynchronous operation fails.
Custom request.
Definition: dnp3.hpp:2814
void add_two_byte_range_header(Variation variation, uint16_t start, uint16_t stop)
Add a two-byte start/stop variation interrogation.
static Request one_byte_range(Variation variation, uint8_t start, uint8_t stop)
Create a new request asking for range of objects (using 8-bit start/stop).
~Request()
Destroy a request created with Request::Request() or Request::class_request().
Request(Request &&other) noexcept
Transfer ownership of the underlying C-type to this instance and invalidate the other instance.
Definition: dnp3.hpp:2830
static Request two_byte_range(Variation variation, uint16_t start, uint16_t stop)
Create a new request asking for range of objects (using 16-bit start/stop).
static Request two_byte_limited_count(Variation variation, uint16_t count)
Create a new request asking for a limited count of objects (using 16-bit start/stop).
void add_one_byte_limited_count_header(Variation variation, uint8_t count)
Add a one-byte limited count variation interrogation.
static Request class_request(bool class0, bool class1, bool class2, bool class3)
Create a new request asking for classes.
static Request one_byte_limited_count(Variation variation, uint8_t count)
Create a new request asking for a limited count of objects (using 8-bit start/stop).
Request()
Create a new request.
void add_all_objects_header(Variation variation)
Add an all objects variation interrogation.
static Request all_objects(Variation variation)
Create a new request asking for all objects of a particular variation.
void add_two_byte_limited_count_header(Variation variation, uint16_t count)
Add a two-byte limited count variation interrogation.
void add_one_byte_range_header(Variation variation, uint8_t start, uint8_t stop)
Add a one-byte start/stop variation interrogation.
Exception type corresponding to the underlying error enum RestartError.
Definition: dnp3.hpp:3241
RestartException(RestartError error)
construct the exception with an instance of the enum
Definition: dnp3.hpp:3246
RestartError error
underlying error enum
Definition: dnp3.hpp:3244
Handler for restart tasks.
Definition: dnp3.hpp:3251
virtual void on_complete(std::chrono::steady_clock::duration result)=0
Invoked when the asynchronous operation completes successfully.
virtual void on_failure(RestartError error)=0
Invoked when the asynchronous operation fails.
Handle to the underlying runtime.
Definition: dnp3.hpp:439
Runtime(const RuntimeConfig &config)
Creates a new runtime for running the protocol stack.
~Runtime()
Destroy a runtime.
Runtime(Runtime &&other) noexcept
Transfer ownership of the underlying C-type to this instance and invalidate the other instance.
Definition: dnp3.hpp:455
Exception type corresponding to the underlying error enum TimeSyncError.
Definition: dnp3.hpp:3191
TimeSyncError error
underlying error enum
Definition: dnp3.hpp:3194
TimeSyncException(TimeSyncError error)
construct the exception with an instance of the enum
Definition: dnp3.hpp:3196
Handler for time synchronization tasks.
Definition: dnp3.hpp:3201
virtual void on_failure(TimeSyncError error)=0
Invoked when the asynchronous operation fails.
virtual void on_complete(Nothing result)=0
Invoked when the asynchronous operation completes successfully.
class that implements AssociationHandler in terms of a lambda expression
Definition: dnp3.hpp:2698
AssociationHandlerLambda(const T &lambda)
constructor
Definition: dnp3.hpp:2706
UtcTimestamp get_current_time() override
implement virtual method from base class
Definition: dnp3.hpp:2709
class that implements ClientStateListener in terms of a lambda expression
Definition: dnp3.hpp:2276
ClientStateListenerLambda(const T &lambda)
constructor
Definition: dnp3.hpp:2284
void on_change(ClientState state) override
implement virtual method from base class
Definition: dnp3.hpp:2287
class that implements ConnectionStateListener in terms of a lambda expression
Definition: dnp3.hpp:5142
ConnectionStateListenerLambda(const T &lambda)
constructor
Definition: dnp3.hpp:5150
void on_change(ConnectionState state) override
implement virtual method from base class
Definition: dnp3.hpp:5153
class that implements DatabaseTransaction in terms of a lambda expression
Definition: dnp3.hpp:4329
DatabaseTransactionLambda(const T &lambda)
constructor
Definition: dnp3.hpp:4337
void execute(Database &database) override
implement virtual method from base class
Definition: dnp3.hpp:4340
class that implements Logger in terms of a lambda expression
Definition: dnp3.hpp:249
LoggerLambda(const T &lambda)
constructor
Definition: dnp3.hpp:257
void on_message(LogLevel level, const char *message) override
implement virtual method from base class
Definition: dnp3.hpp:260
class that implements PortStateListener in terms of a lambda expression
Definition: dnp3.hpp:1400
void on_change(PortState state) override
implement virtual method from base class
Definition: dnp3.hpp:1411
PortStateListenerLambda(const T &lambda)
constructor
Definition: dnp3.hpp:1408
constexpr uint8_t restart
Object value has not been updated since device restart.
Definition: dnp3.hpp:120
constexpr uint8_t discontinuity
Reported counter value cannot be compared against a prior value to obtain the correct count differenc...
Definition: dnp3.hpp:132
constexpr uint8_t chatter_filter
Object value is changing state rapidly (device dependent meaning)
Definition: dnp3.hpp:128
constexpr uint8_t reference_err
Object's value might not have the expected level of accuracy.
Definition: dnp3.hpp:134
constexpr uint8_t over_range
Object's true exceeds the measurement range of the reported variation.
Definition: dnp3.hpp:130
constexpr uint8_t remote_forced
Object value is overridden in a downstream reporting device.
Definition: dnp3.hpp:124
constexpr uint8_t local_forced
Object value is overridden by the device reporting this flag.
Definition: dnp3.hpp:126
constexpr uint8_t online
Object value is 'good' / 'valid' / 'nominal'.
Definition: dnp3.hpp:118
constexpr uint8_t comm_lost
Object value represents the last value available before a communication failure occurred....
Definition: dnp3.hpp:122
std::unique_ptr< ConnectionStateListener > connection_state_listener(const T &lambda)
construct an implementation of ConnectionStateListener based on a lambda expression
Definition: dnp3.hpp:5164
std::unique_ptr< Logger > logger(const T &lambda)
construct an implementation of Logger based on a lambda expression
Definition: dnp3.hpp:271
std::unique_ptr< PortStateListener > port_state_listener(const T &lambda)
construct an implementation of PortStateListener based on a lambda expression
Definition: dnp3.hpp:1422
std::unique_ptr< ClientStateListener > client_state_listener(const T &lambda)
construct an implementation of ClientStateListener based on a lambda expression
Definition: dnp3.hpp:2298
DatabaseTransactionLambda< T > database_transaction(const T &lambda)
construct an implementation of DatabaseTransaction based on a lambda expression
Definition: dnp3.hpp:4351
std::unique_ptr< AssociationHandler > association_handler(const T &lambda)
construct an implementation of AssociationHandler based on a lambda expression
Definition: dnp3.hpp:2720
main namespace for the dnp3 library
Definition: dnp3.hpp:39
AutoTimeSync
Automatic time synchronization configuration.
Definition: dnp3.hpp:2548
@ non_lan
Perform automatic time sync with Delay Measurement (0x17) function code.
@ lan
Perform automatic time sync with Record Current Time (0x18) function code.
EventBinaryOutputStatusVariation
Event binary output status variation.
Definition: dnp3.hpp:3729
ResponseFunction
Type of response.
Definition: dnp3.hpp:1883
TimeFormat
Describes if and how the time will be formatted in log messages.
Definition: dnp3.hpp:174
@ none
Don't format the timestamp as part of the message.
@ system
Format the time in a human readable format e.g. 'Jun 25 14:27:12.955'.
@ rfc_3339
Format the time using RFC 3339.
CommandMode
Command operation mode.
Definition: dnp3.hpp:3072
@ select_before_operate
Perform a Select and Operate (0x03 then 0x04)
DataBits
Number of bits per character.
Definition: dnp3.hpp:1658
@ eight
8 bits per character
@ five
5 bits per character
@ seven
7 bits per character
@ six
6 bits per character
ReadType
Describes the source of a read event.
Definition: dnp3.hpp:2076
@ single_poll
Single poll requested by the user.
@ startup_integrity
Startup integrity poll.
@ unsolicited
Unsolicited message.
@ periodic_poll
Periodic poll configured by the user.
EventMode
Controls how events are processed when updating values in the database.
Definition: dnp3.hpp:3537
@ detect
Detect events in a type dependent fashion.
@ suppress
Never produce an event regardless of change.
@ force
Produce an event whether the value has changed or not.
EventAnalogOutputStatusVariation
Event analog output status variation.
Definition: dnp3.hpp:4013
LogLevel
Log level.
Definition: dnp3.hpp:140
@ trace
Trace log level.
@ warn
Warning log level.
@ debug
Debugging log level.
@ info
Information log level.
@ error
Error log level.
FlowControl
Flow control modes.
Definition: dnp3.hpp:1675
@ hardware
Flow control using RTS/CTS signals.
@ software
Flow control using XON/XOFF bytes.
EventAnalogInputVariation
Event analog variation.
Definition: dnp3.hpp:3936
WriteTimeResult
Write time result used by OutstationApplication::write_absolute_time()
Definition: dnp3.hpp:4702
@ parameter_error
The request parameters are nonsensical.
StaticBinaryOutputStatusVariation
Static binary output status variation.
Definition: dnp3.hpp:3716
TransportDecodeLevel
Controls how transmitted and received transport segments are decoded at the INFO log level.
Definition: dnp3.hpp:312
@ payload
Decode the header and the raw payload as hexadecimal.
TimeSyncError
Possible errors that can occur during a time synchronization procedure.
Definition: dnp3.hpp:3152
@ overflow
Overflow in calculation.
@ system_time_not_unix
The system time cannot be converted to a Unix timestamp.
@ system_time_not_available
System time not available.
@ bad_outstation_time_delay
Outstation time delay exceeded the response delay.
@ clock_rollback
Detected a clock rollback.
@ iin_error
Outstation indicated an error.
@ still_needs_time
Outstation did not clear the NEED_TIME IIN bit.
TaskType
Task type used in AssociationInformation.
Definition: dnp3.hpp:2728
@ command
Command request.
@ user_read
User-defined read request.
@ auto_event_scan
Automatic event scan caused by RESTART IIN bit detection.
@ time_sync
Time synchronisation task.
@ clear_restart_bit
Clear RESTART IIN bit.
Variation
Group/Variation.
Definition: dnp3.hpp:1430
@ group41_var4
Analog Output - Double-precision floating point.
@ group42_var1
Analog Output Event - 32-bit without time.
@ group23_var2
Frozen Counter Event - 16-bit with flags.
@ group40_var3
Analog Output Status - Single-precision floating point with flags.
@ group60_var4
Class objects - Class 3 data.
@ group21_var9
Frozen Counter - 32-bit without flag.
@ group21_var2
Frozen Counter - 16-bit with flags.
@ group40_var1
Analog Output Status - 32-bit with flags.
@ group30_var3
Analog Input - 32-bit without flag.
@ group11_var1
Binary Output Event - Without time.
@ group42_var5
Analog Output Event - Single-precision floating point without time.
@ group22_var2
Counter Event - 16-bit with flags.
@ group12_var1
Binary Output Command - Pattern Control Block.
@ group42_var3
Analog Output Event - 32-bit with time.
@ group11_var2
Binary Output Event - With time.
@ group22_var5
Counter Event - 32-bit with flags and time.
@ group42_var8
Analog Output Event - Double-preicions floating point with time.
@ group30_var6
Analog Input - Double-precision floating point with flags.
@ group50_var1
Time and Date - Absolute time.
@ group60_var2
Class objects - Class 1 data.
@ group20_var2
Counter - 16-bit with flags.
@ group2_var0
Binary Input Event - Default variation.
@ group41_var0
Analog Output - Default variation.
@ group21_var5
Frozen Counter - 32-bit with flags and time.
@ group2_var3
Binary Input Event - With relative time.
@ group42_var6
Analog Output Event - Double-precision floating point without time.
@ group32_var0
Analog Input Event - Default variation.
@ group22_var6
Counter Event - 16-bit with flags and time.
@ group20_var1
Counter - 32-bit with flags.
@ group32_var1
Analog Input Event - 32-bit without time.
@ group40_var4
Analog Output Status - Double-precision floating point with flags.
@ group1_var2
Binary Input - With flags.
@ group23_var5
Frozen Counter Event - 32-bit with flags and time.
@ group60_var1
Class objects - Class 0 data.
@ group42_var4
Analog Output Event - 16-bit with time.
@ group32_var4
Analog Input Event - 16-bit with time.
@ group3_var1
Double-bit Binary Input - Packed format.
@ group42_var7
Analog Output Event - Single-preicions floating point with time.
@ group110
Octet String.
@ group10_var1
Binary Output - Packed format.
@ group10_var2
Binary Output - With flags.
@ group4_var1
Double-bit Binary Input Event - Without time.
@ group30_var0
Analog Input - Default variation.
@ group21_var0
Frozen Counter - Default variation.
@ group51_var2
Time and date CTO - Absolute time, unsynchronized.
@ group12_var0
Binary Output Command - Control Relay Output Block.
@ group40_var0
Analog Output Status - Default variation.
@ group50_var4
Time and Date - Indexed absolute time and long interval.
@ group52_var1
Time delay - Coarse.
@ group51_var1
Time and date CTO - Absolute time, synchronized.
@ group52_var2
Time delay - Fine.
@ group20_var0
Counter - Default variation.
@ group32_var7
Analog Input Event - Single-precision floating point with time.
@ group3_var0
Double-bit Binary Input - Default variation.
@ group30_var1
Analog Input - 32-bit with flags.
@ group32_var8
Analog Input Event - Double-precision floating point with time.
@ group32_var6
Analog Input Event - Double-precision floating point without time.
@ group22_var1
Counter Event - 32-bit with flags.
@ group42_var0
Analog Output Event - Default variation.
@ group23_var0
Frozen Counter Event - Default variation.
@ group50_var3
Time and Date - Absolute time at last recorded time.
@ group22_var0
Counter Event - Default variation.
@ group30_var2
Analog Input - 16-bit with flags.
@ group20_var5
Counter - 32-bit without flag.
@ group3_var2
Double-bit Binary Input - With flags.
@ group32_var3
Analog Input Event - 32-bit with time.
@ group41_var3
Analog Output - Single-precision floating point.
@ group10_var0
Binary Output - Default variation.
@ group42_var2
Analog Output Event - 16-bit without time.
@ group40_var2
Analog Output Status - 16-bit with flags.
@ group1_var0
Binary Input - Default variation.
@ group60_var3
Class objects - Class 2 data.
@ group32_var5
Analog Input Event - Single-precision floating point without time.
@ group21_var10
Frozen Counter - 16-bit without flag.
@ group2_var1
Binary Input Event - Without time.
@ group41_var2
Analog Output - 16-bit.
@ group30_var4
Analog Input - 16-bit without flag.
@ group41_var1
Analog Output - 32-bit.
@ group20_var6
Counter - 16-bit without flag.
@ group32_var2
Analog Input Event - 16-bit without time.
@ group1_var1
Binary Input - Packed format.
@ group30_var5
Analog Input - Single-precision floating point with flags.
@ group21_var6
Frozen Counter - 16-bit with flags and time.
@ group80_var1
Internal Indications - Packed format.
@ group21_var1
Frozen Counter - 32-bit with flags.
@ group4_var2
Double-bit Binary Input Event - With absolute time.
@ group11_var0
Binary Output Event - Default variation.
@ group23_var1
Frozen Counter Event - 32-bit with flags.
@ group111
Octet String Event.
@ group2_var2
Binary Input Event - With absolute time.
@ group23_var6
Frozen Counter Event - 16-bit with flags and time.
@ group4_var3
Double-bit Binary Input Event - With relative time.
@ group4_var0
Double-bit Binary Input Event - Default variation.
OpType
Operation Type field, used in conjunction with TripCloseCode to specify a control operation.
Definition: dnp3.hpp:520
@ pulse_on
PULSE_ON (1)
@ pulse_off
PULSE_OFF (2)
@ latch_on
LATCH_ON (3)
@ latch_off
LATCH_OFF(4)
EventCounterVariation
Event counter variation.
Definition: dnp3.hpp:3790
OperateType
Enumeration describing how the master requested the control operation.
Definition: dnp3.hpp:4987
@ direct_operate_no_ack
operate the control via a DirectOperateNoAck request
EventDoubleBitBinaryInputVariation
Event double-bit binary input variation.
Definition: dnp3.hpp:3670
StaticAnalogOutputStatusVariation
Static analog output status variation.
Definition: dnp3.hpp:3996
CommandStatus
Enumeration received from an outstation in response to command request.
Definition: dnp3.hpp:4936
@ format_error
bad control code or timing values (value == 3)
@ automation_inhibit
command not accepted because it was prevented or inhibited by a local automation process,...
@ success
command was accepted, initiated, or queued (value == 0)
@ too_many_ops
the command has been done too often and has been throttled (value == 8)
@ no_select
command requires being selected before operate, configuration issue (value == 2)
@ already_active
command is all ready in progress or its all ready in that mode (value == 5)
@ out_of_range
command not accepted because the value is outside the acceptable range permitted for this point (valu...
@ non_participating
(deprecated) indicates the outstation shall not issue or perform the control operation (value == 126)
@ blocked
command not accepted because the requested function is specifically blocked at the outstation (value ...
@ already_complete
command not accepted because the outstation has already completed the requested operation (value == 1...
@ not_authorized
the command was rejected because the device denied it or an RTU intercepted it (value == 9)
@ timeout
command timed out before completing (value == 1)
@ unknown
captures any value not defined in the enumeration
@ canceled
command not accepted because the operation was cancelled (value == 16)
@ hardware_error
something is stopping the command, often a local/remote interlock (value == 6)
@ blocked_other_master
command not accepted because another master is communicating with the outstation and has exclusive ri...
@ processing_limited
command not accepted because the device cannot process any more activities than are presently in prog...
@ local
the function governed by the control is in local only control (value == 7)
@ downstream_local
command not accepted because the outstation is forwarding the request to another downstream device wh...
@ downstream_fail
command not accepted because the outstation is forwarding the request to another downstream device wh...
TimeQuality
Timestamp quality.
Definition: dnp3.hpp:666
@ invalid_time
Timestamp is not valid, ignore the value and use a local timestamp.
@ synchronized_time
The timestamp is UTC synchronized at the remote device.
@ unsynchronized_time
The device indicates the timestamp may be not be synchronized.
constexpr uint64_t dnp3_version_major
major version number
Definition: dnp3.hpp:42
StaticDoubleBitBinaryInputVariation
Static double-bit binary input variation.
Definition: dnp3.hpp:3657
StaticAnalogInputVariation
Static analog variation.
Definition: dnp3.hpp:3915
FunctionCode
Application layer function code.
Definition: dnp3.hpp:1808
@ cold_restart
Outstation shall perform a complete reset of all hardware and software in the device (value == 13)
@ operate
Outstation shall activate the output points selected (or armed) by a previous select function code co...
@ get_file_info
Outstation shall retrieve information about a file (value == 28)
@ stop_application
Outstation shall stop running the applications specified by the objects in the request (value == 18)
@ immediate_freeze
Outstation shall copy the point data values specified by the objects in the request to a separate fre...
@ initialize_data
Obsolete-Do not use for new designs (value == 15)
@ delay_measure
Outstation shall report the time it takes to process and initiate the transmission of its response (v...
@ abort_file
Outstation shall abort a file transfer operation (value == 30)
@ disable_unsolicited
Prevents outstation from initiating unsolicited responses from points specified by the objects in the...
@ immediate_freeze_no_response
Same as ImmediateFreeze but outstation shall not send a response (value == 8)
@ unsolicited_response
Master shall interpret this fragment as an unsolicited response that was not prompted by an explicit ...
@ enable_unsolicited
Enables outstation to initiate unsolicited responses from points specified by the objects in the requ...
@ close_file
Outstation shall close a file (value == 26)
@ freeze_clear_no_response
Same as FreezeClear but outstation shall not send a response (value == 10)
@ save_configuration
This code is deprecated-Do not use for new designs (value == 19)
@ record_current_time
Outstation shall save the time when the last octet of this message is received (value == 24)
@ assign_class
Outstation shall assign the events generated by the points specified by the objects in the request to...
@ select
Outstation shall select (or arm) the output points specified by the objects in the request in prepara...
@ delete_file
Outstation shall delete a file (value == 27)
@ start_application
Outstation shall start running the applications specified by the objects in the request (value == 17)
@ freeze_clear
Outstation shall copy the point data values specified by the objects in the request into a separate f...
@ freeze_at_time_no_response
Same as FreezeAtTime but outstation shall not send a response (value == 12)
@ direct_operate_no_response
Same as DirectOperate but outstation shall not send a response (value == 6)
@ confirm
Master sends this to an outstation to confirm the receipt of an Application Layer fragment (value == ...
@ response
Master shall interpret this fragment as an Application Layer response to an ApplicationLayer request ...
@ initialize_application
Outstation shall place the applications specified by the objects in the request into the ready to run...
@ direct_operate
Outstation shall immediately actuate the output points specified by the objects in the request (value...
@ authenticate_file
Outstation shall return a file authentication key (value == 29)
@ read
Outstation shall return the data specified by the objects in the request (value == 1)
@ write
Outstation shall store the data specified by the objects in the request (value == 2)
@ open_file
Outstation shall open a file (value == 25)
@ freeze_at_time
Outstation shall copy the point data values specified by the objects in the request to a separate fre...
@ warm_restart
Outstation shall reset only portions of the device (value == 14)
Nothing
A single value enum which is used as a placeholder for futures that don't return a value.
Definition: dnp3.hpp:2399
StaticBinaryInputVariation
Static binary input variation.
Definition: dnp3.hpp:3598
RestartDelayType
Type of restart delay value. Used by RestartDelay.
Definition: dnp3.hpp:4633
@ seconds
Value is in seconds (corresponds to g51v1)
@ not_supported
Restart mode not supported.
@ milli_seconds
Value is in milliseconds (corresponds to g51v2)
LinkDecodeLevel
Controls how transmitted and received link frames are decoded at the INFO log level.
Definition: dnp3.hpp:327
CertificateMode
Determines how the certificate(s) presented by the peer are validated.
Definition: dnp3.hpp:1789
@ authority_based
Validates the peer certificate against one or more configured trust anchors.
@ self_signed
Validates that the peer presents a single certificate which is a byte-for-byte match against the conf...
CommandError
Result of a command.
Definition: dnp3.hpp:3085
@ header_mismatch
Number of headers or objects in the response didn't match the number in the request.
@ bad_status
Outstation indicated that a command was not SUCCESS.
EventBinaryInputVariation
Event binary input variation.
Definition: dnp3.hpp:3611
const char * to_string(ParamError value)
convert an instance of enum ParamError into a C-style string
DoubleBit
Double-bit binary input value.
Definition: dnp3.hpp:733
@ determined_off
Determined to be OFF.
@ intermediate
Transition between conditions.
@ indeterminate
Abnormal or custom condition.
@ determined_on
Determined to be ON.
StaticFrozenCounterVariation
Static frozen counter variation.
Definition: dnp3.hpp:3842
StopBits
Number of stop bits.
Definition: dnp3.hpp:1705
@ two
Two stop bits.
@ one
One stop bit.
ReadError
Errors that can occur during a read operation.
Definition: dnp3.hpp:2929
FreezeType
Freeze operation type.
Definition: dnp3.hpp:4717
@ freeze_and_clear
Copy the current value of a counter to the associated point and clear the current value to 0.
constexpr uint64_t dnp3_version_patch
patch version number
Definition: dnp3.hpp:46
AppDecodeLevel
Controls how transmitted and received application-layer fragments are decoded at the INFO log level.
Definition: dnp3.hpp:295
@ header
Decode the header-only.
@ object_values
Decode the header, the object headers, and the object values.
@ nothing
Decode nothing.
@ object_headers
Decode the header and the object headers.
EventFrozenCounterVariation
Event frozen counter variation.
Definition: dnp3.hpp:3863
FreezeResult
Result of a freeze operation.
Definition: dnp3.hpp:4730
constexpr uint64_t dnp3_version_minor
minor version number
Definition: dnp3.hpp:44
QualifierCode
Qualifier code used in the response.
Definition: dnp3.hpp:2023
@ range8
8-bit start stop (0x00)
@ all_objects
All objects (0x06)
@ free_format_16
16-bit free format (0x5B)
@ range16
16-bit start stop (0x01)
@ count_and_prefix_16
16-bit count and prefix (0x28)
@ count_and_prefix_8
8-bit count and prefix (0x17)
@ count8
8-bit count (0x07)
@ count16
16-bit count (0x08)
LinkErrorMode
Controls how errors in parsed link-layer frames are handled. This behavior is configurable for physic...
Definition: dnp3.hpp:1761
@ discard
Framing errors are discarded. The link-layer parser is reset on any error, and the parser begins scan...
constexpr char const * dnp3_version_string
version number as the string major.minor.patch
Definition: dnp3.hpp:48
TaskError
Task error used in AssociationInformation.
Definition: dnp3.hpp:2757
@ no_connection
no connection
@ response_timeout
timeout occurred before receiving a response
@ too_many_requests
too many user requests queued
@ bad_response
response was malformed or contained object headers
@ write_error
insufficient buffer space to serialize the request
@ association_removed
association was removed mid-task
RestartError
Errors that can occur during a cold/warm restart operation.
Definition: dnp3.hpp:3216
ParamError
Error type used throughout the library.
Definition: dnp3.hpp:52
@ invalid_local_certificate
Invalid local certificate file.
@ invalid_timeout
The supplied timeout value is too small or too large.
@ no_support
Native library was compiled without support for this feature.
@ server_bind_error
Server failed to bind to the specified port.
@ ok
Success, i.e. no error occurred.
@ server_already_started
Server already started.
@ invalid_dns_name
Invalid DNS name.
@ other_tls_error
Other TLS error.
@ master_already_shutdown
Master was already shutdown.
@ association_does_not_exist
The specified association does not exist.
@ null_parameter
Null parameter.
@ invalid_peer_certificate
Invalid peer certificate file.
@ invalid_private_key
Invalid private key file.
@ runtime_cannot_block_within_async
Runtime cannot execute blocking call within asynchronous context.
@ association_duplicate_address
Duplicate association address.
@ runtime_creation_failure
Failed to create Tokio runtime.
@ point_does_not_exist
Point does not exist.
@ invalid_socket_address
Invalid socket address.
@ invalid_dnp3_address
Invalid link-layer DNP3 address.
@ runtime_destroyed
Runtime has already been disposed.
@ address_filter_conflict
Conflict in the address filter specification.
@ logging_already_configured
Logging can only be configured once.
@ invalid_buffer_size
Invalid buffer size.
EventClass
Event class.
Definition: dnp3.hpp:3520
@ class3
Class 3 event.
@ class1
Class 1 event.
@ class2
Class 2 event.
TimeSyncMode
Time synchronization mode.
Definition: dnp3.hpp:3139
LinkStatusError
Errors that can occur during a manually initiated link status check. See MasterChannel::check_link_st...
Definition: dnp3.hpp:3266
@ unexpected_response
There was activity on the link, but it wasn't a LINK_STATUS.
StaticCounterVariation
Static counter variation.
Definition: dnp3.hpp:3773
BroadcastAction
Enumeration describing how the outstation processed a broadcast request.
Definition: dnp3.hpp:4859
@ bad_object_headers
Outstation was unable to parse the object headers and ignored the request.
@ ignored_by_configuration
Outstation ignored the broadcast message b/c it is disabled by configuration.
@ processed
Outstation processed the broadcast.
@ unsupported_function
Outstation ignore the broadcast message b/c the function is not supported via Broadcast.
ConnectionState
Outstation connection state for connection-oriented transports, e.g. TCP.
Definition: dnp3.hpp:5112
@ disconnected
Disconnected from the master.
TripCloseCode
Trip-Close Code field, used in conjunction with OpType to specify a control operation.
Definition: dnp3.hpp:503
@ reserved
RESERVED (3)
MinTlsVersion
Minimum TLS version to allow.
Definition: dnp3.hpp:1774
@ v12
Allow TLS 1.2 and 1.3.
@ v13
Only allow TLS 1.3.
LogOutputFormat
Describes how each log event is formatted.
Definition: dnp3.hpp:161
@ text
A simple text-based format.
@ json
Output formatted as JSON.
Parity
Parity checking modes.
Definition: dnp3.hpp:1690
@ odd
Parity bit sets odd number of 1 bits.
@ even
Parity bit sets even number of 1 bits.
PortState
State of the serial port.
Definition: dnp3.hpp:1366
@ disabled
Disabled until enabled.
@ wait
Waiting to perform an open retry.
@ shutdown
Task has been shut down.
@ open
Port is open.
ClientState
State of the client connection.
Definition: dnp3.hpp:2238
@ connected
Client is connected to the remote device.
@ wait_after_failed_connect
Failed to establish a connection, waiting before retrying.
@ connecting
Client is trying to establish a connection to the remote device.
@ wait_after_disconnect
Client was disconnected, waiting before retrying.
PhysDecodeLevel
Controls how data transmitted at the physical layer (TCP, serial, etc) is logged.
Definition: dnp3.hpp:342
@ length
Log only the length of data that is sent and received.
@ data
Log the length and the actual data that is sent and received.
Analog configuration.
Definition: dnp3.hpp:3963
double deadband
Deadband value.
Definition: dnp3.hpp:3992
AnalogInputConfig()
Initialize to defaults.
StaticAnalogInputVariation static_variation
Default static variation.
Definition: dnp3.hpp:3988
EventAnalogInputVariation event_variation
Default event variation.
Definition: dnp3.hpp:3990
analog_input point
Definition: dnp3.hpp:1112
Timestamp time
Point timestamp.
Definition: dnp3.hpp:1133
uint16_t index
Point index.
Definition: dnp3.hpp:1127
AnalogInput(uint16_t index, double value, const Flags &flags, const Timestamp &time)
Fully construct AnalogInput specifying the value of each field.
Flags flags
Point flags.
Definition: dnp3.hpp:1131
double value
Point value.
Definition: dnp3.hpp:1129
Analog Output Status configuration.
Definition: dnp3.hpp:4040
double deadband
Deadband value.
Definition: dnp3.hpp:4069
StaticAnalogOutputStatusVariation static_variation
Default static variation.
Definition: dnp3.hpp:4065
EventAnalogOutputStatusVariation event_variation
Default event variation.
Definition: dnp3.hpp:4067
AnalogOutputStatusConfig()
Initialize to defaults.
analog_output_status point
Definition: dnp3.hpp:1184
Timestamp time
Point timestamp.
Definition: dnp3.hpp:1205
AnalogOutputStatus(uint16_t index, double value, const Flags &flags, const Timestamp &time)
Fully construct AnalogOutputStatus specifying the value of each field.
uint16_t index
Point index.
Definition: dnp3.hpp:1199
Flags flags
Point flags.
Definition: dnp3.hpp:1203
double value
Point value.
Definition: dnp3.hpp:1201
Application-controlled IIN bits.
Definition: dnp3.hpp:4747
bool config_corrupt
IIN2.5 - Configuration corrupt.
Definition: dnp3.hpp:4780
bool need_time
IIN1.4 - Time synchronization is required.
Definition: dnp3.hpp:4774
bool local_control
IIN1.5 - Some output points are in local mode.
Definition: dnp3.hpp:4776
bool device_trouble
IIN1.6 - Device trouble.
Definition: dnp3.hpp:4778
ApplicationIin()
Initialize all fields in ApplicationIin to false.
Association configuration.
Definition: dnp3.hpp:2565
Classes startup_integrity_classes
Startup integrity classes to ask on master startup and when an outstation restart is detected.
Definition: dnp3.hpp:2613
std::chrono::steady_clock::duration keep_alive_timeout
Delay of inactivity before sending a REQUEST_LINK_STATUS to the outstation.
Definition: dnp3.hpp:2621
AssociationConfig(const EventClasses &disable_unsol_classes, const EventClasses &enable_unsol_classes, const Classes &startup_integrity_classes, const EventClasses &event_scan_on_events_available)
Initialize the configuration with the specified values.
AutoTimeSync auto_time_sync
Automatic time synchronization configuration.
Definition: dnp3.hpp:2615
EventClasses enable_unsol_classes
Classes to enable unsolicited responses at startup.
Definition: dnp3.hpp:2609
EventClasses event_scan_on_events_available
Classes to automatically send reads when the IIN bit is asserted.
Definition: dnp3.hpp:2625
uint16_t max_queued_user_requests
maximum number of user requests (e.g. commands, adhoc reads, etc) that will be queued before back-pre...
Definition: dnp3.hpp:2627
EventClasses disable_unsol_classes
Classes to disable unsolicited responses at startup.
Definition: dnp3.hpp:2607
bool auto_integrity_scan_on_buffer_overflow
Automatic integrity scan when an EVENT_BUFFER_OVERFLOW is detected.
Definition: dnp3.hpp:2623
RetryStrategy auto_tasks_retry_strategy
Automatic tasks retry strategy.
Definition: dnp3.hpp:2617
std::chrono::steady_clock::duration response_timeout
Timeout for receiving a response on this association.
Definition: dnp3.hpp:2605
Association identifier.
Definition: dnp3.hpp:2412
Binary Input configuration.
Definition: dnp3.hpp:3628
StaticBinaryInputVariation static_variation
Default static variation.
Definition: dnp3.hpp:3651
EventBinaryInputVariation event_variation
Default event variation.
Definition: dnp3.hpp:3653
BinaryInputConfig()
Initialize to defaults.
binary_input point
Definition: dnp3.hpp:752
uint16_t index
Point index.
Definition: dnp3.hpp:767
Timestamp time
Point timestamp.
Definition: dnp3.hpp:773
bool value
Point value.
Definition: dnp3.hpp:769
BinaryInput(uint16_t index, bool value, const Flags &flags, const Timestamp &time)
Fully construct BinaryInput specifying the value of each field.
Flags flags
Point flags.
Definition: dnp3.hpp:771
Binary Output Status configuration.
Definition: dnp3.hpp:3744
EventBinaryOutputStatusVariation event_variation
Default event variation.
Definition: dnp3.hpp:3769
StaticBinaryOutputStatusVariation static_variation
Default static variation.
Definition: dnp3.hpp:3767
BinaryOutputStatusConfig()
Initialize to defaults.
binary_output_status point
Definition: dnp3.hpp:896
uint16_t index
Point index.
Definition: dnp3.hpp:911
BinaryOutputStatus(uint16_t index, bool value, const Flags &flags, const Timestamp &time)
Fully construct BinaryOutputStatus specifying the value of each field.
bool value
Point value.
Definition: dnp3.hpp:913
Flags flags
Point flags.
Definition: dnp3.hpp:915
Timestamp time
Point timestamp.
Definition: dnp3.hpp:917
Controls which types are reported during a Class 0 read.
Definition: dnp3.hpp:4445
ClassZeroConfig()
Initialize to default values.
bool analog_output_status
Include Analog Output Status in Class 0 reads.
Definition: dnp3.hpp:4492
bool binary
Include Binary Inputs in Class 0 reads.
Definition: dnp3.hpp:4480
bool frozen_counter
Include Frozen Counters in Class 0 reads.
Definition: dnp3.hpp:4488
bool analog
Include Analog Inputs in Class 0 reads.
Definition: dnp3.hpp:4490
bool octet_string
Include Binary Inputs in Class 0 reads.
Definition: dnp3.hpp:4496
bool binary_output_status
Include Binary Output Status in Class 0 reads.
Definition: dnp3.hpp:4484
bool double_bit_binary
Include Double-Bit Binary Inputs in Class 0 reads.
Definition: dnp3.hpp:4482
bool counter
Include Counters in Class 0 reads.
Definition: dnp3.hpp:4486
Class 0, 1, 2 and 3 config.
Definition: dnp3.hpp:2499
bool class3
Class 3 events.
Definition: dnp3.hpp:2544
bool class0
Class 0 (static data)
Definition: dnp3.hpp:2538
static Classes all()
Initialize all classes to true.
static Classes none()
Initialize all classes to false.
Classes(bool class0, bool class1, bool class2, bool class3)
Fully construct Classes specifying the value of each field.
bool class1
Class 1 events.
Definition: dnp3.hpp:2540
bool class2
Class 2 events.
Definition: dnp3.hpp:2542
Timing parameters for connection attempts.
Definition: dnp3.hpp:2366
std::chrono::steady_clock::duration reconnect_delay
Delay before attempting a connection after a disconnect.
Definition: dnp3.hpp:2395
std::chrono::steady_clock::duration min_connect_delay
Minimum delay between two connection attempts, doubles up to the maximum delay.
Definition: dnp3.hpp:2391
std::chrono::steady_clock::duration max_connect_delay
Maximum delay between two connection attempts.
Definition: dnp3.hpp:2393
ConnectStrategy()
Initialize to default values.
CROB (Group12Var1) control code.
Definition: dnp3.hpp:541
bool clear
Support for this field is optional. When the clear bit is set, the device shall remove pending contro...
Definition: dnp3.hpp:599
OpType op_type
This field is used in conjunction with the ControlCode::tcc field to specify a control operation.
Definition: dnp3.hpp:603
ControlCode(TripCloseCode tcc, bool clear, OpType op_type)
Initialize a ControlCode instance.
bool queue
This field is obsolete and should always be 0.
Definition: dnp3.hpp:601
static ControlCode from_op_type(OpType op_type)
Initialize a ControlCode instance from a OpType
TripCloseCode tcc
This field is used in conjunction with ControlCode::op_type to specify a control operation.
Definition: dnp3.hpp:597
static ControlCode from_tcc_and_op_type(TripCloseCode tcc, OpType op_type)
Initialize a ControlCode instance from a TripCloseCode and a OpType.
APDU Control field.
Definition: dnp3.hpp:474
bool fir
First fragment in the message.
Definition: dnp3.hpp:491
bool uns
Unsolicited response.
Definition: dnp3.hpp:497
bool fin
Final fragment of the message.
Definition: dnp3.hpp:493
bool con
Requires confirmation.
Definition: dnp3.hpp:495
uint8_t seq
Sequence number.
Definition: dnp3.hpp:499
Counter configuration.
Definition: dnp3.hpp:3809
StaticCounterVariation static_variation
Default static variation.
Definition: dnp3.hpp:3834
uint32_t deadband
Deadband value.
Definition: dnp3.hpp:3838
CounterConfig()
Initialize to defaults.
EventCounterVariation event_variation
Default event variation.
Definition: dnp3.hpp:3836
counter point
Definition: dnp3.hpp:968
uint16_t index
Point index.
Definition: dnp3.hpp:983
Timestamp time
Point timestamp.
Definition: dnp3.hpp:989
Flags flags
Point flags.
Definition: dnp3.hpp:987
uint32_t value
Point value.
Definition: dnp3.hpp:985
Counter(uint16_t index, uint32_t value, const Flags &flags, const Timestamp &time)
Fully construct Counter specifying the value of each field.
Controls the decoding of transmitted and received data at the application, transport,...
Definition: dnp3.hpp:359
TransportDecodeLevel transport
Controls transport segment layer decoding.
Definition: dnp3.hpp:400
DecodeLevel()
Initialize log levels to defaults.
AppDecodeLevel application
Controls application fragment decoding.
Definition: dnp3.hpp:398
LinkDecodeLevel link
Controls link frame decoding.
Definition: dnp3.hpp:402
static DecodeLevel nothing()
Initialize log levels to nothing.
PhysDecodeLevel physical
Controls the logging of physical layer read/write.
Definition: dnp3.hpp:404
Double-Bit Binary Input configuration.
Definition: dnp3.hpp:3687
EventDoubleBitBinaryInputVariation event_variation
Default event variation.
Definition: dnp3.hpp:3712
StaticDoubleBitBinaryInputVariation static_variation
Default static variation.
Definition: dnp3.hpp:3710
DoubleBitBinaryInputConfig()
Initialize to defaults.
double_bit_binary_input point
Definition: dnp3.hpp:824
DoubleBit value
Point value.
Definition: dnp3.hpp:841
DoubleBitBinaryInput(uint16_t index, DoubleBit value, const Flags &flags, const Timestamp &time)
Fully construct DoubleBitBinaryInput specifying the value of each field.
Flags flags
Point flags.
Definition: dnp3.hpp:843
uint16_t index
Point index.
Definition: dnp3.hpp:839
Timestamp time
Point timestamp.
Definition: dnp3.hpp:845
Maximum number of events for each type.
Definition: dnp3.hpp:4390
uint16_t max_counter
Maximum number of Counter events (g22)
Definition: dnp3.hpp:4431
uint16_t max_frozen_counter
Maximum number of Frozen Counter events (g23)
Definition: dnp3.hpp:4433
uint16_t max_binary
Maximum number of Binary Input events (g2)
Definition: dnp3.hpp:4425
uint16_t max_analog_output_status
Maximum number of Analog Output Status events (g42)
Definition: dnp3.hpp:4437
EventBufferConfig(uint16_t max_binary, uint16_t max_double_bit_binary, uint16_t max_binary_output_status, uint16_t max_counter, uint16_t max_frozen_counter, uint16_t max_analog, uint16_t max_analog_output_status, uint16_t max_octet_string)
Fully construct EventBufferConfig specifying the value of each field.
uint16_t max_octet_string
Maximum number of Octet String events (g111)
Definition: dnp3.hpp:4439
uint16_t max_analog
Maximum number of Analog Input events (g32)
Definition: dnp3.hpp:4435
static EventBufferConfig no_events()
Create a configuration where no events are buffered.
uint16_t max_binary_output_status
Maximum number of Binary Output Status events (g11)
Definition: dnp3.hpp:4429
uint16_t max_double_bit_binary
Maximum number of Double-Bit Binary Input events (g4)
Definition: dnp3.hpp:4427
Event classes.
Definition: dnp3.hpp:2453
bool class2
Class 2 events.
Definition: dnp3.hpp:2491
static EventClasses none()
Initialize all classes to false.
bool class1
Class 1 events.
Definition: dnp3.hpp:2489
EventClasses(bool class1, bool class2, bool class3)
Fully construct EventClasses specifying the value of each field.
static EventClasses all()
Initialize all classes to true.
bool class3
Class 3 events.
Definition: dnp3.hpp:2493
Collection of individual flag bits represented by an underlying mask value.
Definition: dnp3.hpp:650
Flags(uint8_t value)
Fully construct Flags specifying the value of each field.
uint8_t value
bit-mask representing a set of individual flag bits
Definition: dnp3.hpp:662
Frozen Counter configuration.
Definition: dnp3.hpp:3882
FrozenCounterConfig()
Initialize to defaults.
uint32_t deadband
Deadband value.
Definition: dnp3.hpp:3911
StaticFrozenCounterVariation static_variation
Default static variation.
Definition: dnp3.hpp:3907
EventFrozenCounterVariation event_variation
Default event variation.
Definition: dnp3.hpp:3909
frozen_counter point
Definition: dnp3.hpp:1040
Flags flags
Point flags.
Definition: dnp3.hpp:1059
Timestamp time
Point timestamp.
Definition: dnp3.hpp:1061
uint16_t index
Point index.
Definition: dnp3.hpp:1055
FrozenCounter(uint16_t index, uint32_t value, const Flags &flags, const Timestamp &time)
Fully construct FrozenCounter specifying the value of each field.
uint32_t value
Point value.
Definition: dnp3.hpp:1057
Control Relay Output Block.
Definition: dnp3.hpp:609
static Group12Var1 from_code(const ControlCode &code)
Construct a Group12Var1 from a ControlCode.
uint32_t off_time
Duration the output drive remains non-active (in milliseconds)
Definition: dnp3.hpp:644
uint32_t on_time
Duration the output drive remains active (in milliseconds)
Definition: dnp3.hpp:642
uint8_t count
Count.
Definition: dnp3.hpp:640
ControlCode code
Control code.
Definition: dnp3.hpp:638
Group12Var1(const ControlCode &code, uint8_t count, uint32_t on_time, uint32_t off_time)
Fully construct Group12Var1 specifying the value of each field.
Information about the object header and specific variation.
Definition: dnp3.hpp:2050
bool has_flags
true if a flags byte is present on the underlying variation, false otherwise
Definition: dnp3.hpp:2072
QualifierCode qualifier
Qualifier code used in the response.
Definition: dnp3.hpp:2068
Variation variation
underlying variation in the response
Definition: dnp3.hpp:2066
bool is_event
true if the received variation is an event type, false otherwise
Definition: dnp3.hpp:2070
First IIN byte.
Definition: dnp3.hpp:1898
bool need_time
Outstation requires time synchronization.
Definition: dnp3.hpp:1926
bool class_2_events
Outstation has unreported Class 2 events.
Definition: dnp3.hpp:1922
bool device_trouble
An abnormal, device-specific condition exists in the outstation.
Definition: dnp3.hpp:1930
bool local_control
One or more of the outstation’s points are in local control mode.
Definition: dnp3.hpp:1928
bool class_1_events
Outstation has unreported Class 1 events.
Definition: dnp3.hpp:1920
bool class_3_events
Outstation has unreported Class 3 events.
Definition: dnp3.hpp:1924
bool broadcast
Broadcast message was received.
Definition: dnp3.hpp:1918
bool device_restart
Outstation restarted.
Definition: dnp3.hpp:1932
Second IIN byte.
Definition: dnp3.hpp:1938
bool object_unknown
Outstation does not support requested operation for objects in the request.
Definition: dnp3.hpp:1960
bool config_corrupt
The outstation detected corrupt configuration (optional support)
Definition: dnp3.hpp:1968
bool reserved_2
Reserved for future use - should always be set to 0.
Definition: dnp3.hpp:1970
bool event_buffer_overflow
An event buffer overflow condition exists in the outstation, and at least one unconfirmed event was l...
Definition: dnp3.hpp:1964
bool no_func_code_support
Outstation does not support this function code.
Definition: dnp3.hpp:1958
bool reserved_1
Reserved for future use - should always be set to 0.
Definition: dnp3.hpp:1972
bool already_executing
The operation requested is already executing (optional support)
Definition: dnp3.hpp:1966
bool parameter_error
Outstation does not support requested operation for objects in the request.
Definition: dnp3.hpp:1962
Pair of IIN bytes.
Definition: dnp3.hpp:1978
Iin2 iin2
Second IIN byte.
Definition: dnp3.hpp:1994
Iin1 iin1
First IIN byte.
Definition: dnp3.hpp:1992
Logging configuration options.
Definition: dnp3.hpp:189
LogOutputFormat output_format
output formatting options
Definition: dnp3.hpp:220
bool print_level
optionally print the log level as part to the message string
Definition: dnp3.hpp:224
LoggingConfig()
Initialize the configuration to default values.
TimeFormat time_format
optional time format
Definition: dnp3.hpp:222
bool print_module_info
optionally print the underlying Rust module information to the message string
Definition: dnp3.hpp:226
LogLevel level
logging level
Definition: dnp3.hpp:218
Generic configuration for a MasterChannel.
Definition: dnp3.hpp:2194
DecodeLevel decode_level
Decoding level for this master. You can modify this later on with MasterChannel::set_decode_level().
Definition: dnp3.hpp:2224
uint16_t address
Local DNP3 data-link address.
Definition: dnp3.hpp:2222
MasterChannelConfig(uint16_t address)
Initialize MasterChannelConfig to default values.
uint16_t tx_buffer_size
TX buffer size.
Definition: dnp3.hpp:2228
uint16_t rx_buffer_size
RX buffer size.
Definition: dnp3.hpp:2232
Octet String point.
Definition: dnp3.hpp:1301
uint16_t index
Point index.
Definition: dnp3.hpp:1315
ByteIterator value
Point value.
Definition: dnp3.hpp:1317
Outstation configuration.
Definition: dnp3.hpp:4537
uint32_t max_unsolicited_retries
Maximum number of unsolicited retries.
Definition: dnp3.hpp:4615
uint16_t max_controls_per_request
Maximum number of controls in a single request.
Definition: dnp3.hpp:4627
DecodeLevel decode_level
Decoding level.
Definition: dnp3.hpp:4607
uint16_t unsolicited_buffer_size
Unsolicited response buffer size.
Definition: dnp3.hpp:4601
OutstationFeatures features
Optional features.
Definition: dnp3.hpp:4613
OutstationConfig(uint16_t outstation_address, uint16_t master_address, const EventBufferConfig &event_buffer_config)
Initialize to defaults.
std::chrono::steady_clock::duration select_timeout
Select timeout.
Definition: dnp3.hpp:4611
std::chrono::steady_clock::duration unsolicited_retry_delay
Delay to wait before retrying an unsolicited response.
Definition: dnp3.hpp:4617
std::chrono::steady_clock::duration keep_alive_timeout
Delay of inactivity before sending a REQUEST_LINK_STATUS to the master.
Definition: dnp3.hpp:4621
std::chrono::steady_clock::duration confirm_timeout
Confirmation timeout.
Definition: dnp3.hpp:4609
ClassZeroConfig class_zero
Controls responses to Class 0 reads.
Definition: dnp3.hpp:4629
uint16_t max_read_request_headers
Maximum number of headers that will be processed in a READ request.
Definition: dnp3.hpp:4625
uint16_t master_address
Link-layer master address.
Definition: dnp3.hpp:4591
EventBufferConfig event_buffer_config
Event buffer sizes configuration.
Definition: dnp3.hpp:4593
uint16_t outstation_address
Link-layer outstation address.
Definition: dnp3.hpp:4589
uint16_t solicited_buffer_size
Solicited response buffer size.
Definition: dnp3.hpp:4597
uint16_t rx_buffer_size
Receive buffer size.
Definition: dnp3.hpp:4605
Optional outstation features that can be enabled or disabled.
Definition: dnp3.hpp:4502
bool broadcast
Process valid broadcast messages.
Definition: dnp3.hpp:4529
OutstationFeatures()
Initialize to default values.
bool self_address
Respond to the self address.
Definition: dnp3.hpp:4527
bool unsolicited
Respond to enable/disable unsolicited response and produce unsolicited responses.
Definition: dnp3.hpp:4531
Poll identifier.
Definition: dnp3.hpp:2431
Application-layer header for requests.
Definition: dnp3.hpp:4839
ControlField control_field
Control field.
Definition: dnp3.hpp:4853
FunctionCode function
Function code.
Definition: dnp3.hpp:4855
Response header information.
Definition: dnp3.hpp:2000
ResponseFunction func
Response type.
Definition: dnp3.hpp:2017
Iin iin
IIN bytes.
Definition: dnp3.hpp:2019
ControlField control_field
Application control field.
Definition: dnp3.hpp:2015
Restart delay used by OutstationApplication::cold_restart() and OutstationApplication::warm_restart()
Definition: dnp3.hpp:4652
static RestartDelay not_supported()
RestartDelay indicating that the request is not supported.
static RestartDelay milliseconds(uint16_t value)
RestartDelay with a count of milliseconds.
uint16_t value
Expected delay before the outstation comes back online.
Definition: dnp3.hpp:4698
static RestartDelay seconds(uint16_t value)
RestartDelay with a count of seconds.
RestartDelayType restart_type
Indicates what RestartDelay::value is.
Definition: dnp3.hpp:4696
Retry strategy configuration.
Definition: dnp3.hpp:1629
RetryStrategy()
Initialize to defaults.
std::chrono::steady_clock::duration max_delay
Maximum delay between two retries.
Definition: dnp3.hpp:1654
std::chrono::steady_clock::duration min_delay
Minimum delay between two retries.
Definition: dnp3.hpp:1652
Runtime configuration.
Definition: dnp3.hpp:412
uint16_t num_core_threads
Number of runtime threads to spawn. For a guess of the number of CPU cores, use 0.
Definition: dnp3.hpp:435
RuntimeConfig()
Initialize the configuration to default values.
Serial port settings.
Definition: dnp3.hpp:1720
StopBits stop_bits
Number of bits to use to signal the end of a character.
Definition: dnp3.hpp:1757
FlowControl flow_control
Type of signalling to use for controlling data transfer.
Definition: dnp3.hpp:1753
Parity parity
Type of parity to use for error checking.
Definition: dnp3.hpp:1755
SerialSettings()
Initialize to default values.
uint32_t baud_rate
Baud rate (in symbols-per-second)
Definition: dnp3.hpp:1749
DataBits data_bits
Number of bits used to represent a character sent on the line.
Definition: dnp3.hpp:1751
Timestamp value.
Definition: dnp3.hpp:683
static Timestamp synchronized_timestamp(uint64_t value)
Creates a synchronized timestamp struct.
static Timestamp invalid_timestamp()
Creates an invalid timestamp struct.
TimeQuality quality
Timestamp quality.
Definition: dnp3.hpp:729
static Timestamp unsynchronized_timestamp(uint64_t value)
Creates an unsynchronized timestamp struct.
uint64_t value
Timestamp value.
Definition: dnp3.hpp:727
TLS client configuration.
Definition: dnp3.hpp:2310
MinTlsVersion min_tls_version
Minimum TLS version allowed.
Definition: dnp3.hpp:2358
CertificateMode certificate_mode
Certificate validation mode.
Definition: dnp3.hpp:2360
TlsClientConfig(const std::string &dns_name, const std::string &peer_cert_path, const std::string &local_cert_path, const std::string &private_key_path, const std::string &password)
construct the configuration with defaults
std::string peer_cert_path
Path to the PEM-encoded certificate of the peer.
Definition: dnp3.hpp:2346
std::string local_cert_path
Path to the PEM-encoded local certificate.
Definition: dnp3.hpp:2348
std::string private_key_path
Path to the the PEM-encoded private key.
Definition: dnp3.hpp:2350
std::string password
Optional password if the private key file is encrypted.
Definition: dnp3.hpp:2356
std::string dns_name
Expected name to validate in the presented certificate (only in CertificateMode::authority_based mode...
Definition: dnp3.hpp:2344
TLS server configuration.
Definition: dnp3.hpp:5291
std::string dns_name
Expected name to validate in the presented certificate (only in CertificateMode::authority_based mode...
Definition: dnp3.hpp:5325
CertificateMode certificate_mode
Certificate validation mode.
Definition: dnp3.hpp:5341
std::string local_cert_path
Path to the PEM-encoded local certificate.
Definition: dnp3.hpp:5329
MinTlsVersion min_tls_version
Minimum TLS version allowed.
Definition: dnp3.hpp:5339
std::string password
Optional password if the private key file is encrypted.
Definition: dnp3.hpp:5337
std::string peer_cert_path
Path to the PEM-encoded certificate of the peer.
Definition: dnp3.hpp:5327
std::string private_key_path
Path to the the PEM-encoded private key.
Definition: dnp3.hpp:5331
TlsServerConfig(const std::string &dns_name, const std::string &peer_cert_path, const std::string &local_cert_path, const std::string &private_key_path, const std::string &password)
construct the configuration with defaults
Options that control how the update is performed.
Definition: dnp3.hpp:3558
static UpdateOptions detect_event()
Default event detection mode. Updates the static value and automatically detects event.
EventMode event_mode
Determines how/if an event is produced.
Definition: dnp3.hpp:3594
bool update_static
Optionally bypass updating the static database (the current value)
Definition: dnp3.hpp:3592
static UpdateOptions no_event()
Only update the static value. Usefull during initialization of the database.
Timestamp value returned by AssociationHandler::get_current_time().
Definition: dnp3.hpp:2635
static UtcTimestamp invalid()
Construct an invalid UtcTimestamp.
uint64_t value
Value of the timestamp (in milliseconds from UNIX Epoch).
Definition: dnp3.hpp:2671
static UtcTimestamp valid(uint64_t value)
Construct a valid UtcTimestamp.
bool is_valid
True if the timestamp is valid, false otherwise.
Definition: dnp3.hpp:2673