Browse Source

rev 写入方法

master
周俊杰 1 year ago
parent
commit
8b27a98268
  1. 4
      acs/nladmin-system/src/main/java/org/nl/acs/device_driver/driver/ItemValue.java
  2. 9
      acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/converor_barcode/ConveyorBarcodeDeviceDriver.java
  3. 9
      acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/conveyor_press_station/ConveyorPressStationDeviceDriver.java
  4. 9
      acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_Laminating_machine/LnshLaminatingMachineDeviceDriver.java
  5. 9
      acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_fold_disc_site/LnshFoldDiscSiteDeviceDriver.java
  6. 9
      acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_mixing_mill/LnshMixingMillDeviceDriver.java
  7. 9
      acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_package_pallet_manipulator/LnshPackagePalletManipulatorDeviceDriver.java
  8. 9
      acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_package_site/LnshPackageSiteDeviceDriver.java
  9. 11
      acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_palletizing_manipulator_site/LnshPalletizingManipulatorSiteDeviceDriver.java
  10. 9
      acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_press/LnshPressDeviceDriver.java
  11. 9
      acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_rgv/LnshRGVDeviceDriver.java
  12. 9
      acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_split_manipulator/LnshSplitManipulatorDeviceDriver.java
  13. 9
      acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_station/LnshStationDeviceDriver.java
  14. 7
      acs/nladmin-system/src/main/java/org/nl/acs/opc/OpcServerService.java
  15. 157
      acs/nladmin-system/src/main/java/org/nl/acs/opc/OpcServerServiceImpl.java
  16. 322
      acs/nladmin-system/src/main/java/org/nl/acs/opc/OpcUtl.java
  17. 12
      acs/nladmin-ui/src/views/system/monitor/device/index.vue

4
acs/nladmin-system/src/main/java/org/nl/acs/device_driver/driver/ItemValue.java

@ -0,0 +1,4 @@
package org.nl.acs.device_driver.driver;
public class ItemValue {
}

9
acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/converor_barcode/ConveyorBarcodeDeviceDriver.java

@ -902,10 +902,13 @@ public class ConveyorBarcodeDeviceDriver extends AbstractOpcDeviceDriver impleme
if (ObjectUtil.isNotEmpty(itemMap)) {
try {
this.checkcontrol(itemMap);
} catch (JIException e) {
e.printStackTrace();
} catch (AddFailedException e) {
} catch (Exception e) {
e.printStackTrace();
try{
this.checkcontrol(itemMap);
} catch (Exception e1){
e1.printStackTrace();
}
}
logServer.deviceExecuteLog(this.getDevice().getDevice_code(), "", "", "下发多个电气信号:" + itemMap);
lucene.deviceExecuteLog(new LuceneLogDto(this.getDeviceCode(), "下发多个电气信号:" + itemMap));

9
acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/conveyor_press_station/ConveyorPressStationDeviceDriver.java

@ -880,10 +880,13 @@ public class ConveyorPressStationDeviceDriver extends AbstractOpcDeviceDriver im
if (ObjectUtil.isNotEmpty(itemMap)) {
try {
this.checkcontrol(itemMap);
} catch (JIException e) {
e.printStackTrace();
} catch (AddFailedException e) {
} catch (Exception e) {
e.printStackTrace();
try{
this.checkcontrol(itemMap);
} catch (Exception e1){
e1.printStackTrace();
}
}
logServer.deviceExecuteLog(this.getDevice().getDevice_code(), "", "", "下发多个电气信号:" + itemMap);
lucene.deviceExecuteLog(new LuceneLogDto(this.getDeviceCode(), "下发多个电气信号:" + itemMap));

9
acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_Laminating_machine/LnshLaminatingMachineDeviceDriver.java

@ -408,10 +408,13 @@ public class LnshLaminatingMachineDeviceDriver extends AbstractOpcDeviceDriver i
if (ObjectUtil.isNotEmpty(itemMap)) {
try {
this.checkcontrol(itemMap);
} catch (JIException e) {
e.printStackTrace();
} catch (AddFailedException e) {
} catch (Exception e) {
e.printStackTrace();
try{
this.checkcontrol(itemMap);
} catch (Exception e1){
e1.printStackTrace();
}
}
logServer.deviceExecuteLog(this.getDevice().getDevice_code(), "", "", "下发多个电气信号:" + itemMap);
lucene.deviceExecuteLog(new LuceneLogDto(this.getDeviceCode(), "下发多个电气信号:" + itemMap));

9
acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_fold_disc_site/LnshFoldDiscSiteDeviceDriver.java

@ -298,10 +298,13 @@ public class LnshFoldDiscSiteDeviceDriver extends AbstractOpcDeviceDriver implem
if (ObjectUtil.isNotEmpty(itemMap)) {
try {
this.checkcontrol(itemMap);
} catch (JIException e) {
e.printStackTrace();
} catch (AddFailedException e) {
} catch (Exception e) {
e.printStackTrace();
try{
this.checkcontrol(itemMap);
} catch (Exception e1){
e1.printStackTrace();
}
}
logServer.deviceExecuteLog(this.getDevice().getDevice_code(), "", "", "下发多个电气信号:" + itemMap);
lucene.deviceExecuteLog(new LuceneLogDto(this.getDeviceCode(), "下发多个电气信号:" + itemMap));

9
acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_mixing_mill/LnshMixingMillDeviceDriver.java

@ -249,10 +249,13 @@ public class LnshMixingMillDeviceDriver extends AbstractOpcDeviceDriver implemen
if (ObjectUtil.isNotEmpty(itemMap)) {
try {
this.checkcontrol(itemMap);
} catch (JIException e) {
e.printStackTrace();
} catch (AddFailedException e) {
} catch (Exception e) {
e.printStackTrace();
try{
this.checkcontrol(itemMap);
} catch (Exception e1){
e1.printStackTrace();
}
}
logServer.deviceExecuteLog(this.getDevice().getDevice_code(), "", "", "下发多个电气信号:" + itemMap);
lucene.deviceExecuteLog(new LuceneLogDto(this.getDeviceCode(), "下发多个电气信号:" + itemMap));

9
acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_package_pallet_manipulator/LnshPackagePalletManipulatorDeviceDriver.java

@ -548,10 +548,13 @@ public class LnshPackagePalletManipulatorDeviceDriver extends AbstractOpcDeviceD
if (ObjectUtil.isNotEmpty(itemMap)) {
try {
this.checkcontrol(itemMap);
} catch (JIException e) {
e.printStackTrace();
} catch (AddFailedException e) {
} catch (Exception e) {
e.printStackTrace();
try{
this.checkcontrol(itemMap);
} catch (Exception e1){
e1.printStackTrace();
}
}
logServer.deviceExecuteLog(this.getDevice().getDevice_code(), "", "", "下发多个电气信号:" + itemMap);
lucene.deviceExecuteLog(new LuceneLogDto(this.getDeviceCode(), "下发多个电气信号:" + itemMap));

9
acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_package_site/LnshPackageSiteDeviceDriver.java

@ -260,10 +260,13 @@ public class LnshPackageSiteDeviceDriver extends AbstractOpcDeviceDriver impleme
if (ObjectUtil.isNotEmpty(itemMap)) {
try {
this.checkcontrol(itemMap);
} catch (JIException e) {
e.printStackTrace();
} catch (AddFailedException e) {
} catch (Exception e) {
e.printStackTrace();
try{
this.checkcontrol(itemMap);
} catch (Exception e1){
e1.printStackTrace();
}
}
logServer.deviceExecuteLog(this.getDevice().getDevice_code(), "", "", "下发多个电气信号:" + itemMap);
lucene.deviceExecuteLog(new LuceneLogDto(this.getDeviceCode(), "下发多个电气信号:" + itemMap));

11
acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_palletizing_manipulator_site/LnshPalletizingManipulatorSiteDeviceDriver.java

@ -747,7 +747,7 @@ public class LnshPalletizingManipulatorSiteDeviceDriver extends AbstractOpcDevic
ApplyTaskResponse resp = JSON.toJavaObject(JSONObject.parseObject(acsToWmsService.applyTask(request)),ApplyTaskResponse.class);
if (resp.getCode() == 200) {
Map<String, Object> map = new LinkedHashMap<>();
map.put("to_command",102);
map.put("to_command",200);
this.writing(map);
this.setRequireSucess(true);
} else {
@ -1710,10 +1710,13 @@ public class LnshPalletizingManipulatorSiteDeviceDriver extends AbstractOpcDevic
if (ObjectUtil.isNotEmpty(itemMap)) {
try {
this.checkcontrol(itemMap);
} catch (JIException e) {
e.printStackTrace();
} catch (AddFailedException e) {
} catch (Exception e) {
e.printStackTrace();
try{
this.checkcontrol(itemMap);
} catch (Exception e1){
e1.printStackTrace();
}
}
logServer.deviceExecuteLog(this.getDevice().getDevice_code(), "", "", "下发多个电气信号:" + itemMap);
lucene.deviceExecuteLog(new LuceneLogDto(this.getDeviceCode(), "下发多个电气信号:" + itemMap));

9
acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_press/LnshPressDeviceDriver.java

@ -470,10 +470,13 @@ public class LnshPressDeviceDriver extends AbstractOpcDeviceDriver implements De
if (ObjectUtil.isNotEmpty(itemMap)) {
try {
this.checkcontrol(itemMap);
} catch (JIException e) {
e.printStackTrace();
} catch (AddFailedException e) {
} catch (Exception e) {
e.printStackTrace();
try{
this.checkcontrol(itemMap);
} catch (Exception e1){
e1.printStackTrace();
}
}
logServer.deviceExecuteLog(this.getDevice().getDevice_code(), "", "", "下发多个电气信号:" + itemMap);
lucene.deviceExecuteLog(new LuceneLogDto(this.getDeviceCode(), "下发多个电气信号:" + itemMap));

9
acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_rgv/LnshRGVDeviceDriver.java

@ -894,10 +894,13 @@ public class LnshRGVDeviceDriver extends AbstractOpcDeviceDriver implements Devi
if (ObjectUtil.isNotEmpty(itemMap)) {
try {
this.checkcontrol(itemMap);
} catch (JIException e) {
e.printStackTrace();
} catch (AddFailedException e) {
} catch (Exception e) {
e.printStackTrace();
try{
this.checkcontrol(itemMap);
} catch (Exception e1){
e1.printStackTrace();
}
}
logServer.deviceExecuteLog(this.getDevice().getDevice_code(), "", "", "下发多个电气信号:" + itemMap);
lucene.deviceExecuteLog(new LuceneLogDto(this.getDeviceCode(), "下发多个电气信号:" + itemMap));

9
acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_split_manipulator/LnshSplitManipulatorDeviceDriver.java

@ -1441,10 +1441,13 @@ public class LnshSplitManipulatorDeviceDriver extends AbstractOpcDeviceDriver im
if (ObjectUtil.isNotEmpty(itemMap)) {
try {
this.checkcontrol(itemMap);
} catch (JIException e) {
e.printStackTrace();
} catch (AddFailedException e) {
} catch (Exception e) {
e.printStackTrace();
try{
this.checkcontrol(itemMap);
} catch (Exception e1){
e1.printStackTrace();
}
}
logServer.deviceExecuteLog(this.getDevice().getDevice_code(), "", "", "下发多个电气信号:" + itemMap);
lucene.deviceExecuteLog(new LuceneLogDto(this.getDeviceCode(), "下发多个电气信号:" + itemMap));

9
acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_station/LnshStationDeviceDriver.java

@ -386,10 +386,13 @@ public class LnshStationDeviceDriver extends AbstractOpcDeviceDriver implements
if (ObjectUtil.isNotEmpty(itemMap)) {
try {
this.checkcontrol(itemMap);
} catch (JIException e) {
e.printStackTrace();
} catch (AddFailedException e) {
} catch (Exception e) {
e.printStackTrace();
try{
this.checkcontrol(itemMap);
} catch (Exception e1){
e1.printStackTrace();
}
}
logServer.deviceExecuteLog(this.getDevice().getDevice_code(), "", "", "下发多个电气信号:" + itemMap);
lucene.deviceExecuteLog(new LuceneLogDto(this.getDeviceCode(), "下发多个电气信号:" + itemMap));

7
acs/nladmin-system/src/main/java/org/nl/acs/opc/OpcServerService.java

@ -1,5 +1,6 @@
package org.nl.acs.opc;
import org.nl.acs.device_driver.driver.ItemValue;
import org.openscada.opc.lib.da.Group;
/**
@ -14,11 +15,11 @@ public interface OpcServerService {
Group getServer(String var1);
void writeInteger(String var1, ItemValue... var2);
Group getServerByNewConn(String var1);
void clearServer(String var1);
void writeInteger(String var1, ItemValue... var2);
void cleanGroups(String var1);
void writeIntegerByNewConn(String var1, ItemValue... var2);
void clearServer(String var1);
}

157
acs/nladmin-system/src/main/java/org/nl/acs/opc/OpcServerServiceImpl.java

@ -3,7 +3,9 @@ package org.nl.acs.opc;
import cn.hutool.core.util.StrUtil;
import org.jinterop.dcom.common.JIException;
import org.nl.acs.auto.initial.ApplicationAutoInitial;
import org.nl.acs.device_driver.driver.ItemValue;
import org.nl.modules.common.exception.BadRequestException;
import org.nl.modules.wql.exception.WDKException;
import org.openscada.opc.lib.common.NotConnectedException;
import org.openscada.opc.lib.da.Group;
import org.openscada.opc.lib.da.Server;
@ -29,32 +31,33 @@ import java.util.Map;
public class OpcServerServiceImpl implements OpcServerService, ApplicationAutoInitial {
private static final Logger log = LoggerFactory.getLogger(OpcServerServiceImpl.class);
@Autowired
OpcServerManageService opcServerManageService;
@Autowired OpcServerManageService opcServerManageService;
Map<String, OpcServerManageDto> opcServerManageDtos = new HashMap();
Map<String, Server> servers = Collections.synchronizedMap(new HashMap());
Map<String, Group> groups = Collections.synchronizedMap(new HashMap());
public OpcServerServiceImpl() {
}
public OpcServerServiceImpl() {}
public void autoInitial() throws Exception {
this.reload();
if (OpcConfig.auto_start_opc) {
Thread t = new Thread(() -> {
Iterator var1 = OpcServerServiceImpl.this.opcServerManageDtos.values().iterator();
while (var1.hasNext()) {
OpcServerManageDto dto = (OpcServerManageDto) var1.next();
try {
OpcServerServiceImpl.this.getServer(dto.getOpc_code());
OpcServerServiceImpl.log.info("加载opc server {}", dto.getOpc_code());
} catch (Exception var4) {
OpcServerServiceImpl.log.warn("启动无法载入servers", var4);
}
}
});
Thread t =
new Thread() {
public void run() {
Iterator var1 = OpcServerServiceImpl.this.opcServerManageDtos.values().iterator();
while (var1.hasNext()) {
OpcServerManageDto dto = (OpcServerManageDto) var1.next();
try {
OpcServerServiceImpl.this.getServer(dto.getOpc_code());
OpcServerServiceImpl.log.info("加载opc server {}", dto.getOpc_code());
} catch (Exception var4) {
OpcServerServiceImpl.log.warn("启动无法载入servers", var4);
}
}
}
};
t.start();
}
}
@ -64,31 +67,12 @@ public class OpcServerServiceImpl implements OpcServerService, ApplicationAutoIn
this.opcServerManageDtos = Collections.synchronizedMap(this.opcServerManageDtos);
}
public void cleanGroups(String opcCode) {
Group group = (Group) this.groups.get(opcCode);
if (group != null) {
Server server = group.getServer();
try {
group.remove();
} catch (JIException var5) {
var5.printStackTrace();
}
this.groups.remove(opcCode);
server.disconnect();
this.servers.remove(opcCode);
}
}
public Group getServer(String code) {
synchronized (this.buildLock(code)) {
public Group getServer(String code) {
synchronized(this.buildLock(code)) {
Group group = null;
group = (Group) this.groups.get(code);
group = (Group)this.groups.get(code);
if (group != null) {
label68:
{
label68: {
Group var10000;
try {
if (!group.isActive()) {
@ -105,7 +89,7 @@ public class OpcServerServiceImpl implements OpcServerService, ApplicationAutoIn
}
}
Server server = (Server) this.servers.get(code);
Server server = (Server)this.servers.get(code);
boolean needcreate = false;
String groupName = code;
if (server == null) {
@ -113,17 +97,16 @@ public class OpcServerServiceImpl implements OpcServerService, ApplicationAutoIn
} else {
try {
group = server.findGroup(groupName);
} catch (UnknownHostException | JIException | UnknownGroupException | NotConnectedException |
IllegalArgumentException var13) {
} catch (UnknownHostException | JIException | UnknownGroupException | NotConnectedException | IllegalArgumentException var13) {
log.error(code, var13);
needcreate = true;
}
}
if (needcreate) {
OpcServerManageDto dto = (OpcServerManageDto) this.opcServerManageDtos.get(code);
OpcServerManageDto dto = (OpcServerManageDto)this.opcServerManageDtos.get(code);
if (dto == null) {
throw new RuntimeException(code + "不存在");
throw new RuntimeException(code+"不存在");
}
// if (server!=null){
@ -132,8 +115,7 @@ public class OpcServerServiceImpl implements OpcServerService, ApplicationAutoIn
// }
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);
@ -157,42 +139,6 @@ public class OpcServerServiceImpl implements OpcServerService, ApplicationAutoIn
}
}
public void clearServer(String code) {
synchronized (this.buildLock(code)) {
try {
Server server = (Server) this.servers.get(code);
server.disconnect();
} catch (Exception var5) {
}
this.servers.remove(code);
this.groups.remove(code);
}
}
public void writeInteger(String code, ItemValue... values) {
try {
Group group = this.getServer(code);
OpcUtl.writeValue(group, values);
} catch (Exception var4) {
this.clearServer(code);
log.warn("写入出错opc server {} 重新加载", code, var4);
ThreadUtl.sleep(5000L);
// throw var4;
}
}
private String buildLock(String key) {
if (StrUtil.isEmpty(key)) {
key = "";
}
StringBuilder builder = new StringBuilder();
builder.append("OpcServerService.");
builder.append(key);
String lock = builder.toString().intern();
return lock;
}
public Group getServerByNewConn(String code) {
synchronized(this.buildLock(code)) {
@ -231,6 +177,32 @@ public class OpcServerServiceImpl implements OpcServerService, ApplicationAutoIn
return group;
}
}
public void clearServer(String code) {
synchronized(this.buildLock(code)) {
try {
Server server = (Server)this.servers.get(code);
server.disconnect();
} catch (Exception var5) {
}
this.servers.remove(code);
this.groups.remove(code);
}
}
public void writeInteger(String code, ItemValue... values) {
try {
Group group = this.getServer(code);
OpcUtl.writeValue(group, values);
} catch (Exception var4) {
this.clearServer(code);
log.info("写入出错opc server {} 重新加载", code, var4);
ThreadUtl.sleep(1000L);
throw var4;
}
}
public void writeIntegerByNewConn(String code, ItemValue... values) {
try {
Group group = this.getServerByNewConn(code);
@ -239,11 +211,18 @@ public class OpcServerServiceImpl implements OpcServerService, ApplicationAutoIn
this.clearServer(code);
log.info("写入出错opc server {} 重新加载", code, var4);
ThreadUtl.sleep(1000L);
try {
throw var4;
} catch (Exception e) {
e.printStackTrace();
}
throw var4;
}
}
private String buildLock(String key) {
if (StrUtil.isEmpty(key)) {
key = "";
}
StringBuilder builder = new StringBuilder();
builder.append("OpcServerService.");
builder.append(key);
String lock = builder.toString().intern();
return lock;
}
}

322
acs/nladmin-system/src/main/java/org/nl/acs/opc/OpcUtl.java

@ -1,118 +1,119 @@
package org.nl.acs.opc;
import java.net.UnknownHostException;
import cn.hutool.core.util.NumberUtil;
import lombok.extern.slf4j.Slf4j;
import org.jinterop.dcom.common.JIException;
import org.jinterop.dcom.core.*;
import org.nl.acs.device_driver.driver.ItemValue;
import org.nl.modules.common.exception.BadRequestException;
import org.nl.modules.wql.exception.WDKException;
import org.openscada.opc.lib.common.ConnectionInformation;
import org.openscada.opc.lib.da.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Executors;
import lombok.extern.slf4j.Slf4j;
import org.jinterop.dcom.common.JIException;
import org.jinterop.dcom.core.IJIUnsigned;
import org.jinterop.dcom.core.JIArray;
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;
import org.openscada.opc.lib.da.AddFailedException;
import org.openscada.opc.lib.da.AutoReconnectController;
import org.openscada.opc.lib.da.Group;
import org.openscada.opc.lib.da.Item;
import org.openscada.opc.lib.da.ItemState;
import org.openscada.opc.lib.da.Server;
import org.openscada.opc.lib.da.WriteRequest;
import org.openscada.opc.lib.list.Categories;
import org.openscada.opc.lib.list.Category;
import org.openscada.opc.lib.list.ServerList;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Slf4j
public class OpcUtl {
private static int timeout = 180000;
private static int timeout = 1*60*1000;
private static String key = "rpc.socketTimeout";
static {
checkTimeout();
}
public static void checkTimeout() {
if (Integer.getInteger(key, 0) != timeout) {
if (Integer.getInteger(key, 0).intValue() != timeout) {
System.setProperty(key, String.valueOf(timeout));
}
}
private OpcUtl() {
}
public static List<Map<String, String>> showAllOpcServer(String host, String user, String password, String domain) throws Exception {
public static void writeValue(Group group, WriteRequest... requests) throws WDKException {
try {
List<Map<String, String>> listResult = new ArrayList();
ServerList serverList = new ServerList(host, user, password, domain);
Collection<ClassDetails> classDetails = serverList.listServersWithDetails(new Category[]{Categories.OPCDAServer10, Categories.OPCDAServer20, Categories.OPCDAServer30}, new Category[0]);
Iterator var7 = classDetails.iterator();
while(var7.hasNext()) {
ClassDetails details = (ClassDetails)var7.next();
Map<String, String> result = new LinkedHashMap();
result.put("classId", details.getClsId());
result.put("progId", details.getProgId());
result.put("description", details.getDescription());
listResult.add(result);
Map<Item, Integer> e=group.write(requests);
boolean is_success = true;
StringBuilder message = new StringBuilder();
Iterator arg4 = e.keySet().iterator();
while (arg4.hasNext()) {
Item item = (Item) arg4.next();
Integer integer = (Integer) e.get(item);
if (integer.intValue() != 0) {
if (is_success) {
is_success = false;
}
message.append(item.getId());
message.append(":error code:");
message.append(integer);
message.append("; ");
}
}
return listResult;
} catch (UnknownHostException | JIException | IllegalArgumentException var10) {
throw new Exception(var10);
if (!is_success) {
log.info("下发信号失败:"+message.toString());
throw new WDKException(message.toString());
}
} catch (JIException arg7) {
log.info("下发信号失败Exception:"+arg7.getMessage());
throw new WDKException("下发信号失败Exception:"+arg7);
}
}
public static Server getServer(String host, String clsid, String user, String password, String domain)
throws WDKException {
checkTimeout();
Server server = null;
public static void writeValue(Group group, ItemValue... values) throws WDKException {
try {
server = new Server(getConnection(host, clsid, user, password, domain),
Executors.newSingleThreadScheduledExecutor());
server.connect();
return server;
} catch (Exception e) {
System.out.println("server error:"+e.getMessage());
throw new WDKException(e.getMessage());
}
}
if (values != null && values.length > 0) {
List<WriteRequest> ws = new ArrayList();
ItemValue[] var3 = values;
int var4 = values.length;
for(int var5 = 0; var5 < var4; ++var5) {
ItemValue value = var3[var5];
Item item = group.addItem(value.getItem_code());
ws.add(new WriteRequest(item, getVariant(value.getItem_value())));
}
writeValue(group, (WriteRequest[])ws.toArray(new WriteRequest[0]));
}
public static Server getAutoServer(String host, String clsid, String user, String password, String domain) throws Exception {
checkTimeout();
Server server = null;
server = new Server(getConnection(host, clsid, user, password, domain), Executors.newSingleThreadScheduledExecutor());
AutoReconnectController autoReconnectController = new AutoReconnectController(server);
autoReconnectController.connect();
return server;
} catch (AddFailedException | JIException var8) {
throw new WDKException(var8);
}
}
public static ConnectionInformation getConnection(String host, String clsid, String user, String password, String domain) {
ConnectionInformation connection = new ConnectionInformation();
connection.setHost(host);
connection.setClsid(clsid);
connection.setUser(user);
connection.setPassword(password);
connection.setDomain(domain);
return connection;
public static JIVariant getVariant(Object object) {
if (object instanceof Integer) {
return getIntegerVariant((Integer)object);
} else if (object instanceof String) {
return getStringVariant((String)object);
} else if (object instanceof byte[]) {
return getByteArrayVariant((byte[])((byte[])object));
} else if (object instanceof Byte[]) {
return getByteArrayVariant((Byte[])((Byte[])object));
} else if (object instanceof Boolean) {
return new JIVariant((Boolean)object);
} else if (object instanceof int[]) {
return getByteArrayVariantxx((int[])((int[])object));
} else if (object instanceof Integer[]) {
JIArray array = new JIArray((Integer)object, false);
JIVariant value = new JIVariant(array);
return value;
} else if (object instanceof JIVariant) {
return (JIVariant)object;
} else {
throw new WDKException("未实现目前支持是int,string,byte[]");
}
}
public static Object getValue(Item item, ItemState itemState) throws Exception {
if (!ObjectUtl.isEquals(itemState.getQuality(), QualityTypeValue.OPC_QUALITY_GOOD)) {
public static Object getValue(Item item, ItemState itemState) throws BadRequestException {
if (NumberUtil.compare(itemState.getQuality(), Short.valueOf(QualityTypeValue.OPC_QUALITY_GOOD)) != 0) {
if (item != null) {
log.debug("value is not good {} : {}", item.getId(), itemState.getQuality());
// throw new WDKException("值不健康进行重连!");
} else {
log.debug("value is not good {}", itemState.getQuality());
}
@ -124,36 +125,24 @@ public class OpcUtl {
}
}
public static int getIntegerValue(Item item, ItemState itemState) throws Exception {
return (Integer)getValue(item, itemState);
}
public static String getStringValue(Item item, ItemState itemState) throws Exception {
return (String)getValue(item, itemState);
}
public static byte[] getByteArrayValue(Item item, ItemState itemState) throws Exception {
return (byte[])((byte[])getValue(item, itemState));
}
public static Object getValue(JIVariant jiVariant, String id) {
public static Object getValue(JIVariant jiVariant, String id) throws BadRequestException {
try {
Object object = jiVariant.getObject();
if (object instanceof IJIUnsigned) {
return ((IJIUnsigned)object).getValue().intValue();
} else if (object instanceof Boolean) {
return jiVariant.getObjectAsBoolean() ? 1 : 0;
} else if (object instanceof JIString) {
return ((JIString)object).getString();
} else if (!(object instanceof JIArray)) {
if (object instanceof Integer) {
Object e = jiVariant.getObject();
if (e instanceof IJIUnsigned) {
return Integer.valueOf(((IJIUnsigned) e).getValue().intValue());
} else if (e instanceof Boolean) {
return jiVariant.getObjectAsBoolean() ? Integer.valueOf(1) : Integer.valueOf(0);
} else if (e instanceof JIString) {
return ((JIString) e).getString();
} else if (!(e instanceof JIArray)) {
if (e instanceof Integer) {
return jiVariant.getObject();
} else if (object instanceof Short) {
} else if (e instanceof Short) {
return jiVariant.getObject();
} else if (object instanceof Float) {
} else if (e instanceof Float) {
return jiVariant.getObject();
} else {
System.err.println(id + "不明类型" + object.getClass());
System.err.println(id + "不明类型" + e.getClass());
if (jiVariant.getType() == 0) {
System.err.println("因类型为emtpy 返回 null");
return null;
@ -165,15 +154,15 @@ public class OpcUtl {
}
}
} else {
Class<?> clazz = ((JIArray)object).getArrayClass();
Class clazz = ((JIArray) e).getArrayClass();
int[] r;
int i;
if (JIUnsignedByte.class.isAssignableFrom(clazz)) {
JIUnsignedByte[] array = (JIUnsignedByte[])((JIUnsignedByte[])((JIArray)object).getArrayInstance());
r = new int[array.length];
JIUnsignedByte[] arg7 = (JIUnsignedByte[]) ((JIUnsignedByte[]) ((JIArray) e).getArrayInstance());
r = new int[arg7.length];
for(i = 0; i < array.length; ++i) {
r[i] = array[i].getValue().byteValue();
for (i = 0; i < arg7.length; ++i) {
r[i] = arg7[i].getValue().byteValue();
}
return r;
@ -186,99 +175,60 @@ public class OpcUtl {
System.err.println("因类型为null 返回 null");
return null;
} else {
return ((JIArray)object).getArrayInstance();
return ((JIArray) e).getArrayInstance();
}
} else {
JIUnsignedShort[] array = (JIUnsignedShort[])((JIUnsignedShort[])((JIArray)object).getArrayInstance());
JIUnsignedShort[] array = (JIUnsignedShort[]) ((JIUnsignedShort[]) ((JIArray) e)
.getArrayInstance());
r = new int[array.length];
for(i = 0; i < array.length; ++i) {
for (i = 0; i < array.length; ++i) {
r[i] = array[i].getValue().intValue();
}
return r;
}
}
} catch (JIException var7) {
// throw new Exception(var7);
var7.printStackTrace();
} catch (JIException e) {
throw new BadRequestException(e.getMessage());
}
return null;
}
public static void writeValue(Group group, WriteRequest... requests) throws Exception {
try {
Map<Item, Integer> write = group.write(requests);
boolean is_success = true;
StringBuilder message = new StringBuilder();
Iterator var5 = write.keySet().iterator();
while(var5.hasNext()) {
Item item = (Item)var5.next();
Integer integer = (Integer)write.get(item);
if (integer != 0) {
if (is_success) {
is_success = false;
}
message.append(item.getId());
message.append(":error code:");
message.append(integer);
message.append("; ");
}
}
public static Server getServer(String host, String clsid, String user, String password, String domain)
throws WDKException {
checkTimeout();
Server server = null;
if (!is_success) {
throw new Exception(message.toString());
}
} catch (JIException var8) {
throw new Exception(var8);
try {
server = new Server(getConnection(host, clsid, user, password, domain),
Executors.newSingleThreadScheduledExecutor());
server.connect();
return server;
} catch (Exception e) {
System.out.println("server error:"+e.getMessage());
throw new WDKException(e.getMessage());
}
}
public static void writeValue(Group group, ItemValue... values) throws Exception {
try {
if (values != null && values.length > 0) {
List<WriteRequest> ws = new ArrayList();
ItemValue[] var3 = values;
int var4 = values.length;
for(int var5 = 0; var5 < var4; ++var5) {
ItemValue value = var3[var5];
Item item = group.addItem(value.getItem_code());
ws.add(new WriteRequest(item, getVariant(value.getItem_value())));
}
writeValue(group, (WriteRequest[])ws.toArray(new WriteRequest[0]));
}
} catch (AddFailedException | JIException var8) {
throw new Exception(var8);
}
public static Server getAutoServer(String host, String clsid, String user, String password, String domain) throws WDKException {
checkTimeout();
Server server = null;
server = new Server(getConnection(host, clsid, user, password, domain), Executors.newSingleThreadScheduledExecutor());
AutoReconnectController autoReconnectController = new AutoReconnectController(server);
autoReconnectController.connect();
return server;
}
public static JIVariant getVariant(Object object) throws Exception {
if (object instanceof Integer) {
return getIntegerVariant((Integer)object);
} else if (object instanceof String) {
return getStringVariant((String)object);
} else if (object instanceof byte[]) {
return getByteArrayVariant((byte[])((byte[])object));
} else if (object instanceof Byte[]) {
return getByteArrayVariant((Byte[])((Byte[])object));
} else if (object instanceof Boolean) {
return new JIVariant((Boolean)object);
} else if (object instanceof int[]) {
return getByteArrayVariantxx((int[])((int[])object));
} else if (object instanceof Integer[]) {
JIArray array = new JIArray((Integer)object, false);
JIVariant value = new JIVariant(array);
return value;
} else if (object instanceof JIVariant) {
return (JIVariant)object;
} else {
throw new Exception("未实现目前支持是int,string,byte[]");
}
public static ConnectionInformation getConnection(String host, String clsid, String user, String password,
String domain) {
ConnectionInformation connection = new ConnectionInformation();
connection.setHost(host);
connection.setClsid(clsid);
connection.setUser(user);
connection.setPassword(password);
connection.setDomain(domain);
return connection;
}
public static JIVariant getByteArrayVariantxx(int[] bytes) {
@ -319,8 +269,6 @@ public class OpcUtl {
return value;
}
static {
checkTimeout();
}
}

12
acs/nladmin-ui/src/views/system/monitor/device/index.vue

@ -470,9 +470,10 @@ export default {
const obj = { name: '行走列', value: data[val] }
this.arr.push(obj)
} else if (val === 'task1') {
const obj = { name: '前工位任务', value: data[val] }
const obj = { name: '前工位任务', value: data[val] }
this.arr.push(obj)
} else if (val === 'task2') {
}
else if (val === 'task2') {
const obj = { name: '后工位任务号', value: data[val] }
this.arr.push(obj)
} else if (val === 'labeling_qty') {
@ -539,6 +540,13 @@ export default {
const obj = { name: '模式名称', value: data[val] }
this.arr.push(obj)
}
else if (val==='requireSucess1'){
const obj = { name: '请求成功标记', value: data[val] }
this.arr.push(obj)
}
// const obj = { name: '', value: data[requireSucess1] }
// this.arr.push(obj)
}
}
// console.log('arr:', this.arr)

Loading…
Cancel
Save