fix:写入修改
This commit is contained in:
@@ -9,6 +9,7 @@ import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.Data;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jinterop.dcom.common.JIException;
|
||||
import org.nl.acs.device.service.DeviceService;
|
||||
import org.nl.acs.device_driver.DeviceDriver;
|
||||
import org.nl.acs.device_driver.RouteableDeviceDriver;
|
||||
@@ -19,6 +20,7 @@ import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver;
|
||||
import org.nl.acs.device_driver.driver.ExecutableDeviceDriver;
|
||||
import org.nl.acs.ext.wms.data.ApplyManipulatorActionRequest;
|
||||
import org.nl.acs.ext.wms.data.ApplyManipulatorActionResponse;
|
||||
import org.nl.acs.ext.wms.data.JsonUtl;
|
||||
import org.nl.acs.ext.wms.service.AcsToWmsService;
|
||||
import org.nl.acs.history.ErrorUtil;
|
||||
import org.nl.acs.history.service.DeviceErrorLogService;
|
||||
@@ -28,9 +30,7 @@ import org.nl.acs.instruction.service.InstructionService;
|
||||
import org.nl.acs.instruction.service.dto.Instruction;
|
||||
import org.nl.acs.log.service.DeviceExecuteLogService;
|
||||
import org.nl.acs.monitor.DeviceStageMonitor;
|
||||
import org.nl.acs.opc.Device;
|
||||
import org.nl.acs.opc.DeviceAppService;
|
||||
import org.nl.acs.opc.DeviceAppServiceImpl;
|
||||
import org.nl.acs.opc.*;
|
||||
import org.nl.acs.route.service.RouteLineService;
|
||||
import org.nl.acs.task.service.TaskService;
|
||||
import org.nl.acs.task.service.dto.TaskDto;
|
||||
@@ -38,7 +38,12 @@ import org.nl.modules.common.exception.BadRequestException;
|
||||
import org.nl.modules.system.service.ParamService;
|
||||
import org.nl.modules.system.service.impl.ParamServiceImpl;
|
||||
import org.nl.modules.wql.core.bean.WQLObject;
|
||||
import org.nl.modules.wql.exception.WDKException;
|
||||
import org.nl.modules.wql.util.SpringContextHolder;
|
||||
import org.openscada.opc.lib.da.AddFailedException;
|
||||
import org.openscada.opc.lib.da.Group;
|
||||
import org.openscada.opc.lib.da.Item;
|
||||
import org.openscada.opc.lib.da.ItemState;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.util.*;
|
||||
@@ -54,6 +59,8 @@ public class IndoorManipulatorDeviceDriver extends AbstractOpcDeviceDriver imple
|
||||
protected org.nl.acs.device_driver.basedriver.indoor_manipulator.ItemProtocol itemProtocol = new ItemProtocol(this);
|
||||
@Autowired
|
||||
InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl");
|
||||
private OpcServerService opcServerService = SpringContextHolder.getBean(OpcServerService .class);
|
||||
|
||||
@Autowired
|
||||
DeviceService deviceservice = SpringContextHolder.getBean("deviceServiceImpl");
|
||||
@Autowired
|
||||
@@ -391,7 +398,11 @@ public class IndoorManipulatorDeviceDriver extends AbstractOpcDeviceDriver imple
|
||||
}
|
||||
});
|
||||
if (ObjectUtil.isNotEmpty(itemMap)) {
|
||||
this.control(itemMap);
|
||||
try {
|
||||
this.checkcontrol(itemMap);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
logServer.deviceExecuteLog(this.getDevice().getDevice_code(), "", "", "下发多个电气信号:" + itemMap);
|
||||
}
|
||||
}
|
||||
@@ -436,8 +447,8 @@ public class IndoorManipulatorDeviceDriver extends AbstractOpcDeviceDriver imple
|
||||
applyManipulatorActionResponse = acsToWmsService.applyManipulatorActionRequest(applyManipulatorActionRequest);
|
||||
if (applyManipulatorActionResponse.getstatus() == 200) {
|
||||
feedbackSucess = true;
|
||||
message = "反馈LMS成功...";
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "反馈完成请求成功,响应参数:" + JSON.toJSONString(applyManipulatorActionResponse));
|
||||
message = "反馈尺寸LMS成功...";
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "反馈尺寸成请求成功,响应参数:" + JSON.toJSONString(applyManipulatorActionResponse));
|
||||
String is_bushing = task.getIs_bushing();
|
||||
String version = task.getVersion();
|
||||
String bushing_num = task.getBushing_num();
|
||||
@@ -450,7 +461,7 @@ public class IndoorManipulatorDeviceDriver extends AbstractOpcDeviceDriver imple
|
||||
} else {
|
||||
feedbackSucess = false;
|
||||
message = "完成反馈LMS失败," + String.valueOf(applyManipulatorActionResponse);
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "反馈完成请求失败,响应参数:" + JSON.toJSONString(applyManipulatorActionResponse));
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "反馈尺寸成请求失败,响应参数:" + JSON.toJSONString(applyManipulatorActionResponse));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -460,14 +471,22 @@ public class IndoorManipulatorDeviceDriver extends AbstractOpcDeviceDriver imple
|
||||
applyManipulatorActionRequest.setType("3");
|
||||
applyManipulatorActionRequest.setTask_code1(task_code);
|
||||
applyManipulatorActionResponse = acsToWmsService.applyManipulatorActionRequest(applyManipulatorActionRequest);
|
||||
String put_device_code = applyManipulatorActionResponse.getPut_device_code();
|
||||
Device device = deviceAppService.findDeviceByCode(put_device_code);
|
||||
String to_putpoint = device.getExtraValue().get("address").toString();
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
map.put("to_command", 3);
|
||||
map.put("to_putpoint", Integer.parseInt(to_putpoint));
|
||||
this.writing(map);
|
||||
feedbackSucess = true;
|
||||
if (applyManipulatorActionResponse.getstatus()==200) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "申请放货点请求成功,响应参数:" + JSON.toJSONString(applyManipulatorActionResponse));
|
||||
String put_device_code = applyManipulatorActionResponse.getPut_device_code();
|
||||
Device device = deviceAppService.findDeviceByCode(put_device_code);
|
||||
String to_putpoint = device.getExtraValue().get("address").toString();
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
map.put("to_command", 3);
|
||||
map.put("to_putpoint", Integer.parseInt(to_putpoint));
|
||||
this.writing(map);
|
||||
feedbackSucess = true;
|
||||
message = "申请新取货点成功";
|
||||
} else {
|
||||
feedbackSucess = false;
|
||||
message = "申请放货点LMS失败," + String.valueOf(applyManipulatorActionResponse);
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "反馈尺寸成请求失败,响应参数:" + JSON.toJSONString(applyManipulatorActionResponse));
|
||||
}
|
||||
}
|
||||
|
||||
//申请新取货点
|
||||
@@ -489,8 +508,8 @@ public class IndoorManipulatorDeviceDriver extends AbstractOpcDeviceDriver imple
|
||||
message = "申请新取货点成功";
|
||||
} else {
|
||||
feedbackSucess = false;
|
||||
message = "申请失败";
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "申请失败,返回参数:" + applyManipulatorActionResponse);
|
||||
message = "申请新取货点失败";
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "申请新取货点,返回参数:" + applyManipulatorActionResponse);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -509,12 +528,12 @@ public class IndoorManipulatorDeviceDriver extends AbstractOpcDeviceDriver imple
|
||||
map.put("to_two_putpoint", Integer.parseInt(to_two_putpoint));
|
||||
this.writing(map);
|
||||
feedbackSucess = true;
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "申请二次放货点,返回参数:" + applyManipulatorActionResponse);
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "申请二次放货点成功,返回参数:" + applyManipulatorActionResponse);
|
||||
message = "申请二次放货点成功";
|
||||
} else {
|
||||
feedbackSucess = false;
|
||||
message = "申请失败";
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "申请失败,返回参数:" + applyManipulatorActionResponse);
|
||||
message = "申请二次放货点失败";
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "申请二次放货点,返回参数:" + applyManipulatorActionResponse);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -523,11 +542,19 @@ public class IndoorManipulatorDeviceDriver extends AbstractOpcDeviceDriver imple
|
||||
String task_code = inst1.getTask_code();
|
||||
applyManipulatorActionRequest.setAction("1");
|
||||
applyManipulatorActionRequest.setTask_code1(task_code);
|
||||
acsToWmsService.actionFinishRequest(applyManipulatorActionRequest);
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
map.put("to_command", 6);
|
||||
this.writing(map);
|
||||
feedbackSucess = true;
|
||||
ApplyManipulatorActionResponse applyManipulatorActionResponse1 = acsToWmsService.actionFinishRequest(applyManipulatorActionRequest);
|
||||
if (applyManipulatorActionResponse1.getstatus() == 200) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "缓存库取货请求成功,响应参数:" + JSON.toJSONString(applyManipulatorActionResponse1));
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
map.put("to_command", 6);
|
||||
this.writing(map);
|
||||
message = "缓存库取货完成";
|
||||
feedbackSucess = true;
|
||||
}else {
|
||||
feedbackSucess = false;
|
||||
message = "缓存库取货失败";
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "缓存库取货失败,返回参数:" + applyManipulatorActionResponse1);
|
||||
}
|
||||
}
|
||||
|
||||
//缓存库放货完成
|
||||
@@ -535,11 +562,20 @@ public class IndoorManipulatorDeviceDriver extends AbstractOpcDeviceDriver imple
|
||||
String task_code = inst1.getTask_code();
|
||||
applyManipulatorActionRequest.setAction("2");
|
||||
applyManipulatorActionRequest.setTask_code1(task_code);
|
||||
acsToWmsService.actionFinishRequest(applyManipulatorActionRequest);
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
map.put("to_command", 7);
|
||||
this.writing(map);
|
||||
feedbackSucess = true;
|
||||
ApplyManipulatorActionResponse applyManipulatorActionResponse1 = acsToWmsService.actionFinishRequest(applyManipulatorActionRequest);
|
||||
if (applyManipulatorActionResponse1.getstatus() == 200) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "缓存库放货完成,响应参数:" + JSON.toJSONString(applyManipulatorActionResponse1));
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
map.put("to_command", 7);
|
||||
this.writing(map);
|
||||
feedbackSucess = true;
|
||||
message = "缓存库放货成功";
|
||||
}else {
|
||||
feedbackSucess = false;
|
||||
message = "缓存库放货失败";
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "缓存库放货完成,返回参数:" + applyManipulatorActionResponse1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -552,7 +588,9 @@ public class IndoorManipulatorDeviceDriver extends AbstractOpcDeviceDriver imple
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
map.put("to_command", 8);
|
||||
this.writing(map);
|
||||
message = "放货完成";
|
||||
} catch (Exception e) {
|
||||
message = "放货失败";
|
||||
e.printStackTrace();
|
||||
}
|
||||
feedMessage = "";
|
||||
@@ -574,11 +612,11 @@ public class IndoorManipulatorDeviceDriver extends AbstractOpcDeviceDriver imple
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
} else {
|
||||
}else {
|
||||
feedMessage = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public Instruction checkInst() {
|
||||
if (ObjectUtil.isNotEmpty(this.inst)) {
|
||||
@@ -710,6 +748,95 @@ public class IndoorManipulatorDeviceDriver extends AbstractOpcDeviceDriver imple
|
||||
}
|
||||
}
|
||||
|
||||
public void checkcontrol(Map<String, Object> itemValues) throws JIException, AddFailedException {
|
||||
Group group = opcServerService.getServer(this.getOpcServer());
|
||||
Map<String, Object> write = new HashMap();
|
||||
Map<String, Item> readitems = new LinkedHashMap();
|
||||
List<String> itemsString = new ArrayList();
|
||||
itemsString = new ArrayList<> (itemValues.keySet());
|
||||
Iterator is = itemsString.iterator();
|
||||
|
||||
while (is.hasNext()) {
|
||||
String string = (String) is.next();
|
||||
try {
|
||||
readitems.put(string, group.addItem(string));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
int i = 0;
|
||||
while(true) {
|
||||
//下发信号
|
||||
try{
|
||||
if(i == 0){
|
||||
control( itemValues);
|
||||
} else {
|
||||
controlByNewConn( itemValues);
|
||||
}
|
||||
|
||||
} catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
Map<String, Object> read = new HashMap();
|
||||
Map<Item, ItemState> itemStatus = null;
|
||||
boolean check = true;
|
||||
try{
|
||||
if(i>0){
|
||||
group = opcServerService.getServer(this.getOpcServer());
|
||||
itemsString = new ArrayList<> (itemValues.keySet());
|
||||
Iterator nis = itemsString.iterator();
|
||||
|
||||
while (nis.hasNext()) {
|
||||
String string = (String) nis.next();
|
||||
try {
|
||||
readitems.put(string, group.addItem(string));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
itemStatus = group.read(true, (Item[])readitems.values().toArray(new Item[0]));
|
||||
|
||||
} else {
|
||||
itemStatus = group.read(true, (Item[])readitems.values().toArray(new Item[0]));
|
||||
}
|
||||
Set<Item> items = itemStatus.keySet();
|
||||
Iterator var15 = items.iterator();
|
||||
while(var15.hasNext()) {
|
||||
Item item = (Item)var15.next();
|
||||
ItemState itemState = (ItemState)itemStatus.get(item);
|
||||
Object value = OpcUtl.getValue(item, itemState);
|
||||
read.put(item.getId(), value);
|
||||
}
|
||||
|
||||
Iterator var24 = itemsString.iterator();
|
||||
|
||||
while(var24.hasNext()) {
|
||||
String itemString = (String)var24.next();
|
||||
if (!ObjectUtl.isEquals(itemValues.get(itemString), JsonUtl.parse(read.get(itemString)))) {
|
||||
check = false;
|
||||
}
|
||||
}
|
||||
} catch (Exception e){
|
||||
e.printStackTrace();
|
||||
check = false;
|
||||
}
|
||||
|
||||
if (check) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (i > 0) {
|
||||
ThreadUtl.sleep(300L);
|
||||
}
|
||||
|
||||
if (i > 3) {
|
||||
log.info("写入次数超过3次而失败");
|
||||
throw new WDKException("写入次数超过3次而失败");
|
||||
}
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
public void writing(String param, String value) {
|
||||
|
||||
String to_param = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
|
||||
|
||||
@@ -463,7 +463,7 @@ public class PaperTubeConveyor2DeviceDriver extends AbstractOpcDeviceDriver impl
|
||||
}
|
||||
});
|
||||
if (ObjectUtil.isNotEmpty(itemMap)) {
|
||||
this.control(itemMap);
|
||||
this.checkcontrol(itemMap);
|
||||
logServer.deviceExecuteLog(this.getDevice().getDevice_code(), "", "", "下发多个电气信号:" + itemMap);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.Data;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jinterop.dcom.common.JIException;
|
||||
import org.nl.acs.device.service.DeviceService;
|
||||
import org.nl.acs.device_driver.DeviceDriver;
|
||||
import org.nl.acs.device_driver.RouteableDeviceDriver;
|
||||
@@ -29,6 +30,7 @@ import org.nl.acs.task.service.TaskService;
|
||||
import org.nl.modules.system.service.ParamService;
|
||||
import org.nl.modules.system.service.impl.ParamServiceImpl;
|
||||
import org.nl.modules.wql.util.SpringContextHolder;
|
||||
import org.openscada.opc.lib.da.AddFailedException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.util.*;
|
||||
@@ -146,11 +148,11 @@ public class PluggingUnpluggingMachineDeviceDriver extends AbstractOpcDeviceDriv
|
||||
// bushingSucess();
|
||||
// }
|
||||
// break;
|
||||
// case 6:
|
||||
// if (task1 > 0 && !requireSucess) {
|
||||
// pullingSucess();
|
||||
// }
|
||||
// break;
|
||||
case 6:
|
||||
if (task1 > 0 && !requireSucess) {
|
||||
pullingSucess();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
@@ -165,6 +167,7 @@ public class PluggingUnpluggingMachineDeviceDriver extends AbstractOpcDeviceDriv
|
||||
}
|
||||
|
||||
private synchronized void pullingSucess() {
|
||||
List list = new ArrayList();
|
||||
ApplyManipulatorActionRequest applyManipulatorActionRequest = new ApplyManipulatorActionRequest();
|
||||
ApplyManipulatorActionResponse applyManipulatorActionResponse;
|
||||
Instruction inst1 = instructionService.findByCode(String.valueOf(task1));
|
||||
@@ -177,7 +180,7 @@ public class PluggingUnpluggingMachineDeviceDriver extends AbstractOpcDeviceDriv
|
||||
map.put("to_command", 6);
|
||||
this.writing(map);
|
||||
requireSucess = true;
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "申请拔轴,返回参数:" + applyManipulatorActionResponse);
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "拔轴完成反馈,返回参数:" + applyManipulatorActionResponse);
|
||||
message = "拔轴完成成功";
|
||||
}else{
|
||||
message = applyManipulatorActionResponse.getMessage();
|
||||
@@ -185,12 +188,13 @@ public class PluggingUnpluggingMachineDeviceDriver extends AbstractOpcDeviceDriv
|
||||
map.put("to_command", 99);
|
||||
requireSucess = true;
|
||||
message = "拔轴失败";
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "申请拔轴,返回参数:" + applyManipulatorActionResponse);
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "拔轴完成反馈,返回参数:" + applyManipulatorActionResponse);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private synchronized void bushingSucess() {
|
||||
List list = new ArrayList();
|
||||
ApplyManipulatorActionRequest applyManipulatorActionRequest = new ApplyManipulatorActionRequest();
|
||||
ApplyManipulatorActionResponse applyManipulatorActionResponse;
|
||||
Instruction inst1 = instructionService.findByCode(String.valueOf(task1));
|
||||
@@ -221,6 +225,7 @@ public class PluggingUnpluggingMachineDeviceDriver extends AbstractOpcDeviceDriv
|
||||
}
|
||||
|
||||
private synchronized void applyBushing() {
|
||||
List list = new ArrayList();
|
||||
ApplyManipulatorActionRequest applyManipulatorActionRequest = new ApplyManipulatorActionRequest();
|
||||
ApplyManipulatorActionResponse applyManipulatorActionResponse;
|
||||
Instruction inst1 = instructionService.findByCode(String.valueOf(task1));
|
||||
@@ -273,7 +278,7 @@ public class PluggingUnpluggingMachineDeviceDriver extends AbstractOpcDeviceDriv
|
||||
*
|
||||
* @param map
|
||||
*/
|
||||
public void writing(Map<String, Object> map) {
|
||||
public void writing(Map<String, Object> map) {
|
||||
DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl");
|
||||
Map<String, Object> itemMap = new LinkedHashMap<>();
|
||||
map.forEach((key, value) -> {
|
||||
@@ -282,7 +287,11 @@ public class PluggingUnpluggingMachineDeviceDriver extends AbstractOpcDeviceDriv
|
||||
}
|
||||
});
|
||||
if (ObjectUtil.isNotEmpty(itemMap)) {
|
||||
this.control(itemMap);
|
||||
try {
|
||||
this.checkcontrol(itemMap);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
logServer.deviceExecuteLog(this.getDevice().getDevice_code(), "", "", "下发多个电气信号:" + itemMap);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user