| | |
| | | replaceCollector(DevelopmentCollectorSimulation.configureChannel(current, channelCode, metrics)); |
| | | } |
| | | |
| | | /** 模拟现场人工统一开关机;只改变模拟设备事实,不代表系统具备真实设备控制能力。 */ |
| | | public synchronized void setAllDevicesPoweredOn(boolean poweredOn) |
| | | { |
| | | List<DeviceState> devices = state.devices().stream() |
| | | .map(device -> new DeviceState(device.deviceId(), device.ip(), poweredOn, |
| | | device.channels().stream() |
| | | .map(channel -> new ChannelState(channel.channelId(), poweredOn, |
| | | DeviceWorkStatus.STOPPED)) |
| | | .toList())) |
| | | .toList(); |
| | | Instant changedAt = Instant.now(); |
| | | List<CollectorState> collectors = state.collectors().stream() |
| | | .map(collector -> DevelopmentCollectorSimulation.resize(collector, collector.ip(), |
| | | collector.channelCount(), poweredOn, changedAt)) |
| | | .toList(); |
| | | persist(new SimulatorState(state.version(), devices, collectors, state.nextDeviceId(), |
| | | state.nextCollectorId(), state.tombstones())); |
| | | } |
| | | |
| | | /** 按每台采集器自己的频率推进实时和历史采样。 */ |
| | | public synchronized void advanceCollectors(Instant now) |
| | | { |
| | | boolean hasOnlineCollector = false; |
| | | for (CollectorState collector : state.collectors()) |
| | | { |
| | | if (!collector.online()) continue; |
| | | hasOnlineCollector = true; |
| | | break; |
| | | } |
| | | if (!hasOnlineCollector) return; |
| | | List<CollectorState> collectors = new ArrayList<>(state.collectors().size()); |
| | | List<CollectorHistoryAppend> historyAppends = new ArrayList<>(); |
| | | for (CollectorState collector : state.collectors()) |