代码更新
This commit is contained in:
@@ -1,9 +1,9 @@
|
|||||||
package org.nl.acs.device_driver;
|
package org.nl.acs.device_driver;
|
||||||
|
|
||||||
public interface ScannerDeviceDriver extends DeviceDriver {
|
public interface ScannerDeviceDriver extends DeviceDriver {
|
||||||
void writeBarcode(String var1) throws Exception;
|
void writeBarcode(String var1) ;
|
||||||
|
|
||||||
void cleanBarcode() throws Exception;
|
void cleanBarcode() ;
|
||||||
|
|
||||||
String readBarcode() throws Exception;
|
String readBarcode();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ public class CargoLiftConveyorDeviceDriver extends AbstractOpcDeviceDriver imple
|
|||||||
Boolean requireSucess = false;
|
Boolean requireSucess = false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute() throws Exception {
|
public void execute() {
|
||||||
String message = null;
|
String message = null;
|
||||||
|
|
||||||
device_code = this.getDeviceCode();
|
device_code = this.getDeviceCode();
|
||||||
@@ -183,7 +183,7 @@ public class CargoLiftConveyorDeviceDriver extends AbstractOpcDeviceDriver imple
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized boolean instruction_require() throws Exception {
|
public synchronized boolean instruction_require(){
|
||||||
Date date = new Date();
|
Date date = new Date();
|
||||||
if (date.getTime() - this.instruction_require_time.getTime() < (long) this.instruction_require_time_out) {
|
if (date.getTime() - this.instruction_require_time.getTime() < (long) this.instruction_require_time_out) {
|
||||||
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out);
|
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out);
|
||||||
@@ -264,7 +264,13 @@ public class CargoLiftConveyorDeviceDriver extends AbstractOpcDeviceDriver imple
|
|||||||
instdto.setPriority(priority);
|
instdto.setPriority(priority);
|
||||||
instdto.setInstruction_status("0");
|
instdto.setInstruction_status("0");
|
||||||
instdto.setExecute_device_code(start_point_code);
|
instdto.setExecute_device_code(start_point_code);
|
||||||
instructionService.create(instdto);
|
try {
|
||||||
|
instructionService.create(instdto);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
log.error("指令创建失败!",e.getMessage());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
//创建指令后修改任务状态
|
//创建指令后修改任务状态
|
||||||
task.setTask_status("1");
|
task.setTask_status("1");
|
||||||
taskserver.update(task);
|
taskserver.update(task);
|
||||||
|
|||||||
@@ -137,7 +137,7 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute() throws Exception {
|
public void execute() {
|
||||||
try {
|
try {
|
||||||
device_code = this.getDeviceCode();
|
device_code = this.getDeviceCode();
|
||||||
mode = this.itemProtocol.getMode();
|
mode = this.itemProtocol.getMode();
|
||||||
@@ -512,7 +512,7 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme
|
|||||||
/**
|
/**
|
||||||
* 请求指令
|
* 请求指令
|
||||||
*/
|
*/
|
||||||
public synchronized boolean instruction_require() throws Exception {
|
public synchronized boolean instruction_require() {
|
||||||
Date date = new Date();
|
Date date = new Date();
|
||||||
if (date.getTime() - this.instruction_require_time.getTime() < (long) this.instruction_require_time_out) {
|
if (date.getTime() - this.instruction_require_time.getTime() < (long) this.instruction_require_time_out) {
|
||||||
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out);
|
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out);
|
||||||
@@ -632,7 +632,13 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme
|
|||||||
instdto.setPriority(priority);
|
instdto.setPriority(priority);
|
||||||
instdto.setInstruction_status("0");
|
instdto.setInstruction_status("0");
|
||||||
instdto.setExecute_device_code(start_point_code);
|
instdto.setExecute_device_code(start_point_code);
|
||||||
instructionService.create(instdto);
|
try {
|
||||||
|
instructionService.create(instdto);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
log.error("指令创建失败!",e.getMessage());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
//创建指令后修改任务状态
|
//创建指令后修改任务状态
|
||||||
taskdto.setTask_status("1");
|
taskdto.setTask_status("1");
|
||||||
taskserver.update(taskdto);
|
taskserver.update(taskdto);
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -140,7 +140,7 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized void execute() throws Exception {
|
public synchronized void execute(){
|
||||||
String message = null;
|
String message = null;
|
||||||
try {
|
try {
|
||||||
device_code = this.getDeviceCode();
|
device_code = this.getDeviceCode();
|
||||||
|
|||||||
@@ -141,7 +141,7 @@ public class StandardCoveyorControlDeviceDriver extends AbstractOpcDeviceDriver
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute() throws Exception {
|
public void execute() {
|
||||||
String message = null;
|
String message = null;
|
||||||
try {
|
try {
|
||||||
device_code = this.getDeviceCode();
|
device_code = this.getDeviceCode();
|
||||||
@@ -371,7 +371,7 @@ public class StandardCoveyorControlDeviceDriver extends AbstractOpcDeviceDriver
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean instruction_apply() throws Exception {
|
public boolean instruction_apply() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -433,7 +433,7 @@ public class StandardCoveyorControlDeviceDriver extends AbstractOpcDeviceDriver
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized boolean apply_InEmpty() throws Exception {
|
public synchronized boolean apply_InEmpty(){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -148,7 +148,7 @@ public class StandardCoveyorControlWithPlcScannerDeviceDriver extends AbstractOp
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute() throws Exception {
|
public void execute() {
|
||||||
try {
|
try {
|
||||||
device_code = this.getDeviceCode();
|
device_code = this.getDeviceCode();
|
||||||
mode = this.itemProtocol.getMode();
|
mode = this.itemProtocol.getMode();
|
||||||
@@ -614,12 +614,12 @@ public class StandardCoveyorControlWithPlcScannerDeviceDriver extends AbstractOp
|
|||||||
this.control(itemMap);
|
this.control(itemMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean instruction_require(String container_code) throws Exception {
|
public boolean instruction_require(String container_code) {
|
||||||
return instruction_require(container_code, WcsConfig.task_container_type_default_desc);
|
return instruction_require(container_code, WcsConfig.task_container_type_default_desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public synchronized boolean instruction_apply(String container_code) throws Exception {
|
public synchronized boolean instruction_apply(String container_code) {
|
||||||
Date date = new Date();
|
Date date = new Date();
|
||||||
if (date.getTime() - this.instruction_apply_time.getTime() < (long) this.instruction_require_time_out) {
|
if (date.getTime() - this.instruction_apply_time.getTime() < (long) this.instruction_require_time_out) {
|
||||||
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out);
|
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out);
|
||||||
@@ -725,7 +725,7 @@ public class StandardCoveyorControlWithPlcScannerDeviceDriver extends AbstractOp
|
|||||||
* @param container_type
|
* @param container_type
|
||||||
*/
|
*/
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public synchronized boolean instruction_require(String container_code, String container_type) throws Exception {
|
public synchronized boolean instruction_require(String container_code, String container_type) {
|
||||||
Date date = new Date();
|
Date date = new Date();
|
||||||
if (date.getTime() - this.instruction_require_time.getTime() < (long) this.instruction_require_time_out) {
|
if (date.getTime() - this.instruction_require_time.getTime() < (long) this.instruction_require_time_out) {
|
||||||
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out);
|
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out);
|
||||||
|
|||||||
@@ -132,39 +132,48 @@ public class StandardCoveyorControlWithScannerDeviceDriver extends AbstractOpcDe
|
|||||||
return barcode;
|
return barcode;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String barcode() throws Exception {
|
public String barcode() {
|
||||||
ScannerDeviceDriver scanner = this.getScanner();
|
ScannerDeviceDriver scanner = this.getScanner();
|
||||||
return scanner.readBarcode();
|
return scanner.readBarcode();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clearBarcode() throws Exception {
|
public void clearBarcode() {
|
||||||
ScannerDeviceDriver scanner = this.getScanner();
|
ScannerDeviceDriver scanner = this.getScanner();
|
||||||
scanner.cleanBarcode();
|
scanner.cleanBarcode();
|
||||||
logServer.deviceExecuteLog(this.device_code, "", "", "清理条码");
|
logServer.deviceExecuteLog(this.device_code, "", "", "清理条码");
|
||||||
}
|
}
|
||||||
public synchronized boolean finish_instruction() throws Exception {
|
public synchronized boolean finish_instruction(){
|
||||||
instructionService.finish(inst);
|
try {
|
||||||
|
instructionService.finish(inst);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ScannerDeviceDriver getScanner() throws Exception {
|
private ScannerDeviceDriver getScanner() {
|
||||||
String scanner_code = (String) this.getDevice().getExtraValue().get(StandardConveyorWithScannerConfig.relation_scanner);
|
String scanner_code = (String) this.getDevice().getExtraValue().get(StandardConveyorWithScannerConfig.relation_scanner);
|
||||||
if (StrUtil.isEmpty(scanner_code)) {
|
if (StrUtil.isEmpty(scanner_code)) {
|
||||||
throw new Exception("未配置读码器");
|
log.error("未配置读码器");
|
||||||
|
// throw new Exception("未配置读码器");
|
||||||
} else {
|
} else {
|
||||||
Device device = deviceAppservice.findDeviceByCode(scanner_code);
|
Device device = deviceAppservice.findDeviceByCode(scanner_code);
|
||||||
if (device == null) {
|
if (device == null) {
|
||||||
throw new Exception("无设备:" + scanner_code);
|
// throw new Exception("无设备:" + scanner_code);
|
||||||
|
log.error("无设备:" + scanner_code);
|
||||||
} else {
|
} else {
|
||||||
DeviceDriver deviceDriver = device.getDeviceDriver();
|
DeviceDriver deviceDriver = device.getDeviceDriver();
|
||||||
if (!(deviceDriver instanceof ScannerDeviceDriver)) {
|
if (!(deviceDriver instanceof ScannerDeviceDriver)) {
|
||||||
throw new Exception("扫码器类型不对,不是ScannerDeviceDriver");
|
// throw new Exception("扫码器类型不对,不是ScannerDeviceDriver");
|
||||||
|
log.error("扫码器类型不对,不是ScannerDeviceDriver");
|
||||||
} else {
|
} else {
|
||||||
ScannerDeviceDriver driver = (ScannerDeviceDriver) deviceDriver;
|
ScannerDeviceDriver driver = (ScannerDeviceDriver) deviceDriver;
|
||||||
return driver;
|
return driver;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -174,7 +183,7 @@ public class StandardCoveyorControlWithScannerDeviceDriver extends AbstractOpcDe
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute() throws Exception {
|
public void execute(){
|
||||||
String message = null;
|
String message = null;
|
||||||
try {
|
try {
|
||||||
device_code = this.getDeviceCode();
|
device_code = this.getDeviceCode();
|
||||||
@@ -414,11 +423,11 @@ public class StandardCoveyorControlWithScannerDeviceDriver extends AbstractOpcDe
|
|||||||
this.control(itemMap);
|
this.control(itemMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean instruction_require(String container_code) throws Exception {
|
public boolean instruction_require(String container_code) {
|
||||||
return instruction_require(container_code, WcsConfig.task_container_type_default_desc);
|
return instruction_require(container_code, WcsConfig.task_container_type_default_desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized boolean instruction_apply(String container_code) throws Exception {
|
public synchronized boolean instruction_apply(String container_code) {
|
||||||
Date date = new Date();
|
Date date = new Date();
|
||||||
if (date.getTime() - this.instruction_apply_time.getTime() < (long) this.instruction_require_time_out) {
|
if (date.getTime() - this.instruction_apply_time.getTime() < (long) this.instruction_require_time_out) {
|
||||||
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out);
|
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out);
|
||||||
@@ -480,7 +489,7 @@ public class StandardCoveyorControlWithScannerDeviceDriver extends AbstractOpcDe
|
|||||||
* @param container_code
|
* @param container_code
|
||||||
* @param container_type
|
* @param container_type
|
||||||
*/
|
*/
|
||||||
public synchronized boolean instruction_require(String container_code, String container_type) throws Exception {
|
public synchronized boolean instruction_require(String container_code, String container_type) {
|
||||||
Date date = new Date();
|
Date date = new Date();
|
||||||
if (date.getTime() - this.instruction_require_time.getTime() < (long) this.instruction_require_time_out) {
|
if (date.getTime() - this.instruction_require_time.getTime() < (long) this.instruction_require_time_out) {
|
||||||
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out);
|
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out);
|
||||||
@@ -646,7 +655,13 @@ public class StandardCoveyorControlWithScannerDeviceDriver extends AbstractOpcDe
|
|||||||
instdto.setPriority(priority);
|
instdto.setPriority(priority);
|
||||||
instdto.setInstruction_status("0");
|
instdto.setInstruction_status("0");
|
||||||
instdto.setExecute_device_code(start_point_code);
|
instdto.setExecute_device_code(start_point_code);
|
||||||
instructionService.create(instdto);
|
try {
|
||||||
|
instructionService.create(instdto);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
log.error("指令创建失败!",e.getMessage());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
//创建指令后修改任务状态
|
//创建指令后修改任务状态
|
||||||
taskdto.setTask_status("1");
|
taskdto.setTask_status("1");
|
||||||
taskserver.update(taskdto);
|
taskserver.update(taskdto);
|
||||||
|
|||||||
@@ -12,71 +12,71 @@ import org.nl.acs.socket.SocketConfig;
|
|||||||
import org.nl.acs.udw.UnifiedDataAccessor;
|
import org.nl.acs.udw.UnifiedDataAccessor;
|
||||||
import org.nl.acs.udw.UnifiedDataAccessorFactory;
|
import org.nl.acs.udw.UnifiedDataAccessorFactory;
|
||||||
|
|
||||||
/**
|
/** 标准版扫码器 */
|
||||||
* 标准版扫码器
|
|
||||||
*/
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Data
|
@Data
|
||||||
public class StandardScannerDeviceDriver extends AbstractDeviceDriver implements ScannerDeviceDriver, DeviceDriver, DeviceStageMonitor {
|
public class StandardScannerDeviceDriver extends AbstractDeviceDriver
|
||||||
|
implements ScannerDeviceDriver, DeviceDriver, DeviceStageMonitor {
|
||||||
|
|
||||||
UnifiedDataAccessor accessor_value;
|
UnifiedDataAccessor accessor_value;
|
||||||
|
|
||||||
public StandardScannerDeviceDriver() {
|
public StandardScannerDeviceDriver() {
|
||||||
this.accessor_value = UnifiedDataAccessorFactory.getAccessor(SocketConfig.udw_unit_key);
|
this.accessor_value = UnifiedDataAccessorFactory.getAccessor(SocketConfig.udw_unit_key);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getIp() {
|
||||||
|
String ip = (String) this.getDevice().getExtraValue().get("scannerIP");
|
||||||
|
return StrUtil.isEmpty(ip) ? null : ip;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String readBarcode() {
|
||||||
|
String ip = this.getIp();
|
||||||
|
if (StrUtil.isEmpty(ip)) {
|
||||||
|
// throw new Exception("ip未配置");
|
||||||
|
log.error("ip未配置");
|
||||||
|
} else {
|
||||||
|
String result = (String) this.accessor_value.getValue(this.getIp());
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public String getIp() {
|
@Override
|
||||||
String ip = (String) this.getDevice().getExtraValue().get("scannerIP");
|
public void writeBarcode(String barcode) {
|
||||||
return StrUtil.isEmpty(ip) ? null : ip;
|
String ip = this.getIp();
|
||||||
|
if (StrUtil.isEmpty(ip)) {
|
||||||
|
// throw new Exception("ip未配置");
|
||||||
|
log.error("ip未配置");
|
||||||
|
} else {
|
||||||
|
this.accessor_value.setValueWithPersistence(this.getIp(), barcode);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String readBarcode() throws Exception {
|
public void cleanBarcode() {
|
||||||
String ip = this.getIp();
|
String ip = this.getIp();
|
||||||
if (StrUtil.isEmpty(ip)) {
|
if (StrUtil.isEmpty(ip)) {
|
||||||
throw new Exception("ip未配置");
|
log.error("ip未配置");
|
||||||
} else {
|
// throw new Exception("ip未配置");
|
||||||
String result = (String) this.accessor_value.getValue(this.getIp());
|
} else {
|
||||||
return result;
|
this.accessor_value.setValueWithPersistence(this.getIp(), (Object) null);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeBarcode(String barcode) throws Exception {
|
public JSONObject getDeviceStatusName() throws Exception {
|
||||||
String ip = this.getIp();
|
JSONObject jo = new JSONObject();
|
||||||
if (StrUtil.isEmpty(ip)) {
|
jo.put("device_name", this.getDevice().getDevice_name());
|
||||||
throw new Exception("ip未配置");
|
jo.put("isOnline", true);
|
||||||
} else {
|
jo.put("device_type", device.getDevice_type());
|
||||||
this.accessor_value.setValueWithPersistence(this.getIp(), barcode);
|
// 点击弹出
|
||||||
}
|
jo.put("is_click", true);
|
||||||
}
|
jo.put("ip", this.getIp());
|
||||||
|
jo.put("container", StrUtil.isEmpty(this.readBarcode()) ? "" : this.readBarcode());
|
||||||
|
return jo;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void cleanBarcode() throws Exception {
|
public void setDeviceStatus(JSONObject data) {}
|
||||||
String ip = this.getIp();
|
|
||||||
if (StrUtil.isEmpty(ip)) {
|
|
||||||
throw new Exception("ip未配置");
|
|
||||||
} else {
|
|
||||||
this.accessor_value.setValueWithPersistence(this.getIp(), (Object) null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public JSONObject getDeviceStatusName() throws Exception {
|
|
||||||
JSONObject jo = new JSONObject();
|
|
||||||
jo.put("device_name", this.getDevice().getDevice_name());
|
|
||||||
jo.put("isOnline", true);
|
|
||||||
jo.put("device_type", device.getDevice_type());
|
|
||||||
//点击弹出
|
|
||||||
jo.put("is_click", true);
|
|
||||||
jo.put("ip", this.getIp());
|
|
||||||
jo.put("container", StrUtil.isEmpty(this.readBarcode()) ? "" : this.readBarcode());
|
|
||||||
return jo;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setDeviceStatus(JSONObject data) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,14 +1,11 @@
|
|||||||
package org.nl.acs.device_driver.driver;
|
package org.nl.acs.device_driver.driver;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
|
||||||
import org.nl.acs.ext.wms.data.JsonUtl;
|
import org.nl.acs.ext.wms.data.JsonUtl;
|
||||||
import org.nl.acs.opc.OpcConfig;
|
import org.nl.acs.opc.OpcConfig;
|
||||||
import org.nl.acs.opc.OpcServerService;
|
import org.nl.acs.opc.OpcServerService;
|
||||||
import org.nl.acs.opc.OpcServerServiceImpl;
|
import org.nl.acs.opc.OpcServerServiceImpl;
|
||||||
import org.nl.acs.opc.WcsConfig;
|
|
||||||
import org.nl.acs.udw.UnifiedDataAccessor;
|
import org.nl.acs.udw.UnifiedDataAccessor;
|
||||||
import org.nl.acs.udw.UnifiedDataAccessorFactory;
|
import org.nl.acs.udw.UnifiedDataAccessorFactory;
|
||||||
import org.nl.acs.udw.UnifiedDataAppService;
|
|
||||||
import org.nl.modules.wql.exception.WDKException;
|
import org.nl.modules.wql.exception.WDKException;
|
||||||
import org.nl.modules.wql.util.SpringContextHolder;
|
import org.nl.modules.wql.util.SpringContextHolder;
|
||||||
|
|
||||||
@@ -40,21 +37,19 @@ public class AbstractOpcDeviceDriver extends AbstractDeviceDriver implements Opc
|
|||||||
|
|
||||||
ItemValue p2[];
|
ItemValue p2[];
|
||||||
p2 = new ItemValue[itemValues.size()];
|
p2 = new ItemValue[itemValues.size()];
|
||||||
int i=0;
|
int i = 0;
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
Map.Entry<String, Object> entry = it.next();
|
Map.Entry<String, Object> entry = it.next();
|
||||||
System.out.println(entry.getKey() + ":" + entry.getValue());
|
System.out.println(entry.getKey() + ":" + entry.getValue());
|
||||||
p2[i] = new ItemValue();
|
p2[i] = new ItemValue();
|
||||||
p2[i].setItem_code(entry.getKey());
|
p2[i].setItem_code(entry.getKey());
|
||||||
p2[i].setItem_value((String) entry.getValue());
|
p2[i].setItem_value( entry.getValue());
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.control(p2);
|
return this.control(p2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public boolean control(ItemValue[] itemValues) {
|
public boolean control(ItemValue[] itemValues) {
|
||||||
if (itemValues != null && itemValues.length != 0) {
|
if (itemValues != null && itemValues.length != 0) {
|
||||||
String this_items = JsonUtl.parseWithoutException(itemValues);
|
String this_items = JsonUtl.parseWithoutException(itemValues);
|
||||||
@@ -72,9 +67,9 @@ public class AbstractOpcDeviceDriver extends AbstractDeviceDriver implements Opc
|
|||||||
sb.append(":");
|
sb.append(":");
|
||||||
sb.append(JsonUtl.parseWithoutException(udw_value));
|
sb.append(JsonUtl.parseWithoutException(udw_value));
|
||||||
sb.append(";");
|
sb.append(";");
|
||||||
// if (!need_write && !UnifiedDataAppService.isEquals(udw_value, write_value)) {
|
// if (!need_write && !UnifiedDataAppService.isEquals(udw_value, write_value)) {
|
||||||
// need_write = true;
|
// need_write = true;
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
need_write = true;
|
need_write = true;
|
||||||
|
|
||||||
|
|||||||
@@ -1,17 +1,18 @@
|
|||||||
package org.nl.acs.device_driver.driver;
|
package org.nl.acs.device_driver.driver;
|
||||||
|
|
||||||
|
import com.esotericsoftware.minlog.Log;
|
||||||
import org.nl.acs.device_driver.DeviceDriver;
|
import org.nl.acs.device_driver.DeviceDriver;
|
||||||
|
|
||||||
public interface ExecutableDeviceDriver extends DeviceDriver {
|
public interface ExecutableDeviceDriver extends DeviceDriver {
|
||||||
default void executeAuto() {
|
default void executeAuto() {
|
||||||
try {
|
try {
|
||||||
this.execute();
|
this.execute();
|
||||||
} catch (Throwable var6) {
|
} catch (Throwable var6) {
|
||||||
String message = "线程调用异常:" + var6.getMessage();
|
String message = "线程调用异常:" + var6.getMessage();
|
||||||
} finally {
|
Log.error(message);
|
||||||
}
|
} finally {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void execute() throws Exception;
|
void execute();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ public interface InstructionService {
|
|||||||
* @param dto
|
* @param dto
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
void createAgain(Instruction dto) throws Exception;
|
void createAgain(Instruction dto) throws Exception ;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 编辑
|
* 编辑
|
||||||
|
|||||||
@@ -637,7 +637,7 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void finish(String id) throws Exception {
|
public void finish(String id) {
|
||||||
Instruction entity = this.findById(id);
|
Instruction entity = this.findById(id);
|
||||||
//if (entity == null) throw new BadRequestException("被删除或无权限,操作失败!");
|
//if (entity == null) throw new BadRequestException("被删除或无权限,操作失败!");
|
||||||
String currentUsername = SecurityUtils.getCurrentUsername();
|
String currentUsername = SecurityUtils.getCurrentUsername();
|
||||||
@@ -718,7 +718,7 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void finish(Instruction dto) throws Exception {
|
public void finish(Instruction dto) {
|
||||||
String now = DateUtil.now();
|
String now = DateUtil.now();
|
||||||
dto.setInstruction_status("2");
|
dto.setInstruction_status("2");
|
||||||
WQLObject wo = WQLObject.getWQLObject("acs_instruction");
|
WQLObject wo = WQLObject.getWQLObject("acs_instruction");
|
||||||
@@ -773,7 +773,7 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void finishAndCreateNextInst(Instruction dto) throws Exception {
|
public void finishAndCreateNextInst(Instruction dto){
|
||||||
dto = foramte(dto);
|
dto = foramte(dto);
|
||||||
String device_code = dto.getNext_device_code();
|
String device_code = dto.getNext_device_code();
|
||||||
WQLObject taskwo = WQLObject.getWQLObject("acs_task");
|
WQLObject taskwo = WQLObject.getWQLObject("acs_task");
|
||||||
@@ -829,7 +829,12 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
|||||||
instdto.setPriority(acsTask.getPriority());
|
instdto.setPriority(acsTask.getPriority());
|
||||||
instdto.setInstruction_status("0");
|
instdto.setInstruction_status("0");
|
||||||
instdto.setExecute_device_code(dto.getNext_device_code());
|
instdto.setExecute_device_code(dto.getNext_device_code());
|
||||||
this.create(instdto);
|
try {
|
||||||
|
this.create(instdto);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
log.error("完成并创建下一条指令",e.getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -128,7 +128,9 @@ public class OpcServerServiceImpl implements OpcServerService, ApplicationAutoIn
|
|||||||
try {
|
try {
|
||||||
Server server = (Server) this.servers.get(code);
|
Server server = (Server) this.servers.get(code);
|
||||||
server.disconnect();
|
server.disconnect();
|
||||||
} catch (Exception var3) {
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
log.error("清理server异常,",e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
this.servers.remove(code);
|
this.servers.remove(code);
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ public class OpcUtl {
|
|||||||
|
|
||||||
public static void writeValue(Group group, WriteRequest... requests) throws WDKException {
|
public static void writeValue(Group group, WriteRequest... requests) throws WDKException {
|
||||||
try {
|
try {
|
||||||
Map e = group.write(requests);
|
Map<Item, Integer> e = group.write(requests);
|
||||||
boolean is_success = true;
|
boolean is_success = true;
|
||||||
StringBuilder message = new StringBuilder();
|
StringBuilder message = new StringBuilder();
|
||||||
Iterator arg4 = e.keySet().iterator();
|
Iterator arg4 = e.keySet().iterator();
|
||||||
@@ -59,6 +59,7 @@ public class OpcUtl {
|
|||||||
// group.write(requests);
|
// group.write(requests);
|
||||||
}
|
}
|
||||||
} catch (JIException arg7) {
|
} catch (JIException arg7) {
|
||||||
|
log.info("下发信号失败:"+arg7.getMessage());
|
||||||
throw new WDKException(arg7);
|
throw new WDKException(arg7);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user