diff --git a/src/main/java/com/iflytop/sgs/app/service/device/DeviceSensorService.java b/src/main/java/com/iflytop/sgs/app/service/device/DeviceSensorService.java index 8583381..c0a58d8 100644 --- a/src/main/java/com/iflytop/sgs/app/service/device/DeviceSensorService.java +++ b/src/main/java/com/iflytop/sgs/app/service/device/DeviceSensorService.java @@ -34,7 +34,9 @@ public class DeviceSensorService { }; return deviceStatusService.getInputState(deviceSensorCode.name()); } else { - if(heatModuleCode.equals(HeatModuleCode.heat_module_04)){return false;} + if (heatModuleCode.equals(HeatModuleCode.heat_module_04)) { + return false; + } return true; } @@ -85,7 +87,7 @@ public class DeviceSensorService { public Double getXYServoPosition(DevicePartId devicePartId) throws HardwareException { if (!deviceStateService.getDeviceState().isVirtual()) { return deviceStatusService.getXYServoPosition(devicePartId.name()); - }else { + } else { return 50.0; } } @@ -96,7 +98,7 @@ public class DeviceSensorService { public Integer readLiquidValvePosition() throws HardwareException { if (!deviceStateService.getDeviceState().isVirtual()) { return deviceStatusService.readLiquidValvePosition(DevicePartId.LiquidValve.name()); - }else { + } else { return 1; } } @@ -107,32 +109,59 @@ public class DeviceSensorService { */ public void collectSensorState() throws HardwareException { HeatModuleState heat_module_01 = deviceStateService.getDeviceState().getHeatModuleByCode(HeatModuleCode.heat_module_01); - heat_module_01.setTrayStatus(this.getSensorStatus(DeviceSensorCode.HEATER_TRAY_1_EXIST)); + if (heat_module_01 != null) { + heat_module_01.setTrayStatus(this.getSensorStatus(DeviceSensorCode.HEATER_TRAY_1_EXIST)); + }else{ + log.error("Heat module 01 not found"); + } HeatModuleState heat_module_02 = deviceStateService.getDeviceState().getHeatModuleByCode(HeatModuleCode.heat_module_02); - heat_module_02.setTrayStatus(this.getSensorStatus(DeviceSensorCode.HEATER_TRAY_2_EXIST)); + if (heat_module_02 != null) { + heat_module_02.setTrayStatus(this.getSensorStatus(DeviceSensorCode.HEATER_TRAY_2_EXIST)); + }else{ + log.error("Heat module 02 not found"); + } HeatModuleState heat_module_03 = deviceStateService.getDeviceState().getHeatModuleByCode(HeatModuleCode.heat_module_03); - heat_module_03.setTrayStatus(this.getSensorStatus(DeviceSensorCode.HEATER_TRAY_3_EXIST)); + if (heat_module_03 != null) { + heat_module_03.setTrayStatus(this.getSensorStatus(DeviceSensorCode.HEATER_TRAY_3_EXIST)); + }else{ + log.error("Heat module 03 not found"); + } HeatModuleState heat_module_04 = deviceStateService.getDeviceState().getHeatModuleByCode(HeatModuleCode.heat_module_04); - heat_module_04.setTrayStatus(this.getSensorStatus(DeviceSensorCode.HEATER_TRAY_4_EXIST)); + if (heat_module_04 != null) { + heat_module_04.setTrayStatus(this.getSensorStatus(DeviceSensorCode.HEATER_TRAY_4_EXIST)); + }else{ + log.error("Heat module 04 not found"); + } SolutionModuleState solutionModuleState = deviceStateService.getDeviceState().getSolutionModule(); - solutionModuleState.setFeedAreaTrayStatus(this.getSensorStatus(DeviceSensorCode.LIQUID_TRAY_EXIST)); + if (solutionModuleState != null) { + solutionModuleState.setFeedAreaTrayStatus(this.getSensorStatus(DeviceSensorCode.LIQUID_TRAY_EXIST)); + } + SolutionContainerState container_01 = solutionModuleState.getContainerStateByCode(ContainerCode.container_01); - container_01.setEmpty(this.getSensorStatus(DeviceSensorCode.THIN_LOW_LEVEL)); + if (container_01 != null) { + container_01.setEmpty(this.getSensorStatus(DeviceSensorCode.THIN_LOW_LEVEL)); + } SolutionContainerState container_02 = solutionModuleState.getContainerStateByCode(ContainerCode.container_02); - container_02.setEmpty(this.getSensorStatus(DeviceSensorCode.THICK_LOW_LEVEL)); + if (container_02 != null) { + container_02.setEmpty(this.getSensorStatus(DeviceSensorCode.THICK_LOW_LEVEL)); + } SolutionContainerState container_03 = solutionModuleState.getContainerStateByCode(ContainerCode.container_03); - container_03.setEmpty(this.getSensorStatus(DeviceSensorCode.WATER_LOW_LEVEL)); + if (container_03 != null) { + container_03.setEmpty(this.getSensorStatus(DeviceSensorCode.WATER_LOW_LEVEL)); + } SolutionContainerState container_04 = solutionModuleState.getContainerStateByCode(ContainerCode.container_04); - container_04.setFull(this.getSensorStatus(DeviceSensorCode.WASTE_HIGH_LEVEL)); + if (container_04 != null) { + container_04.setFull(this.getSensorStatus(DeviceSensorCode.WASTE_HIGH_LEVEL)); + } }