|
@ -6,6 +6,7 @@ import com.iflytop.gd.app.model.dto.CmdDTO; |
|
|
import com.iflytop.gd.app.service.device.DeviceStateService; |
|
|
import com.iflytop.gd.app.service.device.DeviceStateService; |
|
|
import com.iflytop.gd.app.service.device.module.SolutionModuleService; |
|
|
import com.iflytop.gd.app.service.device.module.SolutionModuleService; |
|
|
import com.iflytop.gd.common.annotation.CommandMapping; |
|
|
import com.iflytop.gd.common.annotation.CommandMapping; |
|
|
|
|
|
import com.iflytop.gd.common.enums.automaton.CraftStates; |
|
|
import com.iflytop.gd.common.exception.AppException; |
|
|
import com.iflytop.gd.common.exception.AppException; |
|
|
import com.iflytop.gd.common.result.ResultCode; |
|
|
import com.iflytop.gd.common.result.ResultCode; |
|
|
import lombok.RequiredArgsConstructor; |
|
|
import lombok.RequiredArgsConstructor; |
|
@ -38,12 +39,20 @@ public class ShakeStartCommand extends BaseCommandHandler { |
|
|
} |
|
|
} |
|
|
TrayState trayState = deviceStateService.getDeviceState().getTrayInSolutionModule(); |
|
|
TrayState trayState = deviceStateService.getDeviceState().getTrayInSolutionModule(); |
|
|
if (trayState != null && trayState.getCrafts() != null) { |
|
|
if (trayState != null && trayState.getCrafts() != null) { |
|
|
throw new AppException(ResultCode.CRAFT_RUNNING); |
|
|
|
|
|
|
|
|
CraftStates craftStates = trayState.getCrafts().getState(); |
|
|
|
|
|
if (!(CraftStates.ERROR.equals(craftStates) || CraftStates.STOPPED.equals(craftStates))) { |
|
|
|
|
|
throw new AppException(ResultCode.CRAFT_RUNNING); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
deviceStateService.getCommandMutexState().get().setShakeStartCommandExecuting(true); |
|
|
|
|
|
deviceStateService.getDeviceState().getSolutionModule().setShaking(true); |
|
|
return runAsync(() -> { |
|
|
return runAsync(() -> { |
|
|
deviceStateService.getCommandMutexState().get().setShakeStartCommandExecuting(true); |
|
|
|
|
|
solutionModuleService.shakeStart(cmdDTO.getCommandId(), cmdDTO.getCommand());//开始摇匀 |
|
|
|
|
|
deviceStateService.getDeviceState().getSolutionModule().setShaking(true); |
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
solutionModuleService.shakeStart(cmdDTO.getCommandId(), cmdDTO.getCommand());//开始摇匀 |
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
deviceStateService.getCommandMutexState().get().setShakeStartCommandExecuting(false); |
|
|
|
|
|
deviceStateService.getDeviceState().getSolutionModule().setShaking(false); |
|
|
|
|
|
} |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|