Browse Source

rev:修改

master
刘先源 2 weeks ago
parent
commit
77097cbda3
  1. 4
      acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/auto/run/OneNDCSocketConnectionAutoRun.java
  2. 67
      acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/autodoor/standard_autodoor/StandardAutodoorDeviceDriver.java

4
acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/auto/run/OneNDCSocketConnectionAutoRun.java

@ -233,7 +233,7 @@ public class OneNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
log.error("agv车号为"+carno+",进入自动门区域:"+"自动门:"+device_code+"未联机,无法开门。"); log.error("agv车号为"+carno+",进入自动门区域:"+"自动门:"+device_code+"未联机,无法开门。");
} }
if (flag) { if (flag) {
driver.writing(ItemProtocol.item_to_command,1); driver.writing(ItemProtocol.item_to_command,"1");
driver.setMessage(""); driver.setMessage("");
log.info("agv车号为"+carno+",进入自动门区域"+"自动门:"+device_code+"已联机,允许开门。"); log.info("agv车号为"+carno+",进入自动门区域"+"自动门:"+device_code+"已联机,允许开门。");
logServer.deviceExecuteLog(device_code, "", "", "允许开门。"); logServer.deviceExecuteLog(device_code, "", "", "允许开门。");
@ -277,7 +277,7 @@ public class OneNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
} }
log.info("自动门:"+device_code+"关门的action的值此时为:"+driver.getAction()+"该值应为0"); log.info("自动门:"+device_code+"关门的action的值此时为:"+driver.getAction()+"该值应为0");
if (flag) { if (flag) {
driver.writing(ItemProtocol.item_to_command,2); driver.writing(ItemProtocol.item_to_command,"2");
driver.setMessage(""); driver.setMessage("");
log.info("自动门:"+device_code+"工作模式正常,"+"agv车号为"+carno+",写入关门信号2,准备离开自动门。"); log.info("自动门:"+device_code+"工作模式正常,"+"agv车号为"+carno+",写入关门信号2,准备离开自动门。");
logServer.deviceExecuteLog(device_code, "", "", "允许关门。"); logServer.deviceExecuteLog(device_code, "", "", "允许关门。");

67
acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/autodoor/standard_autodoor/StandardAutodoorDeviceDriver.java

@ -1,5 +1,6 @@
package org.nl.acs.device_driver.autodoor.standard_autodoor; package org.nl.acs.device_driver.autodoor.standard_autodoor;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import lombok.Data; import lombok.Data;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
@ -13,14 +14,18 @@ import org.nl.acs.device_driver.driver.ExecutableDeviceDriver;
import org.nl.acs.ext.wms.data.one.feedBackTaskStatus.FeedBackTaskStatusRequest; import org.nl.acs.ext.wms.data.one.feedBackTaskStatus.FeedBackTaskStatusRequest;
import org.nl.acs.ext.wms.service.AcsToWmsService; import org.nl.acs.ext.wms.service.AcsToWmsService;
import org.nl.acs.instruction.service.InstructionService; import org.nl.acs.instruction.service.InstructionService;
import org.nl.acs.log.service.DeviceExecuteLogService;
import org.nl.acs.route.service.RouteLineService; import org.nl.acs.route.service.RouteLineService;
import org.nl.acs.task.service.TaskService; import org.nl.acs.task.service.TaskService;
import org.nl.acs.utils.ReadUtil; import org.nl.acs.utils.ReadUtil;
import org.nl.config.SpringContextHolder; import org.nl.config.SpringContextHolder;
import org.nl.system.service.lucene.LuceneExecuteLogService;
import org.nl.system.service.lucene.dto.LuceneLogDto;
import org.openscada.opc.lib.da.Server; import org.openscada.opc.lib.da.Server;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map; import java.util.Map;
/** /**
@ -34,6 +39,8 @@ public class StandardAutodoorDeviceDriver extends AbstractOpcDeviceDriver implem
InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl"); InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl");
LuceneExecuteLogService lucene = SpringContextHolder.getBean("luceneExecuteLogServiceImpl");
DeviceService deviceservice = SpringContextHolder.getBean("deviceServiceImpl"); DeviceService deviceservice = SpringContextHolder.getBean("deviceServiceImpl");
RouteLineService routelineserver = SpringContextHolder.getBean("routeLineServiceImpl"); RouteLineService routelineserver = SpringContextHolder.getBean("routeLineServiceImpl");
@ -129,26 +136,70 @@ public class StandardAutodoorDeviceDriver extends AbstractOpcDeviceDriver implem
} }
public void writing(String param, int command) { /**
String to_command = String.format("%s.%s.%s.%s", this.getDevice().getOpc_server_code(), this.getDevice().getOpc_plc_code(), this.getDevice().getDevice_code(), param); * 多个信号一起下发电气
*
* @param map
*/
public void writing(Map<String, Object> map) {
LuceneExecuteLogService lucene = SpringContextHolder.getBean(LuceneExecuteLogService.class);
DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl");
Map<String, Object> itemMap = new LinkedHashMap<>();
map.forEach((key, value) -> {
if (ObjectUtil.isNotEmpty(value)) {
itemMap.put(getToParam() + key, value);
}
});
if (ObjectUtil.isNotEmpty(itemMap)) {
try {
this.checkcontrol(itemMap);
} 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));
}
}
/**
* 抽取统一下发电气信号前缀
*
* @return
*/
public String getToParam() {
return this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + ".";
}
public void writing(String param, String value) {
String to_param = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
+ "." + param;
String opcservcerid = this.getDevice().getOpc_server_id(); String opcservcerid = this.getDevice().getOpc_server_id();
Server server = ReadUtil.getServer(opcservcerid); Server server = ReadUtil.getServer(opcservcerid);
Map<String, Object> itemMap = new HashMap<String, Object>(); Map<String, Object> itemMap = new HashMap<String, Object>();
itemMap.put(to_command, command); if (value instanceof String) {
itemMap.put(to_param, value);
} else {
itemMap.put(to_param, value);
}
ReadUtil.write(itemMap, server); ReadUtil.write(itemMap, server);
log.info("下发PLC信号:{},{}", to_command, command); server.disconnect();
System.out.println("设备:" + devicecode + ",下发PLC信号:" + to_command + ",value:" + command); log.info("下发PLC信号:{},{}", this.devicecode, "to_command:" + value);
lucene.deviceExecuteLog(new LuceneLogDto(this.devicecode, message + param + " 写入 " + value));
} }
public synchronized void OpenOrClose(String type) { public synchronized void OpenOrClose(String type) {
//开门 //开门
if (CommonFinalParam.ONE.equals(type)) { if (CommonFinalParam.ONE.equals(type)) {
writing(ItemProtocol.item_to_command, 1); writing(ItemProtocol.item_to_command, "1");
} else { } else {
writing(ItemProtocol.item_to_command, 2); writing(ItemProtocol.item_to_command, "2");
} }
} }

Loading…
Cancel
Save