解决acs值偶尔无法写入问题
This commit is contained in:
@@ -200,11 +200,11 @@ public class BoxPalletizingManipulatorDeviceDriver extends AbstractOpcDeviceDriv
|
||||
|
||||
itemMap.put(to_param, value);
|
||||
// itemMap.put(to_param, Integer.parseInt(value));
|
||||
ReadUtil.write(itemMap, server);
|
||||
this.control(itemMap);
|
||||
}
|
||||
|
||||
public void executing(Server server, Map<String, Object> itemMap) {
|
||||
ReadUtil.write(itemMap, server);
|
||||
this.control(itemMap);
|
||||
}
|
||||
|
||||
public void writing(int command) {
|
||||
@@ -212,7 +212,7 @@ public class BoxPalletizingManipulatorDeviceDriver extends AbstractOpcDeviceDriv
|
||||
String opcservcerid = this.getDevice().getOpc_server_id();
|
||||
Server server = ReadUtil.getServer(opcservcerid);
|
||||
Map<String, Object> itemMap = new HashMap<String, Object>();
|
||||
ReadUtil.write(itemMap, server);
|
||||
this.control(itemMap);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -285,7 +285,7 @@ public class CargoLiftConveyorDeviceDriver extends AbstractOpcDeviceDriver imple
|
||||
Server server = ReadUtil.getServer(opcservcerid);
|
||||
Map<String, Object> itemMap = new HashMap<String, Object>();
|
||||
itemMap.put(to_command, command);
|
||||
ReadUtil.write(itemMap, server);
|
||||
this.control(itemMap);
|
||||
}
|
||||
|
||||
public void writing(int type, int command) {
|
||||
@@ -310,7 +310,7 @@ public class CargoLiftConveyorDeviceDriver extends AbstractOpcDeviceDriver imple
|
||||
log.info("设备:" + device_code + ",下发PLC信号" + to_task + ",value:" + command);
|
||||
}
|
||||
|
||||
ReadUtil.write(itemMap, server);
|
||||
this.control(itemMap);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -181,7 +181,7 @@ public class EmptyVehicleStackingPositionDeviceDriver extends AbstractOpcDeviceD
|
||||
Server server = ReadUtil.getServer(opcservcerid);
|
||||
Map<String, Object> itemMap = new HashMap<String, Object>();
|
||||
itemMap.put(to_command, command);
|
||||
ReadUtil.write(itemMap, server);
|
||||
this.control(itemMap);
|
||||
}
|
||||
|
||||
public void writing(String key, String value) {
|
||||
@@ -191,7 +191,7 @@ public class EmptyVehicleStackingPositionDeviceDriver extends AbstractOpcDeviceD
|
||||
Server server = ReadUtil.getServer(opcservcerid);
|
||||
Map<String, Object> itemMap = new HashMap<String, Object>();
|
||||
itemMap.put(to_command, value);
|
||||
ReadUtil.write(itemMap, server);
|
||||
this.control(itemMap);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -213,7 +213,7 @@ public class HailiangSmartplcTestDeviceDriver extends AbstractOpcDeviceDriver im
|
||||
Server server = ReadUtil.getServer(opcservcerid);
|
||||
Map<String, Object> itemMap = new HashMap<String, Object>();
|
||||
itemMap.put(to_command, command);
|
||||
ReadUtil.write(itemMap, server);
|
||||
this.control(itemMap);
|
||||
}
|
||||
|
||||
public void writing(String key, String value) {
|
||||
@@ -223,7 +223,7 @@ public class HailiangSmartplcTestDeviceDriver extends AbstractOpcDeviceDriver im
|
||||
Server server = ReadUtil.getServer(opcservcerid);
|
||||
Map<String, Object> itemMap = new HashMap<String, Object>();
|
||||
itemMap.put(to_command, value);
|
||||
ReadUtil.write(itemMap, server);
|
||||
this.control(itemMap);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -149,7 +149,7 @@ public class HongXiangStationDeviceDriver extends AbstractOpcDeviceDriver implem
|
||||
Server server = ReadUtil.getServer(opcservcerid);
|
||||
Map<String, Object> itemMap = new HashMap<String, Object>();
|
||||
itemMap.put(to_command, command);
|
||||
ReadUtil.write(itemMap, server);
|
||||
this.control(itemMap);
|
||||
}
|
||||
|
||||
//将扩展表中的字符串数据转换成集合
|
||||
@@ -178,7 +178,7 @@ public class HongXiangStationDeviceDriver extends AbstractOpcDeviceDriver implem
|
||||
|
||||
itemMap.put(to_param, value);
|
||||
// itemMap.put(to_param, Integer.parseInt(value));
|
||||
ReadUtil.write(itemMap, server);
|
||||
this.control(itemMap);
|
||||
}
|
||||
|
||||
public void writing(int type, int command) {
|
||||
@@ -203,7 +203,7 @@ public class HongXiangStationDeviceDriver extends AbstractOpcDeviceDriver implem
|
||||
log.info("设备:" + device_code + ",下发PLC信号" + to_task + ",value:" + command);
|
||||
}
|
||||
|
||||
ReadUtil.write(itemMap, server);
|
||||
this.control(itemMap);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -225,7 +225,7 @@ public class HongXiangConveyorDeviceDriver extends AbstractOpcDeviceDriver imple
|
||||
Server server = ReadUtil.getServer(opcservcerid);
|
||||
Map<String, Object> itemMap = new HashMap<String, Object>();
|
||||
itemMap.put(to_command, command);
|
||||
ReadUtil.write(itemMap, server);
|
||||
this.control(itemMap);
|
||||
}
|
||||
|
||||
//将扩展表中的字符串数据转换成集合
|
||||
@@ -254,7 +254,7 @@ public class HongXiangConveyorDeviceDriver extends AbstractOpcDeviceDriver imple
|
||||
|
||||
itemMap.put(to_param, Integer.parseInt(value));
|
||||
// itemMap.put(to_param, Integer.parseInt(value));
|
||||
ReadUtil.write(itemMap, server);
|
||||
this.control(itemMap);
|
||||
logServer.deviceExecuteLog(device_code, "", "", "下发电气信号设备号:" + device_code + ",下发电气:" + to_param + ",下发电气值:" + value);
|
||||
|
||||
}
|
||||
@@ -281,7 +281,7 @@ public class HongXiangConveyorDeviceDriver extends AbstractOpcDeviceDriver imple
|
||||
log.info("设备:" + device_code + ",下发PLC信号" + to_task + ",value:" + command);
|
||||
}
|
||||
|
||||
ReadUtil.write(itemMap, server);
|
||||
this.control(itemMap);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -653,12 +653,12 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
|
||||
|
||||
itemMap.put(to_param, Integer.parseInt(value));
|
||||
// itemMap.put(to_param, Integer.parseInt(value));
|
||||
ReadUtil.write(itemMap, server);
|
||||
this.control(itemMap);
|
||||
logServer.deviceExecuteLog(device_code, "", "", "下发电气信号设备号:" + device_code + ",下发电气:" + to_param + ",下发电气值:" + value);
|
||||
}
|
||||
|
||||
public void executing(Server server, Map<String, Object> itemMap) {
|
||||
ReadUtil.write(itemMap, server);
|
||||
this.control(itemMap);
|
||||
}
|
||||
|
||||
//判断取货位或放货位为烘箱设备时关联的同一列烘箱设备是否有开门
|
||||
@@ -731,7 +731,7 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
|
||||
String opcservcerid = this.getDevice().getOpc_server_id();
|
||||
Server server = ReadUtil.getServer(opcservcerid);
|
||||
Map<String, Object> itemMap = new HashMap<String, Object>();
|
||||
ReadUtil.write(itemMap, server);
|
||||
this.control(itemMap);
|
||||
|
||||
}
|
||||
|
||||
@@ -844,7 +844,7 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
|
||||
// if (type == 2) {
|
||||
// itemMap.put(to_material_code, command);
|
||||
// }
|
||||
// ReadUtil.write(itemMap, server);
|
||||
// this.control(itemMap);
|
||||
//
|
||||
// }
|
||||
|
||||
|
||||
@@ -246,7 +246,7 @@ public class PaintConveyorDeviceDriver extends AbstractOpcDeviceDriver implement
|
||||
Server server = ReadUtil.getServer(opcservcerid);
|
||||
Map<String, Object> itemMap = new HashMap<String, Object>();
|
||||
itemMap.put(to_command, command);
|
||||
ReadUtil.write(itemMap, server);
|
||||
this.control(itemMap);
|
||||
}
|
||||
|
||||
public void writing(String key, String value) {
|
||||
@@ -256,7 +256,7 @@ public class PaintConveyorDeviceDriver extends AbstractOpcDeviceDriver implement
|
||||
Server server = ReadUtil.getServer(opcservcerid);
|
||||
Map<String, Object> itemMap = new HashMap<String, Object>();
|
||||
itemMap.put(to_command, value);
|
||||
ReadUtil.write(itemMap, server);
|
||||
this.control(itemMap);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -161,7 +161,7 @@ public class PlugPullDeviceSiteDeviceDriver extends AbstractOpcDeviceDriver impl
|
||||
}
|
||||
}
|
||||
logServer.deviceExecuteLog(device_code, "", "", "下发电气信号:" + itemMap);
|
||||
ReadUtil.write(itemMap, server);
|
||||
this.control(itemMap);
|
||||
}
|
||||
|
||||
//将扩展表中的字符串数据转换成集合
|
||||
@@ -232,7 +232,7 @@ public class PlugPullDeviceSiteDeviceDriver extends AbstractOpcDeviceDriver impl
|
||||
|
||||
itemMap.put(to_param, value);
|
||||
// itemMap.put(to_param, Integer.parseInt(value));
|
||||
ReadUtil.write(itemMap, server);
|
||||
this.control(itemMap);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -389,12 +389,12 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme
|
||||
|
||||
itemMap.put(to_param, Integer.parseInt(value));
|
||||
// itemMap.put(to_param, Integer.parseInt(value));
|
||||
ReadUtil.write(itemMap, server);
|
||||
this.control(itemMap);
|
||||
logServer.deviceExecuteLog(device_code, "", "", "下发电气信号设备号:" + device_code + ",下发电气:" + to_param + ",下发电气值:" + value);
|
||||
}
|
||||
|
||||
public void executing(Server server, Map<String, Object> itemMap) {
|
||||
ReadUtil.write(itemMap, server);
|
||||
this.control(itemMap);
|
||||
}
|
||||
|
||||
public void writing(int command) {
|
||||
@@ -402,7 +402,7 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme
|
||||
String opcservcerid = this.getDevice().getOpc_server_id();
|
||||
Server server = ReadUtil.getServer(opcservcerid);
|
||||
Map<String, Object> itemMap = new HashMap<String, Object>();
|
||||
ReadUtil.write(itemMap, server);
|
||||
this.control(itemMap);
|
||||
|
||||
}
|
||||
|
||||
@@ -494,7 +494,7 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme
|
||||
}
|
||||
}
|
||||
logServer.deviceExecuteLog(device_code, "", "", "下发电气信号:" + itemMap);
|
||||
ReadUtil.write(itemMap, server);
|
||||
this.control(itemMap);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -345,12 +345,12 @@ public class SiemensConveyorLabelingDeviceDriver extends AbstractOpcDeviceDriver
|
||||
|
||||
itemMap.put(to_param, Integer.parseInt(value));
|
||||
// itemMap.put(to_param, Integer.parseInt(value));
|
||||
ReadUtil.write(itemMap, server);
|
||||
this.control(itemMap);
|
||||
logServer.deviceExecuteLog(device_code, "", "", "下发电气信号设备号:" + device_code + ",下发电气:" + to_param + ",下发电气值:" + value);
|
||||
}
|
||||
|
||||
public void executing(Server server, Map<String, Object> itemMap) {
|
||||
ReadUtil.write(itemMap, server);
|
||||
this.control(itemMap);
|
||||
}
|
||||
|
||||
public void writing(int command) {
|
||||
@@ -358,7 +358,7 @@ public class SiemensConveyorLabelingDeviceDriver extends AbstractOpcDeviceDriver
|
||||
String opcservcerid = this.getDevice().getOpc_server_id();
|
||||
Server server = ReadUtil.getServer(opcservcerid);
|
||||
Map<String, Object> itemMap = new HashMap<String, Object>();
|
||||
ReadUtil.write(itemMap, server);
|
||||
this.control(itemMap);
|
||||
|
||||
}
|
||||
|
||||
@@ -449,7 +449,7 @@ public class SiemensConveyorLabelingDeviceDriver extends AbstractOpcDeviceDriver
|
||||
}
|
||||
}
|
||||
logServer.deviceExecuteLog(device_code, "", "", "下发电气信号:" + itemMap);
|
||||
ReadUtil.write(itemMap, server);
|
||||
this.control(itemMap);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1277,7 +1277,7 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl
|
||||
Map<String, Object> itemMap = new HashMap<String, Object>();
|
||||
itemMap.put(to_param, Integer.parseInt(value));
|
||||
|
||||
ReadUtil.write(itemMap, server);
|
||||
this.control(itemMap);
|
||||
logServer.deviceExecuteLog(device_code, "", "", "下发电气信号设备号:" + device_code + ",下发电气:" + to_param + ",下发电气值:" + value);
|
||||
}
|
||||
|
||||
@@ -1294,7 +1294,7 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl
|
||||
String opcservcerid = this.getDevice().getOpc_server_id();
|
||||
Server server = ReadUtil.getServer(opcservcerid);
|
||||
Map<String, Object> itemMap = new HashMap<String, Object>();
|
||||
ReadUtil.write(itemMap, server);
|
||||
this.control(itemMap);
|
||||
|
||||
}
|
||||
|
||||
@@ -1306,7 +1306,7 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl
|
||||
|
||||
|
||||
public void executing(Server server, Map<String, Object> itemMap) {
|
||||
ReadUtil.write(itemMap, server);
|
||||
this.control(itemMap);
|
||||
}
|
||||
|
||||
public void writing1(int command) {
|
||||
@@ -1317,7 +1317,7 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl
|
||||
Server server = ReadUtil.getServer(opcservcerid);
|
||||
Map<String, Object> itemMap = new HashMap<String, Object>();
|
||||
itemMap.put(to_command1, command);
|
||||
ReadUtil.write(itemMap, server);
|
||||
this.control(itemMap);
|
||||
|
||||
}
|
||||
|
||||
@@ -1329,7 +1329,7 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl
|
||||
Server server = ReadUtil.getServer(opcservcerid);
|
||||
Map<String, Object> itemMap = new HashMap<String, Object>();
|
||||
itemMap.put(to_command2, command);
|
||||
ReadUtil.write(itemMap, server);
|
||||
this.control(itemMap);
|
||||
|
||||
}
|
||||
|
||||
@@ -1337,7 +1337,7 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl
|
||||
String opcservcerid = this.getDevice().getOpc_server_id();
|
||||
Server server = ReadUtil.getServer(opcservcerid);
|
||||
Map<String, Object> itemMap = new HashMap<String, Object>();
|
||||
ReadUtil.write(itemMap, server);
|
||||
this.control(itemMap);
|
||||
}
|
||||
|
||||
public void writing(List list) {
|
||||
@@ -1355,7 +1355,7 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl
|
||||
}
|
||||
}
|
||||
logServer.deviceExecuteLog(device_code, "", "", "下发电气信号:" + itemMap);
|
||||
ReadUtil.write(itemMap, server);
|
||||
this.control(itemMap);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -312,12 +312,12 @@ public class StandardCoveyorControlDeviceDriver extends AbstractOpcDeviceDriver
|
||||
Map<String, Object> itemMap = new HashMap<String, Object>();
|
||||
itemMap.put(to_command, 1);
|
||||
itemMap.put(to_task, instruction_num);
|
||||
ReadUtil.write(itemMap, server);
|
||||
this.control(itemMap);
|
||||
|
||||
}
|
||||
|
||||
public void executing(Server server, Map<String, Object> itemMap) {
|
||||
ReadUtil.write(itemMap, server);
|
||||
this.control(itemMap);
|
||||
}
|
||||
|
||||
public void writing(int command) {
|
||||
@@ -328,7 +328,7 @@ public class StandardCoveyorControlDeviceDriver extends AbstractOpcDeviceDriver
|
||||
Server server = ReadUtil.getServer(opcservcerid);
|
||||
Map<String, Object> itemMap = new HashMap<String, Object>();
|
||||
itemMap.put(to_command, command);
|
||||
ReadUtil.write(itemMap, server);
|
||||
this.control(itemMap);
|
||||
|
||||
}
|
||||
|
||||
@@ -346,7 +346,7 @@ public class StandardCoveyorControlDeviceDriver extends AbstractOpcDeviceDriver
|
||||
itemMap.put(to_command, command);
|
||||
itemMap.put(to_target, target);
|
||||
itemMap.put(to_task, task);
|
||||
ReadUtil.write(itemMap, server);
|
||||
this.control(itemMap);
|
||||
}
|
||||
|
||||
public void writing(int type, int command) {
|
||||
@@ -367,7 +367,7 @@ public class StandardCoveyorControlDeviceDriver extends AbstractOpcDeviceDriver
|
||||
} else if (type == 3) {
|
||||
itemMap.put(to_task, command);
|
||||
}
|
||||
ReadUtil.write(itemMap, server);
|
||||
this.control(itemMap);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -537,12 +537,12 @@ public class StandardCoveyorControlWithPlcScannerDeviceDriver extends AbstractOp
|
||||
Map<String, Object> itemMap = new HashMap<String, Object>();
|
||||
itemMap.put(to_command, 1);
|
||||
itemMap.put(to_task, instruction_num);
|
||||
ReadUtil.write(itemMap, server);
|
||||
this.control(itemMap);
|
||||
|
||||
}
|
||||
|
||||
public void executing(Server server, Map<String, Object> itemMap) {
|
||||
ReadUtil.write(itemMap, server);
|
||||
this.control(itemMap);
|
||||
}
|
||||
|
||||
public void writing() {
|
||||
@@ -559,7 +559,7 @@ public class StandardCoveyorControlWithPlcScannerDeviceDriver extends AbstractOp
|
||||
itemMap.put(to_command, 1);
|
||||
itemMap.put(to_target, deviceAppservice.findDeviceByCode(inst.getNext_device_code()).getAddress());
|
||||
itemMap.put(to_task, inst.getInstruction_code());
|
||||
ReadUtil.write(itemMap, server);
|
||||
this.control(itemMap);
|
||||
}
|
||||
|
||||
public void writing(int command, int target, int task) {
|
||||
@@ -577,7 +577,9 @@ public class StandardCoveyorControlWithPlcScannerDeviceDriver extends AbstractOp
|
||||
itemMap.put(to_target, target);
|
||||
itemMap.put(to_task, task);
|
||||
|
||||
ReadUtil.write(itemMap, server);
|
||||
this.control(itemMap);
|
||||
|
||||
// this.control(itemMap);
|
||||
}
|
||||
|
||||
public void writing(int command) {
|
||||
@@ -587,7 +589,7 @@ public class StandardCoveyorControlWithPlcScannerDeviceDriver extends AbstractOp
|
||||
Server server = ReadUtil.getServer(opcservcerid);
|
||||
Map<String, Object> itemMap = new HashMap<String, Object>();
|
||||
itemMap.put(to_command, command);
|
||||
ReadUtil.write(itemMap, server);
|
||||
this.control(itemMap);
|
||||
}
|
||||
|
||||
public void writing(int type, int command) {
|
||||
@@ -609,7 +611,7 @@ public class StandardCoveyorControlWithPlcScannerDeviceDriver extends AbstractOp
|
||||
itemMap.put(to_task, command);
|
||||
}
|
||||
|
||||
ReadUtil.write(itemMap, server);
|
||||
this.control(itemMap);
|
||||
}
|
||||
|
||||
public boolean instruction_require(String container_code) throws Exception {
|
||||
|
||||
@@ -360,7 +360,7 @@ public class StandardCoveyorControlWithScannerDeviceDriver extends AbstractOpcDe
|
||||
}
|
||||
|
||||
public void executing(Server server, Map<String, Object> itemMap) {
|
||||
ReadUtil.write(itemMap, server);
|
||||
this.control(itemMap);
|
||||
}
|
||||
|
||||
public void writing(int command, int target, int task) {
|
||||
@@ -378,7 +378,7 @@ public class StandardCoveyorControlWithScannerDeviceDriver extends AbstractOpcDe
|
||||
itemMap.put(to_target, target);
|
||||
itemMap.put(to_task, task);
|
||||
|
||||
ReadUtil.write(itemMap, server);
|
||||
this.control(itemMap);
|
||||
}
|
||||
|
||||
public void writing(int command) {
|
||||
@@ -388,7 +388,7 @@ public class StandardCoveyorControlWithScannerDeviceDriver extends AbstractOpcDe
|
||||
Server server = ReadUtil.getServer(opcservcerid);
|
||||
Map<String, Object> itemMap = new HashMap<String, Object>();
|
||||
itemMap.put(to_command, command);
|
||||
ReadUtil.write(itemMap, server);
|
||||
this.control(itemMap);
|
||||
}
|
||||
|
||||
public void writing(int type, int command) {
|
||||
@@ -411,7 +411,7 @@ public class StandardCoveyorControlWithScannerDeviceDriver extends AbstractOpcDe
|
||||
}
|
||||
|
||||
|
||||
ReadUtil.write(itemMap, server);
|
||||
this.control(itemMap);
|
||||
}
|
||||
|
||||
public boolean instruction_require(String container_code) throws Exception {
|
||||
@@ -747,7 +747,7 @@ public class StandardCoveyorControlWithScannerDeviceDriver extends AbstractOpcDe
|
||||
|
||||
itemMap.put(to_param, Integer.parseInt(value));
|
||||
// itemMap.put(to_param, Integer.parseInt(value));
|
||||
ReadUtil.write(itemMap, server);
|
||||
this.control(itemMap);
|
||||
|
||||
}
|
||||
|
||||
@@ -766,7 +766,7 @@ public class StandardCoveyorControlWithScannerDeviceDriver extends AbstractOpcDe
|
||||
}
|
||||
}
|
||||
logServer.deviceExecuteLog(device_code, "", "", "下发电气信号:" + itemMap);
|
||||
ReadUtil.write(itemMap, server);
|
||||
this.control(itemMap);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -348,12 +348,12 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp
|
||||
Map<String, Object> itemMap = new HashMap<String, Object>();
|
||||
itemMap.put(to_command, 1);
|
||||
itemMap.put(to_task, instruction_num);
|
||||
ReadUtil.write(itemMap, server);
|
||||
this.control(itemMap);
|
||||
|
||||
}
|
||||
|
||||
public void executing(Server server, Map<String, Object> itemMap) {
|
||||
ReadUtil.write(itemMap, server);
|
||||
this.control(itemMap);
|
||||
}
|
||||
|
||||
public void writing(int command) {
|
||||
@@ -364,7 +364,7 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp
|
||||
Server server = ReadUtil.getServer(opcservcerid);
|
||||
Map<String, Object> itemMap = new HashMap<String, Object>();
|
||||
itemMap.put(to_command, command);
|
||||
ReadUtil.write(itemMap, server);
|
||||
this.control(itemMap);
|
||||
|
||||
}
|
||||
|
||||
@@ -386,7 +386,7 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp
|
||||
} else if (type == 3) {
|
||||
itemMap.put(to_task, command);
|
||||
}
|
||||
ReadUtil.write(itemMap, server);
|
||||
this.control(itemMap);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,18 +1,113 @@
|
||||
package org.nl.acs.device_driver.driver;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.nl.acs.ext.wms.data.JsonUtl;
|
||||
import org.nl.acs.opc.OpcConfig;
|
||||
import org.nl.acs.opc.OpcServerService;
|
||||
import org.nl.acs.opc.OpcServerServiceImpl;
|
||||
import org.nl.acs.opc.WcsConfig;
|
||||
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 java.util.Date;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
public class AbstractOpcDeviceDriver extends AbstractDeviceDriver implements OpcDeviceDriver {
|
||||
UnifiedDataAccessor opcUdw;
|
||||
UnifiedDataAccessor opcUdw;
|
||||
|
||||
public AbstractOpcDeviceDriver() {
|
||||
this.opcUdw = UnifiedDataAccessorFactory.getAccessor(OpcConfig.udw_opc_value_key);
|
||||
private Date sendTime;
|
||||
private String last_items;
|
||||
private int noLog_sendTimeOut;
|
||||
private Date noLog_sendTime;
|
||||
private String noLog_last_items;
|
||||
|
||||
public AbstractOpcDeviceDriver() {
|
||||
this.opcUdw = UnifiedDataAccessorFactory.getAccessor(OpcConfig.udw_opc_value_key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UnifiedDataAccessor getOpcValueAccessor() {
|
||||
return this.opcUdw;
|
||||
}
|
||||
|
||||
public boolean control(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((String) entry.getValue());
|
||||
i++;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UnifiedDataAccessor getOpcValueAccessor() {
|
||||
return this.opcUdw;
|
||||
return this.control(p2);
|
||||
}
|
||||
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
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("下发 无内容");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
package org.nl.acs.device_driver.driver;
|
||||
|
||||
/**
|
||||
* @author ldjun
|
||||
* @version 1.0
|
||||
* @date 2023年02月01日 11:21
|
||||
* @desc desc
|
||||
*/
|
||||
public class ItemValue {
|
||||
private String item_code;
|
||||
private Object item_value;
|
||||
|
||||
public ItemValue() {
|
||||
}
|
||||
|
||||
public ItemValue(String item_code, Object item_value) {
|
||||
this.item_code = item_code;
|
||||
this.item_value = item_value;
|
||||
}
|
||||
|
||||
public String getItem_code() {
|
||||
return this.item_code;
|
||||
}
|
||||
|
||||
public void setItem_code(String item_code) {
|
||||
this.item_code = item_code;
|
||||
}
|
||||
|
||||
public Object getItem_value() {
|
||||
return this.item_value;
|
||||
}
|
||||
|
||||
public void setItem_value(Object item_value) {
|
||||
this.item_value = item_value;
|
||||
}
|
||||
}
|
||||
@@ -81,4 +81,9 @@ public interface OpcDeviceDriver extends DeviceDriver {
|
||||
return this.getOpcServer() + "." + this.getOpcPlc() + "." + this.getDeviceCode() + "." + item;
|
||||
}
|
||||
|
||||
default Object getUdwValue(String protocol) {
|
||||
return this.getOpcValueAccessor().getValue(protocol);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -19,10 +19,12 @@ public class DeviceOpcProtocolRunable implements Runnable {
|
||||
OpcServerManageDto OpcServer;
|
||||
int error_num;
|
||||
String message;
|
||||
private Server server;
|
||||
|
||||
public DeviceOpcProtocolRunable() {
|
||||
this.error_num = 0;
|
||||
this.message = null;
|
||||
this.server = null;
|
||||
}
|
||||
|
||||
public List<OpcItemDto> getProtocols() {
|
||||
@@ -60,7 +62,7 @@ public class DeviceOpcProtocolRunable implements Runnable {
|
||||
public void run() {
|
||||
while (true) {
|
||||
try {
|
||||
Server server = OpcServerUtl.getServerWithOutException(this.OpcServer.getOpc_host(), this.OpcServer.getCls_id(), this.OpcServer.getUser(), this.OpcServer.getPassword(), this.OpcServer.getDomain());
|
||||
server = OpcServerUtl.getServerWithOutException(this.OpcServer.getOpc_host(), this.OpcServer.getCls_id(), this.OpcServer.getUser(), this.OpcServer.getPassword(), this.OpcServer.getDomain());
|
||||
Group group = server.addGroup();
|
||||
List<String> itemsString = new ArrayList();
|
||||
Iterator it = this.protocols.iterator();
|
||||
@@ -178,6 +180,15 @@ public class DeviceOpcProtocolRunable implements Runnable {
|
||||
}
|
||||
}
|
||||
} catch (Exception var30) {
|
||||
if (this.server != null) {
|
||||
try {
|
||||
this.server.disconnect();
|
||||
} catch (Exception var6) {
|
||||
}
|
||||
|
||||
this.server = null;
|
||||
}
|
||||
|
||||
String error_message = "设备信息同步异常";
|
||||
if (!StrUtil.equals(this.message, error_message)) {
|
||||
log.warn("", var30);
|
||||
|
||||
@@ -17,6 +17,8 @@ import java.util.concurrent.Executors;
|
||||
*/
|
||||
@Component
|
||||
public class DeviceOpcSynchronizeAutoRun extends AbstractAutoRunnable {
|
||||
|
||||
public static boolean isRun = false;
|
||||
ExecutorService executorService = Executors.newCachedThreadPool();
|
||||
@Autowired
|
||||
private DeviceAppService deviceAppService;
|
||||
@@ -36,6 +38,7 @@ public class DeviceOpcSynchronizeAutoRun extends AbstractAutoRunnable {
|
||||
@Override
|
||||
public void autoRun() throws Exception {
|
||||
{
|
||||
isRun = true;
|
||||
|
||||
Map<String, OpcServerManageDto> servers = this.opcServerManageService.queryAllServerMap();
|
||||
Map<String, List<List<OpcItemDto>>> pros;
|
||||
@@ -72,6 +75,7 @@ public class DeviceOpcSynchronizeAutoRun extends AbstractAutoRunnable {
|
||||
|
||||
@Override
|
||||
public void after() {
|
||||
isRun = false;
|
||||
this.executorService.shutdownNow();
|
||||
this.executorService = Executors.newCachedThreadPool();
|
||||
}
|
||||
|
||||
@@ -10,4 +10,7 @@ public class OpcConfig {
|
||||
public static String opc_server_default_group = "group";
|
||||
public static String resource_code = "opc_sync";
|
||||
public static String resource_name = "opc同步";
|
||||
|
||||
//OPC 数据同步是否采用回调机制实现。之前是线程定期全部读,效率低。
|
||||
public static Boolean opc_item_read_using_callback = false;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package org.nl.acs.opc;
|
||||
|
||||
import org.nl.acs.device_driver.driver.ItemValue;
|
||||
import org.openscada.opc.lib.da.Group;
|
||||
|
||||
/**
|
||||
* @author ldjun
|
||||
* @version 1.0
|
||||
* @date 2023年02月01日 11:26
|
||||
* @desc desc
|
||||
*/
|
||||
public interface OpcServerService {
|
||||
|
||||
void reload();
|
||||
|
||||
Group getServer(String var1);
|
||||
|
||||
void writeInteger(String var1, ItemValue... var2);
|
||||
|
||||
void clearServer(String var1);
|
||||
}
|
||||
@@ -0,0 +1,149 @@
|
||||
package org.nl.acs.opc;
|
||||
|
||||
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.wql.exception.WDKException;
|
||||
import org.openscada.opc.lib.common.NotConnectedException;
|
||||
import org.openscada.opc.lib.da.Group;
|
||||
import org.openscada.opc.lib.da.Server;
|
||||
import org.openscada.opc.lib.da.UnknownGroupException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author ldjun
|
||||
* @version 1.0
|
||||
* @date 2023年02月01日 11:27
|
||||
* @desc desc
|
||||
*/
|
||||
@Service
|
||||
public class OpcServerServiceImpl implements OpcServerService, ApplicationAutoInitial {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(OpcServerServiceImpl.class);
|
||||
@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 void autoInitial() throws Exception {
|
||||
this.reload();
|
||||
if (OpcConfig.auto_start_opc) {
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void reload() {
|
||||
this.opcServerManageDtos = this.opcServerManageService.queryAllServerMap();
|
||||
this.opcServerManageDtos = Collections.synchronizedMap(this.opcServerManageDtos);
|
||||
}
|
||||
|
||||
public synchronized Group getServer(String code) {
|
||||
Group group = null;
|
||||
group = (Group) this.groups.get(code);
|
||||
if (group != null) {
|
||||
try {
|
||||
if (group.isActive()) {
|
||||
return group;
|
||||
}
|
||||
} catch (JIException var9) {
|
||||
var9.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
Server server = (Server) this.servers.get(code);
|
||||
boolean needcreate = false;
|
||||
if (server == null) {
|
||||
needcreate = true;
|
||||
} else {
|
||||
try {
|
||||
group = server.findGroup(OpcConfig.opc_server_default_group);
|
||||
} catch (UnknownHostException
|
||||
| JIException
|
||||
| UnknownGroupException
|
||||
| NotConnectedException
|
||||
| IllegalArgumentException var8) {
|
||||
var8.printStackTrace();
|
||||
needcreate = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (needcreate) {
|
||||
OpcServerManageDto dto = (OpcServerManageDto) this.opcServerManageDtos.get(code);
|
||||
if (dto == null) {
|
||||
throw new WDKException("code 不存在");
|
||||
}
|
||||
|
||||
server = OpcServerUtl.getServerWithOutException(
|
||||
dto.getOpc_host(),
|
||||
dto.getCls_id(),
|
||||
dto.getUser(),
|
||||
dto.getPassword(),
|
||||
dto.getDomain());
|
||||
|
||||
// server = OpcServerUtl.getServerWithOutException(this.OpcServer.getOpc_host(), this.OpcServer.getCls_id(), this.OpcServer.getUser(), this.OpcServer.getPassword(), this.OpcServer.getDomain());
|
||||
|
||||
|
||||
try {
|
||||
group = server.addGroup(OpcConfig.opc_server_default_group);
|
||||
} catch (Exception var7) {
|
||||
throw new WDKException(var7);
|
||||
}
|
||||
|
||||
this.servers.put(code, server);
|
||||
this.groups.put(code, group);
|
||||
}
|
||||
|
||||
return group;
|
||||
}
|
||||
|
||||
public synchronized void clearServer(String code) {
|
||||
try {
|
||||
Server server = (Server) this.servers.get(code);
|
||||
server.disconnect();
|
||||
} catch (Exception var3) {
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,12 +4,15 @@ 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.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
@@ -59,10 +62,56 @@ public class OpcUtl {
|
||||
}
|
||||
}
|
||||
|
||||
public static void writeValue(Group group, ItemValue... values) throws WDKException {
|
||||
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 WDKException(var8);
|
||||
}
|
||||
}
|
||||
|
||||
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 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());
|
||||
}
|
||||
@@ -179,6 +228,44 @@ public class OpcUtl {
|
||||
return connection;
|
||||
}
|
||||
|
||||
public static JIVariant getByteArrayVariantxx(int[] bytes) {
|
||||
Integer[] byte_Data = new Integer[bytes.length];
|
||||
|
||||
for(int i = 0; i < bytes.length; ++i) {
|
||||
byte_Data[i] = bytes[i];
|
||||
}
|
||||
|
||||
JIArray array = new JIArray(byte_Data, false);
|
||||
JIVariant value = new JIVariant(array);
|
||||
return value;
|
||||
}
|
||||
|
||||
public static JIVariant getIntegerVariant(Integer integer) {
|
||||
return new JIVariant(integer);
|
||||
}
|
||||
|
||||
public static JIVariant getStringVariant(String string) {
|
||||
return new JIVariant(string);
|
||||
}
|
||||
|
||||
public static JIVariant getByteArrayVariant(byte[] bytes) {
|
||||
Byte[] byte_Data = new Byte[bytes.length];
|
||||
|
||||
for(int i = 0; i < bytes.length; ++i) {
|
||||
byte_Data[i] = bytes[i];
|
||||
}
|
||||
|
||||
JIArray array = new JIArray(byte_Data, false);
|
||||
JIVariant value = new JIVariant(array);
|
||||
return value;
|
||||
}
|
||||
|
||||
public static JIVariant getByteArrayVariant(Byte[] bytes) {
|
||||
JIArray array = new JIArray(bytes, false);
|
||||
JIVariant value = new JIVariant(array);
|
||||
return value;
|
||||
}
|
||||
|
||||
public static String read(String item) throws Exception {
|
||||
System.out.println(item);
|
||||
Server server = getServer("192.168.81.251", "7bc0cc8e-482c-47ca-abdc-0fe7f9c6e729", "administrator", "Huawei@123", "");
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package org.nl.acs.opc;
|
||||
|
||||
/**
|
||||
* @author ldjun
|
||||
* @version 1.0
|
||||
* @date 2023年02月01日 11:28
|
||||
* @desc desc
|
||||
*/
|
||||
public class ThreadUtl {
|
||||
private ThreadUtl() {
|
||||
}
|
||||
|
||||
public static void sleep(long times) throws RuntimeException {
|
||||
try {
|
||||
Thread.sleep(times);
|
||||
} catch (InterruptedException var3) {
|
||||
throw new RuntimeException(var3);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,4 +10,7 @@ public class WcsConfig {
|
||||
//物料默认类型描述
|
||||
public static String task_container_type_default_desc;
|
||||
|
||||
//重复的指令下发超时 ms
|
||||
public static Integer opc_write_repeat_check = 1000;
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user