| | |
| | | if (battery.getBinding() != null) |
| | | sources.add(snapshotFor(cabinetSource(battery, cabinets), receiving)); |
| | | if (battery.getCollectorId() != null) |
| | | sources.add(snapshotFor(collectorSource(battery), receiving)); |
| | | sources.add(collectorSource(battery, receiving)); |
| | | } |
| | | List<Map<String, Object>> exceptions = new ArrayList<>(); |
| | | if (receiving) |
| | |
| | | return value; |
| | | } |
| | | |
| | | private LiveSource collectorSource(TTestBattery battery) |
| | | private LiveSource collectorSource(TTestBattery battery, boolean receiving) |
| | | { |
| | | if (adapter == null || mapper == null) return new LiveSource("COLLECTOR", battery.getCollectorId(), battery.getBatteryNo(), |
| | | "OFFLINE", Map.of()); |
| | | var collector = adapter.latestCollector(mapper.selectCollectorCode(battery.getCollectorId())); |
| | | String collectorCode = mapper.selectCollectorCode(battery.getCollectorId()); |
| | | // 非接收状态只读设备发现事实,不能先请求测量再隐藏,否则仍会产生新观测。 |
| | | if (!receiving) |
| | | { |
| | | boolean online = candidates.findCollector(collectorCode, Instant.now()) |
| | | .map(DeviceDiscoveryCandidateStore.CollectorCandidate::online).orElse(false); |
| | | return new LiveSource("COLLECTOR", battery.getCollectorId(), battery.getBatteryNo(), |
| | | online ? "ONLINE" : "OFFLINE", Map.of()); |
| | | } |
| | | var collector = adapter.latestCollector(collectorCode); |
| | | if (collector != null) |
| | | { |
| | | Map<String, Object> value = new LinkedHashMap<>(); |