|
|
@@ -3,6 +3,7 @@ package cz.senslog.watchdog.config;
|
|
|
import cz.senslog.watchdog.provider.Record;
|
|
|
import cz.senslog.watchdog.util.Tuple;
|
|
|
|
|
|
+import java.time.LocalTime;
|
|
|
import java.util.*;
|
|
|
|
|
|
public class MonitoredObjectsConfig {
|
|
|
@@ -20,7 +21,7 @@ public class MonitoredObjectsConfig {
|
|
|
Unit(String id, long interval) {
|
|
|
if (interval == -1) {
|
|
|
throw new IllegalArgumentException(String.format(
|
|
|
- "The unit '%s' does not contain 'interval' argument.", id
|
|
|
+ "The unit '%s' does not contain 'interval' argument.", id
|
|
|
));
|
|
|
}
|
|
|
this.id = id;
|
|
|
@@ -89,20 +90,29 @@ public class MonitoredObjectsConfig {
|
|
|
Set<String> unitIds = config.getAttributes();
|
|
|
Map<String, Unit> units = new HashMap<>(unitIds.size());
|
|
|
long minInterval = Long.MAX_VALUE, maxInterval = Long.MIN_VALUE;
|
|
|
+// LocalTime start = LocalTime.now().plusMinutes(1);
|
|
|
+
|
|
|
for (String unitId : unitIds) {
|
|
|
PropertyConfig unitConfig = config.getPropertyConfig(unitId);
|
|
|
long unitInterval = -1;
|
|
|
if (unitConfig.containsProperty("interval")) {
|
|
|
unitInterval = unitConfig.getIntegerProperty("interval");
|
|
|
}
|
|
|
+
|
|
|
+// if (unitConfig.containsProperty("startAt")) {
|
|
|
+// String stringStartAt = unitConfig.getStringProperty("startAt");
|
|
|
+// String[] split = stringStartAt.split(":"); // 0 - hours, 1 - minutes
|
|
|
+
|
|
|
+// start = LocalTime.of(Integer.parseInt(split[0]), Integer.parseInt(split[1]));
|
|
|
+// }
|
|
|
if (unitConfig.containsProperty("sensors")) {
|
|
|
Map<String, Sensor> sensors = new HashMap<>();
|
|
|
Object unitSensorsObj = unitConfig.getProperty("sensors");
|
|
|
if (unitSensorsObj instanceof List) {
|
|
|
- List<?> unitSensors = (List<?>)unitSensorsObj;
|
|
|
+ List<?> unitSensors = (List<?>) unitSensorsObj;
|
|
|
for (Object sensorIdObj : unitSensors) {
|
|
|
if (sensorIdObj instanceof Integer) {
|
|
|
- long sensorId = (Integer)sensorIdObj;
|
|
|
+ long sensorId = (Integer) sensorIdObj;
|
|
|
String sensorIdStr = String.valueOf(sensorId);
|
|
|
sensors.put(sensorIdStr, new Sensor(sensorIdStr, unitInterval));
|
|
|
}
|
|
|
@@ -126,6 +136,7 @@ public class MonitoredObjectsConfig {
|
|
|
maxInterval = Math.max(unitInterval, maxInterval);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
return new MonitoredObjectsConfig(units, minInterval, maxInterval);
|
|
|
}
|
|
|
|