|
|
@ -29,13 +29,18 @@ public class SensorCollector { |
|
|
|
ScheduledExecutorService executorService = Executors.newSingleThreadScheduledExecutor(); |
|
|
|
executorService.scheduleAtFixedRate(() -> { |
|
|
|
try { |
|
|
|
DeviceCommand humidityGetCmd = DeviceCommandGenerator.humidityGet(); // 生成获取湿度指令 |
|
|
|
DeviceCommand humidityGetCmd = DeviceCommandGenerator.humidityGet(); |
|
|
|
CommandFuture humidityGetCmdFuture = deviceCommandService.sendCommandNoFront(humidityGetCmd); |
|
|
|
commandWait(humidityGetCmdFuture); |
|
|
|
DeviceCommand getSlidePlatHeat = DeviceCommandGenerator.getSlidePlatHeat(); |
|
|
|
CommandFuture getSlidePlatHeatFuture = deviceCommandService.sendCommandNoFront(getSlidePlatHeat); |
|
|
|
commandWait(humidityGetCmdFuture,getSlidePlatHeatFuture); |
|
|
|
JSONObject humidityGetCmdFutureResult = humidityGetCmdFuture.getResponseResult(); |
|
|
|
JSONObject getSlidePlatHeatFutureResult = getSlidePlatHeatFuture.getResponseResult(); |
|
|
|
Double deviceHumidity = humidityGetCmdFutureResult.getJSONObject("data").getDouble("humidity"); |
|
|
|
Double temperature = getSlidePlatHeatFutureResult.getJSONObject("data").getDouble("temperature"); |
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
map.put("humidity", deviceHumidity); |
|
|
|
map.put("temperature", temperature); |
|
|
|
webSocketService.pushMsgNoLog(WebSocketMessageType.SENSOR, map); |
|
|
|
} catch (Exception ignored) { |
|
|
|
} |
|
|
|