dnp3 / opendnp3

DNP3 (IEEE-1815) protocol stack. Modern C++ with bindings for .NET and Java.
https://dnp3.github.io
Apache License 2.0
300 stars 231 forks source link

Trying to undestando the OutstationStackConfig #424

Closed ejs94 closed 3 years ago

ejs94 commented 3 years ago

I am developing a project that will need to use DNP3 and experimenting with the library on a raspberry pi. After mixing a little bit of what exists in the https://github.com/dnp3/rpi-dnp3-gpio repository with the demo outstation example. I'm using a master scada, and several extra points are consuming tags. So, how to create only binary or analog points and not all of each type? I know that the library version of the rpi repository is older, but I would like to know how to make a configuration in the current version of opendnp3.

In the main.cpp from rpi-dnp3-gpio

OutstationStackConfig stack(
        DatabaseSizes(
            config.inputs.size(), 0, 0, 0, 0,
            config.outputs.size(), 0, 0
        )
    );

In the main.cpp from outstation example

DatabaseConfig ConfigureDatabase()
{
    DatabaseConfig config(10); // 10 of each type with default settings

    config.analog_input[0].clazz = PointClass::Class2;
    config.analog_input[0].svariation = StaticAnalogVariation::Group30Var5;
    config.analog_input[0].evariation = EventAnalogVariation::Group32Var7;

    return config;
}
emgre commented 3 years ago

To create an outstation with only binary and analog points, simply call the default constructor of DatabaseConfig then fill the maps with only the points you want. Something like that:

DatabaseConfig ConfigureDatabase()
{
    DatabaseConfig config();

    config.binary_input[0] = {};
    config.binary_input[1] = {};
    config.binary_input[2] = {};

    config.analog_input[0] = {};
    config.analog_input[1] = {};
    config.analog_input[2] = {};

    return config;
}

You can of course customize the point configuration. I went with the default constructor for simplicity.