| | |
| | | } |
| | | |
| | | @Test |
| | | void developmentSimulatorSupportsNewareProfilesAndDynamicObservation() throws Exception |
| | | void developmentSimulatorSupportsNewareProfilesAndFixedObservation() throws Exception |
| | | { |
| | | try (BtsDevelopmentSimulator simulator = new BtsDevelopmentSimulator(0); |
| | | BtsTcpTransport transport = new BtsTcpTransport("127.0.0.1", simulator.port(), |
| | |
| | | var first = adapter.inquire(channel).values().iterator().next(); |
| | | var second = adapter.inquire(channel).values().iterator().next(); |
| | | assertEquals(DeviceWorkStatus.WORKING, first.workStatus()); |
| | | assertNotEquals(first.currentA(), second.currentA()); |
| | | assertEquals(first.currentA(), second.currentA()); |
| | | assertTrue(first.voltageV().doubleValue() >= 0.0 && first.voltageV().doubleValue() <= 5.0); |
| | | } |
| | | } |
| | | |
| | | @Test |
| | | void configuredChannelValuesReachBtsInquireWithoutClampingOrRounding() throws Exception |
| | | { |
| | | try (var simulator = new BtsDevelopmentSimulator(0); |
| | | var transport = new BtsTcpTransport("127.0.0.1", simulator.port(), Duration.ofSeconds(1), Duration.ofSeconds(1)); |
| | | DeviceAdapter adapter = new BtsDeviceAdapter("dev-sim", transport, |
| | | new BtsXmlCodec("dev-sim", ZoneId.of("Asia/Hong_Kong")))) { |
| | | simulator.configureChannel(1, 1, new com.battery.device.simulator.BtsSimulatorStateStore.ChannelConfiguration( |
| | | new java.math.BigDecimal("-2.123456"), new java.math.BigDecimal("8.125"), |
| | | new java.math.BigDecimal("7.2"), new java.math.BigDecimal("29.7"), 2, 2, 5, 120, 30, |
| | | List.of(new com.battery.device.simulator.BtsSimulatorStateStore.SimulatorPlanStep("充电", "cc", 60, 4.2), |
| | | new com.battery.device.simulator.BtsSimulatorStateStore.SimulatorPlanStep("放电 <验证>", "dc", 90, 3.0)))); |
| | | var channel = adapter.discoverChannels().stream().filter(item -> item.identity().chlid() == 1) |
| | | .findFirst().orElseThrow().identity(); |
| | | var observation = adapter.inquire(Set.of(channel)).get(channel); |
| | | assertEquals(-2.123456, observation.currentA().doubleValue()); |
| | | assertEquals(8.125, observation.voltageV().doubleValue()); |
| | | assertEquals(7.2, observation.capacityAh().doubleValue()); |
| | | assertEquals(29.7, observation.energyWh().doubleValue()); |
| | | assertEquals(2, observation.cycleNo()); |
| | | assertEquals(2, observation.stepNo()); |
| | | assertEquals("dc", observation.stepType()); |
| | | assertEquals(120L, observation.totalTimeSeconds()); |
| | | assertEquals(30L, observation.relativeTimeSeconds()); |
| | | } |
| | | } |
| | | |
| | | @Test |
| | | void developmentSimulatorPersistsNewareProfileMetadata() throws Exception |
| | | { |
| | | InMemoryBtsSimulatorStateStore store = new InMemoryBtsSimulatorStateStore(); |