use of com.automatak.dnp3.DatabaseConfig in project solarnetwork-node by SolarNetwork.
the class OutstationService method createDatabaseConfig.
private DatabaseConfig createDatabaseConfig(Map<MeasurementType, List<MeasurementConfig>> configs, Map<ControlType, List<ControlConfig>> controlConfigs) {
int analogCount = 0;
int aoStatusCount = 0;
int binaryCount = 0;
int boStatusCount = 0;
int counterCount = 0;
int doubleBinaryCount = 0;
int frozenCounterCount = 0;
StringBuilder infoBuf = new StringBuilder();
if (configs != null) {
for (Map.Entry<MeasurementType, List<MeasurementConfig>> me : configs.entrySet()) {
MeasurementType type = me.getKey();
List<MeasurementConfig> list = me.getValue();
if (type == null || list == null || list.isEmpty()) {
continue;
}
switch(type) {
case AnalogInput:
analogCount = list.size();
appendMeasurementInfos(infoBuf, type, list);
break;
case AnalogOutputStatus:
aoStatusCount = list.size();
break;
case BinaryInput:
binaryCount = list.size();
appendMeasurementInfos(infoBuf, type, list);
break;
case BinaryOutputStatus:
boStatusCount = list.size();
break;
case Counter:
counterCount = list.size();
appendMeasurementInfos(infoBuf, type, list);
break;
case DoubleBitBinaryInput:
doubleBinaryCount = list.size();
appendMeasurementInfos(infoBuf, type, list);
break;
case FrozenCounter:
frozenCounterCount = list.size();
appendMeasurementInfos(infoBuf, type, list);
break;
}
}
}
if (controlConfigs != null) {
for (Map.Entry<ControlType, List<ControlConfig>> me : controlConfigs.entrySet()) {
ControlType type = me.getKey();
List<ControlConfig> list = me.getValue();
if (type == null || list == null || list.isEmpty()) {
continue;
}
switch(type) {
case Analog:
appendControlInfos(infoBuf, type, list, aoStatusCount);
aoStatusCount += list.size();
break;
case Binary:
appendControlInfos(infoBuf, type, list, boStatusCount);
boStatusCount += list.size();
break;
}
}
}
log.info("DNP3 outstation [{}] database configured with following registers:\n{}", getUid(), infoBuf);
return new DatabaseConfig(binaryCount, doubleBinaryCount, analogCount, counterCount, frozenCounterCount, boStatusCount, aoStatusCount);
}
Aggregations