Browse Source

调整系统状态采用Aspect的方式推送

master
白凤吉 2 months ago
parent
commit
c0c01951fd
  1. 26
      build.gradle
  2. 4
      src/main/java/com/iflytop/sgs/app/cmd/control/AnnealStartCommand.java
  3. 10
      src/main/java/com/iflytop/sgs/app/cmd/control/MoveToHeatAreaCommand.java
  4. 10
      src/main/java/com/iflytop/sgs/app/cmd/control/MoveToSolutionAreaCommand.java
  5. 59
      src/main/java/com/iflytop/sgs/app/core/aspect/DeviceStateChangeAspect.java
  6. 21
      src/main/java/com/iflytop/sgs/app/model/bo/status/device/DeviceState.java
  7. 2
      src/main/java/com/iflytop/sgs/app/model/bo/status/device/HeatModuleState.java
  8. 365
      src/main/java/com/iflytop/sgs/app/service/device/DeviceStateService.java

26
build.gradle

@ -21,27 +21,27 @@ repositories {
}
dependencies {
implementation files('lib/modbus4j-3.1.0.jar')
implementation 'ch.qos.logback:logback-core:1.5.16'
implementation 'cn.hutool:hutool-all:5.8.35'
implementation 'com.baomidou:mybatis-plus-boot-starter:3.5.10.1'
implementation 'com.baomidou:mybatis-plus-generator:3.5.10.1'
implementation 'com.baomidou:mybatis-plus-jsqlparser:3.5.10.1'
implementation 'com.github.xiaoymin:knife4j-openapi3-jakarta-spring-boot-starter:4.5.0'
implementation 'jakarta.annotation:jakarta.annotation-api:3.0.0'
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.8.6'
implementation 'org.freemarker:freemarker:2.3.34'
implementation 'org.mybatis.spring.boot:mybatis-spring-boot-starter:3.0.4'
implementation 'org.springframework.boot:spring-boot-starter'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-websocket:3.4.2'
implementation 'org.springframework.statemachine:spring-statemachine-core:4.0.0'
implementation 'org.xerial:sqlite-jdbc:3.48.0.0'
implementation 'org.springframework.boot:spring-boot-starter-validation:3.4.5'
implementation 'org.springframework.boot:spring-boot-starter-aop'
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.8.6'
implementation 'org.freemarker:freemarker:2.3.34'
implementation 'org.xerial:sqlite-jdbc:3.48.0.0'
implementation 'org.mybatis.spring.boot:mybatis-spring-boot-starter:3.0.4'
implementation 'com.baomidou:mybatis-plus-boot-starter:3.5.10.1'
implementation 'com.baomidou:mybatis-plus-generator:3.5.10.1'
implementation 'com.baomidou:mybatis-plus-jsqlparser:3.5.10.1'
implementation 'org.java-websocket:Java-WebSocket:1.6.0'
implementation 'ch.qos.logback:logback-core:1.5.16'
implementation 'cn.hutool:hutool-all:5.8.35'
implementation 'com.github.xiaoymin:knife4j-openapi3-jakarta-spring-boot-starter:4.5.0'
implementation 'jakarta.annotation:jakarta.annotation-api:3.0.0'
implementation 'com.fazecast:jSerialComm:2.11.0'
implementation 'com.opencsv:opencsv:5.11'
implementation files('lib/modbus4j-3.1.0.jar')
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'

4
src/main/java/com/iflytop/sgs/app/cmd/control/AnnealStartCommand.java

@ -33,9 +33,9 @@ public class AnnealStartCommand extends BaseCommandHandler {
//获取当前加热区
String heatId = heatIdJsonArray.getStr(i);
HeatModuleCode heatModuleId = HeatModuleCode.valueOf(heatId);
HeatModuleState heatModuleState = deviceStateService.getHeatModuleState(heatModuleId);
HeatModuleState heatModuleState = deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleId);
//设置加热区目标温度
deviceStateService.setHeatModuleStateTargetTemperature(heatModuleId,heatModuleState.getAnnealTemperature());
deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleId).setTargetTemperature(heatModuleState.getAnnealTemperature());
//从系统状态中获取指定加热区设定的退火温度数值
double temperature = deviceStateService.getHeatModuleState(heatModuleId).getAnnealTemperature();
//开启退火

10
src/main/java/com/iflytop/sgs/app/cmd/control/MoveToHeatAreaCommand.java

@ -36,16 +36,16 @@ public class MoveToHeatAreaCommand extends BaseCommandHandler {
@Override
public CompletableFuture<Void> handle(CmdDTO cmdDTO) throws Exception {
if (deviceStateService.getCommandState().get().isMoveToHeatAreaCommandExecuting()) {
if (deviceStateService.getCommandMutexState().get().isMoveToHeatAreaCommandExecuting()) {
throw new AppException(ResultCode.COMMAND_ALREADY_EXECUTING);
}
if (deviceStateService.getCommandState().get().isMoveToSolutionAreaCommandExecuting()) {
if (deviceStateService.getCommandMutexState().get().isMoveToSolutionAreaCommandExecuting()) {
throw new AppException(ResultCode.CMD_BUSY);
}
try {
deviceStateService.getCommandState().get().setMoveToHeatAreaCommandExecuting(true);
deviceStateService.getCommandMutexState().get().setMoveToHeatAreaCommandExecuting(true);
} catch (Exception e) {
deviceStateService.getCommandState().get().setMoveToHeatAreaCommandExecuting(false);
deviceStateService.getCommandMutexState().get().setMoveToHeatAreaCommandExecuting(false);
throw e;
}
String heatId = cmdDTO.getStringParam("heatId");
@ -72,7 +72,7 @@ public class MoveToHeatAreaCommand extends BaseCommandHandler {
solutionModuleService.motorLiquidMove(0);
} finally {
deviceStateService.setGantryArmStateIdle(true);
deviceStateService.getCommandState().get().setMoveToHeatAreaCommandExecuting(false);
deviceStateService.getCommandMutexState().get().setMoveToHeatAreaCommandExecuting(false);
}
});
}

10
src/main/java/com/iflytop/sgs/app/cmd/control/MoveToSolutionAreaCommand.java

@ -36,10 +36,10 @@ public class MoveToSolutionAreaCommand extends BaseCommandHandler {
@Override
public CompletableFuture<Void> handle(CmdDTO cmdDTO) throws Exception {
if (deviceStateService.getCommandState().get().isMoveToSolutionAreaCommandExecuting()) {
if (deviceStateService.getCommandMutexState().get().isMoveToSolutionAreaCommandExecuting()) {
throw new AppException(ResultCode.COMMAND_ALREADY_EXECUTING);
}
if (deviceStateService.getCommandState().get().isMoveToHeatAreaCommandExecuting()) {
if (deviceStateService.getCommandMutexState().get().isMoveToHeatAreaCommandExecuting()) {
throw new AppException(ResultCode.CMD_BUSY);
}
String heatId = cmdDTO.getStringParam("heatId");
@ -57,9 +57,9 @@ public class MoveToSolutionAreaCommand extends BaseCommandHandler {
//校验目标加热位是否有托盘
try {
deviceStateService.getCommandState().get().setMoveToSolutionAreaCommandExecuting(true);
deviceStateService.getCommandMutexState().get().setMoveToSolutionAreaCommandExecuting(true);
} catch (Exception e) {
deviceStateService.getCommandState().get().setMoveToSolutionAreaCommandExecuting(false);
deviceStateService.getCommandMutexState().get().setMoveToSolutionAreaCommandExecuting(false);
throw e;
}
return runAsync(() -> {
@ -78,7 +78,7 @@ public class MoveToSolutionAreaCommand extends BaseCommandHandler {
transferModuleService.transferMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidAreaTrayPoint3D);
} finally {
deviceStateService.setGantryArmStateIdle(true);
deviceStateService.getCommandState().get().setMoveToSolutionAreaCommandExecuting(false);
deviceStateService.getCommandMutexState().get().setMoveToSolutionAreaCommandExecuting(false);
}
});
}

59
src/main/java/com/iflytop/sgs/app/core/aspect/DeviceStateChangeAspect.java

@ -0,0 +1,59 @@
package com.iflytop.sgs.app.core.aspect;
import com.iflytop.sgs.app.service.device.DeviceStateService;
import com.iflytop.sgs.app.ws.server.WebSocketSender;
import com.iflytop.sgs.common.constant.WebSocketMessageType;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.stereotype.Component;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
@Slf4j
@Aspect
@Component
@RequiredArgsConstructor
public class DeviceStateChangeAspect {
private final WebSocketSender webSocketService;
private final DeviceStateService deviceStateService;
private final Lock lock = new ReentrantLock();
private Object beforeValue;
@Before("execution(* com.iflytop.sgs.app.model.bo.status..set*(..))")
public void beforeSetMethod(JoinPoint joinPoint) {
lock.lock();
try {
Object[] methodArgs = joinPoint.getArgs();
if (methodArgs != null && methodArgs.length > 0) {
beforeValue = methodArgs[0];
}
} catch (Exception e) {
log.error("处理状态变更前的值失败", e);
}
}
@After("execution(* com.iflytop.sgs.app.model.bo.status..set*(..))")
public void afterSetMethod(JoinPoint joinPoint) {
try {
String className = joinPoint.getSignature().getDeclaringType().getName(); // 获取类名
String methodName = joinPoint.getSignature().getName();
Object[] methodArgs = joinPoint.getArgs();
if (methodArgs != null && methodArgs.length > 0) {
// 保存修改后的值
Object afterValue = methodArgs[0];
log.info("设备状态发生改变,类型{}.{} ,from {} to {}", className, methodName, beforeValue, afterValue);
webSocketService.push(WebSocketMessageType.STATUS, deviceStateService.getDeviceState());
}
} catch (Exception e) {
log.error("处理状态变更后的值失败", e);
} finally {
lock.unlock();
}
}
}

21
src/main/java/com/iflytop/sgs/app/model/bo/status/device/DeviceState.java

@ -2,6 +2,7 @@ package com.iflytop.sgs.app.model.bo.status.device;
import com.iflytop.sgs.app.model.entity.Tasks;
import com.iflytop.sgs.app.model.entity.User;
import com.iflytop.sgs.common.enums.HeatModuleCode;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@ -33,4 +34,24 @@ public class DeviceState {
private User currentUser;
@Schema(description = "当前实验")
private Tasks currentTasks;
/**
* 获取指定加热模块状态
*/
public synchronized HeatModuleState getHeatModuleByCode(HeatModuleCode heatModuleCode) {
for (HeatModuleState h : heatModule) {
if (h.getModuleCode().equals(heatModuleCode)) {
return h;
}
}
return null;
}
public synchronized TrayState getTrayState(String trayUUID) {
for (TrayState t : tray) {
if (t.getUuid().equals(trayUUID)) {
return t;
}
}
return null;
}
}

2
src/main/java/com/iflytop/sgs/app/model/bo/status/device/HeatModuleState.java

@ -33,8 +33,10 @@ public class HeatModuleState {
@Schema(description = "加热器烘干温度")
private Double dryTemperature;
@Schema(description = "加热器退火温度")
private Double annealTemperature;
@Schema(description = "加热器加热温度")
private Double heatTemperature;

365
src/main/java/com/iflytop/sgs/app/service/device/DeviceStateService.java

@ -1,19 +1,11 @@
package com.iflytop.sgs.app.service.device;
import com.iflytop.sgs.app.core.listener.DeviceStateListener;
import com.iflytop.sgs.app.model.bo.status.CommandMutexState;
import com.iflytop.sgs.app.model.bo.status.device.*;
import com.iflytop.sgs.app.model.entity.Tasks;
import com.iflytop.sgs.app.model.entity.User;
import com.iflytop.sgs.app.model.vo.SetTargetTemperatureVO;
import com.iflytop.sgs.common.enums.ContainerCode;
import com.iflytop.sgs.common.enums.HeatModuleCode;
import com.iflytop.sgs.app.model.bo.status.device.DeviceState;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import java.beans.PropertyChangeSupport;
import java.util.List;
import java.util.concurrent.atomic.AtomicReference;
/**
@ -22,361 +14,10 @@ import java.util.concurrent.atomic.AtomicReference;
@Service
@RequiredArgsConstructor
public class DeviceStateService {
private final transient PropertyChangeSupport support = new PropertyChangeSupport(this);
@Getter
private final DeviceState deviceState = new DeviceState();
@Getter
private final AtomicReference<CommandMutexState> commandState = new AtomicReference<>(new CommandMutexState());
public synchronized DeviceState getDeviceState() {
return deviceState;
}
public void addListener(DeviceStateListener deviceStateListener) {
support.addPropertyChangeListener(deviceStateListener);
}
public synchronized HeatModuleState getHeatModuleState(HeatModuleCode moduleCode) {
HeatModuleState heatModuleState = null;
for (HeatModuleState t : deviceState.getHeatModule()) {
if (moduleCode.equals(t.getModuleCode())) {
heatModuleState = t;
break;
}
}
return heatModuleState;
}
public synchronized TrayState getTrayState(String trayUUID) {
TrayState foundTrayState = null;
for (TrayState t : deviceState.getTray()) {
if (trayUUID.equals(t.getUuid())) {
foundTrayState = t;
break;
}
}
return foundTrayState;
}
public synchronized TrayState getTrayInSolutionModule() {
List<TrayState> trayList = deviceState.getTray();
return trayList.stream()
.filter(TrayState::isInSolutionModule)
.findFirst()
.orElse(null);
}
public synchronized void setVirtual(boolean virtual) {
boolean oldValue = deviceState.isVirtual();
deviceState.setVirtual(virtual);
support.firePropertyChange("setVirtual", oldValue, virtual);
}
public synchronized void setInitComplete(boolean initComplete) {
boolean oldValue = deviceState.isInitComplete();
deviceState.setInitComplete(initComplete);
support.firePropertyChange("setInitComplete", oldValue, initComplete);
}
public synchronized void setEmergencyStop(boolean emergencyStop) {
boolean oldValue = deviceState.isEmergencyStop();
deviceState.setEmergencyStop(emergencyStop);
support.firePropertyChange("setEmergencyStop", oldValue, emergencyStop);
}
public synchronized void setSelfTest(boolean selfTest) {
boolean oldValue = deviceState.isSelfTest();
deviceState.setSelfTest(selfTest);
support.firePropertyChange("setSelfTest", oldValue, selfTest);
}
public synchronized void setDoorStatus(boolean status) {
boolean oldValue = deviceState.getDoorModule().isOpen();
deviceState.getDoorModule().setOpen(status);
support.firePropertyChange("setDoorStatus", oldValue, status);
}
public synchronized void setGantryArmStateIdle(boolean idle) {
boolean oldValue = deviceState.getTransferModule().isIdle();
deviceState.getTransferModule().setIdle(idle);
support.firePropertyChange("setGantryArmStateIdle", oldValue, idle);
}
public synchronized void setHeatModuleStateTrayUp(HeatModuleCode heatModuleId, int trayStatusUp) {
HeatModuleState heatModuleState = null;
for (HeatModuleState t : deviceState.getHeatModule()) {
if (heatModuleId.equals(t.getModuleCode())) {
heatModuleState = t;
break;
}
}
assert heatModuleState != null;
int oldValue = heatModuleState.getTrayUp();
heatModuleState.setTrayUp(trayStatusUp);
support.firePropertyChange("setHeatModuleStateTrayUp", oldValue, trayStatusUp);
}
public synchronized void setHeatModuleStateTrayStatus(HeatModuleCode heatModuleId, int trayStatus) {
HeatModuleState heatModuleState = null;
for (HeatModuleState t : deviceState.getHeatModule()) {
if (heatModuleId.equals(t.getModuleCode())) {
heatModuleState = t;
break;
}
}
assert heatModuleState != null;
int oldValue = heatModuleState.getTrayStatus();
heatModuleState.setTrayStatus(trayStatus);
support.firePropertyChange("setHeatModuleStateTrayStatus", oldValue, trayStatus);
}
public synchronized void setHeatModuleStateHeating(HeatModuleCode heatModuleId, boolean heating) {
HeatModuleState heatModuleState = null;
for (HeatModuleState t : deviceState.getHeatModule()) {
if (heatModuleId.equals(t.getModuleCode())) {
heatModuleState = t;
break;
}
}
assert heatModuleState != null;
boolean oldValue = heatModuleState.isHeating();
heatModuleState.setHeating(heating);
support.firePropertyChange("setHeatModuleStateHeating", oldValue, heating);
}
public synchronized void setHeatModuleStateDrying(HeatModuleCode heatModuleId, boolean drying) {
HeatModuleState heatModuleState = null;
for (HeatModuleState t : deviceState.getHeatModule()) {
if (heatModuleId.equals(t.getModuleCode())) {
heatModuleState = t;
break;
}
}
assert heatModuleState != null;
boolean oldValue = heatModuleState.isDrying();
heatModuleState.setDrying(drying);
support.firePropertyChange("setHeatModuleStateDrying", oldValue, drying);
}
public synchronized void setHeatModuleStateAnnealing(HeatModuleCode heatModuleId, boolean annealing) {
HeatModuleState heatModuleState = null;
for (HeatModuleState t : deviceState.getHeatModule()) {
if (heatModuleId.equals(t.getModuleCode())) {
heatModuleState = t;
break;
}
}
assert heatModuleState != null;
boolean oldValue = heatModuleState.isAnnealing();
heatModuleState.setAnnealing(annealing);
support.firePropertyChange("setHeatModuleStateHeating", oldValue, annealing);
}
public synchronized void setHeatModuleStateFanOpen(HeatModuleCode heatModuleId, boolean fanOpen) {
HeatModuleState heatModuleState = null;
for (HeatModuleState t : deviceState.getHeatModule()) {
if (heatModuleId.equals(t.getModuleCode())) {
heatModuleState = t;
break;
}
}
assert heatModuleState != null;
boolean oldValue = heatModuleState.isFanOpen();
heatModuleState.setFanOpen(fanOpen);
support.firePropertyChange("setHeatModuleStateFanOpen", oldValue, fanOpen);
}
public synchronized void setHeatModuleStatePreSetTemperature(HeatModuleCode heatModuleId, SetTargetTemperatureVO setTargetTemperatureVO) {
HeatModuleState heatModuleState = null;
for (HeatModuleState t : deviceState.getHeatModule()) {
if (heatModuleId.equals(t.getModuleCode())) {
heatModuleState = t;
break;
}
}
assert heatModuleState != null;
heatModuleState.setHeatTemperature(setTargetTemperatureVO.getHeatTemperature());
heatModuleState.setAnnealTemperature(setTargetTemperatureVO.getAnnealTemperature());
heatModuleState.setDryTemperature(setTargetTemperatureVO.getDryTemperature());
//support.firePropertyChange("setHeatModuleStateTargetTemperature", oldValue, targetTemperature);
}
public synchronized void setHeatModuleStateTargetTemperature(HeatModuleCode heatModuleId, double targetTemperature) {
HeatModuleState heatModuleState = null;
for (HeatModuleState t : deviceState.getHeatModule()) {
if (heatModuleId.equals(t.getModuleCode())) {
heatModuleState = t;
break;
}
}
assert heatModuleState != null;
double oldValue = heatModuleState.getTargetTemperature();
heatModuleState.setTargetTemperature(targetTemperature);
support.firePropertyChange("setHeatModuleStateTargetTemperature", oldValue, targetTemperature);
}
public synchronized void setHeatModuleStateTemperature(HeatModuleCode heatModuleId, double temperature) {
HeatModuleState heatModuleState = null;
for (HeatModuleState t : deviceState.getHeatModule()) {
if (heatModuleId.equals(t.getModuleCode())) {
heatModuleState = t;
break;
}
}
assert heatModuleState != null;
Double oldValue = heatModuleState.getTemperature();
heatModuleState.setTemperature(temperature);
support.firePropertyChange("setHeatModuleStateTemperature", oldValue, temperature);
}
public synchronized void setSolutionModuleStateIdle(boolean idle) {
boolean oldValue = deviceState.getSolutionModule().isIdle();
deviceState.getSolutionModule().setIdle(idle);
support.firePropertyChange("setSolutionModuleStateIdle", oldValue, idle);
}
public synchronized void setSolutionModuleStateTrayStatus(int trayStatus) {
int oldValue = deviceState.getSolutionModule().getTrayStatus();
deviceState.getSolutionModule().setTrayStatus(trayStatus);
support.firePropertyChange("setSolutionModuleStateTrayStatus", oldValue, trayStatus);
}
public synchronized void setSolutionModuleStatePumping(boolean pumping) {
boolean oldValue = deviceState.getSolutionModule().isPumping();
deviceState.getSolutionModule().setPumping(pumping);
support.firePropertyChange("setSolutionModuleStatePumping", oldValue, pumping);
}
public synchronized void setSolutionContainerStateEmpty(ContainerCode containerCode, boolean empty) {
SolutionContainerState solutionContainerState = null;
for (SolutionContainerState t : deviceState.getSolutionModule().getSolutionContainer()) {
if (containerCode.equals(t.getContainerCode())) {
solutionContainerState = t;
break;
}
}
assert solutionContainerState != null;
boolean oldValue = solutionContainerState.isEmpty();
solutionContainerState.setEmpty(empty);
support.firePropertyChange("setSolutionContainerStateEmpty", oldValue, empty);
}
public synchronized void setSolutionContainerStateFull(ContainerCode containerCode, boolean full) {
SolutionContainerState solutionContainerState = null;
for (SolutionContainerState t : deviceState.getSolutionModule().getSolutionContainer()) {
if (containerCode.equals(t.getContainerCode())) {
solutionContainerState = t;
break;
}
}
assert solutionContainerState != null;
boolean oldValue = solutionContainerState.isFull();
solutionContainerState.setFull(full);
support.firePropertyChange("setSolutionContainerStateFull", oldValue, full);
}
public synchronized void setTrayStateHeatModuleId(String trayUUID, HeatModuleCode heatModuleId) {
TrayState foundTrayState = null;
for (TrayState t : deviceState.getTray()) {
if (trayUUID.equals(t.getUuid())) {
foundTrayState = t;
break;
}
}
assert foundTrayState != null;
HeatModuleCode oldValue = foundTrayState.getHeatModuleId();
foundTrayState.setHeatModuleId(heatModuleId);
support.firePropertyChange("setTrayStateHeatModuleId", oldValue, heatModuleId);
}
public synchronized void setTrayStateInSolutionModule(String trayUUID, boolean inSolutionModule) {
TrayState foundTrayState = null;
for (TrayState t : deviceState.getTray()) {
if (trayUUID.equals(t.getUuid())) {
foundTrayState = t;
break;
}
}
assert foundTrayState != null;
boolean oldValue = foundTrayState.isInSolutionModule();
foundTrayState.setInSolutionModule(inSolutionModule);
support.firePropertyChange("traySetInSolutionModule", oldValue, inSolutionModule);
}
public synchronized void setTrayStateInHeatModule(String trayUUID, boolean inHeatModule) {
TrayState foundTrayState = null;
for (TrayState t : deviceState.getTray()) {
if (trayUUID.equals(t.getUuid())) {
foundTrayState = t;
break;
}
}
assert foundTrayState != null;
boolean oldValue = foundTrayState.isInHeatModule();
foundTrayState.setInHeatModule(inHeatModule);
support.firePropertyChange("setTrayStateInHeatModule", oldValue, inHeatModule);
}
public synchronized void setTrayStateTubes(String trayUUID, TubeState[] tubes) {
TrayState foundTrayState = null;
for (TrayState t : deviceState.getTray()) {
if (trayUUID.equals(t.getUuid())) {
foundTrayState = t;
break;
}
}
assert foundTrayState != null;
TubeState[] oldValue = foundTrayState.getTubes();
foundTrayState.setTubes(tubes);
support.firePropertyChange("setTrayStateTubes", oldValue, tubes);
}
public synchronized void setTubeStateExists(String trayUUID, int tubeNum, boolean exists) {
TrayState foundTrayState = null;
for (TrayState t : deviceState.getTray()) {
if (trayUUID.equals(t.getUuid())) {
foundTrayState = t;
break;
}
}
assert foundTrayState != null;
TubeState tubeState = foundTrayState.getTubes()[tubeNum];
boolean oldValue = tubeState.isExists();
tubeState.setExists(exists);
support.firePropertyChange("setTubeStateExists", oldValue, exists);
}
public synchronized void setTubeStateAddSolution(String trayUUID, int tubeNum, boolean addSolution) {
TrayState foundTrayState = null;
for (TrayState t : deviceState.getTray()) {
if (trayUUID.equals(t.getUuid())) {
foundTrayState = t;
break;
}
}
assert foundTrayState != null;
TubeState tubeState = foundTrayState.getTubes()[tubeNum];
boolean oldValue = tubeState.isAddSolution();
tubeState.setAddSolution(addSolution);
support.firePropertyChange("setTubeStateAddSolution", oldValue, addSolution);
}
public synchronized void setCurrentUser(User currentUser) {
User oldValue = deviceState.getCurrentUser();
deviceState.setCurrentUser(currentUser);
support.firePropertyChange("setCurrentUser", oldValue, currentUser);
}
public synchronized void setCurrentTasks(Tasks currentTasks) {
User oldValue = deviceState.getCurrentUser();
deviceState.setCurrentTasks(currentTasks);
support.firePropertyChange("setCurrentTasks", oldValue, currentTasks);
}
private final AtomicReference<CommandMutexState> commandMutexState = new AtomicReference<>(new CommandMutexState());
}
Loading…
Cancel
Save