rev 更新信号写入问题
This commit is contained in:
@@ -60,28 +60,60 @@ public class AbstractOpcDeviceDriver extends AbstractDeviceDriver implements Opc
|
||||
int i = 0;
|
||||
while(true) {
|
||||
//下发信号
|
||||
control( itemValues);
|
||||
Map<String, Object> read = new HashMap();
|
||||
Map<Item, ItemState> itemStatus = group.read(true, (Item[])readitems.values().toArray(new Item[0]));
|
||||
Set<Item> items = itemStatus.keySet();
|
||||
Iterator var15 = items.iterator();
|
||||
|
||||
while(var15.hasNext()) {
|
||||
Item item = (Item)var15.next();
|
||||
ItemState itemState = (ItemState)itemStatus.get(item);
|
||||
Object value = OpcUtl.getValue(item, itemState);
|
||||
read.put(item.getId(), value);
|
||||
}
|
||||
|
||||
boolean check = true;
|
||||
Iterator var24 = itemsString.iterator();
|
||||
|
||||
while(var24.hasNext()) {
|
||||
String itemString = (String)var24.next();
|
||||
if (!ObjectUtl.isEquals(itemValues.get(itemString), JsonUtl.parse(read.get(itemString)))) {
|
||||
check = false;
|
||||
try{
|
||||
if(i == 0){
|
||||
control( itemValues);
|
||||
} else {
|
||||
controlByNewConn( itemValues);
|
||||
}
|
||||
|
||||
} catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
Map<String, Object> read = new HashMap();
|
||||
Map<Item, ItemState> itemStatus = null;
|
||||
boolean check = true;
|
||||
try{
|
||||
if(i>0){
|
||||
group = opcServerService.getServer(this.getOpcServer());
|
||||
itemsString = new ArrayList<> (itemValues.keySet());
|
||||
Iterator nis = itemsString.iterator();
|
||||
|
||||
while (nis.hasNext()) {
|
||||
String string = (String) nis.next();
|
||||
try {
|
||||
readitems.put(string, group.addItem(string));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
itemStatus = group.read(true, (Item[])readitems.values().toArray(new Item[0]));
|
||||
|
||||
} else {
|
||||
itemStatus = group.read(true, (Item[])readitems.values().toArray(new Item[0]));
|
||||
}
|
||||
Set<Item> items = itemStatus.keySet();
|
||||
Iterator var15 = items.iterator();
|
||||
while(var15.hasNext()) {
|
||||
Item item = (Item)var15.next();
|
||||
ItemState itemState = (ItemState)itemStatus.get(item);
|
||||
Object value = OpcUtl.getValue(item, itemState);
|
||||
read.put(item.getId(), value);
|
||||
}
|
||||
|
||||
Iterator var24 = itemsString.iterator();
|
||||
|
||||
while(var24.hasNext()) {
|
||||
String itemString = (String)var24.next();
|
||||
if (!ObjectUtl.isEquals(itemValues.get(itemString), JsonUtl.parse(read.get(itemString)))) {
|
||||
check = false;
|
||||
}
|
||||
}
|
||||
} catch (Exception e){
|
||||
e.printStackTrace();
|
||||
check = false;
|
||||
}
|
||||
|
||||
if (check) {
|
||||
return;
|
||||
}
|
||||
@@ -91,6 +123,7 @@ public class AbstractOpcDeviceDriver extends AbstractDeviceDriver implements Opc
|
||||
}
|
||||
|
||||
if (i > 3) {
|
||||
log.info("写入次数超过3次而失败");
|
||||
throw new WDKException("写入次数超过3次而失败");
|
||||
}
|
||||
++i;
|
||||
@@ -98,6 +131,25 @@ public class AbstractOpcDeviceDriver extends AbstractDeviceDriver implements Opc
|
||||
}
|
||||
|
||||
|
||||
public boolean controlByNewConn(Map<String, Object> itemValues) {
|
||||
|
||||
Iterator<Map.Entry<String, Object>> it = itemValues.entrySet().iterator();
|
||||
|
||||
ItemValue p2[];
|
||||
p2 = new ItemValue[itemValues.size()];
|
||||
int i=0;
|
||||
while (it.hasNext()) {
|
||||
Map.Entry<String, Object> entry = it.next();
|
||||
System.out.println("即将写入值:"+entry.getKey() + ":" + entry.getValue());
|
||||
p2[i] = new ItemValue();
|
||||
p2[i].setItem_code(entry.getKey());
|
||||
p2[i].setItem_value(entry.getValue());
|
||||
i++;
|
||||
}
|
||||
|
||||
return this.controlByNewConn(p2);
|
||||
}
|
||||
|
||||
|
||||
public boolean control(Map<String, Object> itemValues) {
|
||||
|
||||
@@ -120,7 +172,7 @@ public class AbstractOpcDeviceDriver extends AbstractDeviceDriver implements Opc
|
||||
|
||||
|
||||
|
||||
public boolean control(ItemValue[] itemValues) {
|
||||
public boolean controlByNewConn(ItemValue[] itemValues) {
|
||||
if (itemValues != null && itemValues.length != 0) {
|
||||
String this_items = JsonUtl.parseWithoutException(itemValues);
|
||||
boolean need_write = false;
|
||||
@@ -128,23 +180,22 @@ public class AbstractOpcDeviceDriver extends AbstractDeviceDriver implements Opc
|
||||
ItemValue[] var5 = itemValues;
|
||||
int var6 = itemValues.length;
|
||||
|
||||
for (int var7 = 0; var7 < var6; ++var7) {
|
||||
ItemValue itemValue = var5[var7];
|
||||
String code = itemValue.getItem_code();
|
||||
Object udw_value = this.getUdwValue(code);
|
||||
Object write_value = itemValue.getItem_value();
|
||||
sb.append(code);
|
||||
sb.append(":");
|
||||
sb.append(JsonUtl.parseWithoutException(udw_value));
|
||||
sb.append(";");
|
||||
if (!need_write && !UnifiedDataAppService.isEquals(udw_value, write_value)) {
|
||||
need_write = true;
|
||||
} else {
|
||||
log.warn("下发信号点位{} 当前写入值:{} 与系统内存值:{} 相同,不再写入 ", code, write_value, udw_value );
|
||||
}
|
||||
}
|
||||
// need_write = true;
|
||||
|
||||
// for (int var7 = 0; var7 < var6; ++var7) {
|
||||
// ItemValue itemValue = var5[var7];
|
||||
// String code = itemValue.getItem_code();
|
||||
// Object udw_value = this.getUdwValue(code);
|
||||
// Object write_value = itemValue.getItem_value();
|
||||
// sb.append(code);
|
||||
// sb.append(":");
|
||||
// sb.append(JsonUtl.parseWithoutException(udw_value));
|
||||
// sb.append(";");
|
||||
// if (!need_write && !UnifiedDataAppService.isEquals(udw_value, write_value)) {
|
||||
// need_write = true;
|
||||
// } else {
|
||||
// log.warn("下发信号点位{} 当前写入值:{} 与系统内存值:{} 相同,不再写入 ", code, write_value, udw_value );
|
||||
// }
|
||||
// }
|
||||
need_write = true;
|
||||
if (need_write) {
|
||||
Date date = new Date();
|
||||
/*if (StringUtl.isEqual(this_items, this.last_items) && date.getTime() - this.sendTime.getTime() < (long) WcsConfig.opc_write_repeat_check) {
|
||||
@@ -154,13 +205,76 @@ public class AbstractOpcDeviceDriver extends AbstractDeviceDriver implements Opc
|
||||
|
||||
this.last_items = this_items;
|
||||
this.sendTime = date;
|
||||
/* this.execute_log.setResource(this.getDevice().getCode(), this.getDevice().getName());
|
||||
this.execute_log.log("原始记录{}->变更为{}", new Object[]{sb, this_items});
|
||||
OpcServerService opcServerService = OpcServerFactory.getOpcServerService();*/
|
||||
/* this.execute_log.setResource(this.getDevice().getCode(), this.getDevice().getName());
|
||||
this.execute_log.log("原始记录{}->变更为{}", new Object[]{sb, this_items});
|
||||
OpcServerService opcServerService = OpcServerFactory.getOpcServerService();*/
|
||||
|
||||
OpcServerService opcServerService = SpringContextHolder.getBean(OpcServerServiceImpl.class);
|
||||
|
||||
opcServerService.writeIntegerByNewConn(this.getOpcServer(), itemValues);
|
||||
|
||||
|
||||
UnifiedDataAccessor opcValueAccessor = this.getOpcValueAccessor();
|
||||
ItemValue[] var17 = itemValues;
|
||||
int var18 = itemValues.length;
|
||||
|
||||
for (int var19 = 0; var19 < var18; ++var19) {
|
||||
ItemValue itemValue = var17[var19];
|
||||
String code = itemValue.getItem_code();
|
||||
Object value = itemValue.getItem_value();
|
||||
opcValueAccessor.setValue(code, value);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
} else {
|
||||
throw new WDKException("下发 无内容");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public boolean control(ItemValue[] itemValues) {
|
||||
if (itemValues != null && itemValues.length != 0) {
|
||||
String this_items = JsonUtl.parseWithoutException(itemValues);
|
||||
boolean need_write = false;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
ItemValue[] var5 = itemValues;
|
||||
int var6 = itemValues.length;
|
||||
|
||||
// for (int var7 = 0; var7 < var6; ++var7) {
|
||||
// ItemValue itemValue = var5[var7];
|
||||
// String code = itemValue.getItem_code();
|
||||
// Object udw_value = this.getUdwValue(code);
|
||||
// Object write_value = itemValue.getItem_value();
|
||||
// sb.append(code);
|
||||
// sb.append(":");
|
||||
// sb.append(JsonUtl.parseWithoutException(udw_value));
|
||||
// sb.append(";");
|
||||
// if (!need_write && !UnifiedDataAppService.isEquals(udw_value, write_value)) {
|
||||
// need_write = true;
|
||||
// } else {
|
||||
// log.warn("下发信号点位{} 当前写入值:{} 与系统内存值:{} 相同,不再写入 ", code, write_value, udw_value );
|
||||
// }
|
||||
// }
|
||||
need_write = true;
|
||||
if (need_write) {
|
||||
Date date = new Date();
|
||||
/*if (StringUtl.isEqual(this_items, this.last_items) && date.getTime() - this.sendTime.getTime() < (long) WcsConfig.opc_write_repeat_check) {
|
||||
log.trace("发送时间因为小于{}毫秒,而被无视", WcsConfig.opc_write_repeat_check);
|
||||
return false;
|
||||
}*/
|
||||
|
||||
this.last_items = this_items;
|
||||
this.sendTime = date;
|
||||
/* this.execute_log.setResource(this.getDevice().getCode(), this.getDevice().getName());
|
||||
this.execute_log.log("原始记录{}->变更为{}", new Object[]{sb, this_items});
|
||||
OpcServerService opcServerService = OpcServerFactory.getOpcServerService();*/
|
||||
|
||||
OpcServerService opcServerService = SpringContextHolder.getBean(OpcServerServiceImpl.class);
|
||||
|
||||
opcServerService.writeInteger(this.getOpcServer(), itemValues);
|
||||
|
||||
UnifiedDataAccessor opcValueAccessor = this.getOpcValueAccessor();
|
||||
ItemValue[] var17 = itemValues;
|
||||
int var18 = itemValues.length;
|
||||
|
||||
@@ -448,7 +448,16 @@ public class LnshLaminatingMachineDeviceDriver extends AbstractOpcDeviceDriver i
|
||||
|
||||
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();
|
||||
try{
|
||||
this.checkcontrol(itemMap);
|
||||
} catch (Exception e1){
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", to_command + " 写入 " + command);
|
||||
}
|
||||
|
||||
@@ -483,7 +492,16 @@ public class LnshLaminatingMachineDeviceDriver extends AbstractOpcDeviceDriver i
|
||||
Map<String, Object> itemMap = new HashMap<String, Object>();
|
||||
itemMap.put(to_param,value);
|
||||
|
||||
this.control(itemMap);
|
||||
try {
|
||||
this.checkcontrol(itemMap);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
try{
|
||||
this.checkcontrol(itemMap);
|
||||
} catch (Exception e1){
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", to_param + " 写入 " + value);
|
||||
}
|
||||
|
||||
|
||||
@@ -1341,7 +1341,12 @@ public class LnshPackagePalletManipulatorDeviceDriver extends AbstractOpcDeviceD
|
||||
|
||||
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();
|
||||
}
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", to_command + " 写入 " + command);
|
||||
}
|
||||
|
||||
|
||||
@@ -575,8 +575,16 @@ public class LnshPalletizingManipulatorDeviceDriver extends AbstractOpcDeviceDri
|
||||
Map<String, Object> itemMap = new HashMap<String, Object>();
|
||||
itemMap.put(to_command, 1);
|
||||
itemMap.put(to_task, instruction_num);
|
||||
this.control(itemMap);
|
||||
|
||||
try {
|
||||
this.checkcontrol(itemMap);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
try{
|
||||
this.checkcontrol(itemMap);
|
||||
} catch (Exception e1){
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void executing(Server server, Map<String, Object> itemMap) {
|
||||
@@ -600,8 +608,16 @@ public class LnshPalletizingManipulatorDeviceDriver extends AbstractOpcDeviceDri
|
||||
} else if (type == 3) {
|
||||
itemMap.put(to_task, command);
|
||||
}
|
||||
this.control(itemMap);
|
||||
|
||||
try {
|
||||
this.checkcontrol(itemMap);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
try{
|
||||
this.checkcontrol(itemMap);
|
||||
} catch (Exception e1){
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void writing(String param, String value) {
|
||||
@@ -612,7 +628,16 @@ public class LnshPalletizingManipulatorDeviceDriver extends AbstractOpcDeviceDri
|
||||
Map<String, Object> itemMap = new HashMap<String, Object>();
|
||||
itemMap.put(to_param, value);
|
||||
|
||||
this.control(itemMap);
|
||||
try {
|
||||
this.checkcontrol(itemMap);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
try{
|
||||
this.checkcontrol(itemMap);
|
||||
} catch (Exception e1){
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", to_param + " 写入 " + value);
|
||||
}
|
||||
|
||||
@@ -622,7 +647,16 @@ public class LnshPalletizingManipulatorDeviceDriver extends AbstractOpcDeviceDri
|
||||
|
||||
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();
|
||||
try{
|
||||
this.checkcontrol(itemMap);
|
||||
} catch (Exception e1){
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", to_command + " 写入 " + command);
|
||||
}
|
||||
|
||||
|
||||
@@ -620,7 +620,16 @@ public class LnshPalletizingManipulatorSiteDeviceDriver extends AbstractOpcDevic
|
||||
|
||||
Map<String, Object> itemMap = new HashMap<String, Object>();
|
||||
itemMap.put(to_param, value);
|
||||
this.control(itemMap);
|
||||
try {
|
||||
this.checkcontrol(itemMap);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
try{
|
||||
this.checkcontrol(itemMap);
|
||||
} catch (Exception e1){
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", to_param + " 写入 " + value);
|
||||
}
|
||||
|
||||
@@ -630,7 +639,16 @@ public class LnshPalletizingManipulatorSiteDeviceDriver extends AbstractOpcDevic
|
||||
|
||||
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();
|
||||
try{
|
||||
this.checkcontrol(itemMap);
|
||||
} catch (Exception e1){
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", to_command + " 写入 " + command);
|
||||
}
|
||||
|
||||
|
||||
@@ -1173,7 +1173,16 @@ public class LnshSplitManipulatorDeviceDriver extends AbstractOpcDeviceDriver im
|
||||
|
||||
Map<String, Object> itemMap = new HashMap<String, Object>();
|
||||
itemMap.put(to_feedback, feedback);
|
||||
this.control(itemMap);
|
||||
try {
|
||||
this.checkcontrol(itemMap);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
try{
|
||||
this.checkcontrol(itemMap);
|
||||
} catch (Exception e1){
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", to_feedback + " 写入 " + feedback);
|
||||
}
|
||||
|
||||
@@ -1183,8 +1192,16 @@ public class LnshSplitManipulatorDeviceDriver extends AbstractOpcDeviceDriver im
|
||||
|
||||
|
||||
Map<String, Object> itemMap = new HashMap<String, Object>();
|
||||
this.control(itemMap);
|
||||
|
||||
try {
|
||||
this.checkcontrol(itemMap);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
try{
|
||||
this.checkcontrol(itemMap);
|
||||
} catch (Exception e1){
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void writing(String param, String value) {
|
||||
@@ -1195,7 +1212,16 @@ public class LnshSplitManipulatorDeviceDriver extends AbstractOpcDeviceDriver im
|
||||
Map<String, Object> itemMap = new HashMap<String, Object>();
|
||||
itemMap.put(to_param, value);
|
||||
|
||||
this.control(itemMap);
|
||||
try {
|
||||
this.checkcontrol(itemMap);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
try{
|
||||
this.checkcontrol(itemMap);
|
||||
} catch (Exception e1){
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", to_param + " 写入 " + value);
|
||||
}
|
||||
|
||||
|
||||
@@ -605,10 +605,15 @@ public class LnshStationDeviceDriver extends AbstractOpcDeviceDriver implements
|
||||
|
||||
Map<String, Object> itemMap = new HashMap<String, Object>();
|
||||
itemMap.put(to_command, command);
|
||||
try{
|
||||
try {
|
||||
this.checkcontrol(itemMap);
|
||||
} catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
try{
|
||||
this.checkcontrol(itemMap);
|
||||
} catch (Exception e1){
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", to_command + " 写入 " + command);
|
||||
}
|
||||
@@ -726,7 +731,16 @@ public class LnshStationDeviceDriver extends AbstractOpcDeviceDriver implements
|
||||
Map<String, Object> itemMap = new HashMap<String, Object>();
|
||||
itemMap.put(to_param,value);
|
||||
|
||||
this.control(itemMap);
|
||||
try {
|
||||
this.checkcontrol(itemMap);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
try{
|
||||
this.checkcontrol(itemMap);
|
||||
} catch (Exception e1){
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", to_param + " 写入 " + value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -300,6 +300,11 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
|
||||
throw new WDKException("工单号不能为空");
|
||||
}
|
||||
|
||||
ProduceshiftorderDto orderdto = produceshiftorderService.findByCode(producetask_code);
|
||||
if(ObjectUtil.isNotEmpty(orderdto)){
|
||||
throw new WDKException("存在相同工单号的工单:"+ producetask_code);
|
||||
}
|
||||
|
||||
Device device = DeviceAppService.findDeviceByCode(device_code);
|
||||
if (ObjectUtil.isEmpty(device)) {
|
||||
throw new Exception("未找到对应设备:" + device_code);
|
||||
|
||||
@@ -13,11 +13,13 @@ public interface OpcServerService {
|
||||
|
||||
void reload();
|
||||
|
||||
Group getServer(String var1) throws Exception;
|
||||
Group getServer(String var1);
|
||||
|
||||
Group getServerByNewConn(String var1);
|
||||
|
||||
void writeInteger(String var1, ItemValue... var2);
|
||||
|
||||
void clearServer(String var1);
|
||||
void writeIntegerByNewConn(String var1, ItemValue... var2);
|
||||
|
||||
void cleanGroups(String var1);
|
||||
void clearServer(String var1);
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ public class OpcServerServiceImpl implements OpcServerService, ApplicationAutoIn
|
||||
this.opcServerManageDtos = Collections.synchronizedMap(this.opcServerManageDtos);
|
||||
}
|
||||
|
||||
public synchronized Group getServer(String code) throws Exception {
|
||||
public synchronized Group getServer(String code) {
|
||||
synchronized(this.buildLock(code)) {
|
||||
Group group = null;
|
||||
group = (Group)this.groups.get(code);
|
||||
@@ -105,12 +105,16 @@ public class OpcServerServiceImpl implements OpcServerService, ApplicationAutoIn
|
||||
if (needcreate) {
|
||||
OpcServerManageDto dto = (OpcServerManageDto)this.opcServerManageDtos.get(code);
|
||||
if (dto == null) {
|
||||
throw new Exception(code + "{} 不存在");
|
||||
throw new RuntimeException(code+"不存在");
|
||||
}
|
||||
|
||||
// if (server!=null){
|
||||
// server.disconnect();
|
||||
// server=null;
|
||||
// }
|
||||
|
||||
if (server == null) {
|
||||
server = OpcServerUtl.getServerWithOutException(dto.getOpc_host(), StrUtil.trim(dto.getCls_id()), dto.getUser(), dto.getPassword(), StrUtil.trim(dto.getDomain()));
|
||||
}
|
||||
server = OpcServerUtl.getServerWithOutException(dto.getOpc_host(), StrUtil.trim(dto.getCls_id()), dto.getUser(), dto.getPassword(), StrUtil.trim(dto.getDomain())); }
|
||||
|
||||
try {
|
||||
group = server.addGroup(groupName);
|
||||
@@ -119,11 +123,10 @@ public class OpcServerServiceImpl implements OpcServerService, ApplicationAutoIn
|
||||
ThreadUtl.sleep(5000L);
|
||||
log.warn("获取opc出错重新获取", code, var12);
|
||||
server = OpcServerUtl.getServerWithOutException(dto.getOpc_host(), StrUtil.trim(dto.getCls_id()), dto.getUser(), dto.getPassword(), StrUtil.trim(dto.getDomain()));
|
||||
|
||||
try {
|
||||
group = server.addGroup(groupName);
|
||||
} catch (Exception var11) {
|
||||
throw new Exception(var12);
|
||||
throw new RuntimeException(var12);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -173,7 +176,60 @@ public class OpcServerServiceImpl implements OpcServerService, ApplicationAutoIn
|
||||
} catch (Exception var4) {
|
||||
this.clearServer(code);
|
||||
log.warn("写入出错opc server {} 重新加载", code, var4);
|
||||
ThreadUtl.sleep(5000L);
|
||||
ThreadUtl.sleep(1000L);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public Group getServerByNewConn(String code) {
|
||||
synchronized(this.buildLock(code)) {
|
||||
|
||||
Server server = (Server)this.servers.get(code);
|
||||
if (server!=null){
|
||||
this.clearServer(code);
|
||||
}
|
||||
|
||||
OpcServerManageDto dto = (OpcServerManageDto)this.opcServerManageDtos.get(code);
|
||||
if (dto == null) {
|
||||
throw new RuntimeException(code+"不存在");
|
||||
}
|
||||
|
||||
// if (server == null) {
|
||||
server = OpcServerUtl.getServerWithOutException(dto.getOpc_host(), StrUtil.trim(dto.getCls_id()), dto.getUser(), dto.getPassword(), StrUtil.trim(dto.getDomain()));
|
||||
// }
|
||||
String groupName = code;
|
||||
Group group = null;
|
||||
|
||||
try {
|
||||
group = server.addGroup(groupName);
|
||||
} catch (Exception var12) {
|
||||
this.clearServer(code);
|
||||
ThreadUtl.sleep(2000L);
|
||||
log.warn("获取opc出错重新获取", code, var12);
|
||||
server = OpcServerUtl.getServerWithOutException(dto.getOpc_host(), StrUtil.trim(dto.getCls_id()), dto.getUser(), dto.getPassword(), StrUtil.trim(dto.getDomain()));
|
||||
try {
|
||||
group = server.addGroup(groupName);
|
||||
} catch (Exception var11) {
|
||||
throw new RuntimeException(var12);
|
||||
}
|
||||
}
|
||||
|
||||
this.servers.put(code, server);
|
||||
this.groups.put(code, group);
|
||||
return group;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void writeIntegerByNewConn(String code, ItemValue... values) {
|
||||
try {
|
||||
Group group = this.getServerByNewConn(code);
|
||||
OpcUtl.writeValue(group, values);
|
||||
} catch (Exception var4) {
|
||||
this.clearServer(code);
|
||||
log.info("写入出错opc server {} 重新加载", code, var4);
|
||||
ThreadUtl.sleep(1000L);
|
||||
throw var4;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -37,19 +37,7 @@ public class OpcUtl {
|
||||
|
||||
public static void writeValue(Group group, WriteRequest... requests) throws WDKException {
|
||||
try {
|
||||
Map<Item, Integer> e=null;
|
||||
try{
|
||||
e=group.write(requests);
|
||||
group.write(requests);
|
||||
|
||||
}catch (Exception e1){
|
||||
try{
|
||||
e= group.write(requests);
|
||||
}catch (Exception e2){
|
||||
e= group.write(requests);
|
||||
}
|
||||
}
|
||||
|
||||
Map<Item, Integer> e=group.write(requests);
|
||||
boolean is_success = true;
|
||||
StringBuilder message = new StringBuilder();
|
||||
Iterator arg4 = e.keySet().iterator();
|
||||
@@ -70,16 +58,12 @@ public class OpcUtl {
|
||||
}
|
||||
|
||||
if (!is_success) {
|
||||
// throw new BusinessException(message.toString());
|
||||
System.out.println("下发信号失败:"+message.toString());
|
||||
System.out.println("下发信号失败原因:"+message.toString());
|
||||
log.info("下发信号失败:"+message.toString());
|
||||
throw new WDKException(message.toString());
|
||||
}
|
||||
} catch (JIException arg7) {
|
||||
log.info("下发信号失败:"+arg7.getMessage());
|
||||
System.out.println("下发信号失败原因:"+arg7.getMessage());
|
||||
throw new WDKException(arg7);
|
||||
log.info("下发信号失败Exception:"+arg7.getMessage());
|
||||
throw new WDKException("下发信号失败Exception:"+arg7);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -443,13 +443,11 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable {
|
||||
//检测站点
|
||||
if (ObjectUtil.isNotEmpty(device) && device.getDeviceDriver() instanceof LnshLaminatingMachineDeviceDriver) {
|
||||
lnshLaminatingMachineDeviceDriver = (LnshLaminatingMachineDeviceDriver) device.getDeviceDriver();
|
||||
if (lnshLaminatingMachineDeviceDriver.getMode() != 0 && lnshLaminatingMachineDeviceDriver.getMode() != 6) {
|
||||
if (lnshLaminatingMachineDeviceDriver.getMode() == 2 && lnshLaminatingMachineDeviceDriver.getMode() != 6) {
|
||||
inst.setExecute_status("9");
|
||||
instructionService.update(inst);
|
||||
try {
|
||||
lnshLaminatingMachineDeviceDriver.writing("to_task", inst.getInstruction_code());
|
||||
lnshLaminatingMachineDeviceDriver.writing("to_task", inst.getInstruction_code());
|
||||
lnshLaminatingMachineDeviceDriver.writing(1);
|
||||
lnshLaminatingMachineDeviceDriver.writing(1);
|
||||
} catch (Exception e) {
|
||||
log.info("下发电气信号失败:" + e.getMessage());
|
||||
@@ -470,7 +468,6 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable {
|
||||
if (result.getStatus() == 200 && StrUtil.equals(jsonObject.get("status").toString(),"200")) {
|
||||
try{
|
||||
lnshLaminatingMachineDeviceDriver.writing(6);
|
||||
lnshLaminatingMachineDeviceDriver.writing(6);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -647,14 +644,12 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable {
|
||||
log.info("下发电气信号失败:" + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (lnshStationDeviceDriver.getTo_command() == 3) {
|
||||
// if (lnshStationDeviceDriver.getTo_command() == 3) {
|
||||
inst.setExecute_status("6");
|
||||
instructionService.update(inst);
|
||||
data = AgvService.sendAgvOneModeInst(phase, index, 0);
|
||||
flag = true;
|
||||
} else {
|
||||
logServer.deviceExecuteLog("ndc", "", "", "AGV放货完成请求离开下发命令不等于3,无法反馈");
|
||||
}
|
||||
// }
|
||||
} else {
|
||||
logServer.deviceExecuteLog("ndc", "", "", "AGV放货完成请求离开设备{}无货,无法反馈");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user