| | |
| | | import java.io.IOException; |
| | | import java.util.List; |
| | | import org.springframework.boot.ApplicationRunner; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | | import org.springframework.scheduling.annotation.EnableScheduling; |
| | |
| | | } |
| | | |
| | | @Bean(destroyMethod = "close") |
| | | public BtsDevelopmentSimulator btsDevelopmentSimulator(BtsSimulatorStateStore stateStore) throws IOException |
| | | public BtsDevelopmentSimulator btsDevelopmentSimulator(BtsSimulatorStateStore stateStore, |
| | | @Value("${battery.dev-simulator.port:15020}") int simulatorPort) throws IOException |
| | | { |
| | | return new BtsDevelopmentSimulator(BtsDevelopmentSimulator.DEFAULT_PORT, stateStore); |
| | | return new BtsDevelopmentSimulator(simulatorPort, stateStore); |
| | | } |
| | | |
| | | @Bean |
| | | public ApplicationRunner registerDevelopmentSimulatorAdapter(DeviceAdapterRegistry registry) |
| | | public ApplicationRunner registerDevelopmentSimulatorAdapter(DeviceAdapterRegistry registry, |
| | | @Value("${battery.dev-simulator.port:15020}") int simulatorPort) |
| | | { |
| | | // 固定开发装配不进入 t_device_adapter,直接注册运行时实例。 |
| | | return arguments -> registry.synchronize(developmentSimulatorRuntimeConfig()); |
| | | return arguments -> registry.synchronize(developmentSimulatorRuntimeConfig(simulatorPort)); |
| | | } |
| | | |
| | | private AdapterInstanceConfig developmentSimulatorRuntimeConfig() |
| | | private AdapterInstanceConfig developmentSimulatorRuntimeConfig(int simulatorPort) |
| | | { |
| | | return new AdapterInstanceConfig(BtsDevelopmentSimulator.ADAPTER_CODE, "BTS", BtsDevelopmentSimulator.HOST, |
| | | BtsDevelopmentSimulator.DEFAULT_PORT, BtsDevelopmentSimulator.POLL_INTERVAL_MS, |
| | | simulatorPort, BtsDevelopmentSimulator.POLL_INTERVAL_MS, |
| | | "Asia/Hong_Kong", true, |
| | | new AdapterCapabilities(true, true, false, false)); |
| | | } |