|
|
@ -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 { |
|
|
|