|
|
@ -2,11 +2,13 @@ package com.iflytop.gd.app.command.control; |
|
|
|
|
|
|
|
import com.iflytop.gd.app.core.BaseCommandHandler; |
|
|
|
import com.iflytop.gd.app.model.dto.CmdDTO; |
|
|
|
import com.iflytop.gd.app.service.api.DevicePositionService; |
|
|
|
import com.iflytop.gd.app.service.device.DeviceStateService; |
|
|
|
import com.iflytop.gd.app.service.device.module.HeatModuleService; |
|
|
|
import com.iflytop.gd.common.annotation.CommandMapping; |
|
|
|
import com.iflytop.gd.common.enums.HeatModuleCode; |
|
|
|
import com.iflytop.gd.common.enums.HeatingType; |
|
|
|
import com.iflytop.gd.common.enums.data.DevicePositionCode; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springframework.stereotype.Component; |
|
|
@ -23,6 +25,7 @@ import java.util.concurrent.CompletableFuture; |
|
|
|
public class HeatStartCommand extends BaseCommandHandler { |
|
|
|
private final HeatModuleService heatModuleService; |
|
|
|
private final DeviceStateService deviceStateService; |
|
|
|
private final DevicePositionService devicePositionService; |
|
|
|
|
|
|
|
@Override |
|
|
|
public CompletableFuture<Void> handle(CmdDTO cmdDTO) { |
|
|
@ -32,12 +35,26 @@ public class HeatStartCommand extends BaseCommandHandler { |
|
|
|
Integer seconds = cmdDTO.getIntegerParam("seconds"); |
|
|
|
Double temperature = cmdDTO.getDoubleParam("temperature"); |
|
|
|
HeatModuleCode heatModuleCode = HeatModuleCode.valueOf(heatId); |
|
|
|
|
|
|
|
double trayLower = devicePositionService.getPosition(DevicePositionCode.trayLower).getDistance(); |
|
|
|
double trayLift = devicePositionService.getPosition(DevicePositionCode.trayLift).getDistance(); |
|
|
|
|
|
|
|
return runAsync(() -> { |
|
|
|
heatModuleService.heatRodOpen(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatModuleCode, temperature); |
|
|
|
deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).setTargetTime(time); |
|
|
|
deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).setHeatTemperature(temperature); |
|
|
|
deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).setTargetTemperature(temperature); |
|
|
|
deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).setHeatingType(HeatingType.thermostatic); |
|
|
|
// if (deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).getHeatingType() == HeatingType.thermostatic) { |
|
|
|
// schedulerManager.scheduleOnce(heatModuleCode, () -> { |
|
|
|
// try { |
|
|
|
// heatModuleService.heaterMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatModuleCode, trayLift); |
|
|
|
// deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).setTrayUp(1); |
|
|
|
// } catch (Exception e) { |
|
|
|
// log.error("加热完毕抬起托盘错误{}", heatModuleCode, e); |
|
|
|
// } |
|
|
|
// }, deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).getTargetTime(), TimeUnit.SECONDS); |
|
|
|
// } |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|