Outstation Configuration
You create outstations using three types of components:
- Static configuration values
- Callback interfaces
- Transport-specific configuration (e.g., TCP vs. serial parameters)
Let's look at the static configuration required to create an outstation.
OutstationConfig
The OutstationConfig
structure contains the parameters that modify the behavior of the outstation. The generated API documentation provides a definition for each field. All fields have default values except for the master and outstation link addresses. Keep in mind that we didn't optimize these default values for every use case; for example, you may need to adjust the timeout parameters for higher latency links.
- Rust
- C
- C++
- Java
- C#
// create an outstation configuration with default values
let mut config = OutstationConfig::new(
// outstation address
EndpointAddress::try_new(1024).unwrap(),
// master address
EndpointAddress::try_new(1).unwrap(),
get_event_buffer_config(),
);
// override the default decoding
config.decode_level.application = AppDecodeLevel::ObjectValues;
dnp3_outstation_config_t get_outstation_config()
{
// create an outstation configuration with default values
dnp3_outstation_config_t config = dnp3_outstation_config_init(
// outstation address
1024,
// master address
1,
// event buffer sizes
get_event_buffer_config()
);
// override the default application decoding level
config.decode_level.application = DNP3_APP_DECODE_LEVEL_OBJECT_VALUES;
return config;
}
dnp3::OutstationConfig get_outstation_config()
{
dnp3::OutstationConfig config(1024, 1, get_event_buffer_config());
config.decode_level.application = dnp3::AppDecodeLevel::object_values;
return config;
}
// create an outstation configuration with default values
OutstationConfig config =
new OutstationConfig(
// outstation address
ushort(1024),
// master address
ushort(1),
// event buffer sizes
getEventBufferConfig())
.withDecodeLevel(new DecodeLevel().withApplication(AppDecodeLevel.OBJECT_VALUES));
// create an outstation configuration with default values
var config = new OutstationConfig(
// outstation address
1024,
// master address
1,
// event buffer sizes
GetEventBufferConfig()
).WithDecodeLevel(DecodeLevel.Nothing().WithApplication(AppDecodeLevel.ObjectValues));
EventBufferConfig
The EventBufferConfig
struct controls the number of events buffered for each type that the outstation can report. During the outstation initialization, space is internally pre-allocated for each type based on this configuration. When all the space in the buffer for a particular type has been used, adding another event will cause the oldest event to be discarded, and the outstation will assert IIN 2.3 (Event Buffer Overflow) per the specification.
When determining how many events to configure, remember that there is a fundamental tradeoff between saving events for future reporting and your memory/CPU usage. Determine your event buffer sizes based on these factors:
- How many measurements the outstation database contains
- How often the measurements change
- How often and for how long the master may be disconnected or otherwise unable to empty the event queues via READ or unsolicited reporting
- How important it is to preserve events for a particular type.
Not all events are created equal. For example, it may be important to capture every binary state transition, while missing an analog or counter value might not matter at all.
- Rust
- C
- C++
- Java
- C#
// Rust example only uses analogs so that's all we need to configure
fn get_event_buffer_config() -> EventBufferConfig {
EventBufferConfig::all_types(100)
}
dnp3_event_buffer_config_t get_event_buffer_config()
{
return dnp3_event_buffer_config_init(10, // binary
10, // double-bit binary
10, // binary output status
5, // counter
5, // frozen counter
5, // analog
5, // analog output status
3 // octet string
);
}
dnp3::EventBufferConfig get_event_buffer_config()
{
return EventBufferConfig(10, 10, 10, 10, 10, 10, 10, 10);
}
private static EventBufferConfig getEventBufferConfig() {
return new EventBufferConfig(
ushort(10), // binary
ushort(10), // double-bit binary
ushort(10), // binary output status
ushort(5), // counter
ushort(5), // frozen counter
ushort(5), // analog
ushort(5), // analog output status
ushort(3) // octet string
);
}
private static EventBufferConfig GetEventBufferConfig()
{
return new EventBufferConfig(
10, // binary
10, // double-bit binary
10, // binary output status
5, // counter
5, // frozen counter
5, // analog
5, // analog output status
3 // octet string
);
}
Setting the number of events for a particular type to 0
ensures that you will never record or report events for that type.