|
|
@ -23,13 +23,14 @@ import com.iflytop.sgs.app.ws.server.WebSocketSender; |
|
|
|
import com.iflytop.sgs.common.constant.WebSocketMessageType; |
|
|
|
import com.iflytop.sgs.common.enums.*; |
|
|
|
import com.iflytop.sgs.common.enums.cmd.CmdBeepMode; |
|
|
|
import com.iflytop.sgs.common.enums.cmd.CmdColor; |
|
|
|
import com.iflytop.sgs.common.enums.data.DevicePositionCode; |
|
|
|
import com.iflytop.sgs.common.exception.AppException; |
|
|
|
import com.iflytop.sgs.common.result.ResultCode; |
|
|
|
import com.iflytop.sgs.hardware.exception.HardwareException; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springframework.beans.BeansException; |
|
|
|
import org.springframework.context.ApplicationContext; |
|
|
|
import org.springframework.context.ApplicationContextAware; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
import java.time.LocalDateTime; |
|
|
@ -37,6 +38,7 @@ import java.util.ArrayList; |
|
|
|
import java.util.Arrays; |
|
|
|
import java.util.List; |
|
|
|
import java.util.concurrent.CompletableFuture; |
|
|
|
import java.util.concurrent.Future; |
|
|
|
|
|
|
|
/** |
|
|
|
* 工艺步骤执行服务 |
|
|
@ -44,7 +46,8 @@ import java.util.concurrent.CompletableFuture; |
|
|
|
@Slf4j |
|
|
|
@Service |
|
|
|
@RequiredArgsConstructor |
|
|
|
public class CraftsStepService { |
|
|
|
public class CraftsStepService implements ApplicationContextAware { |
|
|
|
private ApplicationContext applicationContext; |
|
|
|
private final ContainerService containerService; |
|
|
|
private final WebSocketSender webSocketService; |
|
|
|
private final HeatModuleService heatModuleService; |
|
|
@ -58,6 +61,22 @@ public class CraftsStepService { |
|
|
|
private final DeviceLightSoundService deviceLightSoundService; |
|
|
|
private final CraftMonitorService craftMonitorService; |
|
|
|
|
|
|
|
@Override |
|
|
|
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { |
|
|
|
this.applicationContext = applicationContext; |
|
|
|
} |
|
|
|
|
|
|
|
public synchronized void stopAllCrafts() { |
|
|
|
CraftsService craftsService = applicationContext.getBean(CraftsService.class); |
|
|
|
craftsService.getContextMap().forEach((key, ctx) -> { |
|
|
|
Future<?> future = craftsService.getFutureMap().remove(key); |
|
|
|
if (ctx != null && future != null) { |
|
|
|
ctx.stop(); |
|
|
|
future.cancel(true); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 执行单个工艺步骤 |
|
|
|
* |
|
|
@ -244,12 +263,16 @@ public class CraftsStepService { |
|
|
|
transferModuleService.transferZMoveZero();//Z轴抬升至最高 |
|
|
|
deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).setTrayStatus(true);//加热区托盘状态 |
|
|
|
deviceStateService.getDeviceState().getTrayByHeatModuleCode(heatModuleCode).setInHeatModule(true);//托盘状态 |
|
|
|
deviceStateService.getDeviceState().getSolutionModule().setPumping(false);//正在加液 |
|
|
|
deviceStateService.getDeviceState().getTrayByHeatModuleCode(heatModuleCode).setInSolutionPositon(false);//托盘状态 |
|
|
|
deviceStateService.getDeviceState().getSolutionModule().setPumping(false); |
|
|
|
deviceStateService.getDeviceState().getTrayByHeatModuleCode(heatModuleCode).setUseArm(false);//使用机械臂标志 |
|
|
|
transferModuleService.releaseTransferModule();//释放转运模组 |
|
|
|
return true; |
|
|
|
} catch (Exception e) { |
|
|
|
log.error("工艺执行中异常:{}", e.getMessage()); |
|
|
|
throw new Exception(e); |
|
|
|
} finally { |
|
|
|
deviceStateService.getDeviceState().getSolutionModule().setPumping(false); |
|
|
|
transferModuleService.releaseTransferModule();//释放转运模组 |
|
|
|
deviceStateService.getDeviceState().getTrayByHeatModuleCode(heatModuleCode).setUseArm(false);//使用机械臂标志 |
|
|
|
} |
|
|
|
} |
|
|
@ -448,10 +471,13 @@ public class CraftsStepService { |
|
|
|
deviceStateService.getDeviceState().getTrayByHeatModuleCode(heatModuleCode).setInHeatModule(true);//托盘状态 |
|
|
|
deviceStateService.getDeviceState().getSolutionModule().setPumping(false);//正在加液 |
|
|
|
deviceStateService.getDeviceState().getTrayByHeatModuleCode(heatModuleCode).setInSolutionPositon(false);//托盘状态 |
|
|
|
transferModuleService.releaseTransferModule();//释放转运模组 |
|
|
|
return true; |
|
|
|
} catch (Exception e) { |
|
|
|
log.error("工艺执行中异常:{}", e.getMessage()); |
|
|
|
throw new Exception(e); |
|
|
|
} finally { |
|
|
|
deviceStateService.getDeviceState().getSolutionModule().setPumping(false); |
|
|
|
transferModuleService.releaseTransferModule();//释放转运模组 |
|
|
|
deviceStateService.getDeviceState().getTrayByHeatModuleCode(heatModuleCode).setUseArm(false);//使用机械臂标志 |
|
|
|
} |
|
|
|
} |
|
|
@ -462,6 +488,7 @@ public class CraftsStepService { |
|
|
|
* */ |
|
|
|
public boolean heat(HeatModuleCode heatModuleCode, JSONObject params, CraftMonitor craftMonitor) throws Exception { |
|
|
|
/*工艺监控清理上步的记录*/ |
|
|
|
try { |
|
|
|
craftMonitor.setDeviceState(JSONUtil.toJsonStr(deviceStateService.getDeviceState())); |
|
|
|
craftMonitor.setCurrentStepResult(CraftsMonitorResultCode.heat_time.getDescription() + ":0"); |
|
|
|
craftMonitorService.saveMonitor(craftMonitor); |
|
|
@ -508,6 +535,11 @@ public class CraftsStepService { |
|
|
|
log.info("工艺{},加热结束", heatModuleCode); |
|
|
|
webSocketService.pushCraftsDebug(CraftsDebugGenerator.generateJson(heatModuleCode.toString(), "加热结束,持续时间", time)); |
|
|
|
return true; |
|
|
|
} catch (Exception e) { |
|
|
|
log.error("工艺加热异常:{}", e.getMessage()); |
|
|
|
throw new Exception(e); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/* |
|
|
@ -682,11 +714,14 @@ public class CraftsStepService { |
|
|
|
deviceStateService.getDeviceState().getTrayByHeatModuleCode(heatModuleCode).setInHeatModule(true);//托盘状态 |
|
|
|
deviceStateService.getDeviceState().getSolutionModule().setPumping(false);//正在加液 |
|
|
|
deviceStateService.getDeviceState().getTrayByHeatModuleCode(heatModuleCode).setInSolutionPositon(false);//托盘状态 |
|
|
|
log.info("工艺{},释放转运模组", heatModuleCode); |
|
|
|
transferModuleService.releaseTransferModule();//释放转运模组 |
|
|
|
return true; |
|
|
|
} catch (Exception e) { |
|
|
|
log.error("工艺执行中异常:{}", e.getMessage()); |
|
|
|
throw new Exception(e); |
|
|
|
} finally { |
|
|
|
deviceStateService.getDeviceState().getSolutionModule().setPumping(false); |
|
|
|
log.info("工艺{},释放转运模组", heatModuleCode); |
|
|
|
transferModuleService.releaseTransferModule();//释放转运模组 |
|
|
|
deviceStateService.getDeviceState().getTrayByHeatModuleCode(heatModuleCode).setUseArm(false);//使用机械臂标志 |
|
|
|
} |
|
|
|
} |
|
|
@ -695,6 +730,7 @@ public class CraftsStepService { |
|
|
|
* 烘干 |
|
|
|
* */ |
|
|
|
public boolean dry(HeatModuleCode heatModuleCode, JSONObject params, CraftMonitor craftMonitor) throws Exception { |
|
|
|
try { |
|
|
|
/*工艺监控清理上步的记录*/ |
|
|
|
craftMonitor.setDeviceState(JSONUtil.toJsonStr(deviceStateService.getDeviceState())); |
|
|
|
craftMonitor.setCurrentStepResult(CraftsMonitorResultCode.heat_time.getDescription() + ":0"); |
|
|
@ -749,6 +785,11 @@ public class CraftsStepService { |
|
|
|
deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).setTargetTime(null);//加热器目标加热时间 |
|
|
|
deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).setHeatingType(HeatingType.stop); //设置加热区状态 |
|
|
|
return true; |
|
|
|
} catch (Exception e) { |
|
|
|
log.error("工艺烘干异常:{}", e.getMessage()); |
|
|
|
throw new Exception(e); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/* |
|
|
@ -829,10 +870,8 @@ public class CraftsStepService { |
|
|
|
} |
|
|
|
log.info("工艺{},恒温中", HeatModuleCode.heat_module_04); |
|
|
|
delay(seconds); |
|
|
|
// heatModuleService.heatRodClose(HeatModuleCode.heat_module_04);//关闭加热棒 |
|
|
|
deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).setStartHeatTime(null);//开始加热时间 |
|
|
|
deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).setTargetTime(null);//加热器目标加热时间 |
|
|
|
//deviceStateService.getDeviceState().getHeatModuleByCode(HeatModuleCode.heat_module_04).setHeatingType(HeatingType.stop); //设置加热区状态 停止加热 |
|
|
|
deviceStateService.getDeviceState().getHeatModuleByCode(HeatModuleCode.heat_module_04).setStartHeatTime(null);//开始加热时间 |
|
|
|
deviceStateService.getDeviceState().getHeatModuleByCode(HeatModuleCode.heat_module_04).setTargetTime(null);//加热器目标加热时间 |
|
|
|
|
|
|
|
log.info("工艺{},加热完毕", heatModuleCode); |
|
|
|
log.info("工艺{},获取转运模组锁", heatModuleCode); |
|
|
@ -869,8 +908,10 @@ public class CraftsStepService { |
|
|
|
deviceStateService.getDeviceState().getHeatModuleByCode(HeatModuleCode.heat_module_04).setTrayStatus(false); |
|
|
|
deviceStateService.getDeviceState().getTrayByHeatModuleCode(heatModuleCode).setInHeatModule(true);//托盘状态 |
|
|
|
return true; |
|
|
|
} catch (Exception e) { |
|
|
|
log.error("工艺执行中异常:{}", e.getMessage()); |
|
|
|
throw new Exception(e); |
|
|
|
} finally { |
|
|
|
transferModuleService.releaseTransferModule();//释放转运模组 |
|
|
|
deviceStateService.getDeviceState().getTrayByHeatModuleCode(heatModuleCode).setUseArm(false);//使用机械臂标志 |
|
|
|
} |
|
|
|
} |
|
|
|