| | |
| | | /** 完整保存下一版模拟器状态。 */ |
| | | void save(SimulatorState state); |
| | | |
| | | /** 状态和独立历史全部校验通过后,提交兼容旧格式所需的迁移。 */ |
| | | default void completeValidatedRestore(SimulatorState state) { } |
| | | |
| | | /** 原子保存主状态并追加本轮新产生的原始历史。 */ |
| | | default void save(SimulatorState state, List<CollectorHistoryAppend> historyAppends) |
| | | { |
| | | if (!historyAppends.isEmpty()) |
| | | throw new UnsupportedOperationException("Collector history append is not supported"); |
| | | save(state); |
| | | } |
| | | |
| | | /** 读取指定采集器的只追加原始历史。 */ |
| | | default List<CollectorMeasurementRecord> loadCollectorHistory(String collectorCode) |
| | | { |
| | | return List.of(); |
| | | } |
| | | |
| | | /** 原子保存删除采集器后的主状态,并删除该采集器的独立历史。 */ |
| | | default void saveAndDeleteCollectorHistory(SimulatorState state, String collectorCode) |
| | | { |
| | | throw new UnsupportedOperationException("Atomic collector deletion is not supported"); |
| | | } |
| | | |
| | | /** 读取短期保留的最近请求。 */ |
| | | List<RecentRequest> loadRecentRequests(); |
| | | |
| | |
| | | String manufacturer, String model, int channelCount, boolean online, int sampleIntervalMs, |
| | | long nextSequence, Instant lastSampledAt, List<CollectorChannelState> channels, |
| | | List<CollectorRealtimeMeasurement> latestMeasurements, |
| | | List<CollectorMeasurementRecord> history, CollectorHistoryFaults historyFaults) |
| | | long historyRecordCount, CollectorHistoryFaults historyFaults) |
| | | { |
| | | public CollectorState |
| | | { |
| | | channels = List.copyOf(channels); |
| | | latestMeasurements = List.copyOf(latestMeasurements); |
| | | history = List.copyOf(history); |
| | | historyFaults = historyFaults == null ? CollectorHistoryFaults.none() : historyFaults; |
| | | } |
| | | |
| | |
| | | { |
| | | this(collectorId, deviceCode, ip, mac, name, manufacturer, model, channelCount, online, |
| | | DevelopmentCollectorSimulation.DEFAULT_SAMPLE_INTERVAL_MS, 1L, null, |
| | | DevelopmentCollectorSimulation.defaultChannels(channelCount), List.of(), List.of(), |
| | | DevelopmentCollectorSimulation.defaultChannels(channelCount), List.of(), 0L, |
| | | CollectorHistoryFaults.none()); |
| | | } |
| | | } |
| | |
| | | long sequenceId, Instant deviceTime, String deviceTimeRaw, Instant serverReceivedAt, |
| | | String metricCode, BigDecimal value, String unit) { } |
| | | |
| | | record CollectorHistoryAppend(String collectorCode, List<CollectorMeasurementRecord> records) |
| | | { |
| | | public CollectorHistoryAppend { records = List.copyOf(records); } |
| | | } |
| | | |
| | | record CollectorHistoryFaults(List<Long> missingSequences, Long duplicateSequence, |
| | | Long conflictingSequence, boolean outOfOrder) |
| | | { |