|
|
@ -8,6 +8,7 @@ import com.iflytop.sgs.app.model.entity.Container; |
|
|
|
import com.iflytop.sgs.app.model.entity.DeviceParamConfig; |
|
|
|
import com.iflytop.sgs.app.service.api.ContainerService; |
|
|
|
import com.iflytop.sgs.app.service.api.DeviceParamConfigService; |
|
|
|
import com.iflytop.sgs.app.service.device.module.HeatModuleService; |
|
|
|
import com.iflytop.sgs.common.cmd.DeviceCommandBundle; |
|
|
|
import com.iflytop.sgs.common.cmd.DeviceCommandGenerator; |
|
|
|
import com.iflytop.sgs.common.enums.ContainerCode; |
|
|
@ -25,6 +26,7 @@ import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springframework.beans.factory.ObjectProvider; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
import java.util.Arrays; |
|
|
|
import java.util.List; |
|
|
|
import java.util.concurrent.CompletableFuture; |
|
|
|
|
|
|
@ -42,6 +44,7 @@ public class DeviceInitService { |
|
|
|
private final ObjectProvider<SolutionContainerState> solutionContainerStateProvider; |
|
|
|
private final DeviceLightSoundService deviceLightSoundService; |
|
|
|
private final AppEventBusService eventBus; |
|
|
|
private final HeatModuleService heatModuleService; |
|
|
|
|
|
|
|
@PostConstruct |
|
|
|
public void init() throws InterruptedException { |
|
|
@ -50,7 +53,7 @@ public class DeviceInitService { |
|
|
|
} |
|
|
|
|
|
|
|
private void onAppEvent(AppEvent event) { |
|
|
|
if(event instanceof A8kCanBusOnConnectEvent){ |
|
|
|
if (event instanceof A8kCanBusOnConnectEvent) { |
|
|
|
new Thread(() -> { |
|
|
|
try { |
|
|
|
CompletableFuture.runAsync(() -> { |
|
|
@ -64,6 +67,7 @@ public class DeviceInitService { |
|
|
|
canBusService.initOvertime(); |
|
|
|
initEnable(); |
|
|
|
initSensorState(); |
|
|
|
closeIODevice(); |
|
|
|
CompletableFuture.runAsync(() -> { |
|
|
|
try { |
|
|
|
deviceLightSoundService.openColor(CmdColor.green); |
|
|
@ -79,6 +83,20 @@ public class DeviceInitService { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public void closeIODevice() { |
|
|
|
CompletableFuture.runAsync(() -> { |
|
|
|
HeatModuleCode[] heatModuleCodes = HeatModuleCode.values(); |
|
|
|
Arrays.stream(heatModuleCodes).toList().forEach(heatModuleCode -> {//关闭所有的加热和风扇 |
|
|
|
try { |
|
|
|
heatModuleService.fanClose(heatModuleCode);//关闭风扇 |
|
|
|
heatModuleService.heatRodClose(heatModuleCode);//关闭加热棒 |
|
|
|
} catch (Exception e) { |
|
|
|
log.error("自检关闭风扇和加热棒{},{}", heatModuleCode, e.getMessage()); |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
public void initSensorState() throws Exception { |
|
|
|
deviceSensorService.collectSensorState(); |
|
|
|
} |
|
|
|