Search in sources :

Example 1 with OutstationStackConfig

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;
}
Also used : MeasurementType(net.solarnetwork.node.io.dnp3.domain.MeasurementType) OutstationStackConfig(com.automatak.dnp3.OutstationStackConfig) List(java.util.List) ArrayList(java.util.ArrayList) ControlType(net.solarnetwork.node.io.dnp3.domain.ControlType)

Example 2 with OutstationStackConfig

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;
        }
    }
}
Also used : Slf4jChannelListener(net.solarnetwork.dnp3.util.Slf4jChannelListener) Outstation(com.automatak.dnp3.Outstation) Counter(com.automatak.dnp3.Counter) InputStreamReader(java.io.InputStreamReader) OutstationChangeSet(com.automatak.dnp3.OutstationChangeSet) Channel(com.automatak.dnp3.Channel) OutstationStackConfig(com.automatak.dnp3.OutstationStackConfig) BufferedReader(java.io.BufferedReader)

Aggregations

OutstationStackConfig (com.automatak.dnp3.OutstationStackConfig)2 Channel (com.automatak.dnp3.Channel)1 Counter (com.automatak.dnp3.Counter)1 Outstation (com.automatak.dnp3.Outstation)1 OutstationChangeSet (com.automatak.dnp3.OutstationChangeSet)1 BufferedReader (java.io.BufferedReader)1 InputStreamReader (java.io.InputStreamReader)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Slf4jChannelListener (net.solarnetwork.dnp3.util.Slf4jChannelListener)1 ControlType (net.solarnetwork.node.io.dnp3.domain.ControlType)1 MeasurementType (net.solarnetwork.node.io.dnp3.domain.MeasurementType)1