forked from dnp3/pifacertu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPifaceRTU.cpp
43 lines (31 loc) · 1.17 KB
/
PifaceRTU.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include <asiodnp3/DNP3Manager.h>
#include <asiodnp3/ConsoleLogger.h>
#include <opendnp3/outstation/OutstationStackConfig.h>
#include <opendnp3/LogLevels.h>
#include "PifaceIOHandler.h"
#include <thread>
#include <chrono>
using namespace std;
using namespace openpal;
using namespace opendnp3;
using namespace asiodnp3;
int main(int argc, char* argv[])
{
PifaceIOHandler ioHandler; // handles control request, input polling, and measurement tracking/updates
const uint32_t FILTERS = levels::NORMAL;
DNP3Manager dnp3(1, ConsoleLogger::Create());
auto channel = dnp3.AddTCPServer("server", FILTERS, ChannelRetry::Default(), "0.0.0.0", 20000);
OutstationStackConfig stackConfig;
stackConfig.dbTemplate = DatabaseTemplate::BinaryOnly(4);
stackConfig.outstation.eventBufferConfig = EventBufferConfig::AllTypes(10);
stackConfig.outstation.params.allowUnsolicited = true;
auto outstation = channel->AddOutstation("outstation", ioHandler, DefaultOutstationApplication::Instance(), stackConfig);
outstation->Enable();
do {
ioHandler.ReadMeasurements(outstation);
ioHandler.ProcessPulses();
this_thread::sleep_for( chrono::milliseconds(100) );
}
while(true);
return 0;
}