整理模拟器观测边界验收后的业务注释
对齐设备在线状态、暂停期间状态同步、模拟器配置与观测职责及实时预警边界说明,保持已验收功能不变。
| | |
| | | @Max(value = 10000, message = "通道数必须在1到10000之间") |
| | | private Integer channelCount; |
| | | |
| | | /** 在线状态:0正常,1异常。 */ |
| | | /** 接口在线状态:0在线,1离线;数据库保存 ONLINE/OFFLINE。 */ |
| | | private String onlineStatus; |
| | | |
| | | /** 进行中测试关联标记,供启禁用和删除校验使用,不写入检测柜表。 */ |
| | |
| | | import com.battery.business.domain.vo.TestTypeOptionVo; |
| | | import com.battery.business.domain.vo.TestUserOptionVo; |
| | | |
| | | /** 测试配置及其只追加审计的数据访问接口。 */ |
| | | /** 读写测试配置、成功接收数据、修订记录和异常处理事实。 */ |
| | | public interface TTestMapper |
| | | { |
| | | int deleteTestWarningExceptionsByTestId(Long testId); |
| | |
| | | |
| | | /** |
| | | * 发现候选与正式设备是两份事实;正式登记后仍需把成功观测同步到 MySQL。 |
| | | * 离线轮询只更新当前状态,不覆盖最后成功观测时间;暂停期间不会进入此路径。 |
| | | * 暂停期间仍同步设备状态,但不请求该测试的测量;离线不覆盖最后成功观测时间。 |
| | | */ |
| | | private void synchronizeRegisteredFacts(DiscoverySource source, List<DetectedChannel> detected, |
| | | Map<ChannelIdentity, RealtimeSnapshot> snapshots, Instant observedAt) |
| | |
| | | TestDataObservationAdapter adapter) |
| | | { this(tests, candidates, adapter, null); } |
| | | |
| | | /** 返回测试当前设备事实;接收中展示测量和实时提醒,历史异常处理状态不参与判定。 */ |
| | | @Override public LiveState current(Long testId) |
| | | { |
| | | TTest test = tests.selectTestById(testId); |
| | |
| | | TestWarningExceptionService warningExceptions, Clock clock) |
| | | { this.mapper = mapper; this.tests = tests; this.adapter = adapter; this.warningExceptions = warningExceptions; this.clock = clock; } |
| | | |
| | | /** 轮询接收中测试,记录绑定来源离线异常,并保存成功观测的实时槽位及设备汇总。 */ |
| | | /** 轮询接收中测试,判定实时超限和来源离线异常,并按独立周期保存成功观测。 */ |
| | | @Override @Transactional(rollbackFor = Exception.class) |
| | | public void captureReceivedData() |
| | | { |
| | |
| | | state.nextCollectorId(), tombstones)); |
| | | } |
| | | |
| | | /** 使用现场确认的新威检测柜 profile 新增设备,型号之外的控制语义仍保持只读。 */ |
| | | /** 按预设新威型号元数据新增模拟设备;真实协议和拓扑仍待现场验证。 */ |
| | | public synchronized int addNewareDevice(String ip, String model) |
| | | { |
| | | BtsDeviceProfile profile = newareProfile(model); |
| | |
| | | persist(next); |
| | | } |
| | | |
| | | /** 配置一个稳定 S 通道的固定或动态演示指标。 */ |
| | | /** 保存稳定 S 通道的固定测量值及自定义指标,下一次请求时形成观测。 */ |
| | | public synchronized void configureCollectorChannel(int collectorId, String channelCode, |
| | | List<CollectorMetricState> metrics) |
| | | { |
| | |
| | | return sequence; |
| | | } |
| | | |
| | | /** 返回控制页需要的运行状态快照。 */ |
| | | /** 返回模拟器配置、当前状态和最近请求,不触发新的设备观测。 */ |
| | | public synchronized StateSnapshot snapshot() |
| | | { |
| | | List<DeviceSnapshot> deviceSnapshots = state.devices().stream() |
| | |
| | | |
| | | private void persist(SimulatorState nextState) |
| | | { |
| | | // 写穿失败时保留当前内存副本,避免控制页显示未持久化状态。 |
| | | // 写穿失败时保留当前内存副本,避免模拟器页面显示未持久化状态。 |
| | | SimulatorState configured = new SimulatorState(nextState.version(), nextState.devices(), nextState.collectors(), |
| | | nextState.nextDeviceId(), nextState.nextCollectorId(), nextState.tombstones(), |
| | | state.softwareAccessible(), state.observationSequence()); |
| | |
| | | import com.battery.device.simulator.BtsSimulatorStateStore.CollectorMetricState; |
| | | import com.battery.device.simulator.DevelopmentCollectorSimulation.CollectorRealtimeSnapshot; |
| | | |
| | | /** 本机临时 BTS 模拟器控制 API。 */ |
| | | /** 本机开发模拟器的配置与观测 API,不向设备发送控制命令。 */ |
| | | @Anonymous |
| | | @RestController |
| | | @Profile("dev-simulator") |
| | |
| | | this(simulator, candidateStore, null); |
| | | } |
| | | |
| | | /** 返回临时控制页;匿名放行后仍由本机拦截器限制来源。 */ |
| | | /** 返回模拟器配置页;匿名放行后仍由本机拦截器限制来源。 */ |
| | | @GetMapping(value = "/dev/bts-simulator.html", produces = MediaType.TEXT_HTML_VALUE) |
| | | public Resource page() |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | /** 配置稳定 S 通道的固定和动态测量项。 */ |
| | | /** 保存稳定 S 通道的固定测量值及自定义指标,不产生新的成功观测。 */ |
| | | @PutMapping("/dev/bts-simulator/collectors/{collectorId}/channels/{channelCode}") |
| | | public StateSnapshot configureCollectorChannel(@PathVariable int collectorId, |
| | | @PathVariable String channelCode, @RequestBody CollectorChannelCommand command) |
| | |
| | | import com.battery.business.service.ITTestService; |
| | | import com.battery.business.service.ITestLiveService.LiveState; |
| | | |
| | | /** 实时流客户端断连时应结束连接而不触发全局异常处理。 */ |
| | | /** 验证当前测量、实时提醒与历史待办独立,以及实时流断连后的资源清理。 */ |
| | | class TTestLiveServiceImplTest |
| | | { |
| | | @Test |
| | |
| | | import com.battery.business.mapper.TTestMapper; |
| | | import com.battery.business.service.ITTestService; |
| | | |
| | | /** Ticket08 通过接收入口验证三类持久化事实。 */ |
| | | /** 通过接收入口验证三类持久化事实、实时预警和数据归属边界。 */ |
| | | @ExtendWith(OutputCaptureExtension.class) |
| | | class TestDataReceptionServiceImplTest |
| | | { |