rev 写入更新
This commit is contained in:
@@ -1,11 +1,14 @@
|
||||
package org.nl.acs.device_driver.driver;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jinterop.dcom.common.JIException;
|
||||
import org.nl.acs.opc.*;
|
||||
import org.nl.acs.udw.UnifiedDataAccessor;
|
||||
import org.nl.acs.udw.UnifiedDataAccessorFactory;
|
||||
import org.nl.acs.udw.UnifiedDataAppService;
|
||||
import org.nl.modules.wql.exception.WDKException;
|
||||
import org.nl.modules.wql.util.SpringContextHolder;
|
||||
import org.openscada.opc.lib.da.AddFailedException;
|
||||
import org.openscada.opc.lib.da.Group;
|
||||
import org.openscada.opc.lib.da.Item;
|
||||
import org.openscada.opc.lib.da.ItemState;
|
||||
@@ -13,6 +16,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@Slf4j
|
||||
public class AbstractOpcDeviceDriver extends AbstractDeviceDriver implements OpcDeviceDriver {
|
||||
UnifiedDataAccessor opcUdw;
|
||||
|
||||
@@ -36,7 +40,7 @@ public class AbstractOpcDeviceDriver extends AbstractDeviceDriver implements Opc
|
||||
}
|
||||
|
||||
|
||||
public void checkcontrol(Map<String, Object> itemValues) throws Exception {
|
||||
public void checkcontrol(Map<String, Object> itemValues) throws JIException, AddFailedException {
|
||||
Group group = opcServerService.getServer(this.getOpcServer());
|
||||
Map<String, Object> write = new HashMap();
|
||||
Map<String, Item> readitems = new LinkedHashMap();
|
||||
@@ -55,28 +59,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;
|
||||
}
|
||||
@@ -86,11 +122,91 @@ public class AbstractOpcDeviceDriver extends AbstractDeviceDriver implements Opc
|
||||
}
|
||||
|
||||
if (i > 3) {
|
||||
log.info("写入次数超过3次而失败");
|
||||
throw new WDKException("写入次数超过3次而失败");
|
||||
}
|
||||
++i;
|
||||
}
|
||||
}
|
||||
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 controlByNewConn(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.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(Map<String, Object> itemValues) {
|
||||
|
||||
@@ -8,6 +8,7 @@ import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jinterop.dcom.common.JIException;
|
||||
import org.nl.acs.device.device_driver.standard_inspect.ReadUtil;
|
||||
import org.nl.acs.device.service.DeviceService;
|
||||
import org.nl.acs.device_driver.DeviceDriver;
|
||||
@@ -35,6 +36,7 @@ import org.nl.acs.task.service.TaskService;
|
||||
import org.nl.modules.lucene.service.LuceneExecuteLogService;
|
||||
import org.nl.modules.lucene.service.dto.LuceneLogDto;
|
||||
import org.nl.modules.wql.util.SpringContextHolder;
|
||||
import org.openscada.opc.lib.da.AddFailedException;
|
||||
import org.openscada.opc.lib.da.Server;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
@@ -898,7 +900,13 @@ public class ConveyorBarcodeDeviceDriver extends AbstractOpcDeviceDriver impleme
|
||||
}
|
||||
});
|
||||
if (ObjectUtil.isNotEmpty(itemMap)) {
|
||||
this.control(itemMap);
|
||||
try {
|
||||
this.checkcontrol(itemMap);
|
||||
} catch (JIException e) {
|
||||
e.printStackTrace();
|
||||
} catch (AddFailedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
logServer.deviceExecuteLog(this.getDevice().getDevice_code(), "", "", "下发多个电气信号:" + itemMap);
|
||||
lucene.deviceExecuteLog(new LuceneLogDto(this.getDeviceCode(), "下发多个电气信号:" + itemMap));
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jinterop.dcom.common.JIException;
|
||||
import org.nl.acs.AcsConfig;
|
||||
import org.nl.acs.device.device_driver.standard_inspect.ReadUtil;
|
||||
import org.nl.acs.device.service.DeviceService;
|
||||
@@ -35,6 +36,7 @@ import org.nl.modules.lucene.service.dto.LuceneLogDto;
|
||||
import org.nl.modules.system.service.ParamService;
|
||||
import org.nl.modules.system.service.impl.ParamServiceImpl;
|
||||
import org.nl.modules.wql.util.SpringContextHolder;
|
||||
import org.openscada.opc.lib.da.AddFailedException;
|
||||
import org.openscada.opc.lib.da.Server;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
@@ -876,7 +878,13 @@ public class ConveyorPressStationDeviceDriver extends AbstractOpcDeviceDriver im
|
||||
}
|
||||
});
|
||||
if (ObjectUtil.isNotEmpty(itemMap)) {
|
||||
this.control(itemMap);
|
||||
try {
|
||||
this.checkcontrol(itemMap);
|
||||
} catch (JIException e) {
|
||||
e.printStackTrace();
|
||||
} catch (AddFailedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
logServer.deviceExecuteLog(this.getDevice().getDevice_code(), "", "", "下发多个电气信号:" + itemMap);
|
||||
lucene.deviceExecuteLog(new LuceneLogDto(this.getDeviceCode(), "下发多个电气信号:" + itemMap));
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jinterop.dcom.common.JIException;
|
||||
import org.nl.acs.device.device_driver.standard_inspect.ReadUtil;
|
||||
import org.nl.acs.device.service.DeviceService;
|
||||
import org.nl.acs.device_driver.DeviceDriver;
|
||||
@@ -29,6 +30,7 @@ import org.nl.acs.task.service.TaskService;
|
||||
import org.nl.modules.lucene.service.LuceneExecuteLogService;
|
||||
import org.nl.modules.lucene.service.dto.LuceneLogDto;
|
||||
import org.nl.modules.wql.util.SpringContextHolder;
|
||||
import org.openscada.opc.lib.da.AddFailedException;
|
||||
import org.openscada.opc.lib.da.Server;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
@@ -404,7 +406,13 @@ public class LnshLaminatingMachineDeviceDriver extends AbstractOpcDeviceDriver i
|
||||
}
|
||||
});
|
||||
if (ObjectUtil.isNotEmpty(itemMap)) {
|
||||
this.control(itemMap);
|
||||
try {
|
||||
this.checkcontrol(itemMap);
|
||||
} catch (JIException e) {
|
||||
e.printStackTrace();
|
||||
} catch (AddFailedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
logServer.deviceExecuteLog(this.getDevice().getDevice_code(), "", "", "下发多个电气信号:" + itemMap);
|
||||
lucene.deviceExecuteLog(new LuceneLogDto(this.getDeviceCode(), "下发多个电气信号:" + itemMap));
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jinterop.dcom.common.JIException;
|
||||
import org.nl.acs.device.device_driver.standard_inspect.ReadUtil;
|
||||
import org.nl.acs.device.service.DeviceService;
|
||||
import org.nl.acs.device_driver.DeviceDriver;
|
||||
@@ -28,6 +29,7 @@ import org.nl.acs.task.service.TaskService;
|
||||
import org.nl.modules.lucene.service.LuceneExecuteLogService;
|
||||
import org.nl.modules.lucene.service.dto.LuceneLogDto;
|
||||
import org.nl.modules.wql.util.SpringContextHolder;
|
||||
import org.openscada.opc.lib.da.AddFailedException;
|
||||
import org.openscada.opc.lib.da.Server;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
@@ -294,7 +296,13 @@ public class LnshFoldDiscSiteDeviceDriver extends AbstractOpcDeviceDriver implem
|
||||
}
|
||||
});
|
||||
if (ObjectUtil.isNotEmpty(itemMap)) {
|
||||
this.control(itemMap);
|
||||
try {
|
||||
this.checkcontrol(itemMap);
|
||||
} catch (JIException e) {
|
||||
e.printStackTrace();
|
||||
} catch (AddFailedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
logServer.deviceExecuteLog(this.getDevice().getDevice_code(), "", "", "下发多个电气信号:" + itemMap);
|
||||
lucene.deviceExecuteLog(new LuceneLogDto(this.getDeviceCode(), "下发多个电气信号:" + itemMap));
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jinterop.dcom.common.JIException;
|
||||
import org.nl.acs.device.device_driver.standard_inspect.ReadUtil;
|
||||
import org.nl.acs.device.service.DeviceService;
|
||||
import org.nl.acs.device_driver.DeviceDriver;
|
||||
@@ -31,6 +32,7 @@ import org.nl.acs.task.service.TaskService;
|
||||
import org.nl.modules.lucene.service.LuceneExecuteLogService;
|
||||
import org.nl.modules.lucene.service.dto.LuceneLogDto;
|
||||
import org.nl.modules.wql.util.SpringContextHolder;
|
||||
import org.openscada.opc.lib.da.AddFailedException;
|
||||
import org.openscada.opc.lib.da.Server;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
@@ -245,7 +247,13 @@ public class LnshMixingMillDeviceDriver extends AbstractOpcDeviceDriver implemen
|
||||
}
|
||||
});
|
||||
if (ObjectUtil.isNotEmpty(itemMap)) {
|
||||
this.control(itemMap);
|
||||
try {
|
||||
this.checkcontrol(itemMap);
|
||||
} catch (JIException e) {
|
||||
e.printStackTrace();
|
||||
} catch (AddFailedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
logServer.deviceExecuteLog(this.getDevice().getDevice_code(), "", "", "下发多个电气信号:" + itemMap);
|
||||
lucene.deviceExecuteLog(new LuceneLogDto(this.getDeviceCode(), "下发多个电气信号:" + itemMap));
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jinterop.dcom.common.JIException;
|
||||
import org.nl.acs.device.device_driver.standard_inspect.ReadUtil;
|
||||
import org.nl.acs.device.service.DeviceService;
|
||||
import org.nl.acs.device_driver.DeviceDriver;
|
||||
@@ -35,6 +36,7 @@ import org.nl.acs.task.service.TaskService;
|
||||
import org.nl.modules.lucene.service.LuceneExecuteLogService;
|
||||
import org.nl.modules.lucene.service.dto.LuceneLogDto;
|
||||
import org.nl.modules.wql.util.SpringContextHolder;
|
||||
import org.openscada.opc.lib.da.AddFailedException;
|
||||
import org.openscada.opc.lib.da.Server;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
@@ -461,6 +463,9 @@ public class LnshPackagePalletManipulatorDeviceDriver extends AbstractOpcDeviceD
|
||||
|
||||
if (resp.getCode() == 200) {
|
||||
this.setRequireSucess(true);
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
map.put("to_feedback",102);
|
||||
this.writing(map);
|
||||
message = RequestMethodEnum.getName("order_finish") + "order_finish 接口请求成功" + resp.getMessage();
|
||||
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, message + "返回参数:" + JSON.toJSONString(resp)));
|
||||
} else {
|
||||
@@ -541,7 +546,13 @@ public class LnshPackagePalletManipulatorDeviceDriver extends AbstractOpcDeviceD
|
||||
}
|
||||
});
|
||||
if (ObjectUtil.isNotEmpty(itemMap)) {
|
||||
this.control(itemMap);
|
||||
try {
|
||||
this.checkcontrol(itemMap);
|
||||
} catch (JIException e) {
|
||||
e.printStackTrace();
|
||||
} catch (AddFailedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
logServer.deviceExecuteLog(this.getDevice().getDevice_code(), "", "", "下发多个电气信号:" + itemMap);
|
||||
lucene.deviceExecuteLog(new LuceneLogDto(this.getDeviceCode(), "下发多个电气信号:" + itemMap));
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jinterop.dcom.common.JIException;
|
||||
import org.nl.acs.device.device_driver.standard_inspect.ReadUtil;
|
||||
import org.nl.acs.device.service.DeviceService;
|
||||
import org.nl.acs.device_driver.DeviceDriver;
|
||||
@@ -23,6 +24,7 @@ import org.nl.acs.task.service.TaskService;
|
||||
import org.nl.modules.lucene.service.LuceneExecuteLogService;
|
||||
import org.nl.modules.lucene.service.dto.LuceneLogDto;
|
||||
import org.nl.modules.wql.util.SpringContextHolder;
|
||||
import org.openscada.opc.lib.da.AddFailedException;
|
||||
import org.openscada.opc.lib.da.Server;
|
||||
|
||||
import java.util.*;
|
||||
@@ -256,7 +258,13 @@ public class LnshPackageSiteDeviceDriver extends AbstractOpcDeviceDriver impleme
|
||||
}
|
||||
});
|
||||
if (ObjectUtil.isNotEmpty(itemMap)) {
|
||||
this.control(itemMap);
|
||||
try {
|
||||
this.checkcontrol(itemMap);
|
||||
} catch (JIException e) {
|
||||
e.printStackTrace();
|
||||
} catch (AddFailedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
logServer.deviceExecuteLog(this.getDevice().getDevice_code(), "", "", "下发多个电气信号:" + itemMap);
|
||||
lucene.deviceExecuteLog(new LuceneLogDto(this.getDeviceCode(), "下发多个电气信号:" + itemMap));
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jinterop.dcom.common.JIException;
|
||||
import org.nl.acs.agv.AgvUtil;
|
||||
import org.nl.acs.device.device_driver.standard_inspect.ReadUtil;
|
||||
import org.nl.acs.device.service.DeviceService;
|
||||
@@ -41,6 +42,7 @@ import org.nl.modules.lucene.enums.LogTypeEnum;
|
||||
import org.nl.modules.lucene.service.LuceneExecuteLogService;
|
||||
import org.nl.modules.lucene.service.dto.LuceneLogDto;
|
||||
import org.nl.modules.wql.util.SpringContextHolder;
|
||||
import org.openscada.opc.lib.da.AddFailedException;
|
||||
import org.openscada.opc.lib.da.Server;
|
||||
import org.springframework.http.HttpStatus;
|
||||
|
||||
@@ -926,7 +928,6 @@ public class LnshPalletizingManipulatorSiteDeviceDriver extends AbstractOpcDevic
|
||||
|
||||
// log.info("{}",JSON.toJSONString(new LuceneLogDto(this.device_code, message + "参数:" + JSON.toJSONString(request))));
|
||||
if (resp.getCode() == 200) {
|
||||
this.setRequireSucess(true);
|
||||
if(resp.getIs_satisfy()==1){
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
map.put("to_command",20);
|
||||
@@ -934,6 +935,7 @@ public class LnshPalletizingManipulatorSiteDeviceDriver extends AbstractOpcDevic
|
||||
message = RequestMethodEnum.getName("apply_take_full_vehicle") + "给电气下发20货架没有对应库存无库存";
|
||||
}
|
||||
this.writing(200);
|
||||
this.setRequireSucess(true);
|
||||
message = RequestMethodEnum.getName("apply_take_full_vehicle") + "apply_take_full_vehicle 接口请求成功" + resp.getMessage();
|
||||
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, message + "返回参数:" + JSON.toJSONString(resp)));
|
||||
} else {
|
||||
@@ -1706,7 +1708,13 @@ public class LnshPalletizingManipulatorSiteDeviceDriver extends AbstractOpcDevic
|
||||
}
|
||||
});
|
||||
if (ObjectUtil.isNotEmpty(itemMap)) {
|
||||
this.control(itemMap);
|
||||
try {
|
||||
this.checkcontrol(itemMap);
|
||||
} catch (JIException e) {
|
||||
e.printStackTrace();
|
||||
} catch (AddFailedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
logServer.deviceExecuteLog(this.getDevice().getDevice_code(), "", "", "下发多个电气信号:" + itemMap);
|
||||
lucene.deviceExecuteLog(new LuceneLogDto(this.getDeviceCode(), "下发多个电气信号:" + itemMap));
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jinterop.dcom.common.JIException;
|
||||
import org.nl.acs.device.device_driver.standard_inspect.ReadUtil;
|
||||
import org.nl.acs.device.service.DeviceService;
|
||||
import org.nl.acs.device_driver.DeviceDriver;
|
||||
@@ -33,6 +34,7 @@ import org.nl.acs.task.service.TaskService;
|
||||
import org.nl.modules.lucene.service.LuceneExecuteLogService;
|
||||
import org.nl.modules.lucene.service.dto.LuceneLogDto;
|
||||
import org.nl.modules.wql.util.SpringContextHolder;
|
||||
import org.openscada.opc.lib.da.AddFailedException;
|
||||
import org.openscada.opc.lib.da.Server;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
@@ -466,7 +468,13 @@ public class LnshPressDeviceDriver extends AbstractOpcDeviceDriver implements De
|
||||
}
|
||||
});
|
||||
if (ObjectUtil.isNotEmpty(itemMap)) {
|
||||
this.control(itemMap);
|
||||
try {
|
||||
this.checkcontrol(itemMap);
|
||||
} catch (JIException e) {
|
||||
e.printStackTrace();
|
||||
} catch (AddFailedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
logServer.deviceExecuteLog(this.getDevice().getDevice_code(), "", "", "下发多个电气信号:" + itemMap);
|
||||
lucene.deviceExecuteLog(new LuceneLogDto(this.getDeviceCode(), "下发多个电气信号:" + itemMap));
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.Data;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jinterop.dcom.common.JIException;
|
||||
import org.nl.acs.device.device_driver.standard_inspect.ReadUtil;
|
||||
import org.nl.acs.device.service.DeviceService;
|
||||
import org.nl.acs.device_driver.DeviceDriver;
|
||||
@@ -34,6 +35,7 @@ import org.nl.modules.lucene.service.LuceneExecuteLogService;
|
||||
import org.nl.modules.lucene.service.dto.LuceneLogDto;
|
||||
import org.nl.modules.wql.core.bean.WQLObject;
|
||||
import org.nl.modules.wql.util.SpringContextHolder;
|
||||
import org.openscada.opc.lib.da.AddFailedException;
|
||||
import org.openscada.opc.lib.da.Server;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
@@ -890,7 +892,13 @@ public class LnshRGVDeviceDriver extends AbstractOpcDeviceDriver implements Devi
|
||||
}
|
||||
});
|
||||
if (ObjectUtil.isNotEmpty(itemMap)) {
|
||||
this.control(itemMap);
|
||||
try {
|
||||
this.checkcontrol(itemMap);
|
||||
} catch (JIException e) {
|
||||
e.printStackTrace();
|
||||
} catch (AddFailedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
logServer.deviceExecuteLog(this.getDevice().getDevice_code(), "", "", "下发多个电气信号:" + itemMap);
|
||||
lucene.deviceExecuteLog(new LuceneLogDto(this.getDeviceCode(), "下发多个电气信号:" + itemMap));
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jinterop.dcom.common.JIException;
|
||||
import org.nl.acs.device.device_driver.standard_inspect.ReadUtil;
|
||||
import org.nl.acs.device.service.DeviceService;
|
||||
import org.nl.acs.device_driver.DeviceDriver;
|
||||
@@ -30,6 +31,7 @@ import org.nl.acs.task.service.TaskService;
|
||||
import org.nl.modules.lucene.service.LuceneExecuteLogService;
|
||||
import org.nl.modules.lucene.service.dto.LuceneLogDto;
|
||||
import org.nl.modules.wql.util.SpringContextHolder;
|
||||
import org.openscada.opc.lib.da.AddFailedException;
|
||||
import org.openscada.opc.lib.da.Server;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
@@ -1437,7 +1439,13 @@ public class LnshSplitManipulatorDeviceDriver extends AbstractOpcDeviceDriver im
|
||||
}
|
||||
});
|
||||
if (ObjectUtil.isNotEmpty(itemMap)) {
|
||||
this.control(itemMap);
|
||||
try {
|
||||
this.checkcontrol(itemMap);
|
||||
} catch (JIException e) {
|
||||
e.printStackTrace();
|
||||
} catch (AddFailedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
logServer.deviceExecuteLog(this.getDevice().getDevice_code(), "", "", "下发多个电气信号:" + itemMap);
|
||||
lucene.deviceExecuteLog(new LuceneLogDto(this.getDeviceCode(), "下发多个电气信号:" + itemMap));
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jinterop.dcom.common.JIException;
|
||||
import org.nl.acs.device.device_driver.standard_inspect.ReadUtil;
|
||||
import org.nl.acs.device.service.DeviceService;
|
||||
import org.nl.acs.device_driver.DeviceDriver;
|
||||
@@ -34,6 +35,7 @@ import org.nl.acs.task.service.TaskService;
|
||||
import org.nl.modules.lucene.service.LuceneExecuteLogService;
|
||||
import org.nl.modules.lucene.service.dto.LuceneLogDto;
|
||||
import org.nl.modules.wql.util.SpringContextHolder;
|
||||
import org.openscada.opc.lib.da.AddFailedException;
|
||||
import org.openscada.opc.lib.da.Server;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
@@ -382,7 +384,13 @@ public class LnshStationDeviceDriver extends AbstractOpcDeviceDriver implements
|
||||
}
|
||||
});
|
||||
if (ObjectUtil.isNotEmpty(itemMap)) {
|
||||
this.control(itemMap);
|
||||
try {
|
||||
this.checkcontrol(itemMap);
|
||||
} catch (JIException e) {
|
||||
e.printStackTrace();
|
||||
} catch (AddFailedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
logServer.deviceExecuteLog(this.getDevice().getDevice_code(), "", "", "下发多个电气信号:" + itemMap);
|
||||
lucene.deviceExecuteLog(new LuceneLogDto(this.getDeviceCode(), "下发多个电气信号:" + itemMap));
|
||||
}
|
||||
|
||||
@@ -12,11 +12,13 @@ public interface OpcServerService {
|
||||
|
||||
void reload();
|
||||
|
||||
Group getServer(String var1) throws Exception;
|
||||
Group getServer(String var1);
|
||||
|
||||
void writeInteger(String var1, ItemValue... var2);
|
||||
|
||||
void clearServer(String var1);
|
||||
|
||||
void cleanGroups(String var1);
|
||||
void writeIntegerByNewConn(String var1, ItemValue... var2);
|
||||
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ public class OpcServerServiceImpl implements OpcServerService, ApplicationAutoIn
|
||||
|
||||
}
|
||||
|
||||
public Group getServer(String code) throws Exception {
|
||||
public Group getServer(String code) {
|
||||
synchronized (this.buildLock(code)) {
|
||||
Group group = null;
|
||||
group = (Group) this.groups.get(code);
|
||||
@@ -193,4 +193,57 @@ public class OpcServerServiceImpl implements OpcServerService, ApplicationAutoIn
|
||||
String lock = builder.toString().intern();
|
||||
return lock;
|
||||
}
|
||||
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);
|
||||
try {
|
||||
throw var4;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,12 +6,13 @@ import org.openscada.opc.lib.da.Server;
|
||||
public class OpcServerUtl {
|
||||
|
||||
public static synchronized Server getServerWithOutException(String host, String clsid, String user, String password,
|
||||
String domain) throws Exception {
|
||||
String domain) {
|
||||
if (!StrUtil.isEmpty(host) && !StrUtil.isEmpty(clsid) && !StrUtil.isEmpty(user)) {
|
||||
if (domain == null) {
|
||||
domain = "";
|
||||
}
|
||||
return OpcUtl.getServer(host, clsid, user, password, domain);
|
||||
// return OpcUtl.getAutoServer(host, clsid, user, password, domain);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ import org.jinterop.dcom.core.JIString;
|
||||
import org.jinterop.dcom.core.JIUnsignedByte;
|
||||
import org.jinterop.dcom.core.JIUnsignedShort;
|
||||
import org.jinterop.dcom.core.JIVariant;
|
||||
import org.nl.modules.wql.exception.WDKException;
|
||||
import org.openscada.opc.dcom.list.ClassDetails;
|
||||
import org.openscada.opc.lib.common.AlreadyConnectedException;
|
||||
import org.openscada.opc.lib.common.ConnectionInformation;
|
||||
@@ -48,6 +49,7 @@ public class OpcUtl {
|
||||
private OpcUtl() {
|
||||
}
|
||||
|
||||
|
||||
public static List<Map<String, String>> showAllOpcServer(String host, String user, String password, String domain) throws Exception {
|
||||
try {
|
||||
List<Map<String, String>> listResult = new ArrayList();
|
||||
@@ -70,19 +72,24 @@ public class OpcUtl {
|
||||
}
|
||||
}
|
||||
|
||||
public static Server getServer(String host, String clsid, String user, String password, String domain) throws Exception {
|
||||
|
||||
public static Server getServer(String host, String clsid, String user, String password, String domain)
|
||||
throws WDKException {
|
||||
checkTimeout();
|
||||
Server server = null;
|
||||
|
||||
try {
|
||||
server = new Server(getConnection(host, clsid, user, password, domain), Executors.newSingleThreadScheduledExecutor());
|
||||
server = new Server(getConnection(host, clsid, user, password, domain),
|
||||
Executors.newSingleThreadScheduledExecutor());
|
||||
server.connect();
|
||||
return server;
|
||||
} catch (UnknownHostException | JIException | AlreadyConnectedException | IllegalArgumentException var7) {
|
||||
throw new Exception(var7);
|
||||
} catch (Exception e) {
|
||||
System.out.println("server error:"+e.getMessage());
|
||||
throw new WDKException(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static Server getAutoServer(String host, String clsid, String user, String password, String domain) throws Exception {
|
||||
checkTimeout();
|
||||
Server server = null;
|
||||
|
||||
Reference in New Issue
Block a user