use of com.automatak.dnp3.OutstationStackConfig in project solarnetwork-node by SolarNetwork.
the class OutstationService method createOutstationStackConfig.
private OutstationStackConfig createOutstationStackConfig() {
Map<MeasurementType, List<MeasurementConfig>> configs = measurementTypeMap(getMeasurementConfigs());
Map<ControlType, List<ControlConfig>> controlConfigs = controlTypeMap(getControlConfigs());
OutstationStackConfig config = new OutstationStackConfig(createDatabaseConfig(configs, controlConfigs), createEventBufferConfig(configs, controlConfigs));
copySettings(getLinkLayerConfig(), config.linkConfig);
copySettings(getOutstationConfig(), config.outstationConfig);
return config;
}
use of com.automatak.dnp3.OutstationStackConfig in project solarnetwork-node by SolarNetwork.
the class OutstationDemo method run.
public static void run(DNP3Manager manager) throws Exception {
// Create a tcp channel class that will connect to the loopback
Channel channel = manager.addTCPServer("client", LogMasks.NORMAL | LogMasks.APP_COMMS, ServerAcceptMode.CloseNew, "127.0.0.1", 20000, new Slf4jChannelListener());
// Create the default outstation configuration
OutstationStackConfig config = new OutstationStackConfig(DatabaseConfig.allValues(5), EventBufferConfig.allTypes(50));
// Create an Outstation instance, pass in a simple a command handler that responds successfully to everything
Outstation outstation = channel.addOutstation("outstation", SuccessCommandHandler.getInstance(), DefaultOutstationApplication.getInstance(), config);
outstation.enable();
// all this stuff just to read a line of text in Java. Oh the humanity.
String line = "";
InputStreamReader converter = new InputStreamReader(System.in);
BufferedReader in = new BufferedReader(converter);
int i = 0;
while (true) {
System.out.println("Enter something to update a counter or type <quit> to exit");
line = in.readLine();
if (line.equals("quit"))
break;
else {
OutstationChangeSet set = new OutstationChangeSet();
set.update(new Counter(i, (byte) 0x01, 0), 0);
outstation.apply(set);
++i;
}
}
}
Aggregations