Browse Source

调整初始化链接逻辑

master
白凤吉 2 months ago
parent
commit
d501d08e5e
  1. 55
      src/main/java/com/iflytop/sgs/app/service/device/DeviceInitService.java

55
src/main/java/com/iflytop/sgs/app/service/device/DeviceInitService.java

@ -17,6 +17,7 @@ import com.iflytop.sgs.common.enums.cmd.CmdColor;
import com.iflytop.sgs.common.service.CanBusService;
import com.iflytop.sgs.hardware.exception.HardwareException;
import com.iflytop.sgs.hardware.service.AppEventBusService;
import com.iflytop.sgs.hardware.type.appevent.A8kCanBusOnConnectEvent;
import com.iflytop.sgs.hardware.type.appevent.AppEvent;
import jakarta.annotation.PostConstruct;
import lombok.RequiredArgsConstructor;
@ -48,32 +49,34 @@ public class DeviceInitService {
}
private void onAppEvent(AppEvent event) {
new Thread(() -> {
try {
CompletableFuture.runAsync(() -> {
try {
deviceLightSoundService.openColor(CmdColor.blue);
} catch (HardwareException e) {
log.error("设备初始化灯光失败,CmdColor.blue");
}
});
initDeviceState();
initDeviceSetData();
canBusService.initOvertime();
initEnable();
initSensorState();
CompletableFuture.runAsync(() -> {
try {
deviceLightSoundService.openColor(CmdColor.green);
} catch (HardwareException e) {
log.error("设备初始化灯光失败,CmdColor.green");
}
});
deviceStateService.getDeviceState().setInitComplete(true);
} catch (Exception e) {
log.error("设备初始化失败", e);
}
}).start();
if(event instanceof A8kCanBusOnConnectEvent){
new Thread(() -> {
try {
CompletableFuture.runAsync(() -> {
try {
deviceLightSoundService.openColor(CmdColor.blue);
} catch (HardwareException e) {
log.error("设备初始化灯光失败,CmdColor.blue");
}
});
initDeviceState();
initDeviceSetData();
canBusService.initOvertime();
initEnable();
initSensorState();
CompletableFuture.runAsync(() -> {
try {
deviceLightSoundService.openColor(CmdColor.green);
} catch (HardwareException e) {
log.error("设备初始化灯光失败,CmdColor.green");
}
});
deviceStateService.getDeviceState().setInitComplete(true);
} catch (Exception e) {
log.error("设备初始化失败", e);
}
}).start();
}
}
public void initSensorState() throws Exception {

Loading…
Cancel
Save