fix 信号写入重新建立group

This commit is contained in:
USER-20220102CG\noblelift
2023-06-05 16:55:25 +08:00
parent 0370c14d21
commit 567b1feee1
5 changed files with 228 additions and 136 deletions

View File

@@ -227,7 +227,6 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
}
this.setPhase(phase);
} else if (device.getDeviceDriver() instanceof PhotoelectricInspectionSiteDeviceDriver) {
photoelectricInspectionSiteDeviceDriver = (PhotoelectricInspectionSiteDeviceDriver) device.getDeviceDriver();
@@ -344,11 +343,13 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic
if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver();
standardOrdinarySiteDeviceDriver.setAgvphase(phase);
if (ObjectUtil.isNotEmpty(standardOrdinarySiteDeviceDriver.getDevice().getExtraValue().get("wait"))
&& StrUtil.equals("true", standardOrdinarySiteDeviceDriver.getDevice().getExtraValue().get("wait").toString())
&& StrUtil.equals(task.getTask_type(), "1")) {
//
if (standardOrdinarySiteDeviceDriver.getOption() == 1) {
standardOrdinarySiteDeviceDriver.setAgvphase(0);
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
} else {
log.info("等待LMS系统进行确认允许取货设备号{},指令号{}", device_code, ikey);
@@ -360,7 +361,6 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
}
this.setPhase(phase);
} else {
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
}
@@ -533,21 +533,21 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic
}
if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver();
if (ObjectUtil.isNotEmpty(standardOrdinarySiteDeviceDriver.getDevice().getExtraValue().get("wait"))
&& StrUtil.equals("true", standardOrdinarySiteDeviceDriver.getDevice().getExtraValue().get("wait").toString())
&& StrUtil.equals(task.getTask_type(), "1")) {
//
if (standardOrdinarySiteDeviceDriver.getOption() == 2) {
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
standardOrdinarySiteDeviceDriver.setOption(0);
} else {
log.info("等待LMS系统进行确认离开设备号{},指令号:{}", device_code, ikey);
message = "等待LMS系统进行确认离开,设备号:" + device_code + ",指令号:" + ikey;
}
} else {
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
}
// if (ObjectUtil.isNotEmpty(standardOrdinarySiteDeviceDriver.getDevice().getExtraValue().get("wait"))
// && StrUtil.equals("true", standardOrdinarySiteDeviceDriver.getDevice().getExtraValue().get("wait").toString())
// && StrUtil.equals(task.getTask_type(), "1")) {
// //
// if (standardOrdinarySiteDeviceDriver.getOption() == 2) {
// data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
// standardOrdinarySiteDeviceDriver.setOption(0);
// } else {
// log.info("等待LMS系统进行确认离开设备号{},指令号:{}", device_code, ikey);
// message = "等待LMS系统进行确认离开,设备号:" + device_code + ",指令号:" + ikey;
// }
// } else {
// data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
// }
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
this.setPhase(phase);
} else if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) {
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver();
@@ -592,21 +592,21 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic
if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver();
if (ObjectUtil.isNotEmpty(standardOrdinarySiteDeviceDriver.getDevice().getExtraValue().get("wait"))
&& StrUtil.equals("true", standardOrdinarySiteDeviceDriver.getDevice().getExtraValue().get("wait").toString())
&& StrUtil.equals(task.getTask_type(), "1")) {
//
if (standardOrdinarySiteDeviceDriver.getOption() == 2) {
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
standardOrdinarySiteDeviceDriver.setOption(0);
} else {
log.info("等待LMS系统进行确认离开设备号{},指令号:{}", device_code, ikey);
message = "等待LMS系统进行确认离开,设备号:" + device_code + ",指令号:" + ikey;
}
} else {
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
}
// if (ObjectUtil.isNotEmpty(standardOrdinarySiteDeviceDriver.getDevice().getExtraValue().get("wait"))
// && StrUtil.equals("true", standardOrdinarySiteDeviceDriver.getDevice().getExtraValue().get("wait").toString())
// && StrUtil.equals(task.getTask_type(), "1")) {
// //
// if (standardOrdinarySiteDeviceDriver.getOption() == 2) {
// data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
// standardOrdinarySiteDeviceDriver.setOption(0);
// } else {
// log.info("等待LMS系统进行确认离开设备号{},指令号:{}", device_code, ikey);
// message = "等待LMS系统进行确认离开,设备号:" + device_code + ",指令号:" + ikey;
// }
// } else {
// data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
// }
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
this.setPhase(phase);
} else {
@@ -649,21 +649,21 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic
}
if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver();
if (ObjectUtil.isNotEmpty(standardOrdinarySiteDeviceDriver.getDevice().getExtraValue().get("wait"))
&& StrUtil.equals("true", standardOrdinarySiteDeviceDriver.getDevice().getExtraValue().get("wait").toString())
&& StrUtil.equals(task.getTask_type(), "1")) {
//
if (standardOrdinarySiteDeviceDriver.getOption() == 2) {
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
standardOrdinarySiteDeviceDriver.setOption(0);
} else {
log.info("等待LMS系统进行确认离开设备号{},指令号:{}", device_code, ikey);
message = "等待LMS系统进行确认离开,设备号:" + device_code + ",指令号:" + ikey;
}
} else {
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
}
// if (ObjectUtil.isNotEmpty(standardOrdinarySiteDeviceDriver.getDevice().getExtraValue().get("wait"))
// && StrUtil.equals("true", standardOrdinarySiteDeviceDriver.getDevice().getExtraValue().get("wait").toString())
// && StrUtil.equals(task.getTask_type(), "1")) {
// //
// if (standardOrdinarySiteDeviceDriver.getOption() == 2) {
// data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
// standardOrdinarySiteDeviceDriver.setOption(0);
// } else {
// log.info("等待LMS系统进行确认离开设备号{},指令号:{}", device_code, ikey);
// message = "等待LMS系统进行确认离开,设备号:" + device_code + ",指令号:" + ikey;
// }
// } else {
// data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
// }
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
this.setPhase(phase);
} else {

View File

@@ -648,6 +648,21 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme
map3.put("value", "1");
list.add(map3);
this.writing(list);
while (!StrUtil.equals(this.getOpcValueAccessor().getValue(this.getOpcServer() + "." + this.getOpcPlc() + "." + this.getDevice_code() + ".task").toString()
, inst.getInstruction_code())) {
this.writing(list);
logServer.deviceExecuteLog(device_code, "", "", inst.getInstruction_code() + "再次下发信号");
try {
Thread.sleep(500);
} catch (InterruptedException e) {
e.printStackTrace();
}
if(ObjectUtil.isEmpty(instructionService.findByTaskcodeAndStatus(taskdto.getTask_code()))){
return false;
}
}
// if (task != Integer.parseInt(inst.getInstruction_code())) {
// this.writing(list);
// message = "重新下发电气信号";
@@ -760,11 +775,17 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme
this.writing(list);
logServer.deviceExecuteLog(device_code, "", "", inst.getInstruction_code() + "再次下发电气信号");
try {
Thread.sleep(500);
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
if(ObjectUtil.isEmpty(taskserver.findByCode(taskdto.getTask_code()))){
return false;
}
}
// if (task != Integer.parseInt(inst.getInstruction_code())) {
// this.writing(list);
// message = "重新下发电气信号";
@@ -806,6 +827,9 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme
} catch (InterruptedException e) {
e.printStackTrace();
}
if(ObjectUtil.isEmpty(instructionService.findByDeviceCodeFromCache(this.device_code))){
return false;
}
}
// if (task != Integer.parseInt(inst.getInstruction_code())) {
// this.writing(list);
@@ -977,6 +1001,17 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme
} else {
if (jo.getInteger("status") == 200) {
message = "申请补码AGV搬运任务成功";
List list = new ArrayList();
while (!StrUtil.equals(this.getOpcValueAccessor().getValue(this.getOpcServer() + "." + this.getOpcPlc() + "." + this.getDevice_code() + ".to_command").toString()
, "8")) {
this.writing(list);
logServer.deviceExecuteLog(device_code, "", "", "再次下发mode信号");
try {
Thread.sleep(500);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
logServer.deviceExecuteLog(this.device_code, "", "", "申请补码AGV任务,返回参数:" + jo);
requireSucess = true;
} else {
@@ -1013,6 +1048,22 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme
} else {
if (jo.getInteger("status") == 200) {
message = "申请AGV搬运任务成功";
List list = new ArrayList();
Map map = new HashMap();
map.put("code", "to_command");
map.put("value", "8");
list.add(map);
this.writing(list);
while (!StrUtil.equals(this.getOpcValueAccessor().getValue(this.getOpcServer() + "." + this.getOpcPlc() + "." + this.getDevice_code() + ".to_command").toString()
, "8")) {
this.writing(list);
logServer.deviceExecuteLog(device_code, "", "", inst.getInstruction_code() + "再次下发mode信号");
try {
Thread.sleep(500);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
logServer.deviceExecuteLog(this.device_code, "", "", "申请AGV任务,返回参数:" + jo);
requireSucess = true;
} else {
@@ -1059,5 +1110,4 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme
}
}
}

View File

@@ -585,6 +585,16 @@ public class SiemensConveyorCkkDeviceDriver extends AbstractOpcDeviceDriver impl
map3.put("value", "1");
list.add(map3);
this.writing(list);
while (!StrUtil.equals(this.getOpcValueAccessor().getValue(this.getOpcServer() + "." + this.getOpcPlc() + "." + this.getDevice_code() + ".task").toString()
, inst.getInstruction_code())) {
this.writing(list);
logServer.deviceExecuteLog(device_code, "", "", inst.getInstruction_code() + "再次下发信号");
try {
Thread.sleep(500);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
return true;
}
try {
@@ -659,11 +669,23 @@ public class SiemensConveyorCkkDeviceDriver extends AbstractOpcDeviceDriver impl
map2.put("value", inst.getInstruction_code());
list.add(map4);
this.writing(list);
if (task != Integer.parseInt(inst.getInstruction_code())) {
// if (task != Integer.parseInt(inst.getInstruction_code())) {
// this.writing(list);
// message = "重新下发电气信号";
// logServer.deviceExecuteLog(device_code, "", "", inst.getInstruction_code() + "再次下发电气信号");
// }
while (!StrUtil.equals(this.getOpcValueAccessor().getValue(this.getOpcServer() + "." + this.getOpcPlc() + "." + this.getDevice_code() + ".task").toString()
, inst.getInstruction_code())) {
this.writing(list);
message = "重新下发电气信号";
logServer.deviceExecuteLog(device_code, "", "", inst.getInstruction_code() + "再次下发电气信号");
logServer.deviceExecuteLog(device_code, "", "", inst.getInstruction_code() + "再次下发信号");
try {
Thread.sleep(500);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
message = "下发电气任务号成功";
requireSucess = true;
return true;
@@ -770,10 +792,20 @@ public class SiemensConveyorCkkDeviceDriver extends AbstractOpcDeviceDriver impl
map2.put("value", inst.getInstruction_code());
list.add(map4);
this.writing(list);
if (task != Integer.parseInt(inst.getInstruction_code())) {
// if (task != Integer.parseInt(inst.getInstruction_code())) {
// this.writing(list);
// message = "重新下发电气信号";
// logServer.deviceExecuteLog(device_code, "", "", inst.getInstruction_code() + "再次下发电气信号");
// }
while (!StrUtil.equals(this.getOpcValueAccessor().getValue(this.getOpcServer() + "." + this.getOpcPlc() + "." + this.getDevice_code() + ".task").toString()
, inst.getInstruction_code())) {
this.writing(list);
message = "重新下发电气信号";
logServer.deviceExecuteLog(device_code, "", "", inst.getInstruction_code() + "再次下发电气信号");
logServer.deviceExecuteLog(device_code, "", "", inst.getInstruction_code() + "再次下发信号");
try {
Thread.sleep(500);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
} else {
//如果不存在则直接找对应指令
@@ -799,9 +831,19 @@ public class SiemensConveyorCkkDeviceDriver extends AbstractOpcDeviceDriver impl
map3.put("value", "1");
list.add(map3);
this.writing(list);
if (task != Integer.parseInt(inst.getInstruction_code())) {
// if (task != Integer.parseInt(inst.getInstruction_code())) {
// this.writing(list);
// logServer.deviceExecuteLog(device_code, "", "", inst.getInstruction_code() + "再次下发电气信号");
// }
while (!StrUtil.equals(this.getOpcValueAccessor().getValue(this.getOpcServer() + "." + this.getOpcPlc() + "." + this.getDevice_code() + ".task").toString()
, inst.getInstruction_code())) {
this.writing(list);
logServer.deviceExecuteLog(device_code, "", "", inst.getInstruction_code() + "再次下发电气信号");
logServer.deviceExecuteLog(device_code, "", "", inst.getInstruction_code() + "再次下发信号");
try {
Thread.sleep(500);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
requireSucess = true;
}

View File

@@ -123,67 +123,67 @@ public class StandardOrdinarySiteDeviceDriver extends AbstractDeviceDriver imple
batch = this.getDevice().getBatch();
device_code = this.getDeviceCode();
if (agvphase == 0x03) {
if (ObjectUtil.isNotEmpty(inst)) {
inst.setExecute_status("1");
instructionService.update(inst);
byte[] data = agvService.sendAgvOneModeInst(agvphase, index, 0);
agvphase = 0;
index = 0;
inst = null;
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + agvphase + "反馈成功");
} else {
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + agvphase + "等待反馈");
}
}
if (agvphase == 0x05) {
if (ObjectUtil.isNotEmpty(inst)) {
inst.setExecute_status("2");
instructionService.update(inst);
byte[] data = agvService.sendAgvOneModeInst(agvphase, index, 0);
// OneNDCSocketConnectionAutoRun.write(data);
agvphase = 0;
index = 0;
inst = null;
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + agvphase + "反馈成功");
} else {
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + agvphase + "等待反馈");
}
}
if (agvphase == 0x07) {
if (ObjectUtil.isNotEmpty(inst)) {
inst.setExecute_status("5");
instructionService.update(inst);
byte[] data = agvService.sendAgvOneModeInst(agvphase, index, 0);
// OneNDCSocketConnectionAutoRun.write(data);
agvphase = 0;
index = 0;
inst = null;
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + agvphase + "反馈成功");
} else {
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + agvphase + "等待反馈");
}
}
if (agvphase == 0x09) {
if (ObjectUtil.isNotEmpty(inst)) {
inst.setExecute_status("6");
instructionService.update(inst);
byte[] data = agvService.sendAgvOneModeInst(agvphase, index, 0);
// OneNDCSocketConnectionAutoRun.write(data);
agvphase = 0;
index = 0;
inst = null;
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + agvphase + "反馈成功");
} else {
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + agvphase + "等待反馈");
}
}
// if (agvphase == 0x03) {
// if (ObjectUtil.isNotEmpty(inst)) {
// inst.setExecute_status("1");
// instructionService.update(inst);
// byte[] data = agvService.sendAgvOneModeInst(agvphase, index, 0);
// agvphase = 0;
// index = 0;
// inst = null;
// logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + agvphase + "反馈成功");
// } else {
// logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + agvphase + "等待反馈");
//
// }
// }
//
// if (agvphase == 0x05) {
// if (ObjectUtil.isNotEmpty(inst)) {
// inst.setExecute_status("2");
// instructionService.update(inst);
// byte[] data = agvService.sendAgvOneModeInst(agvphase, index, 0);
//// OneNDCSocketConnectionAutoRun.write(data);
// agvphase = 0;
// index = 0;
// inst = null;
// logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + agvphase + "反馈成功");
// } else {
// logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + agvphase + "等待反馈");
//
// }
// }
//
// if (agvphase == 0x07) {
// if (ObjectUtil.isNotEmpty(inst)) {
// inst.setExecute_status("5");
// instructionService.update(inst);
// byte[] data = agvService.sendAgvOneModeInst(agvphase, index, 0);
//// OneNDCSocketConnectionAutoRun.write(data);
// agvphase = 0;
// index = 0;
// inst = null;
// logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + agvphase + "反馈成功");
// } else {
// logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + agvphase + "等待反馈");
// }
// }
//
// if (agvphase == 0x09) {
// if (ObjectUtil.isNotEmpty(inst)) {
// inst.setExecute_status("6");
// instructionService.update(inst);
// byte[] data = agvService.sendAgvOneModeInst(agvphase, index, 0);
//// OneNDCSocketConnectionAutoRun.write(data);
// agvphase = 0;
// index = 0;
// inst = null;
// logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + agvphase + "反馈成功");
// } else {
// logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + agvphase + "等待反馈");
//
// }
// }
}

View File

@@ -70,24 +70,24 @@ public class OpcServerServiceImpl implements OpcServerService, ApplicationAutoIn
public Group getServer(String code) {
synchronized(this.buildLock(code)) {
Group group = null;
group = (Group)this.groups.get(code);
if (group != null) {
label68: {
Group var10000;
try {
if (!group.isActive()) {
break label68;
}
var10000 = group;
} catch (JIException var14) {
log.error(code, var14);
break label68;
}
return var10000;
}
}
// group = (Group)this.groups.get(code);
// if (group != null) {
// label68: {
// Group var10000;
// try {
// if (!group.isActive()) {
// break label68;
// }
//
// var10000 = group;
// } catch (JIException var14) {
// log.error(code, var14);
// break label68;
// }
//
// return var10000;
// }
// }
Server server = (Server)this.servers.get(code);
boolean needcreate = false;