yeg
2026-09-04 b41d317e9b76b1158a9d21257698e55194bb39f5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package com.ruoyi.config;
 
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.context.annotation.Profile;
import com.battery.device.simulator.BtsDevelopmentSimulator;
import com.battery.device.registry.DeviceAdapterRegistry;
import com.ruoyi.system.service.impl.DeviceDiscoveryPersistenceService;
import com.ruoyi.system.service.impl.DeviceDiscoveryPersistenceService.DiscoverySource;
 
/** 轮询代码固定装配的 dev-sim;该运行时不依赖数据库适配器记录。 */
@Component
@Profile("dev-simulator")
public class DevelopmentSimulatorDiscoveryScheduler
{
    private final DeviceAdapterRegistry registry;
    private final DeviceDiscoveryPersistenceService persistence;
    public DevelopmentSimulatorDiscoveryScheduler(DeviceAdapterRegistry registry,
            DeviceDiscoveryPersistenceService persistence)
    {
        this.registry = registry;
        this.persistence = persistence;
    }
 
    /** 注册表已包含固定开发适配器时,将一轮检测柜观测写入 Redis 候选。 */
    @Scheduled(fixedDelay = BtsDevelopmentSimulator.POLL_INTERVAL_MS)
    public void discover()
    {
        if (!registry.contains(BtsDevelopmentSimulator.ADAPTER_CODE)) return;
        persistence.discoverForReception(registry, new DiscoverySource(BtsDevelopmentSimulator.ADAPTER_CODE, null,
                BtsDevelopmentSimulator.ADAPTER_NAME, BtsDevelopmentSimulator.POLL_INTERVAL_MS));
    }
}