白凤吉 2 months ago
parent
commit
1aa4102ed2
  1. 18
      src/main/java/com/iflytop/gd/app/service/crafts/CraftsStepService.java
  2. 4
      src/main/java/com/iflytop/gd/app/service/device/module/SolutionModuleService.java
  3. 5
      src/main/java/com/iflytop/gd/app/service/scheduled/FetchTemperatureScheduledTask.java
  4. 3
      src/main/java/com/iflytop/gd/hardware/command/handlers/DoorHandler.java

18
src/main/java/com/iflytop/gd/app/service/crafts/CraftsStepService.java

@ -5,18 +5,21 @@ import cn.hutool.json.JSONObject;
import com.iflytop.gd.app.core.CraftsDebugGenerator;
import com.iflytop.gd.app.model.bo.CraftsStep;
import com.iflytop.gd.app.model.bo.Point3D;
import com.iflytop.gd.app.model.entity.Container;
import com.iflytop.gd.app.service.api.ContainerService;
import com.iflytop.gd.app.service.api.DevicePositionService;
import com.iflytop.gd.app.service.device.DeviceCommandTempUtilService;
import com.iflytop.gd.app.service.device.DeviceStateService;
import com.iflytop.gd.app.service.device.module.*;
import com.iflytop.gd.app.ws.server.WebSocketSender;
import com.iflytop.gd.common.command.CommandFuture;
import com.iflytop.gd.common.enums.AcidPumpDeviceCode;
import com.iflytop.gd.common.enums.HeatModuleCode;
import com.iflytop.gd.common.enums.HeatingType;
import com.iflytop.gd.common.enums.data.DevicePositionCode;
import com.iflytop.gd.common.exception.AppException;
import com.iflytop.gd.common.result.ResultCode;
import com.iflytop.gd.common.utils.CommandUtil;
import com.iflytop.gd.hardware.drivers.DODriver.OutputIOCtrlDriver;
import com.iflytop.gd.hardware.drivers.TricolorLightDriver;
import com.iflytop.gd.hardware.exception.HardwareException;
@ -88,14 +91,17 @@ public class CraftsStepService {
JSONObject addLiquid = addLiquidList.getJSONObject(j);
Long solId = addLiquid.getLong("solId");
Double volume = addLiquid.getDouble("volume");
AcidPumpDeviceCode acidPumpDevice = containerService.getPumpBySolutionId(solId);
if (acidPumpDevice == null) {
throw new AppException(ResultCode.CRAFT_CONTAINER_NOT_FOUND);
Container container = containerService.getContainerBySolutionId(solId);
if (container == null) {
throw new AppException(ResultCode.CRAFT_CONTAINER_NOT_FOUND);//未找到对应溶液容器
}
AcidPumpDeviceCode acidPumpDevice = AcidPumpDeviceCode.valueOf(container.getPumpId());//
int scale = container.getScale() == null ? 120 : container.getScale();//系数
webSocketService.pushCraftsDebug(CraftsDebugGenerator.generateJson(heatModuleCode.toString(), "移动加液机械臂到指定试管", tubeNum));
solutionModuleService.dualRobotMovePoint(tubeNum);//移动加液机械臂到指定试管
webSocketService.pushCraftsDebug(CraftsDebugGenerator.generateJson(heatModuleCode.toString(), "添加溶液", addLiquid));
solutionModuleService.acidPumpMoveBy(acidPumpDevice, volume);//添加溶液
CommandFuture deviceCommandFuture = solutionModuleService.acidPumpMoveBy(acidPumpDevice, volume * ((double) scale /100));//添加溶液
CommandUtil.wait(deviceCommandFuture);
}
}
solutionModuleService.dualRobotOrigin();
@ -127,12 +133,14 @@ public class CraftsStepService {
Double temperature = params.getDouble("temperature");
Integer second = params.getInt("second");
heatModuleService.heatRodOpen(heatModuleCode, temperature);//开始加热
deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).setHeatingType(HeatingType.thermostatic);
//达到目标温度后才算开始加热
while (deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).getTemperature() + 1 < temperature) {
delay(1);
}
delay(second);
heatModuleService.heatRodClose(heatModuleCode);//停止加热
deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).setHeatingType(HeatingType.stop);
heatModuleService.heaterMotorMove(heatModuleCode, trayLift);//抬升加热位托盘
return true;
}
@ -171,7 +179,7 @@ public class CraftsStepService {
public void finish(HeatModuleCode heatModuleCode) throws Exception {
moveToSolutionModule(heatModuleCode);
//蜂鸣器提示
otherModuleService.craftsFinishBeepRemind();
// otherModuleService.craftsFinishBeepRemind();
}
/**

4
src/main/java/com/iflytop/gd/app/service/device/module/SolutionModuleService.java

@ -186,8 +186,8 @@ public class SolutionModuleService {
/**
* 添加溶液
*/
public void acidPumpMoveBy(AcidPumpDeviceCode acidPumpDevice, double position) throws Exception {
acidPumpMoveBy(null, null, acidPumpDevice, position);
public CommandFuture acidPumpMoveBy(AcidPumpDeviceCode acidPumpDevice, double position) throws Exception {
return acidPumpMoveBy(null, null, acidPumpDevice, position);
}
/**

5
src/main/java/com/iflytop/gd/app/service/scheduled/FetchTemperatureScheduledTask.java

@ -1,6 +1,5 @@
package com.iflytop.gd.app.service.scheduled;
import com.iflytop.gd.app.model.bo.status.device.HeatModuleState;
import com.iflytop.gd.app.service.device.DeviceStateService;
import com.iflytop.gd.common.enums.HeatModuleCode;
import com.iflytop.gd.hardware.service.GDDeviceStatusService;
@ -10,8 +9,6 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import java.util.List;
@Slf4j
@Service
@RequiredArgsConstructor
@ -19,7 +16,7 @@ public class FetchTemperatureScheduledTask {
private final GDDeviceStatusService gdDeviceStatusService;
private final DeviceStateService deviceStateService;
@Scheduled(fixedRate = 300000)
@Scheduled(fixedRate = 10000)
public void fetchTemperature() {
try {
if (!deviceStateService.getDeviceState().isVirtual()) {

3
src/main/java/com/iflytop/gd/hardware/command/handlers/DoorHandler.java

@ -61,6 +61,9 @@ public class DoorHandler extends CommandHandler {
} else if (command.getAction() == CmdAction.move_end) {
driver_.moveToEnd(stepMotorMId);
}
else if(command.getAction() == CmdAction.move_end) {
driver_.moveToEnd(stepMotorMId);
}
}
}

Loading…
Cancel
Save