add: agv偏移功能

This commit is contained in:
yanps
2024-05-21 18:38:01 +08:00
parent a57a696a9b
commit fa4a85ebcc
8 changed files with 209 additions and 62 deletions

View File

@@ -55,6 +55,15 @@ public interface NDCAgvService {
*/
public byte[] sendAgvTwoModeInst(int phase, int index, int result);
/**
* 下发agv偏移指令
* @param phase
* @param index
* @param result
* @return
*/
public byte[] sendAgvTwoModeInst(int phase, int index, int result,int offset,int quantity);
/**
* 下发一号agv指令
* @param phase

View File

@@ -336,6 +336,39 @@ public class NDCAgvServiceImpl implements NDCAgvService {
return b;
}
@Override
public byte[] sendAgvTwoModeInst(int phase, int index, int result,int offset,int quantity) {
if (phase < 0 || index < 0)
return null;
byte indexhigh = (byte) IntToHexHigh(index);
byte indexlow = (byte) IntToHexLow(index);
byte phasehigh = (byte) IntToHexHigh(phase);
byte phaselow = (byte) IntToHexLow(phase);
byte offsethigh = (byte) IntToHexHigh(offset);
byte offsetlow = (byte) IntToHexLow(offset);
byte quantityhigh = (byte) IntToHexHigh(quantity);
byte quantitylow = (byte) IntToHexLow(quantity);
byte[] b = new byte[]{(byte) 0X87, (byte) 0XCD,
(byte) 0X00, (byte) 0X08,
(byte) 0X00, (byte) 0X0E,
(byte) 0X00, (byte) 0X01,
(byte) 0X00, (byte) 0X6D,
(byte) 0X00, (byte) 0X0A,
(byte) indexhigh, (byte) indexlow,
(byte) 0X01, (byte) 0X12,
(byte) phasehigh, (byte) phaselow,
(byte) offsethigh, (byte) offsetlow,
(byte) quantityhigh, (byte) quantitylow
};
log.info("反馈agv动作数据--index:" + hexToString(indexhigh & 0xFF) + hexToString(indexlow & 0xFF) + ",phase:" + hexToString(phasehigh & 0xFF) + hexToString(phaselow & 0xFF));
System.out.println("反馈agv动作数据:" + Bytes2HexString(b));
return b;
}
@Override
public byte[] sendAgvOneModeInst(int phase, int index, int result) {

View File

@@ -1,5 +1,6 @@
package org.nl.acs.device_driver.agv.ndctwo;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject;
@@ -21,6 +22,7 @@ import org.nl.acs.device_driver.storage.standard_storage.StandardStorageDeviceDr
import org.nl.acs.device_driver.driver.AbstractDeviceDriver;
import org.nl.acs.device_driver.two_conveyor.hongxiang_conveyor.HongXiangStationDeviceDriver;
import org.nl.acs.device_driver.two_conveyor.manipulator_agv_station.ManipulatorAgvStationDeviceDriver;
import org.nl.acs.device_driver.two_conveyor.ranging_stations.RangingStationsDeviceDriver;
import org.nl.acs.ext.wms.service.AcsToWmsService;
import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl;
import org.nl.acs.history.ErrorUtil;
@@ -162,6 +164,8 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic
HongXiangStationDeviceDriver hongXiangStationDeviceDriver;
//行架-agv对接位
ManipulatorAgvStationDeviceDriver manipulatorAgvStationDeviceDriver;
//行架-agv对接位
RangingStationsDeviceDriver rangingStationsDeviceDriver;
if (phase == 0x02) {
if (ObjectUtil.isEmpty(inst)) {
@@ -236,15 +240,15 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic
message = "等待LMS系统进行确认允许取货,设备号:" + device_code + ",指令号:" + ikey;
logServer.deviceExecuteLog(this.device_code, "", "", "等待LMS系统进行确认允许取货,设备号" + device.getDevice_code() + ",指令号" + ikey);
} else {
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0);
}
}else {
} else {
log.info("等待LMS系统进行确认允许取货设备号{},指令号{}", device_code, ikey);
message = "等待LMS系统进行确认允许取货,设备号:" + device_code + ",指令号:" + ikey;
logServer.deviceExecuteLog(this.device_code, "", "", "等待LMS系统进行确认允许取货,设备号" + device.getDevice_code() + ",指令号" + ikey);
}
}else {
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
} else {
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0);
}
} else if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) {
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver();
@@ -256,7 +260,7 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic
}
if ((standardInspectSiteDeviceDriver.getMove() == 1 && standardInspectSiteDeviceDriver.getAction() == 1
&& standardInspectSiteDeviceDriver.getError() == 0)) {
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0);
} else {
message = "设备号:" + device_code + "光电信号:" + standardInspectSiteDeviceDriver.getMove() + ",动作信号:" + standardInspectSiteDeviceDriver.getAction() + "报警信号:" + standardInspectSiteDeviceDriver.getError() + ",指令号:" + ikey + "不满足取货条件";
log.info("设备{}当前光电信号{},动作信号{} ,错误信号{},不满足取货条件,指令号{}", device_code, standardInspectSiteDeviceDriver.getMove(), standardInspectSiteDeviceDriver.getAction()
@@ -271,7 +275,7 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic
e.printStackTrace();
}
if ((manipulatorAgvStationDeviceDriver.getAction() == 1)) {
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0);
} else {
message = "设备号:" + device_code + ",动作信号:" + manipulatorAgvStationDeviceDriver.getAction() + "报警信号:" + ",指令号:" + ikey + "不满足取货条件";
log.info("设备{},动作信号{} ,不满足取货条件,指令号{}", device_code, manipulatorAgvStationDeviceDriver.getAction(), ikey);
@@ -284,7 +288,7 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic
e.printStackTrace();
}
if (hongXiangStationDeviceDriver.getMove() > 0) {
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0);
} else {
message = "设备号:" + device_code + "光电信号:" + hongXiangStationDeviceDriver.getMove() + ",动作信号:" + hongXiangStationDeviceDriver.getAction() + "报警信号:" + hongXiangStationDeviceDriver.getError() + ",指令号:" + ikey + "不满足取货条件";
log.info("设备{}当前光电信号{},动作信号{} ,错误信号{},不满足取货条件,指令号{}", device_code, hongXiangStationDeviceDriver.getMove(), hongXiangStationDeviceDriver.getAction()
@@ -298,14 +302,27 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic
e.printStackTrace();
}
if (paperTubePickSiteDeviceDriver.getMove() > 0) {
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0);
} else {
message = "设备号:" + device_code + "光电信号:" + paperTubePickSiteDeviceDriver.getMove() + ",动作信号:" + paperTubePickSiteDeviceDriver.getAction() + "报警信号:" + paperTubePickSiteDeviceDriver.getError() + ",指令号:" + ikey + "不满足取货条件";
log.info("设备{}当前光电信号{},动作信号{} ,错误信号{},不满足取货条件,指令号{}", device_code, paperTubePickSiteDeviceDriver.getMove(), paperTubePickSiteDeviceDriver.getAction()
, paperTubePickSiteDeviceDriver.getError(), ikey);
}
} else if (device.getDeviceDriver() instanceof RangingStationsDeviceDriver) {
rangingStationsDeviceDriver = (RangingStationsDeviceDriver) device.getDeviceDriver();
String length1 = rangingStationsDeviceDriver.getLength1();
Float len = 0.0F;
if (ObjectUtil.isNotEmpty(length1) && !"null".equals(length1)) {
len = Float.parseFloat(length1);
}
int roundedNumber = ObjectUtil.isNotEmpty(len) ? NumberUtil.round(len, 0).intValue() : 0;
if (roundedNumber == 0) {
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, roundedNumber);
} else {
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 1, roundedNumber);
}
} else {
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0);
LuceneLogDto logDto = LuceneLogDto.builder()
.device_code(device_code)
.content("agvphase:" + phase + "反馈:" + data)
@@ -371,9 +388,9 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic
&& StrUtil.equals("true", this.device.getExtraValue().get("wait").toString())
&& StrUtil.equals(task.getTask_type(), "1")) {
standardOrdinarySiteDeviceDriver.setOption(0);
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
}else {
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0);
} else {
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0);
}
this.setPhase(phase);
} else if (device.getDeviceDriver() instanceof ManipulatorAgvStationDeviceDriver) {
@@ -385,7 +402,7 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic
e.printStackTrace();
}
if ((manipulatorAgvStationDeviceDriver.getAction() == 1)) {
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0);
} else {
message = "设备号:" + device_code + ",动作信号:" + manipulatorAgvStationDeviceDriver.getAction() + "报警信号:" + ",指令号:" + ikey + "不满足取货条件";
log.info("设备{},动作信号{} ,不满足取货条件,指令号{}", device_code, manipulatorAgvStationDeviceDriver.getAction(), ikey);
@@ -398,7 +415,7 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic
e.printStackTrace();
}
if (hongXiangStationDeviceDriver.getMove() > 0) {
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0);
} else {
message = "设备号:" + device_code + "光电信号:" + hongXiangStationDeviceDriver.getMove() + ",动作信号:" + hongXiangStationDeviceDriver.getAction() + "报警信号:" + hongXiangStationDeviceDriver.getError() + ",指令号:" + ikey + "不满足取货条件";
log.info("设备{}当前光电信号{},动作信号{} ,错误信号{},不满足取货条件,指令号{}", device_code, hongXiangStationDeviceDriver.getMove(), hongXiangStationDeviceDriver.getAction()
@@ -412,7 +429,7 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic
e.printStackTrace();
}
if (paperTubePickSiteDeviceDriver.getMove() == 0) {
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0);
} else {
message = "设备号:" + device_code + "光电信号:" + paperTubePickSiteDeviceDriver.getMove() + ",动作信号:" + paperTubePickSiteDeviceDriver.getAction() + "报警信号:" + paperTubePickSiteDeviceDriver.getError() + ",指令号:" + ikey + "不满足取货条件";
log.info("设备{}当前光电信号{},动作信号{} ,错误信号{},不满足取货条件,指令号{}", device_code, paperTubePickSiteDeviceDriver.getMove(), paperTubePickSiteDeviceDriver.getAction()
@@ -427,14 +444,14 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic
e.printStackTrace();
}
if ((standardInspectSiteDeviceDriver.getMove() != 1 && standardInspectSiteDeviceDriver.getAction() == 1 && standardInspectSiteDeviceDriver.getError() == 0)) {
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0);
} else {
message = "设备号:" + device_code + "光电信号:" + standardInspectSiteDeviceDriver.getMove() + ",动作信号:" + standardInspectSiteDeviceDriver.getAction() + "报警信号:" + standardInspectSiteDeviceDriver.getError() + ",指令号:" + ikey + "不满足取货条件";
log.info("设备{}当前光电信号{},动作信号{} ,错误信号{},不满足取货条件,指令号{}", device_code, standardInspectSiteDeviceDriver.getMove(), standardInspectSiteDeviceDriver.getAction()
, standardInspectSiteDeviceDriver.getError(), ikey);
}
} else {
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0);
LuceneLogDto logDto = LuceneLogDto.builder()
.device_code(device_code)
.content("agvphase:" + phase + "反馈:" + data)
@@ -501,15 +518,15 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic
message = "等待LMS系统进行确认允许取货,设备号:" + device_code + ",指令号:" + ikey;
logServer.deviceExecuteLog(this.device_code, "", "", "等待LMS系统进行确认允许取货,设备号" + device.getDevice_code() + ",指令号" + ikey);
} else {
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0);
}
} else {
log.info("等待LMS系统进行确认允许取货设备号{},指令号{}", device_code, ikey);
message = "等待LMS系统进行确认允许取货,设备号:" + device_code + ",指令号:" + ikey;
logServer.deviceExecuteLog(this.device_code, "", "", "等待LMS系统进行确认允许取货,设备号" + device.getDevice_code());
}
}else {
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
} else {
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0);
}
} else if (device.getDeviceDriver() instanceof ManipulatorAgvStationDeviceDriver) {
manipulatorAgvStationDeviceDriver = (ManipulatorAgvStationDeviceDriver) device.getDeviceDriver();
@@ -520,7 +537,7 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic
e.printStackTrace();
}
if ((manipulatorAgvStationDeviceDriver.getAction() == 1)) {
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0);
} else {
message = "设备号:" + device_code + ",动作信号:" + manipulatorAgvStationDeviceDriver.getAction() + "报警信号:" + ",指令号:" + ikey + "不满足取货条件";
log.info("设备{},动作信号{} ,不满足取货条件,指令号{}", device_code, manipulatorAgvStationDeviceDriver.getAction(), ikey);
@@ -533,7 +550,7 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic
e.printStackTrace();
}
if (paperTubePickSiteDeviceDriver.getMove() == 1) {
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0);
} else {
message = "设备号:" + device_code + "光电信号:" + paperTubePickSiteDeviceDriver.getMove() + ",动作信号:" + paperTubePickSiteDeviceDriver.getAction() + "报警信号:" + paperTubePickSiteDeviceDriver.getError() + ",指令号:" + ikey + "不满足取货条件";
log.info("设备{}当前光电信号{},动作信号{} ,错误信号{},不满足取货条件,指令号{}", device_code, paperTubePickSiteDeviceDriver.getMove(), paperTubePickSiteDeviceDriver.getAction()
@@ -547,7 +564,7 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic
e.printStackTrace();
}
if (hongXiangStationDeviceDriver.getMove() > 0) {
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0);
} else {
message = "设备号:" + device_code + "光电信号:" + hongXiangStationDeviceDriver.getMove() + ",动作信号:" + hongXiangStationDeviceDriver.getAction() + "报警信号:" + hongXiangStationDeviceDriver.getError() + ",指令号:" + ikey + "不满足取货条件";
log.info("设备{}当前光电信号{},动作信号{} ,错误信号{},不满足取货条件,指令号{}", device_code, hongXiangStationDeviceDriver.getMove(), hongXiangStationDeviceDriver.getAction()
@@ -562,14 +579,27 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic
e.printStackTrace();
}
if ((standardInspectSiteDeviceDriver.getMove() == 1 && standardInspectSiteDeviceDriver.getAction() == 1 && standardInspectSiteDeviceDriver.getError() == 0)) {
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0);
} else {
message = "设备号:" + device_code + "光电信号:" + standardInspectSiteDeviceDriver.getMove() + ",动作信号:" + standardInspectSiteDeviceDriver.getAction() + "报警信号:" + standardInspectSiteDeviceDriver.getError() + ",指令号:" + ikey + "不满足取货条件";
log.info("设备{}当前光电信号{},动作信号{} ,错误信号{},不满足取货条件,指令号{}", device_code, standardInspectSiteDeviceDriver.getMove(), standardInspectSiteDeviceDriver.getAction()
, standardInspectSiteDeviceDriver.getError(), ikey);
}
} else if (device.getDeviceDriver() instanceof RangingStationsDeviceDriver) {
rangingStationsDeviceDriver = (RangingStationsDeviceDriver) device.getDeviceDriver();
String length1 = rangingStationsDeviceDriver.getLength1();
Float len = 0.0F;
if (ObjectUtil.isNotEmpty(length1) && !"null".equals(length1)) {
len = Float.parseFloat(length1);
}
int roundedNumber = ObjectUtil.isNotEmpty(len) ? NumberUtil.round(len, 0).intValue() : 0;
if (roundedNumber == 0) {
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, roundedNumber);
} else {
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 1, roundedNumber);
}
} else {
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0);
LuceneLogDto logDto = LuceneLogDto.builder()
.device_code(device_code)
.content("agvphase:" + phase + "反馈:" + data)
@@ -625,7 +655,7 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic
if (ObjectUtil.isNotEmpty(standardOrdinarySiteDeviceDriver.getDevice().getExtraValue().get("wait"))
&& StrUtil.equals("true", standardOrdinarySiteDeviceDriver.getDevice().getExtraValue().get("wait").toString())) {
standardOrdinarySiteDeviceDriver.setOption(0);
}else {
} else {
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
}
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
@@ -771,7 +801,7 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic
if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver();
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0);
standardOrdinarySiteDeviceDriver.setAgvphase(phase);
standardOrdinarySiteDeviceDriver.setIndex(index);
@@ -785,7 +815,7 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic
e.printStackTrace();
}
if (paperTubePickSiteDeviceDriver.getMove() == 0) {
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0);
} else {
message = "设备号:" + device_code + "光电信号:" + paperTubePickSiteDeviceDriver.getMove() + ",动作信号:" + paperTubePickSiteDeviceDriver.getAction() + "报警信号:" + paperTubePickSiteDeviceDriver.getError() + ",指令号:" + ikey + "不满足取货条件";
log.info("设备{}当前光电信号{},动作信号{} ,错误信号{},不满足取货条件,指令号{}", device_code, paperTubePickSiteDeviceDriver.getMove(), paperTubePickSiteDeviceDriver.getAction()
@@ -800,7 +830,7 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic
e.printStackTrace();
}
if ((manipulatorAgvStationDeviceDriver.getAction() == 1)) {
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0);
} else {
message = "设备号:" + device_code + ",动作信号:" + manipulatorAgvStationDeviceDriver.getAction() + "报警信号:" + ",指令号:" + ikey + "不满足取货条件";
log.info("设备{},动作信号{} ,不满足取货条件,指令号{}", device_code, manipulatorAgvStationDeviceDriver.getAction(), ikey);
@@ -813,7 +843,7 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic
e.printStackTrace();
}
if (hongXiangStationDeviceDriver.getMove() == 0) {
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0);
} else {
message = "设备号:" + device_code + "光电信号:" + hongXiangStationDeviceDriver.getMove() + ",动作信号:" + hongXiangStationDeviceDriver.getAction() + "报警信号:" + hongXiangStationDeviceDriver.getError() + ",指令号:" + ikey + "不满足取货条件";
log.info("设备{}当前光电信号{},动作信号{} ,错误信号{},不满足取货条件,指令号{}", device_code, hongXiangStationDeviceDriver.getMove(), hongXiangStationDeviceDriver.getAction()
@@ -823,14 +853,27 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver();
standardInspectSiteDeviceDriver.writing(1);
if ((standardInspectSiteDeviceDriver.getMove() == 0 && standardInspectSiteDeviceDriver.getAction() == 1 && standardInspectSiteDeviceDriver.getError() == 0)) {
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0);
} else {
message = "设备号:" + device_code + "光电信号:" + standardInspectSiteDeviceDriver.getMove() + ",动作信号:" + standardInspectSiteDeviceDriver.getAction() + "报警信号:" + standardInspectSiteDeviceDriver.getError() + ",指令号:" + ikey + "不满足放货条件";
log.info("设备{}当前光电信号{},动作信号{} ,报警信号{},不满足放货条件,指令号{}", device_code, standardInspectSiteDeviceDriver.getMove(), standardInspectSiteDeviceDriver.getAction()
, standardInspectSiteDeviceDriver.getError(), ikey);
}
} else if (device.getDeviceDriver() instanceof RangingStationsDeviceDriver) {
rangingStationsDeviceDriver = (RangingStationsDeviceDriver) device.getDeviceDriver();
String length1 = rangingStationsDeviceDriver.getLength1();
Float len = 0.0F;
if (ObjectUtil.isNotEmpty(length1) && !"null".equals(length1)) {
len = Float.parseFloat(length1);
}
int roundedNumber = ObjectUtil.isNotEmpty(len) ? NumberUtil.round(len, 0).intValue() : 0;
if (roundedNumber == 0) {
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, roundedNumber);
} else {
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 1, roundedNumber);
}
} else {
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0);
}
}
//放货完成
@@ -888,7 +931,7 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic
// } else {
// data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
// }
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0);
this.setPhase(phase);
} else if (device.getDeviceDriver() instanceof ManipulatorAgvStationDeviceDriver) {
manipulatorAgvStationDeviceDriver = (ManipulatorAgvStationDeviceDriver) device.getDeviceDriver();
@@ -899,7 +942,7 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic
e.printStackTrace();
}
if ((manipulatorAgvStationDeviceDriver.getAction() == 1)) {
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0);
} else {
message = "设备号:" + device_code + ",动作信号:" + manipulatorAgvStationDeviceDriver.getAction() + "报警信号:" + ",指令号:" + ikey + "不满足取货条件";
log.info("设备{},动作信号{} ,不满足取货条件,指令号{}", device_code, manipulatorAgvStationDeviceDriver.getAction(), ikey);
@@ -912,7 +955,7 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic
e.printStackTrace();
}
if (hongXiangStationDeviceDriver.getMove() > 0) {
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0);
} else {
message = "设备号:" + device_code + "光电信号:" + hongXiangStationDeviceDriver.getMove() + ",动作信号:" + hongXiangStationDeviceDriver.getAction() + "报警信号:" + hongXiangStationDeviceDriver.getError() + ",指令号:" + ikey + "不满足取货条件";
log.info("设备{}当前光电信号{},动作信号{} ,错误信号{},不满足取货条件,指令号{}", device_code, hongXiangStationDeviceDriver.getMove(), hongXiangStationDeviceDriver.getAction()
@@ -926,7 +969,7 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic
e.printStackTrace();
}
if (paperTubePickSiteDeviceDriver.getMove() > 0) {
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0);
} else {
message = "设备号:" + device_code + "光电信号:" + paperTubePickSiteDeviceDriver.getMove() + ",动作信号:" + paperTubePickSiteDeviceDriver.getAction() + "报警信号:" + paperTubePickSiteDeviceDriver.getError() + ",指令号:" + ikey + "不满足取货条件";
log.info("设备{}当前光电信号{},动作信号{} ,错误信号{},不满足取货条件,指令号{}", device_code, paperTubePickSiteDeviceDriver.getMove(), paperTubePickSiteDeviceDriver.getAction()
@@ -936,10 +979,10 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver();
standardInspectSiteDeviceDriver.writing(0);
if ((standardInspectSiteDeviceDriver.getMove() == 1)) {
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0);
}
} else {
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0);
}
}
//到达放货点
@@ -999,7 +1042,7 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic
// } else {
// data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
// }
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0);
this.setPhase(phase);
} else if (device.getDeviceDriver() instanceof ManipulatorAgvStationDeviceDriver) {
@@ -1011,7 +1054,7 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic
e.printStackTrace();
}
if ((manipulatorAgvStationDeviceDriver.getAction() == 1)) {
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0);
} else {
message = "设备号:" + device_code + ",动作信号:" + manipulatorAgvStationDeviceDriver.getAction() + "报警信号:" + ",指令号:" + ikey + "不满足取货条件";
log.info("设备{},动作信号{} ,不满足取货条件,指令号{}", device_code, manipulatorAgvStationDeviceDriver.getAction(), ikey);
@@ -1024,7 +1067,7 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic
e.printStackTrace();
}
if (hongXiangStationDeviceDriver.getMove() == 0) {
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0);
} else {
message = "设备号:" + device_code + "光电信号:" + hongXiangStationDeviceDriver.getMove() + ",动作信号:" + hongXiangStationDeviceDriver.getAction() + "报警信号:" + hongXiangStationDeviceDriver.getError() + ",指令号:" + ikey + "不满足取货条件";
log.info("设备{}当前光电信号{},动作信号{} ,错误信号{},不满足取货条件,指令号{}", device_code, hongXiangStationDeviceDriver.getMove(), hongXiangStationDeviceDriver.getAction()
@@ -1038,14 +1081,27 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic
e.printStackTrace();
}
if (paperTubePickSiteDeviceDriver.getMove() == 0) {
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0);
} else {
message = "设备号:" + device_code + "光电信号:" + paperTubePickSiteDeviceDriver.getMove() + ",动作信号:" + paperTubePickSiteDeviceDriver.getAction() + "报警信号:" + paperTubePickSiteDeviceDriver.getError() + ",指令号:" + ikey + "不满足取货条件";
log.info("设备{}当前光电信号{},动作信号{} ,错误信号{},不满足取货条件,指令号{}", device_code, paperTubePickSiteDeviceDriver.getMove(), paperTubePickSiteDeviceDriver.getAction()
, paperTubePickSiteDeviceDriver.getError(), ikey);
}
} else if (device.getDeviceDriver() instanceof RangingStationsDeviceDriver) {
rangingStationsDeviceDriver = (RangingStationsDeviceDriver) device.getDeviceDriver();
String length1 = rangingStationsDeviceDriver.getLength1();
Float len = 0.0F;
if (ObjectUtil.isNotEmpty(length1) && !"null".equals(length1)) {
len = Float.parseFloat(length1);
}
int roundedNumber = ObjectUtil.isNotEmpty(len) ? NumberUtil.round(len, 0).intValue() : 0;
if (roundedNumber == 0) {
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, roundedNumber);
} else {
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 1, roundedNumber);
}
} else {
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0);
}
}
}

View File

@@ -30,7 +30,10 @@ import org.nl.acs.utils.ConvertUtil;
import org.nl.common.utils.CodeUtil;
import org.nl.config.SpringContextHolder;
import org.nl.config.language.LangProcess;
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.Date;
import java.util.HashMap;
@@ -57,6 +60,9 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp
TaskMapper taskMapper;
AcsToWmsService acsToWmsService = SpringContextHolder.getBean("acsToWmsServiceImpl");
@Autowired
LuceneExecuteLogService luceneExecuteLogService = SpringContextHolder.getBean(LuceneExecuteLogService.class);
String container;
String container_type_desc;
@@ -330,13 +336,19 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp
public void writing(int command) {
String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
+ "." + ItemProtocol.item_to_command;
//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);
this.control(itemMap);
try {
this.checkcontrol(itemMap);
} catch (Exception e) {
e.printStackTrace();
}
LuceneLogDto logDto = LuceneLogDto.builder()
.device_code(devicecode)
.content("下发多个电气信号" + itemMap)
.build();
logDto.setLog_level(3);
luceneExecuteLogService.deviceExecuteLog(logDto);
}
public void writing(int type, int command) {

View File

@@ -123,8 +123,6 @@ public class ItemProtocol {
public String getOpcStringValue(String protocol) {
String value = this.driver.getStringValue(protocol);
if (StrUtil.isBlank(value)) {
//throw new BusinessException("{} : {}", new Object[]{protocol, DeviceErrorProtocol.getMessage(10000)});
} else {
return value;
}

View File

@@ -1,5 +1,6 @@
package org.nl.acs.device_driver.two_conveyor.ranging_stations;
import cn.hutool.core.util.StrUtil;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.nl.acs.device.device_driver.standard_inspect.ItemDto;
@@ -13,7 +14,8 @@ public class ItemProtocol {
public static String item_mode = "mode";
public static String item_length = "length";
public static String item_length1 = "length1";
public static String item_length2 = "length2";
public static String item_action = "action";
public static String item_to_command = "to_command";
@@ -26,12 +28,16 @@ public class ItemProtocol {
public int getMode() {
return this.getOpcIntegerValue(item_mode);
}
public int getLength() {
return this.getOpcIntegerValue(item_length);
public String getLength1() {
return this.getOpcStringValue(item_length1);
}
public int getAction() {
return this.getOpcIntegerValue(item_action);
public String getLength2() {
return this.getOpcStringValue(item_length2);
}
public String getAction() {
return this.getOpcStringValue(item_action);
}
public int getToCommand() {
@@ -61,10 +67,29 @@ public class ItemProtocol {
}
public String getOpcStringValue(String protocol) {
String value = this.driver.getStringValue(protocol);
if (StrUtil.isBlank(value)) {
} else {
return value;
}
return "0";
}
public float getOpcFloatValue(String protocol) {
Float value = this.driver.getDoubleValue(protocol);
if (value == null) {
setIsonline(false);
}
return 0;
}
public static List<ItemDto> getReadableItemDtos() {
ArrayList list = new ArrayList();
list.add(new ItemDto(item_mode, "工作模式", "DB600.B2", Boolean.valueOf(true)));
list.add(new ItemDto(item_length, "测距", "DB600.D6"));
list.add(new ItemDto(item_length1, "测距1", "DB600.D6"));
list.add(new ItemDto(item_length2, "测距2", "DB600.D6"));
list.add(new ItemDto(item_action, "取放信号", "DB600.D8"));
return list;
}

View File

@@ -2,6 +2,7 @@ package org.nl.acs.device_driver.two_conveyor.ranging_stations;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject;
import lombok.Data;
@@ -77,10 +78,14 @@ public class RangingStationsDeviceDriver extends AbstractOpcDeviceDriver impleme
String message = null;
Boolean iserror = false;
int length = 0;
int last_length = 0;
int action = 0;
int last_action = 0;
String length1 = "";
String last_length1 = "";
String length2 = "";
String last_length2 = "";
String action = "";
String last_action = "";
boolean hasVehicle = false;
@@ -156,7 +161,8 @@ public class RangingStationsDeviceDriver extends AbstractOpcDeviceDriver impleme
try {
devicecode = this.getDeviceCode();
mode = this.itemProtocol.getMode();
length = this.itemProtocol.getLength();
length1 = this.itemProtocol.getLength1();
length2 = this.itemProtocol.getLength2();
action = this.itemProtocol.getAction();
if (mode != last_mode) {
this.setRequireSucess(false);