add: 电梯驱动
This commit is contained in:
@@ -247,6 +247,15 @@ public class TwoNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
|
||||
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0);
|
||||
|
||||
}
|
||||
} else {
|
||||
|
||||
inst.setInstruction_status("2");
|
||||
try {
|
||||
instructionService.finish(inst);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -290,17 +299,17 @@ public class TwoNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
|
||||
if (device.getDeviceDriver() instanceof LiftDoorDeviceDriver) {
|
||||
liftDoorDeviceDriver = (LiftDoorDeviceDriver) device.getDeviceDriver();
|
||||
try {
|
||||
liftDoorDeviceDriver.writing("to_open1", "1");
|
||||
liftDoorDeviceDriver.writing("to_close1", "0");
|
||||
liftDoorDeviceDriver.writing("to_open", "1");
|
||||
liftDoorDeviceDriver.writing("to_close", "0");
|
||||
} catch (Exception e) {
|
||||
log.info("下发电梯门电气信号失败:" + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (liftDoorDeviceDriver.getOpen1() == 1 && liftDoorDeviceDriver.getToOpen1() == 1 ) {
|
||||
log.info("下发电梯门开门信号值为:{},读取开门信号值为:{}", liftDoorDeviceDriver.getToOpen1(), liftDoorDeviceDriver.getOpen1());
|
||||
if (liftDoorDeviceDriver.getOpen() == 1 && liftDoorDeviceDriver.getToOpen() == 1 ) {
|
||||
log.info("下发电梯门开门信号值为:{},读取开门信号值为:{}", liftDoorDeviceDriver.getToOpen(), liftDoorDeviceDriver.getOpen());
|
||||
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
|
||||
} else {
|
||||
log.info("未下发NDC信号原因: 下发开门信号值为:{},读取开门信号值为:{}", liftDoorDeviceDriver.getToOpen1(), liftDoorDeviceDriver.getOpen1());
|
||||
log.info("未下发NDC信号原因: 下发开门信号值为:{},读取开门信号值为:{}", liftDoorDeviceDriver.getToOpen(), liftDoorDeviceDriver.getOpen());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.sun.xml.bind.v2.TODO;
|
||||
import lombok.Data;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -557,7 +558,7 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic
|
||||
} else if (device.getDeviceDriver() instanceof ManipulatorAgvStationDeviceDriver) {
|
||||
manipulatorAgvStationDeviceDriver = (ManipulatorAgvStationDeviceDriver) device.getDeviceDriver();
|
||||
try {
|
||||
// manipulatorAgvStationDeviceDriver.writing(3);
|
||||
manipulatorAgvStationDeviceDriver.writing(3);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -996,62 +997,33 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic
|
||||
String start_device_code2 = inst.getStart_device_code2();
|
||||
String next_device_code2 = inst.getNext_device_code2();
|
||||
//取空锟或去烘箱放货的时候需要请求进入
|
||||
if (ObjectUtil.isNotEmpty(start_device_code) && StrUtil.equals(device_code, start_device_code)) {
|
||||
if (device.getDeviceDriver() instanceof ManipulatorAgvStationDeviceDriver) {
|
||||
manipulatorAgvStationDeviceDriver = (ManipulatorAgvStationDeviceDriver) device.getDeviceDriver();
|
||||
try {
|
||||
manipulatorAgvStationDeviceDriver.writing(6);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(manipulatorAgvStationDeviceDriver.getDevice().getExtraValue().get("ignore_release_check"))
|
||||
&& StrUtil.equals("true", manipulatorAgvStationDeviceDriver.getDevice().getExtraValue().get("ignore_release_check").toString())) {
|
||||
if (manipulatorAgvStationDeviceDriver.getAction() == 1 && manipulatorAgvStationDeviceDriver.getMode() == 2 && manipulatorAgvStationDeviceDriver.getMove() == 0) {
|
||||
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0);
|
||||
LuceneLogDto logDto = LuceneLogDto.builder()
|
||||
.device_code(this.getDeviceCode())
|
||||
.content("agvphase:" + phase + "反馈:" + data)
|
||||
.build();
|
||||
logDto.setLog_level(4);
|
||||
luceneExecuteLogService.deviceExecuteLog(logDto);
|
||||
} else {
|
||||
message = "设备号:" + device_code + ",动作信号:" + manipulatorAgvStationDeviceDriver.getAction() + "mode信号:" + manipulatorAgvStationDeviceDriver.getMode() + "光电信号:" + manipulatorAgvStationDeviceDriver.getMove() + ",指令号:" + ikey + "不满足取货条件";
|
||||
LuceneLogDto logDto = LuceneLogDto.builder()
|
||||
.device_code(manipulatorAgvStationDeviceDriver.getDeviceCode())
|
||||
.content(manipulatorAgvStationDeviceDriver.getDevice_code() + "动作信号不为1")
|
||||
.build();
|
||||
logDto.setLog_level(4);
|
||||
luceneExecuteLogService.deviceExecuteLog(logDto);
|
||||
}
|
||||
} else {
|
||||
if ((manipulatorAgvStationDeviceDriver.getAction() == 1)) {
|
||||
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0);
|
||||
LuceneLogDto logDto = LuceneLogDto.builder()
|
||||
.device_code(this.getDeviceCode())
|
||||
.content("agvphase:" + phase + "反馈:" + data)
|
||||
.build();
|
||||
logDto.setLog_level(4);
|
||||
luceneExecuteLogService.deviceExecuteLog(logDto);
|
||||
} else {
|
||||
message = "设备号:" + device_code + ",动作信号:" + manipulatorAgvStationDeviceDriver.getAction() + "报警信号:" + ",指令号:" + ikey + "不满足取货条件";
|
||||
LuceneLogDto logDto = LuceneLogDto.builder()
|
||||
.device_code(manipulatorAgvStationDeviceDriver.getDeviceCode())
|
||||
.content(manipulatorAgvStationDeviceDriver.getDevice_code() + "动作信号不为1")
|
||||
.build();
|
||||
logDto.setLog_level(4);
|
||||
luceneExecuteLogService.deviceExecuteLog(logDto);
|
||||
}
|
||||
}
|
||||
if (device.getDeviceDriver() instanceof ManipulatorAgvStationDeviceDriver) {
|
||||
manipulatorAgvStationDeviceDriver = (ManipulatorAgvStationDeviceDriver) device.getDeviceDriver();
|
||||
try {
|
||||
manipulatorAgvStationDeviceDriver.writing(6);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else if (ObjectUtil.isNotEmpty(start_device_code) && StrUtil.equals(device_code, next_device_code)) {
|
||||
if (device.getDeviceDriver() instanceof ManipulatorAgvStationDeviceDriver) {
|
||||
manipulatorAgvStationDeviceDriver = (ManipulatorAgvStationDeviceDriver) device.getDeviceDriver();
|
||||
|
||||
try {
|
||||
manipulatorAgvStationDeviceDriver.writing(4);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
if (ObjectUtil.isNotEmpty(manipulatorAgvStationDeviceDriver.getDevice().getExtraValue().get("ignore_release_check"))
|
||||
&& StrUtil.equals("true", manipulatorAgvStationDeviceDriver.getDevice().getExtraValue().get("ignore_release_check").toString())) {
|
||||
if (manipulatorAgvStationDeviceDriver.getAction() == 1 && manipulatorAgvStationDeviceDriver.getMode() == 2 && manipulatorAgvStationDeviceDriver.getMove() == 0) {
|
||||
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0);
|
||||
LuceneLogDto logDto = LuceneLogDto.builder()
|
||||
.device_code(this.getDeviceCode())
|
||||
.content("agvphase:" + phase + "反馈:" + data)
|
||||
.build();
|
||||
logDto.setLog_level(4);
|
||||
luceneExecuteLogService.deviceExecuteLog(logDto);
|
||||
} else {
|
||||
message = "设备号:" + device_code + ",动作信号:" + manipulatorAgvStationDeviceDriver.getAction() + "mode信号:" + manipulatorAgvStationDeviceDriver.getMode() + "光电信号:" + manipulatorAgvStationDeviceDriver.getMove() + ",指令号:" + ikey + "不满足取货条件";
|
||||
LuceneLogDto logDto = LuceneLogDto.builder()
|
||||
.device_code(manipulatorAgvStationDeviceDriver.getDeviceCode())
|
||||
.content(manipulatorAgvStationDeviceDriver.getDevice_code() + "不满足取货条件")
|
||||
.build();
|
||||
logDto.setLog_level(4);
|
||||
luceneExecuteLogService.deviceExecuteLog(logDto);
|
||||
}
|
||||
} else {
|
||||
if ((manipulatorAgvStationDeviceDriver.getAction() == 1)) {
|
||||
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0);
|
||||
LuceneLogDto logDto = LuceneLogDto.builder()
|
||||
@@ -1070,90 +1042,8 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic
|
||||
luceneExecuteLogService.deviceExecuteLog(logDto);
|
||||
}
|
||||
}
|
||||
} else if (ObjectUtil.isNotEmpty(start_device_code) && StrUtil.equals(device_code, start_device_code2)) {
|
||||
if (device.getDeviceDriver() instanceof ManipulatorAgvStationDeviceDriver) {
|
||||
manipulatorAgvStationDeviceDriver = (ManipulatorAgvStationDeviceDriver) device.getDeviceDriver();
|
||||
|
||||
try {
|
||||
manipulatorAgvStationDeviceDriver.writing(4);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if ((manipulatorAgvStationDeviceDriver.getAction() == 1)) {
|
||||
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0);
|
||||
LuceneLogDto logDto = LuceneLogDto.builder()
|
||||
.device_code(this.getDeviceCode())
|
||||
.content("agvphase:" + phase + "反馈:" + data)
|
||||
.build();
|
||||
logDto.setLog_level(4);
|
||||
luceneExecuteLogService.deviceExecuteLog(logDto);
|
||||
} else {
|
||||
message = "设备号:" + device_code + ",动作信号:" + manipulatorAgvStationDeviceDriver.getAction() + "报警信号:" + ",指令号:" + ikey + "不满足取货条件";
|
||||
LuceneLogDto logDto = LuceneLogDto.builder()
|
||||
.device_code(this.getDeviceCode())
|
||||
.content(manipulatorAgvStationDeviceDriver.getDevice_code() + "动作信号不为1")
|
||||
.build();
|
||||
logDto.setLog_level(4);
|
||||
luceneExecuteLogService.deviceExecuteLog(logDto);
|
||||
}
|
||||
}
|
||||
} else if (ObjectUtil.isNotEmpty(start_device_code) && StrUtil.equals(device_code, next_device_code2)) {
|
||||
if (device.getDeviceDriver() instanceof ManipulatorAgvStationDeviceDriver) {
|
||||
manipulatorAgvStationDeviceDriver = (ManipulatorAgvStationDeviceDriver) device.getDeviceDriver();
|
||||
try {
|
||||
manipulatorAgvStationDeviceDriver.writing(6);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(manipulatorAgvStationDeviceDriver.getDevice().getExtraValue().get("ignore_release_check"))
|
||||
&& StrUtil.equals("true", manipulatorAgvStationDeviceDriver.getDevice().getExtraValue().get("ignore_release_check").toString())) {
|
||||
if (manipulatorAgvStationDeviceDriver.getAction() == 1 && manipulatorAgvStationDeviceDriver.getMode() == 2 && manipulatorAgvStationDeviceDriver.getMove() == 0) {
|
||||
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0);
|
||||
LuceneLogDto logDto = LuceneLogDto.builder()
|
||||
.device_code(this.getDeviceCode())
|
||||
.content("agvphase:" + phase + "反馈:" + data)
|
||||
.build();
|
||||
logDto.setLog_level(4);
|
||||
luceneExecuteLogService.deviceExecuteLog(logDto);
|
||||
} else {
|
||||
message = "设备号:" + device_code + ",动作信号:" + manipulatorAgvStationDeviceDriver.getAction() + "mode信号:" + manipulatorAgvStationDeviceDriver.getMode() + "光电信号:" + manipulatorAgvStationDeviceDriver.getMove() + ",指令号:" + ikey + "不满足取货条件";
|
||||
LuceneLogDto logDto = LuceneLogDto.builder()
|
||||
.device_code(manipulatorAgvStationDeviceDriver.getDeviceCode())
|
||||
.content(manipulatorAgvStationDeviceDriver.getDevice_code() + "动作信号不为1")
|
||||
.build();
|
||||
logDto.setLog_level(4);
|
||||
luceneExecuteLogService.deviceExecuteLog(logDto);
|
||||
}
|
||||
} else {
|
||||
if ((manipulatorAgvStationDeviceDriver.getAction() == 1)) {
|
||||
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0);
|
||||
LuceneLogDto logDto = LuceneLogDto.builder()
|
||||
.device_code(this.getDeviceCode())
|
||||
.content("agvphase:" + phase + "反馈:" + data)
|
||||
.build();
|
||||
logDto.setLog_level(4);
|
||||
luceneExecuteLogService.deviceExecuteLog(logDto);
|
||||
} else {
|
||||
message = "设备号:" + device_code + ",动作信号:" + manipulatorAgvStationDeviceDriver.getAction() + "报警信号:" + ",指令号:" + ikey + "不满足取货条件";
|
||||
LuceneLogDto logDto = LuceneLogDto.builder()
|
||||
.device_code(manipulatorAgvStationDeviceDriver.getDeviceCode())
|
||||
.content(manipulatorAgvStationDeviceDriver.getDevice_code() + "动作信号不为1")
|
||||
.build();
|
||||
logDto.setLog_level(4);
|
||||
luceneExecuteLogService.deviceExecuteLog(logDto);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// else {
|
||||
// data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0);
|
||||
// LuceneLogDto logDto = LuceneLogDto.builder()
|
||||
// .device_code(this.getDeviceCode())
|
||||
// .content("agvphase:" + phase + "反馈:" + data)
|
||||
// .build();
|
||||
// logDto.setLog_level(4);
|
||||
// luceneExecuteLogService.deviceExecuteLog(logDto);
|
||||
// }
|
||||
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0);
|
||||
}
|
||||
//请求离开
|
||||
else if (phase == 0x4E) {
|
||||
@@ -1227,6 +1117,7 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic
|
||||
|
||||
}
|
||||
}
|
||||
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0);
|
||||
}
|
||||
|
||||
// 取货完毕
|
||||
@@ -2089,42 +1980,23 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic
|
||||
//申请烘箱行架任务
|
||||
if (ObjectUtil.isNotEmpty(manipulatorAgvStationDeviceDriver.getDevice().getExtraValue().get("request_robot_task"))
|
||||
&& StrUtil.equals("true", manipulatorAgvStationDeviceDriver.getDevice().getExtraValue().get("request_robot_task").toString())) {
|
||||
if (manipulatorAgvStationDeviceDriver.getTo_command() != 4) {
|
||||
String task_code = inst.getTask_code();
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("task_code", task_code);
|
||||
String response = acsToWmsService.applyOvenGantryTask(jsonObject);
|
||||
JSONObject jo = JSON.parseObject(response);
|
||||
if (jo.getInteger("status") == 200) {
|
||||
log.info("申请烘箱行架任务成功返回参数:"+ jo);
|
||||
try {
|
||||
manipulatorAgvStationDeviceDriver.writing(4);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
log.info("申请烘箱行架任务失败返回参数:"+ jo);
|
||||
String task_code = inst.getTask_code();
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("task_code", task_code);
|
||||
String response = acsToWmsService.applyOvenGantryTask(jsonObject);
|
||||
JSONObject jo = JSON.parseObject(response);
|
||||
if (jo.getInteger("status") == 200) {
|
||||
log.info("申请烘箱行架任务成功返回参数:" + jo);
|
||||
try {
|
||||
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
//行架取货完成后反馈ndc
|
||||
if ((manipulatorAgvStationDeviceDriver.getAction() == 2)) {
|
||||
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0);
|
||||
LuceneLogDto logDto = LuceneLogDto.builder()
|
||||
.device_code(this.getDeviceCode())
|
||||
.content("agvphase:" + phase + "反馈:" + data)
|
||||
.build();
|
||||
logDto.setLog_level(4);
|
||||
luceneExecuteLogService.deviceExecuteLog(logDto);
|
||||
} else {
|
||||
log.info("设备{},动作信号{} ,不满足取货条件,指令号{}", manipulatorAgvStationDeviceDriver.getDeviceCode(), manipulatorAgvStationDeviceDriver.getAction(), ikey);
|
||||
LuceneLogDto logDto = LuceneLogDto.builder()
|
||||
.device_code(manipulatorAgvStationDeviceDriver.getDeviceCode())
|
||||
.content(manipulatorAgvStationDeviceDriver.getDevice_code() + "动作信号不为1")
|
||||
.build();
|
||||
logDto.setLog_level(4);
|
||||
luceneExecuteLogService.deviceExecuteLog(logDto);
|
||||
log.info("申请烘箱行架任务失败返回参数:" + jo);
|
||||
}
|
||||
}else {
|
||||
manipulatorAgvStationDeviceDriver.writing(4);
|
||||
} else {
|
||||
try {
|
||||
manipulatorAgvStationDeviceDriver.writing(4);
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -45,7 +45,7 @@ public class AirShowerDoorDefination implements OpcDeviceDriverDefination {
|
||||
@Override
|
||||
public List<DeviceType> getFitDeviceTypes() {
|
||||
List<DeviceType> types = new LinkedList();
|
||||
types.add(DeviceType.conveyor);
|
||||
types.add(DeviceType.autodoor);
|
||||
return types;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
package org.nl.acs.device_driver.autodoor.fast_door;
|
||||
|
||||
import org.nl.acs.device.device_driver.standard_inspect.ItemDto;
|
||||
import org.nl.acs.device.domain.Device;
|
||||
import org.nl.acs.device.enums.DeviceType;
|
||||
import org.nl.acs.device_driver.DeviceDriver;
|
||||
import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 快卷门驱动定义
|
||||
*/
|
||||
@Service
|
||||
public class FastDoorDefination implements OpcDeviceDriverDefination {
|
||||
@Override
|
||||
public String getDriverCode() {
|
||||
return "fast_door";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDriverName() {
|
||||
return "快卷门";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDriverDescription() {
|
||||
return "快卷门";
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public DeviceDriver getDriverInstance(Device device) {
|
||||
return (new FastDoorDeviceDriver()).setDevice(device).setDriverDefination(this);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends DeviceDriver> getDeviceDriverType() {
|
||||
return FastDoorDeviceDriver.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DeviceType> getFitDeviceTypes() {
|
||||
List<DeviceType> types = new LinkedList();
|
||||
types.add(DeviceType.autodoor);
|
||||
return types;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<ItemDto> getReadableItemDtos() {
|
||||
return ItemProtocol.getReadableItemDtos();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemDto> getWriteableItemDtos() {
|
||||
return ItemProtocol.getWriteableItemDtos();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
package org.nl.acs.device_driver.autodoor.fast_door;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.Data;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.acs.device.domain.Device;
|
||||
import org.nl.acs.device_driver.DeviceDriver;
|
||||
import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver;
|
||||
import org.nl.acs.device_driver.driver.ExecutableDeviceDriver;
|
||||
import org.nl.acs.log.service.DeviceExecuteLogService;
|
||||
import org.nl.acs.monitor.DeviceStageMonitor;
|
||||
import org.nl.acs.utils.ReadUtil;
|
||||
import org.nl.config.SpringContextHolder;
|
||||
import org.nl.config.lucene.service.LuceneExecuteLogService;
|
||||
import org.nl.config.lucene.service.dto.LuceneLogDto;
|
||||
import org.openscada.opc.lib.da.Server;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* 快卷门驱动
|
||||
*/
|
||||
@Slf4j
|
||||
@Data
|
||||
@RequiredArgsConstructor
|
||||
public class FastDoorDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, DeviceStageMonitor {
|
||||
protected ItemProtocol itemProtocol = new ItemProtocol(this);
|
||||
protected ToDoorCommandControl toDoorCommandControl = new ToDoorCommandControl(this);
|
||||
DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl");
|
||||
@Autowired
|
||||
LuceneExecuteLogService luceneExecuteLogService = SpringContextHolder.getBean(LuceneExecuteLogService.class);
|
||||
|
||||
int open = 0;
|
||||
int close = 0;
|
||||
|
||||
int last_open = 0;
|
||||
int last_close = 0;
|
||||
|
||||
int toOpen = 0;
|
||||
int last_toOpen = 0;
|
||||
int toClose = 0;
|
||||
int last_toClose = 0;
|
||||
String device_code = null;
|
||||
|
||||
@Override
|
||||
public Device getDevice() {
|
||||
return this.device;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
String message = null;
|
||||
|
||||
device_code = this.getDevice().getDevice_code();
|
||||
open = this.itemProtocol.getOpen();
|
||||
close = this.itemProtocol.getClose();
|
||||
toOpen = this.itemProtocol.getToOpen();
|
||||
toClose = this.itemProtocol.getToClose();
|
||||
if (open != last_open) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号open:" + last_open + "->" + open);
|
||||
}
|
||||
if (close != last_close) {
|
||||
if(close ==1 ){
|
||||
this.writing("to_close","0");
|
||||
}
|
||||
}
|
||||
|
||||
last_open = open;
|
||||
last_close = close;
|
||||
last_toClose = toClose;
|
||||
last_toOpen = toOpen;
|
||||
}
|
||||
|
||||
|
||||
public void writing(String param, String value) {
|
||||
String to_param = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
|
||||
+ "." + param;
|
||||
Map<String, Object> itemMap = new HashMap<String, Object>();
|
||||
itemMap.put(to_param, Integer.parseInt(value));
|
||||
LuceneLogDto logDto = LuceneLogDto.builder()
|
||||
.device_code(device_code)
|
||||
.content("下发多个电气信号" + itemMap)
|
||||
.build();
|
||||
luceneExecuteLogService.deviceExecuteLog(logDto);
|
||||
try {
|
||||
this.toDoorCommandControl.control(param,value);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void writing(String param, int command) {
|
||||
String to_command = String.format("%s.%s.%s.%s", this.getDevice().getOpc_server_code(), this.getDevice().getOpc_plc_code(), this.getDevice().getDevice_code(), param);
|
||||
|
||||
String opcservcerid = this.getDevice().getOpc_server_id();
|
||||
Server server = ReadUtil.getServer(opcservcerid);
|
||||
Map<String, Object> itemMap = new HashMap<String, Object>();
|
||||
itemMap.put(to_command, command);
|
||||
ReadUtil.write(itemMap, server);
|
||||
log.info("下发PLC信号:{},{}", to_command, command);
|
||||
System.out.println("设备:" + this.device_code + ",下发PLC信号:" + to_command + ",value:" + command);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject getDeviceStatusName() {
|
||||
JSONObject jo = new JSONObject();
|
||||
String open = "";
|
||||
String close = "";
|
||||
if (this.getOpen() == 0) {
|
||||
open = "未知";
|
||||
} else if (this.getOpen() == 1) {
|
||||
open = "开到位";
|
||||
}
|
||||
if (this.getClose() == 0) {
|
||||
open = "未知";
|
||||
} else if (this.getClose() == 1) {
|
||||
open = "关到位";
|
||||
}
|
||||
jo.put("device_name", this.getDevice().getDevice_name());
|
||||
jo.put("open", open);
|
||||
jo.put("close", close);
|
||||
jo.put("isOnline", true);
|
||||
|
||||
return jo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDeviceStatus(JSONObject data) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
package org.nl.acs.device_driver.autodoor.fast_door;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.acs.device.device_driver.standard_inspect.ItemDto;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
public class ItemProtocol {
|
||||
public static String item_open = "open";
|
||||
public static String item_close = "close";
|
||||
public static String item_to_stop = "stop";
|
||||
public static String item_to_relieve_stop = "to_relieve_stop";
|
||||
public static String item_to_open = "to_open";
|
||||
public static String item_to_close = "to_close";
|
||||
|
||||
|
||||
|
||||
private FastDoorDeviceDriver driver;
|
||||
|
||||
public ItemProtocol(FastDoorDeviceDriver driver) {
|
||||
this.driver = driver;
|
||||
}
|
||||
|
||||
public int getOpen() {
|
||||
return this.getOpcIntegerValue(item_open);
|
||||
}
|
||||
|
||||
public int getClose() {
|
||||
return this.getOpcIntegerValue(item_close);
|
||||
}
|
||||
|
||||
|
||||
public int getToOpen() {
|
||||
return this.getOpcIntegerValue(item_to_open);
|
||||
}
|
||||
|
||||
public int getToClose() {
|
||||
return this.getOpcIntegerValue(item_to_close);
|
||||
}
|
||||
|
||||
public int getOpcIntegerValue(String protocol) {
|
||||
Integer value = this.driver.getIntegeregerValue(protocol);
|
||||
if (value == null) {
|
||||
// log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!");
|
||||
} else {
|
||||
return value;
|
||||
}
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
public String getOpcStringValue(String protocol) {
|
||||
String value = this.driver.getStringValue(protocol);
|
||||
if (StrUtil.isEmpty(value)) {
|
||||
|
||||
} else {
|
||||
return value;
|
||||
}
|
||||
return "0";
|
||||
}
|
||||
|
||||
public static List<ItemDto> getReadableItemDtos() {
|
||||
ArrayList list = new ArrayList();
|
||||
list.add(new ItemDto(item_open, "开到位", "10001"));
|
||||
list.add(new ItemDto(item_close, "关到位", "10002"));
|
||||
return list;
|
||||
}
|
||||
|
||||
public static List<ItemDto> getWriteableItemDtos() {
|
||||
ArrayList list = new ArrayList();
|
||||
list.add(new ItemDto(item_to_open, "下发开门", "00001" ));
|
||||
list.add(new ItemDto(item_to_close, "下发关门", "00002"));
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package org.nl.acs.device_driver.autodoor.fast_door;
|
||||
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class ToDoorCommandControl {
|
||||
|
||||
private FastDoorDeviceDriver driver;
|
||||
|
||||
public ToDoorCommandControl(FastDoorDeviceDriver driver){
|
||||
this.driver = driver;
|
||||
}
|
||||
|
||||
public void control(String param, String value) throws Exception {
|
||||
// ItemValue[] itemValues = new ItemValue[]{new ItemValue(this.driver.getItem(ItemProtocol.item_to_command), command)};
|
||||
Map<String, Object> itemMap = new HashMap<String, Object>();
|
||||
String to_param = this.driver.getDevice().getOpc_server_code() + "." + this.driver.getDevice().getOpc_plc_code() + "." + this.driver.getDevice().getDevice_code()
|
||||
+ "."+ param;
|
||||
itemMap.put(to_param, Integer.parseInt(value));
|
||||
try {
|
||||
this.driver.checkcontrol(itemMap);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -22,27 +22,30 @@ public class ItemProtocol {
|
||||
//机器人状态
|
||||
public static String item_robot_status = "lift_robot_status";
|
||||
|
||||
//主门开到位
|
||||
public static String item_open1 = "open";
|
||||
//门开到位
|
||||
public static String item_open = "open";
|
||||
|
||||
|
||||
//门关到位
|
||||
public static String item_close = "close";
|
||||
|
||||
//主门关到位
|
||||
public static String item_close1 = "close1";
|
||||
|
||||
//主门关到位
|
||||
public static String item_close2 = "close2";
|
||||
|
||||
//楼层
|
||||
public static String item_floor= "floor";
|
||||
|
||||
//开主门
|
||||
public static String item_to_open1 = "to_open1";
|
||||
|
||||
|
||||
|
||||
public static String item_to_call= "to_call";
|
||||
|
||||
//开门
|
||||
public static String item_to_open = "to_open";
|
||||
|
||||
//关门
|
||||
public static String item_to_close = "to_close";
|
||||
|
||||
//报警
|
||||
public static String item_error = "error";
|
||||
|
||||
|
||||
private LiftDoorDeviceDriver driver;
|
||||
|
||||
public ItemProtocol(LiftDoorDeviceDriver driver) {
|
||||
@@ -51,8 +54,8 @@ public class ItemProtocol {
|
||||
|
||||
|
||||
|
||||
public int getOpen1() {
|
||||
return this.getOpcIntegerValue(item_open1);
|
||||
public int getOpen() {
|
||||
return this.getOpcIntegerValue(item_open);
|
||||
}
|
||||
|
||||
public int getLiftStatus() {
|
||||
@@ -71,18 +74,13 @@ public class ItemProtocol {
|
||||
return this.getOpcIntegerValue(item_to_call);
|
||||
}
|
||||
|
||||
public int getClose2() {
|
||||
return this.getOpcIntegerValue(item_close2);
|
||||
}
|
||||
|
||||
public int getClose1() {
|
||||
return this.getOpcIntegerValue(item_close1);
|
||||
public int getClose() {
|
||||
return this.getOpcIntegerValue(item_close);
|
||||
}
|
||||
|
||||
|
||||
public int getToOpen1() {
|
||||
return this.getOpcIntegerValue(item_to_open1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public int getHeartbeat() {
|
||||
@@ -118,20 +116,21 @@ public class ItemProtocol {
|
||||
public static List<ItemDto> getReadableItemDtos() {
|
||||
ArrayList list = new ArrayList();
|
||||
list.add(new ItemDto(item_heartbeat, "心跳", "10003"));
|
||||
list.add(new ItemDto(item_open1, "主开到位", "10001"));
|
||||
list.add(new ItemDto(item_close1, "主关到位", "10002"));
|
||||
list.add(new ItemDto(item_close2, "副关到位", "10002"));
|
||||
list.add(new ItemDto(item_open, "门开到位", "10001"));
|
||||
list.add(new ItemDto(item_close, "门关到位", "10002"));
|
||||
list.add(new ItemDto(item_mode, "工作模式", "10004"));
|
||||
list.add(new ItemDto(item_lift_status, "状态(拥挤 空闲 一般)", "10002"));
|
||||
list.add(new ItemDto(item_robot_status, "机器人状态", "10002"));
|
||||
list.add(new ItemDto(item_floor, "楼层", "10002"));
|
||||
list.add(new ItemDto(item_error, "异常", "10002"));
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
public static List<ItemDto> getWriteableItemDtos() {
|
||||
ArrayList list = new ArrayList();
|
||||
list.add(new ItemDto(item_to_open1, "下发开主门", "10002"));
|
||||
list.add(new ItemDto(item_to_open, "下发开门", "10002"));
|
||||
list.add(new ItemDto(item_to_close, "下发关门", "00002"));
|
||||
list.add(new ItemDto(item_to_call, "呼叫", "10002"));
|
||||
return list;
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ import java.util.List;
|
||||
public class LiftDoorDefination implements OpcDeviceDriverDefination {
|
||||
@Override
|
||||
public String getDriverCode() {
|
||||
return "standard_autodoor";
|
||||
return "lift_door";
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -45,7 +45,7 @@ public class LiftDoorDefination implements OpcDeviceDriverDefination {
|
||||
@Override
|
||||
public List<DeviceType> getFitDeviceTypes() {
|
||||
List<DeviceType> types = new LinkedList();
|
||||
types.add(DeviceType.conveyor);
|
||||
types.add(DeviceType.autodoor);
|
||||
return types;
|
||||
}
|
||||
|
||||
|
||||
@@ -34,12 +34,12 @@ public class LiftDoorDeviceDriver extends AbstractOpcDeviceDriver implements Dev
|
||||
@Autowired
|
||||
LuceneExecuteLogService luceneExecuteLogService = SpringContextHolder.getBean(LuceneExecuteLogService.class);
|
||||
|
||||
int open1 = 0;
|
||||
int close1 = 0;
|
||||
int last_open1 = 0;
|
||||
int last_close1 = 0;
|
||||
int toOpen1 = 0;
|
||||
int last_toOpen1 = 0;
|
||||
int open = 0;
|
||||
int close = 0;
|
||||
int last_open = 0;
|
||||
int last_close = 0;
|
||||
int toOpen = 0;
|
||||
int last_toOpen = 0;
|
||||
int toClose = 0;
|
||||
int last_toClose = 0;
|
||||
String device_code = null;
|
||||
@@ -55,22 +55,23 @@ public class LiftDoorDeviceDriver extends AbstractOpcDeviceDriver implements Dev
|
||||
String message = null;
|
||||
|
||||
device_code = this.getDevice().getDevice_code();
|
||||
open1 = this.itemProtocol.getOpen1();
|
||||
close1 = this.itemProtocol.getClose1();
|
||||
toOpen1 = this.itemProtocol.getToOpen1();
|
||||
open = this.itemProtocol.getOpen();
|
||||
close = this.itemProtocol.getClose();
|
||||
|
||||
if (open1 != last_open1) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号open:" + last_open1 + "->" + open1);
|
||||
|
||||
if (open != last_open) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号open:" + last_open + "->" + open);
|
||||
}
|
||||
if (close1 != last_close1) {
|
||||
if(close1 ==1 ){
|
||||
if (close != last_close) {
|
||||
if(close ==1 ){
|
||||
this.writing("to_close","0");
|
||||
}
|
||||
}
|
||||
|
||||
last_open1 = open1;
|
||||
last_close1 = close1;
|
||||
last_toOpen1 = toOpen1;
|
||||
last_open = open;
|
||||
last_close = close;
|
||||
last_toOpen = toOpen;
|
||||
last_toClose = toClose;
|
||||
}
|
||||
|
||||
|
||||
@@ -109,14 +110,14 @@ public class LiftDoorDeviceDriver extends AbstractOpcDeviceDriver implements Dev
|
||||
JSONObject jo = new JSONObject();
|
||||
String open = "";
|
||||
String close = "";
|
||||
if (this.getOpen1() == 0) {
|
||||
if (this.getOpen() == 0) {
|
||||
open = "未知";
|
||||
} else if (this.getOpen1() == 1) {
|
||||
} else if (this.getOpen() == 1) {
|
||||
open = "开到位";
|
||||
}
|
||||
if (this.getClose1() == 0) {
|
||||
if (this.getClose() == 0) {
|
||||
open = "未知";
|
||||
} else if (this.getClose1() == 1) {
|
||||
} else if (this.getClose() == 1) {
|
||||
open = "关到位";
|
||||
}
|
||||
jo.put("device_name", this.getDevice().getDevice_name());
|
||||
|
||||
@@ -45,7 +45,7 @@ public class StandardAutodoorDefination implements OpcDeviceDriverDefination {
|
||||
@Override
|
||||
public List<DeviceType> getFitDeviceTypes() {
|
||||
List<DeviceType> types = new LinkedList();
|
||||
types.add(DeviceType.conveyor);
|
||||
types.add(DeviceType.autodoor);
|
||||
return types;
|
||||
}
|
||||
|
||||
|
||||
@@ -543,8 +543,20 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
|
||||
Device lift1 = deviceAppService.findDeviceByCode(linkDeviceCode.get(0));
|
||||
Device lift2 = deviceAppService.findDeviceByCode(linkDeviceCode.get(1));
|
||||
if (lift1.getDeviceDriver() instanceof LiftDoorDeviceDriver && lift2.getDeviceDriver() instanceof LiftDoorDeviceDriver){
|
||||
// if (lift1.getDeviceDriver().get)
|
||||
dto.setNext_device_code(lift1.getDevice_code());
|
||||
// if (lift1.getDeviceDriver().get)
|
||||
String nextLift1 = dto.getNext_device_code()+"_"+lift1.getDevice_code();
|
||||
String nextLift2 = dto.getNext_device_code()+"_"+lift2.getDevice_code();
|
||||
|
||||
List<TaskDto> byStarCodeAndExcute1 = taskService.findByNextCodeAndExcute(nextLift1);
|
||||
List<TaskDto> byStarCodeAndExcute2 = taskService.findByNextCodeAndExcute(nextLift2);
|
||||
if (byStarCodeAndExcute1.size() <= byStarCodeAndExcute2.size() ) {
|
||||
// if (lift1.getDeviceDriver()){
|
||||
//
|
||||
// }
|
||||
dto.setNext_device_code(nextLift1);
|
||||
} else {
|
||||
dto.setNext_device_code(nextLift2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -556,4 +556,12 @@ public interface TaskService extends CommonService<Task> {
|
||||
TaskDto findByTaskCode(String task_code);
|
||||
|
||||
List<TaskDto> queryAllHJReadyTask();
|
||||
|
||||
|
||||
/**
|
||||
* 根据终点查询就绪执行中的任务
|
||||
* @param nextLift1
|
||||
* @return
|
||||
*/
|
||||
List<TaskDto> findByNextCodeAndExcute(String nextLift1);
|
||||
}
|
||||
|
||||
@@ -971,6 +971,7 @@ public class TaskServiceImpl extends CommonServiceImpl<TaskMapper, Task> impleme
|
||||
routeLineService.getShortPathLines(
|
||||
start_device_code, acsTask.getNext_device_code(), route_plan_code);
|
||||
Device startDevice = deviceAppService.findDeviceByCode(start_device_code);
|
||||
Device nextDevice = deviceAppService.findDeviceByCode(next_device_code);
|
||||
RouteLineDto routeLineDto = shortPathsList.get(0);
|
||||
String path = routeLineDto.getPath();
|
||||
String type = routeLineDto.getType();
|
||||
@@ -980,7 +981,7 @@ public class TaskServiceImpl extends CommonServiceImpl<TaskMapper, Task> impleme
|
||||
for (int m = 0; m < pathlist.size(); m++) {
|
||||
if (pathlist.get(m).equals(start_device_code)) {
|
||||
//起点为货架跳过堆垛机
|
||||
if (startDevice.getDeviceDriver() instanceof StandardStorageDeviceDriver) {
|
||||
if (startDevice.getDeviceDriver() instanceof StandardStorageDeviceDriver || nextDevice.getDeviceDriver() instanceof StandardStorageDeviceDriver ) {
|
||||
index = m + 2;
|
||||
}else {
|
||||
index = m + 1;
|
||||
@@ -1660,6 +1661,14 @@ public class TaskServiceImpl extends CommonServiceImpl<TaskMapper, Task> impleme
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TaskDto> findByNextCodeAndExcute(String nextLift) {
|
||||
List<TaskDto> taskDtoList = tasks.stream()
|
||||
.filter(task -> StrUtil.equals(task.getStart_device_code(), nextLift)
|
||||
&& (StrUtil.equals(task.getTask_status(), TaskStatusEnum.BUSY.getIndex()) || StrUtil.equals(task.getTask_status(), TaskStatusEnum.READY.getIndex()))).collect(Collectors.toList());
|
||||
return taskDtoList;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 把多个字符串拼接的inst_nextDevice_code解析成集合
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
server:
|
||||
port: 8011
|
||||
port: 8012
|
||||
#配置数据源
|
||||
spring:
|
||||
messages:
|
||||
|
||||
Reference in New Issue
Block a user