|
@ -3,14 +3,21 @@ package com.iflytop.gd.app.core; |
|
|
import io.swagger.v3.oas.annotations.media.Schema; |
|
|
import io.swagger.v3.oas.annotations.media.Schema; |
|
|
import lombok.Data; |
|
|
import lombok.Data; |
|
|
|
|
|
|
|
|
import java.util.concurrent.CopyOnWriteArrayList; |
|
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
|
import java.util.List; |
|
|
import java.util.concurrent.atomic.AtomicBoolean; |
|
|
import java.util.concurrent.atomic.AtomicBoolean; |
|
|
import java.util.concurrent.atomic.AtomicInteger; |
|
|
import java.util.concurrent.atomic.AtomicInteger; |
|
|
import java.util.concurrent.atomic.AtomicReference; |
|
|
import java.util.concurrent.atomic.AtomicReference; |
|
|
|
|
|
import java.util.concurrent.locks.Condition; |
|
|
|
|
|
import java.util.concurrent.locks.Lock; |
|
|
|
|
|
import java.util.concurrent.locks.ReentrantLock; |
|
|
|
|
|
|
|
|
@Schema(description = "当前设备状态") |
|
|
@Schema(description = "当前设备状态") |
|
|
@Data |
|
|
@Data |
|
|
public class DeviceState { |
|
|
public class DeviceState { |
|
|
|
|
|
private final Lock liquidLock = new ReentrantLock(); |
|
|
|
|
|
private final Condition liquidIdleCondition = liquidLock.newCondition(); |
|
|
|
|
|
|
|
|
@Schema(description = "是否是急停状态,true为急停") |
|
|
@Schema(description = "是否是急停状态,true为急停") |
|
|
private AtomicBoolean emergencyStop = new AtomicBoolean(false); |
|
|
private AtomicBoolean emergencyStop = new AtomicBoolean(false); |
|
|
|
|
|
|
|
@ -24,25 +31,19 @@ public class DeviceState { |
|
|
private AtomicReference<LiquidArea> liquidArea = new AtomicReference<>(new LiquidArea()); |
|
|
private AtomicReference<LiquidArea> liquidArea = new AtomicReference<>(new LiquidArea()); |
|
|
|
|
|
|
|
|
@Schema(description = "加热操作区属性") |
|
|
@Schema(description = "加热操作区属性") |
|
|
private CopyOnWriteArrayList<HeatArea> heatArea = new CopyOnWriteArrayList<>(); |
|
|
|
|
|
|
|
|
private List<HeatArea> heatArea = new ArrayList<>(); |
|
|
|
|
|
|
|
|
@Schema(description = "碱容器状态") |
|
|
@Schema(description = "碱容器状态") |
|
|
private AtomicReference<LiquidBucket> alkaliBucket = new AtomicReference<>(new LiquidBucket()); |
|
|
private AtomicReference<LiquidBucket> alkaliBucket = new AtomicReference<>(new LiquidBucket()); |
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 龙门架机械臂属性 |
|
|
|
|
|
*/ |
|
|
|
|
|
@Data |
|
|
@Data |
|
|
private static class GantryArm { |
|
|
private static class GantryArm { |
|
|
@Schema(description = "是否空闲,true为空闲,false为占用") |
|
|
@Schema(description = "是否空闲,true为空闲,false为占用") |
|
|
private AtomicBoolean idle = new AtomicBoolean(true); |
|
|
private AtomicBoolean idle = new AtomicBoolean(true); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 加液操作区属性 |
|
|
|
|
|
*/ |
|
|
|
|
|
@Data |
|
|
@Data |
|
|
private static class LiquidArea { |
|
|
|
|
|
|
|
|
public static class LiquidArea { |
|
|
@Schema(description = "是否空闲,true为空闲,false为占用") |
|
|
@Schema(description = "是否空闲,true为空闲,false为占用") |
|
|
private AtomicBoolean idle = new AtomicBoolean(true); |
|
|
private AtomicBoolean idle = new AtomicBoolean(true); |
|
|
|
|
|
|
|
@ -53,17 +54,14 @@ public class DeviceState { |
|
|
private AtomicInteger trayStatus = new AtomicInteger(0); |
|
|
private AtomicInteger trayStatus = new AtomicInteger(0); |
|
|
|
|
|
|
|
|
@Schema(description = "溶液容器状态") |
|
|
@Schema(description = "溶液容器状态") |
|
|
private CopyOnWriteArrayList<LiquidBucket> solutionBucket = new CopyOnWriteArrayList<>(); |
|
|
|
|
|
|
|
|
private List<LiquidBucket> solutionBucket = new ArrayList<>(); |
|
|
|
|
|
|
|
|
@Schema(description = "加液泵状态") |
|
|
|
|
|
private CopyOnWriteArrayList<Pump> pump = new CopyOnWriteArrayList<>(); |
|
|
|
|
|
|
|
|
@Schema(description = "是否正在加液,true正在加液,false未运行") |
|
|
|
|
|
private AtomicBoolean isPumping = new AtomicBoolean(false); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 加热操作区属性 |
|
|
|
|
|
*/ |
|
|
|
|
|
@Data |
|
|
@Data |
|
|
private static class HeatArea { |
|
|
|
|
|
|
|
|
public static class HeatArea { |
|
|
@Schema(description = "加热器设备id") |
|
|
@Schema(description = "加热器设备id") |
|
|
private String hardwareId; |
|
|
private String hardwareId; |
|
|
|
|
|
|
|
@ -77,23 +75,11 @@ public class DeviceState { |
|
|
private AtomicBoolean capStatus = new AtomicBoolean(false); |
|
|
private AtomicBoolean capStatus = new AtomicBoolean(false); |
|
|
|
|
|
|
|
|
@Schema(description = "加热器当前温度") |
|
|
@Schema(description = "加热器当前温度") |
|
|
private AtomicReference<Double> temperature = new AtomicReference<>(0.0); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 泵属性 |
|
|
|
|
|
*/ |
|
|
|
|
|
@Data |
|
|
|
|
|
private static class Pump { |
|
|
|
|
|
@Schema(description = "加液泵id") |
|
|
|
|
|
private String pumpId; |
|
|
|
|
|
|
|
|
|
|
|
@Schema(description = "是否正在加液,true正在加液,false未运行") |
|
|
|
|
|
private AtomicInteger isPumping = new AtomicInteger(0); |
|
|
|
|
|
|
|
|
private AtomicInteger temperature = new AtomicInteger(0); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Data |
|
|
@Data |
|
|
private static class LiquidBucket { |
|
|
|
|
|
|
|
|
public static class LiquidBucket { |
|
|
@Schema(description = "容器是否为空,true为空,false不为空") |
|
|
@Schema(description = "容器是否为空,true为空,false不为空") |
|
|
private AtomicBoolean isEmpty = new AtomicBoolean(false); |
|
|
private AtomicBoolean isEmpty = new AtomicBoolean(false); |
|
|
|
|
|
|
|
@ -111,4 +97,34 @@ public class DeviceState { |
|
|
private static class DeviceStateHolder { |
|
|
private static class DeviceStateHolder { |
|
|
private static final DeviceState INSTANCE = new DeviceState(); |
|
|
private static final DeviceState INSTANCE = new DeviceState(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 等待加液区空闲 |
|
|
|
|
|
*/ |
|
|
|
|
|
public void waitLiquidIdle() { |
|
|
|
|
|
liquidLock.lock(); |
|
|
|
|
|
try { |
|
|
|
|
|
while (!DeviceState.getInstance().getLiquidArea().get().getIdle().get()) { |
|
|
|
|
|
liquidIdleCondition.await(); |
|
|
|
|
|
} |
|
|
|
|
|
} catch (InterruptedException e) { |
|
|
|
|
|
throw new RuntimeException("等待加液区空闲错误", e); |
|
|
|
|
|
} finally { |
|
|
|
|
|
liquidLock.unlock(); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 释放加液区 |
|
|
|
|
|
*/ |
|
|
|
|
|
public void setLiquidIdleTrue() { |
|
|
|
|
|
liquidLock.lock(); |
|
|
|
|
|
try { |
|
|
|
|
|
DeviceState.getInstance().getLiquidArea().get().getIdle().set(true); |
|
|
|
|
|
liquidIdleCondition.signalAll(); // 唤醒所有等待的线程 |
|
|
|
|
|
} finally { |
|
|
|
|
|
liquidLock.unlock(); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
} |