|
|
@ -165,6 +165,7 @@ public class SprayTaskExecutor { |
|
|
|
commandWait(commandFutureArray); |
|
|
|
currentStep++;//当前喷涂步数。因为暂停可能本次路线还没走完,所以这里只有在走完一次路线后才会自增 |
|
|
|
sprayTask.setCurrentStep(currentStep); |
|
|
|
subFinishTime(); |
|
|
|
} |
|
|
|
//一次喷涂完毕后停止推注射泵 |
|
|
|
DeviceCommand highVoltageCloseCommand = DeviceCommandGenerator.highVoltageClose(); //关闭高压 |
|
|
@ -182,9 +183,9 @@ public class SprayTaskExecutor { |
|
|
|
} |
|
|
|
delay(1, sprayTimes.getDelay() * 1000); |
|
|
|
sprayNum++; |
|
|
|
subFinishTime(); |
|
|
|
sprayTask.setSprayNum(sprayNum); |
|
|
|
sprayTask.setCurrentStep(0); |
|
|
|
subFinishTime(); |
|
|
|
} |
|
|
|
sprayTask.setCurrentIndex(sprayTaskParam.getIndex()); |
|
|
|
sprayTask.setSprayNum(0); |
|
|
@ -325,16 +326,23 @@ public class SprayTaskExecutor { |
|
|
|
SprayTask sprayTask = SprayTask.getInstance(); |
|
|
|
|
|
|
|
// ===== 常量 ===== |
|
|
|
final long CMD_LAT_MS = 12L; // 单条命令往返耗时(ms) |
|
|
|
final long CMD_LAT_MS = 15L; // 单条命令往返耗时(ms) |
|
|
|
final long PER_OVERHEAD_MS = 0L; // 每次喷涂后附加延时(ms) |
|
|
|
final long JOB_OVERHEAD_MS = 0L; // 任务结束后全局延时(ms) |
|
|
|
final double X_SPEED_COMP = 0; // x轴速度补偿 |
|
|
|
final double Y_SPEED_COMP = 0; // y轴速度补偿 |
|
|
|
// ================ |
|
|
|
// ===== 缓存 ===== |
|
|
|
int cacheSprayNum = sprayTask.getSprayNum();//当前玻片已经完成喷涂的次数 |
|
|
|
// ================ |
|
|
|
|
|
|
|
LocalDateTime startTime = LocalDateTime.now(); |
|
|
|
|
|
|
|
List<Map<String, Object>> finishTimes = new ArrayList<>(); |
|
|
|
long cumulativeMs = 0L; |
|
|
|
|
|
|
|
List<SprayTaskParams> sprayTaskParams = sprayTask.getSprayTaskParams(); |
|
|
|
double curX = 0, curY = 0, curZ = 0;//定义当前位置 |
|
|
|
int cacheCurrentStep = sprayTask.getCurrentStep(); |
|
|
|
for (SprayTaskParams sprayTaskParam : sprayTaskParams) {//循环玻片 |
|
|
|
if (sprayTask.getCurrentIndex() != null && sprayTaskParam.getIndex() <= sprayTask.getCurrentIndex()) {//喷涂过的玻片跳过 |
|
|
|
continue; |
|
|
@ -342,13 +350,14 @@ public class SprayTaskExecutor { |
|
|
|
long sliceMs = 0L; //当前玻片耗时 |
|
|
|
int sprayNum = 1; //当前玻片是第几次喷涂 |
|
|
|
for (SprayTimes sprayTimes : sprayTaskParam.getTimes()) {//每个拨片有多次喷涂,循环每次喷涂 |
|
|
|
if (sprayNum < sprayTask.getSprayNum()) { |
|
|
|
if (sprayTask.getCurrentIndex() != null && sprayTaskParam.getIndex() > sprayTask.getCurrentIndex() && sprayNum < cacheSprayNum) { |
|
|
|
sprayNum++; |
|
|
|
continue; |
|
|
|
} |
|
|
|
Double[] slide = slideArr[sprayTaskParam.getIndex()];//获取玻片原点的坐标 |
|
|
|
List<SprayTaskStep> sprayTaskStepList = getSprayPath(sprayTimes);//计算本次喷涂的路线 |
|
|
|
if (sprayTask.getCurrentStep() == 0) { |
|
|
|
//只有在玻片首次喷涂前才需要移动,另外还未喷涂的玻片也需要计算时间 |
|
|
|
if (cacheCurrentStep == 0) { |
|
|
|
//先移动到玻片左上角位置 |
|
|
|
SysSettings slideHeightSysSettings = sysSettingsService.getOne(new LambdaQueryWrapper<SysSettings>().eq(SysSettings::getCode, "slide_height")); |
|
|
|
Double slideHeight = Double.parseDouble(slideHeightSysSettings.getValue()); |
|
|
@ -363,63 +372,55 @@ public class SprayTaskExecutor { |
|
|
|
curY = slideArr[sprayTaskParam.getIndex()][1]; |
|
|
|
curZ = height; |
|
|
|
} |
|
|
|
sliceMs += CMD_LAT_MS + 500;//三通阀切换到注射器管路 |
|
|
|
//因为走的是折线,所以单次指令只需要移动x或y,缓存上一个点位用来判断本次是走x还是y |
|
|
|
double cacheXPoint = -1; |
|
|
|
double cacheYPoint = -1; |
|
|
|
double lastX = 0; |
|
|
|
double lastY = 0; |
|
|
|
int currentStep = 0; //记录当前线程喷涂步骤序号 |
|
|
|
double xLength = 0; |
|
|
|
double yLength = 0; |
|
|
|
for (SprayTaskStep sprayTaskStep : sprayTaskStepList) {//因为田字格喷涂其实是两次 |
|
|
|
if (currentStep >= sprayTask.getCurrentStep()) { |
|
|
|
sliceMs += CMD_LAT_MS;//开启喷嘴阀 |
|
|
|
sliceMs += CMD_LAT_MS;//推动移动注射泵 |
|
|
|
if (sprayTimes.getHighVoltage()) {//加电 |
|
|
|
sliceMs += CMD_LAT_MS;//开启高压 |
|
|
|
} |
|
|
|
} |
|
|
|
for (int i = 0; i < sprayTaskStep.getSprayPathPointList().size(); i++) {//循环路线 |
|
|
|
if (currentStep < sprayTask.getCurrentStep()) { |
|
|
|
if (currentStep < cacheCurrentStep) { |
|
|
|
currentStep++; |
|
|
|
continue; |
|
|
|
} |
|
|
|
Point2D currentPoint = sprayTaskStep.getSprayPathPointList().get(i); |
|
|
|
if (cacheXPoint != currentPoint.x) { |
|
|
|
sliceMs += moveMs(curX, slide[0] + currentPoint.x, sprayTimes.getMovingSpeed(), CMD_LAT_MS); |
|
|
|
cacheXPoint = currentPoint.x; |
|
|
|
if (lastX != currentPoint.x) { |
|
|
|
xLength += currentPoint.x; |
|
|
|
lastX = currentPoint.x; |
|
|
|
curX = slide[0] + currentPoint.x; |
|
|
|
} |
|
|
|
if (cacheYPoint != currentPoint.y) { |
|
|
|
sliceMs += moveMs(curY, slide[1] + currentPoint.y, sprayTimes.getMovingSpeed(), CMD_LAT_MS); |
|
|
|
cacheYPoint = currentPoint.y; |
|
|
|
if (lastY != currentPoint.y) { |
|
|
|
yLength += currentPoint.y; |
|
|
|
lastY = currentPoint.y; |
|
|
|
curY = slide[1] + currentPoint.y; |
|
|
|
} |
|
|
|
sliceMs += CMD_LAT_MS * 3;//向前端推送当前路径 |
|
|
|
currentStep++;//当前喷涂步数。因为暂停可能本次路线还没走完,所以这里只有在走完一次路线后才会自增 |
|
|
|
} |
|
|
|
//一次喷涂完毕后停止推注射泵 |
|
|
|
sliceMs += CMD_LAT_MS; //关闭高压 |
|
|
|
sliceMs += CMD_LAT_MS; //停止推动注射泵 |
|
|
|
sliceMs += CMD_LAT_MS; //关闭喷嘴阀 |
|
|
|
if ("grid".equals(sprayTimes.getMatrixPathType()) && sprayTimes.getGridDelay() != null) { |
|
|
|
if(sprayTask.getRemainingGridDelay() != null){ |
|
|
|
if (sprayTask.getRemainingGridDelay() != null) { |
|
|
|
sliceMs += sprayTask.getRemainingGridDelay(); |
|
|
|
}else{ |
|
|
|
} else { |
|
|
|
sliceMs += sprayTimes.getGridDelay() * 1000; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if(sprayTask.getRemainingDelay() != null){ |
|
|
|
cacheCurrentStep = 0; |
|
|
|
sliceMs += (long) (xLength / sprayTimes.getMovingSpeed()) * 1000; |
|
|
|
sliceMs += (long) (yLength / sprayTimes.getMovingSpeed()) * 1000; |
|
|
|
if (sprayTask.getRemainingDelay() != null) { |
|
|
|
sliceMs += sprayTask.getRemainingDelay(); |
|
|
|
}else{ |
|
|
|
} else { |
|
|
|
sliceMs += sprayTimes.getDelay() * 1000; |
|
|
|
} |
|
|
|
sprayNum++; |
|
|
|
} |
|
|
|
cumulativeMs += sliceMs; |
|
|
|
LocalDateTime startTime = LocalDateTime.now(); |
|
|
|
Map<String, Object> rec = new HashMap<>(); |
|
|
|
rec.put("index", sprayTaskParam.getIndex()); |
|
|
|
rec.put("finishTime", startTime.plus(Duration.ofMillis(sliceMs))); |
|
|
|
rec.put("finishTime", startTime.plus(Duration.ofMillis(cumulativeMs))); |
|
|
|
finishTimes.add(rec); |
|
|
|
} |
|
|
|
|
|
|
|
return finishTimes; |
|
|
|
} |
|
|
|
|
|
|
|