Browse Source

add 新驱动

master
汪菘 2 years ago
parent
commit
0486f40aca
  1. 7
      acs/nladmin-system/src/main/java/org/nl/acs/device/device_driver/DriverTypeEnum.java
  2. 5
      acs/nladmin-system/src/main/java/org/nl/acs/device_driver/RequestMethodEnum.java
  3. 62
      acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/converor_barcode/ConveyorBarcodeDefination.java
  4. 141
      acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/converor_barcode/ItemProtocol.java
  5. 791
      acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/converor_barcode/LnshStationDeviceDriver.java
  6. 62
      acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/conveyor_press_station/ConveyorPressStationDefination.java
  7. 791
      acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/conveyor_press_station/ConveyorPressStationDeviceDriver.java
  8. 147
      acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/conveyor_press_station/ItemProtocol.java
  9. 5
      acs/nladmin-ui/src/views/acs/device/config.vue
  10. 623
      acs/nladmin-ui/src/views/acs/device/driver/lnsh/conveyor_press_station.vue
  11. 623
      acs/nladmin-ui/src/views/acs/device/driver/lnsh/conveyor_ssx_barcode.vue

7
acs/nladmin-system/src/main/java/org/nl/acs/device/device_driver/DriverTypeEnum.java

@ -81,7 +81,12 @@ public enum DriverTypeEnum {
AGV_NDC_ONE(55, "agv_ndc_one", "NDC1楼AGV", "agv"),
AGV_NDC_TWO(56, "agv_ndc_two", "NDC2楼AGV", "agv");
AGV_NDC_TWO(56, "agv_ndc_two", "NDC2楼AGV", "agv"),
CONVEYOR_SSX_BARCODE(54, "conveyor_ssx_barcode", "标准版-下发条码输送线", "station"),
CONVEYOR_PRESS_STATION(54, "conveyor_press_station", "标准版-压制对接位", "station");
//驱动索引
private int index;

5
acs/nladmin-system/src/main/java/org/nl/acs/device_driver/RequestMethodEnum.java

@ -40,7 +40,10 @@ public enum RequestMethodEnum {
feedback_task_status(15, "feedback_task_status", "反馈任务状态","1"),
feedback_device_status(16, "feedback_device_status", "反馈设备状态","1");
feedback_device_status(16, "feedback_device_status", "反馈设备状态","1"),
apply_feedback_weight(16, "apply_feedback_weight", "反馈压机残留重量","0");
//驱动索引
private int index;

62
acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/converor_barcode/ConveyorBarcodeDefination.java

@ -0,0 +1,62 @@
package org.nl.acs.device_driver.lnsh.converor_barcode;
import org.nl.acs.device.device_driver.standard_inspect.ItemDto;
import org.nl.acs.device_driver.DeviceDriver;
import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination;
import org.nl.acs.opc.Device;
import org.nl.acs.opc.DeviceType;
import org.springframework.stereotype.Service;
import java.util.LinkedList;
import java.util.List;
/**
* 下发条码输送线工位
*
*/
@Service
public class ConveyorBarcodeDefination implements OpcDeviceDriverDefination {
@Override
public String getDriverCode() {
return "conveyor_ssx_barcode";
}
@Override
public String getDriverName() {
return "标准版-下发条码输送线";
}
@Override
public String getDriverDescription() {
return "标准版-下发条码输送线";
}
@Override
public DeviceDriver getDriverInstance(Device device) {
return (new LnshStationDeviceDriver()).setDevice(device).setDriverDefination(this);
}
@Override
public Class<? extends DeviceDriver> getDeviceDriverType() {
return LnshStationDeviceDriver.class;
}
@Override
public List<DeviceType> getFitDeviceTypes() {
List<DeviceType> types = new LinkedList();
types.add(DeviceType.station);
return types;
}
@Override
public List<ItemDto> getReadableItemDtos() {
return ItemProtocol.getReadableItemDtos();
}
@Override
public List<ItemDto> getWriteableItemDtos() {
return ItemProtocol.getWriteableItemDtos();
}
}

141
acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/converor_barcode/ItemProtocol.java

@ -0,0 +1,141 @@
package org.nl.acs.device_driver.lnsh.converor_barcode;
import cn.hutool.core.util.StrUtil;
import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.nl.acs.device.device_driver.standard_inspect.ItemDto;
import java.util.ArrayList;
import java.util.List;
@Slf4j
@Getter
@Setter
public class ItemProtocol {
public static String item_heartbeat = "heartbeat";
public static String item_mode = "mode";
public static String item_move = "move";
public static String item_action = "action";
public static String item_ioaction = "ioaction";
public static String item_error = "error";
public static String item_task = "task";
public static String item_weight = "weight";
public static String item_material = "material";
public static String item_barcode = "barcode";
public static String item_to_command = "to_command";
public static String item_to_target = "to_target";
public static String item_to_task = "to_task";
public static String item_to_barcode = "to_barcode";
Boolean isonline;
private LnshStationDeviceDriver driver;
public ItemProtocol(LnshStationDeviceDriver driver) {
this.driver = driver;
}
public int getHeartbeat() {
return this.getOpcIntegerValue(item_heartbeat);
}
public int getMode() {
return this.getOpcIntegerValue(item_mode);
}
public int getMove() {
return this.getOpcIntegerValue(item_move);
}
public int getAction() {
return this.getOpcIntegerValue(item_action);
}
public int getIoAction() {
return this.getOpcIntegerValue(item_ioaction);
}
public int getError() {
return this.getOpcIntegerValue(item_error);
}
public int getTask() {
return this.getOpcIntegerValue(item_task);
}
public int getWeight() {
return this.getOpcIntegerValue(item_weight);
}
public String getMaterial() {
return this.getOpcStringValue(item_material);
}
public int getBarcode() {
return this.getOpcIntegerValue(item_barcode);
}
public int getToCommand() {
return this.getOpcIntegerValue(item_to_command);
}
public int getToTarget() {
return this.getOpcIntegerValue(item_to_target);
}
public int getToTask() {
return this.getOpcIntegerValue(item_to_task);
}
//是否有货
public int hasGoods(int move) {
return move;
}
public int getOpcIntegerValue(String protocol) {
Integer value = this.driver.getIntegeregerValue(protocol);
if (value == null) {
// log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!");
setIsonline(false);
} else {
setIsonline(true);
return value;
}
return 0;
}
public String getOpcStringValue(String protocol) {
String value = this.driver.getStringValue(protocol);
if (StrUtil.isBlank(value)) {
// log.error("读取错误!");
} else {
return value;
}
return "0";
}
public static List<ItemDto> getReadableItemDtos() {
ArrayList list = new ArrayList();
list.add(new ItemDto(item_heartbeat, "心跳", "DB51.B0"));
list.add(new ItemDto(item_mode, "工作模式", "DB51.B1", Boolean.valueOf(true)));
list.add(new ItemDto(item_move, "光电开关信号", "DB51.B2"));
list.add(new ItemDto(item_error, "报警信号", "DB51.B3"));
list.add(new ItemDto(item_task, "任务号", "DB51.D4"));
list.add(new ItemDto(item_barcode, "条码", "DB51.W8"));
return list;
}
public static List<ItemDto> getWriteableItemDtos() {
ArrayList list = new ArrayList();
list.add(new ItemDto(item_to_command, "作业命令", "DB50.W0", Boolean.valueOf(true)));
list.add(new ItemDto(item_to_target, "目标站", "DB50.W2"));
list.add(new ItemDto(item_to_task, "任务号", "DB50.D4"));
list.add(new ItemDto(item_to_barcode, "条码", "DB50.W8"));
return list;
}
}

791
acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/converor_barcode/LnshStationDeviceDriver.java

@ -0,0 +1,791 @@
package org.nl.acs.device_driver.lnsh.converor_barcode;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.nl.acs.device.device_driver.standard_inspect.ReadUtil;
import org.nl.acs.device.service.DeviceService;
import org.nl.acs.device_driver.DeviceDriver;
import org.nl.acs.device_driver.RequestMethodEnum;
import org.nl.acs.device_driver.RouteableDeviceDriver;
import org.nl.acs.device_driver.StandardRequestMethod;
import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver;
import org.nl.acs.device_driver.driver.ExecutableDeviceDriver;
import org.nl.acs.ext.wms.data.AcsToWmsData.applyTask.ApplyTaskRequest;
import org.nl.acs.ext.wms.data.Resp;
import org.nl.acs.ext.wms.service.AcsToWmsService;
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.route.service.RouteLineService;
import org.nl.acs.task.service.TaskService;
import org.nl.modules.lucene.service.LuceneExecuteLogService;
import org.nl.modules.lucene.service.dto.LuceneLogDto;
import org.nl.modules.wql.util.SpringContextHolder;
import org.openscada.opc.lib.da.Server;
import java.lang.reflect.Method;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 晟华-工位(交互模板)
*/
@Slf4j
@Getter
@Setter
@RequiredArgsConstructor
public class LnshStationDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor, StandardRequestMethod {
protected ItemProtocol itemProtocol = new ItemProtocol(this);
LuceneExecuteLogService lucene = SpringContextHolder.getBean("luceneExecuteLogServiceImpl");
InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl");
DeviceService deviceservice = SpringContextHolder.getBean("deviceServiceImpl");
RouteLineService routelineserver = SpringContextHolder.getBean("routeLineServiceImpl");
TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl");
DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl");
AcsToWmsService acsToWmsService = SpringContextHolder.getBean("acsToWmsServiceImpl");
String device_code;
int mode = 0;
int error = 0;
int move = 0;
int action;
int io_action;
int task = 0;
int last_mode = 0;
int last_error = 0;
int last_move = 0;
int last_task = 0;
int last_action = 0;
int last_ioaction = 0;
Boolean isonline = true;
int hasGoods = 0;
Boolean iserror = false;
protected int instruction_num = 0;
protected int instruction_num_truth = 0;
Integer heartbeat_tag;
private Date instruction_require_time = new Date();
private Date instruction_finished_time = new Date();
private int instruction_require_time_out = 3000;
boolean requireSucess = false;
private int instruction_finished_time_out;
int heartbeat;
int last_heartbeat;
private Date checkHeartbeattime = new Date();
private Date last_checkHeartbeattime = new Date();
int branchProtocol = 0;
//当前指令
Instruction inst = null;
//上次指令
Instruction last_inst = null;
//触摸屏手动触发任务
private Boolean is_has_task = false;
//暂定 0就绪 1请求取货 2取货完成 3请求放货 4放货完成 5取货完成离开 6放货完成离开 7请求进入区域 8请求离开区域
int flag;
String message;
int weight = 0;
int last_weight = 0;
String material;
String last_material;
int barcode;
int last_barcode;
@Override
public Device getDevice() {
return this.device;
}
@Override
public void execute() {
message = null;
try {
device_code = this.getDeviceCode();
mode = this.itemProtocol.getMode();
error = this.itemProtocol.getError();
move = this.itemProtocol.getMove();
task = this.itemProtocol.getTask();
hasGoods = this.itemProtocol.getMove();
io_action = this.itemProtocol.getIoAction();
action = this.itemProtocol.getAction();
weight = this.itemProtocol.getWeight();
material = this.itemProtocol.getMaterial();
barcode = this.itemProtocol.getBarcode();
if (mode != last_mode) {
this.setRequireSucess(false);
logServer.deviceItemValue(this.device_code, "mode", String.valueOf(mode));
logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_mode + " -> " + mode);
}
if (move != last_move) {
logServer.deviceItemValue(this.device_code, "move", String.valueOf(move));
logServer.deviceExecuteLog(this.device_code, "", "", "信号move:" + last_move + " -> " + move);
}
if (error != last_error) {
logServer.deviceItemValue(this.device_code, "error", String.valueOf(error));
logServer.deviceExecuteLog(this.device_code, "", "", "信号error:" + last_error + " -> " + error);
}
if (task != last_task) {
logServer.deviceItemValue(this.device_code, "task", String.valueOf(task));
logServer.deviceExecuteLog(this.device_code, "", "", "信号task:" + last_task + " -> " + task);
}
if (action != last_action) {
logServer.deviceItemValue(this.device_code, "action", String.valueOf(action));
logServer.deviceExecuteLog(this.device_code, "", "", "信号action:" + last_action + " -> " + action);
}
if (io_action != last_ioaction) {
logServer.deviceItemValue(this.device_code, "io_action", String.valueOf(io_action));
logServer.deviceExecuteLog(this.device_code, "", "", "信号io_action: " + last_ioaction + " -> " + io_action);
}
if (weight != last_weight) {
logServer.deviceItemValue(this.device_code, "weight", String.valueOf(weight));
logServer.deviceExecuteLog(this.device_code, "", "", "信号weight: " + last_weight + " -> " + weight);
}
if (!StrUtil.equals(material, last_material)) {
logServer.deviceItemValue(this.device_code, "material", material);
logServer.deviceExecuteLog(this.device_code, "", "", "信号material:" + last_material + " -> " + material);
}
if (barcode != last_barcode) {
logServer.deviceItemValue(this.device_code, "barcode", String.valueOf(barcode));
logServer.deviceExecuteLog(this.device_code, "", "", "信号barcode:" + last_barcode + " -> " + barcode);
}
} catch (Exception var17) {
return;
}
//急停
if (this.isStop()) {
//未联机
} else if (mode == 0) {
this.setIsonline(false);
this.setIserror(true);
message = "未联机";
//有报警
} else if (error != 0) {
this.setIsonline(false);
this.setIserror(true);
message = "有报警";
//无报警
} else {
this.setIsonline(true);
this.setIserror(false);
message = "";
Instruction instruction = null;
List toInstructions;
if (mode > 2) {
if (ObjectUtil.isNotEmpty(this.device.getExtraValue().get(String.valueOf(mode)))) {
String modethod = this.device.getExtraValue().get(String.valueOf(mode)).toString();
try {
applyRequest(modethod);
} catch (Exception e) {
message = "错误:" + e.getMessage();
this.setIserror(true);
}
} else {
message = "无效模式请求,驱动未配置此请求方法";
}
} else {
message = "无请求";
}
Object ignore_pickup_check = this.getExtraValue().get("ignore_pickup_check");
}
last_mode = mode;
last_error = error;
last_move = move;
last_task = task;
last_action = action;
last_ioaction = io_action;
last_weight = weight;
last_material = material;
last_barcode = barcode;
}
public boolean exe_error() {
if (this.error == 0) {
return true;
} else {
log.debug("设备报警");
return false;
}
}
public boolean exe_business() {
return true;
}
protected void executing(Instruction instruction) {
this.executing(1, instruction, "");
}
public void executing(int command, Instruction instruction, String appendMessage) {
String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
+ "." + ItemProtocol.item_to_command;
String to_target = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
+ "." + ItemProtocol.item_to_target;
String to_task = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
+ "." + ItemProtocol.item_to_task;
if (appendMessage == null) {
appendMessage = "";
}
if (instruction != null) {
instruction_num = Integer.parseInt(instruction.getInstruction_code());
}
String opcservcerid = this.getDevice().getOpc_server_id();
Server server = ReadUtil.getServer(opcservcerid);
Map<String, Object> itemMap = new HashMap<String, Object>();
itemMap.put(to_command, 1);
itemMap.put(to_task, instruction_num);
ReadUtil.write(itemMap, server);
server.disconnect();
}
public void executing(Server server, Map<String, Object> itemMap) {
ReadUtil.write(itemMap, server);
server.disconnect();
}
public void writing(int type, int command) {
String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
+ "." + ItemProtocol.item_to_command;
String to_target = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
+ "." + ItemProtocol.item_to_target;
String to_task = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
+ "." + ItemProtocol.item_to_task;
String opcservcerid = this.getDevice().getOpc_server_id();
Server server = ReadUtil.getServer(opcservcerid);
Map<String, Object> itemMap = new HashMap<String, Object>();
if (type == 1) {
itemMap.put(to_command, command);
logServer.deviceExecuteLog(this.device_code, "", "", "to_command 写入 " + command);
} else if (type == 2) {
itemMap.put(to_target, command);
logServer.deviceExecuteLog(this.device_code, "", "", "to_target 写入 " + command);
} else if (type == 3) {
itemMap.put(to_task, command);
logServer.deviceExecuteLog(this.device_code, "", "", "to_task 写入 " + command);
}
ReadUtil.write(itemMap, server);
server.disconnect();
}
public void writing(int command) {
String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
+ "." + ItemProtocol.item_to_command;
String opcservcerid = this.getDevice().getOpc_server_id();
Server server = ReadUtil.getServer(opcservcerid);
Map<String, Object> itemMap = new HashMap<String, Object>();
itemMap.put(to_command, command);
ReadUtil.write(itemMap, server);
ReadUtil.write(itemMap, server);
server.disconnect();
logServer.deviceExecuteLog(this.device_code, "", "", "to_command 写入 " + command);
}
public synchronized void OpenOrClose(String type) {
//进入区域
if ("1".equals(type)) {
writing(5);
} else {
//离开区域
writing(6);
}
}
public String toString() {
return "";
}
@Override
public JSONObject getDeviceStatusName() throws Exception {
String mode;
String move;
String action;
String io_action;
boolean hasGoods;
switch (this.mode) {
case 0:
mode = "脱机";
break;
case 2:
mode = "待机";
break;
case 4:
mode = "叫料";
break;
case 5:
mode = "申请空盘";
break;
case 6:
mode = "申请入库";
break;
case 11:
mode = "半托缓存强制去包装";
break;
case 15:
mode = "送空托盘";
break;
default:
mode = String.valueOf(this.mode);
}
if (this.move == 0) {
move = "无货";
hasGoods = false;
} else {
move = "有货";
hasGoods = true;
}
switch (this.action) {
case 1:
action = "允许取货";
break;
case 2:
action = "允许放货";
break;
case 3:
action = "允许取放";
break;
default:
action = "禁止取放";
}
switch (this.io_action) {
case 1:
io_action = "允许进入";
break;
case 2:
io_action = "允许离开";
break;
case 3:
io_action = "允许进入离开";
break;
default:
io_action = "禁止进入离开";
}
String error;
switch (this.error) {
case 1:
error = "急停中";
break;
case 2:
error = "光幕报警";
break;
case 3:
error = "本体报警";
break;
case 4:
error = "未排产报警";
break;
case 5:
error = "扫码故障";
break;
default:
error = String.valueOf(this.error);
}
JSONObject jo = new JSONObject();
jo.put("device_name", this.getDevice().getDevice_name());
jo.put("mode", mode);
jo.put("move", move);
jo.put("action", action);
jo.put("io_action", io_action);
jo.put("error", error);
jo.put("task", task);
jo.put("weight", weight);
jo.put("barcode", barcode);
jo.put("isError", iserror);
jo.put("isOnline", isonline);
jo.put("hasGoods", hasGoods);
jo.put("message", message);
return jo;
}
@Override
public void setDeviceStatus(JSONObject data) {
}
/**
* 请求
*
* @param
*/
public synchronized boolean applyRequest(String modethod) throws Exception {
Object obj1 = this;
Date date = new Date();
if (date.getTime() - this.instruction_require_time.getTime() < (long) this.instruction_require_time_out) {
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out);
return false;
} else {
this.instruction_require_time = date;
Object obj = this.getClass().getDeclaredConstructor().newInstance();
Method method1 = this.getClass().getMethod(modethod, null);
method1.invoke(this, null);
return true;
}
}
/**
* 申请补满料盅托盘
*
* @param
*/
public synchronized boolean apply_put_full_vehicle() {
if(move == 0) {
ApplyTaskRequest request = new ApplyTaskRequest();
request.setDevice_code(this.getDevice_code());
request.setRequest_medthod_code(Thread.currentThread().getStackTrace()[1].getMethodName());
request.setRequest_medthod_name(RequestMethodEnum.getName(Thread.currentThread().getStackTrace()[1].getMethodName()));
request.setWeight(String.valueOf(weight));
request.setVehicle_code(String.valueOf(barcode));
message = RequestMethodEnum.getName("apply_put_full_vehicle") + "apply_put_full_vehicle 接口请求LMS...";
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, message + "参数:" + JSON.toJSONString(request)));
Resp resp = acsToWmsService.applyTask(request);
if (StrUtil.equals(resp.result, "true")) {
this.writing(this.mode);
this.setRequireSucess(true);
} else {
this.writing(400);
message = RequestMethodEnum.getName("apply_put_full_vehicle") + "apply_put_full_vehicle 接口请求失败" + resp.getComment();;
}
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, message));
return true;
} else {
message = RequestMethodEnum.getName("apply_put_full_vehicle") + "apply_put_full_vehicle 设备有货未请求LMS...";
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, message));
return false;
}
}
/**
* 申请补空料盅托盘
*
* @param
*/
public synchronized boolean apply_put_empty_vehicle() {
if(move == 0) {
ApplyTaskRequest request = new ApplyTaskRequest();
request.setDevice_code(this.getDevice_code());
request.setRequest_medthod_code(this.getClass().getName());
request.setRequest_medthod_name(RequestMethodEnum.getName(this.getClass().getName()));
request.setWeight(String.valueOf(weight));
request.setVehicle_code(String.valueOf(barcode));
Resp resp = acsToWmsService.applyTask(request);
message = RequestMethodEnum.getName("apply_put_empty_vehicle") + "apply_put_empty_vehicle 接口请求LMS...";
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, message + "参数:" + JSON.toJSONString(request)));
if (StrUtil.equals(resp.result, "true")) {
this.writing(this.mode);
this.setRequireSucess(true);
} else {
this.writing(400);
message = RequestMethodEnum.getName("apply_put_empty_vehicle") + "apply_put_empty_vehicle 接口请求失败" + resp.getComment();;
}
return true;
} else {
message = RequestMethodEnum.getName("apply_put_empty_vehicle") + "apply_put_empty_vehicle 设备有货未请求LMS...";
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, message));
return false;
}
}
/**
* 申请取走空料盅托盘
*
* @param
*/
public synchronized boolean apply_take_empty_vehicle() {
if(move == 0) {
ApplyTaskRequest request = new ApplyTaskRequest();
request.setDevice_code(this.getDevice_code());
request.setRequest_medthod_code(this.getClass().getName());
request.setRequest_medthod_name(RequestMethodEnum.getName(this.getClass().getName()));
request.setWeight(String.valueOf(weight));
request.setVehicle_code(String.valueOf(barcode));
Resp resp = acsToWmsService.applyTask(request);
message = RequestMethodEnum.getName("apply_take_empty_vehicle") + "apply_take_empty_vehicle 接口请求LMS...";
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, message + "参数:" + JSON.toJSONString(request)));
if (StrUtil.equals(resp.result, "true")) {
this.writing(this.mode);
this.setRequireSucess(true);
} else {
this.writing(400);
message = RequestMethodEnum.getName("apply_take_empty_vehicle") + "apply_take_empty_vehicle 接口请求失败" + resp.getComment();;
}
return true;
} else {
message = RequestMethodEnum.getName("apply_take_empty_vehicle") + "apply_take_empty_vehicle 设备有货未请求LMS...";
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, message));
return false;
}
}
/**
* 申请取走满料盅托盘
*
* @param
*/
public synchronized boolean apply_take_full_vehicle() {
if(move > 0) {
ApplyTaskRequest request = new ApplyTaskRequest();
request.setDevice_code(this.getDevice_code());
request.setRequest_medthod_code(this.getClass().getName());
request.setRequest_medthod_name(RequestMethodEnum.getName(this.getClass().getName()));
request.setWeight(String.valueOf(weight));
request.setVehicle_code(String.valueOf(barcode));
Resp resp = acsToWmsService.applyTask(request);
message = RequestMethodEnum.getName("apply_take_full_vehicle") + "apply_take_full_vehicle 接口请求LMS...";
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, message + "参数:" + JSON.toJSONString(request)));
if (StrUtil.equals(resp.result, "true")) {
this.writing(this.mode);
this.setRequireSucess(true);
} else {
this.writing(400);
message = RequestMethodEnum.getName("apply_take_full_vehicle") + "apply_take_full_vehicle 接口请求失败" + resp.getComment();;
}
return true;
} else {
message = RequestMethodEnum.getName("apply_take_full_vehicle") + "apply_take_full_vehicle 设备无货未请求LMS...";
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, message));
return false;
}
}
/**
* 申请强制取走满料盅托盘
*
* @param
*/
public synchronized boolean apply_force_take_full_vehicle() {
if(move > 0) {
ApplyTaskRequest request = new ApplyTaskRequest();
request.setDevice_code(this.getDevice_code());
request.setRequest_medthod_code(this.getClass().getName());
request.setRequest_medthod_name(RequestMethodEnum.getName(this.getClass().getName()));
request.setWeight(String.valueOf(weight));
request.setVehicle_code(String.valueOf(barcode));
Resp resp = acsToWmsService.applyTask(request);
message = RequestMethodEnum.getName("apply_force_take_full_vehicle") + "apply_force_take_full_vehicle 接口请求LMS...";
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, message + "参数:" + JSON.toJSONString(request)));
if (StrUtil.equals(resp.result, "true")) {
this.writing(this.mode);
this.setRequireSucess(true);
} else {
this.writing(400);
message = RequestMethodEnum.getName("apply_force_take_full_vehicle") + "apply_force_take_full_vehicle 接口请求失败" + resp.getComment();;
}
return true;
} else {
message = RequestMethodEnum.getName("apply_force_take_full_vehicle") + "apply_force_take_full_vehicle 设备无货未请求LMS...";
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, message));
return false;
}
}
/**
* 申请强制满托入缓存
*
* @param
*/
public synchronized boolean apply_force_take_full_vehicle_in_storage() {
if(move > 0) {
ApplyTaskRequest request = new ApplyTaskRequest();
request.setDevice_code(this.getDevice_code());
request.setRequest_medthod_code(this.getClass().getName());
request.setRequest_medthod_name(RequestMethodEnum.getName(this.getClass().getName()));
request.setWeight(String.valueOf(weight));
request.setVehicle_code(String.valueOf(barcode));
Resp resp = acsToWmsService.applyTask(request);
message = RequestMethodEnum.getName("apply_force_take_full_vehicle_in_storage") + "apply_force_take_full_vehicle_in_storage 接口请求LMS...";
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, message + "参数:" + JSON.toJSONString(request)));
if (StrUtil.equals(resp.result, "true")) {
this.writing(this.mode);
this.setRequireSucess(true);
} else {
this.writing(400);
message = RequestMethodEnum.getName("apply_force_take_full_vehicle_in_storage") + "apply_force_take_full_vehicle_in_storage 接口请求失败" + resp.getComment();;
}
return true;
} else {
message = RequestMethodEnum.getName("apply_force_take_full_vehicle_in_storage") + "apply_force_take_full_vehicle_in_storage 设备无货未请求LMS...";
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, message));
return false;
}
}
/**
* 扫码成功申请
*
* @param
*/
public synchronized boolean barcode_sucess_apply() {
if(move > 0) {
ApplyTaskRequest request = new ApplyTaskRequest();
request.setDevice_code(this.getDevice_code());
request.setRequest_medthod_code(this.getClass().getName());
request.setRequest_medthod_name(RequestMethodEnum.getName(this.getClass().getName()));
request.setWeight(String.valueOf(weight));
request.setVehicle_code(String.valueOf(barcode));
Resp resp = acsToWmsService.applyTask(request);
message = RequestMethodEnum.getName("barcode_sucess_apply") + "barcode_sucess_apply 接口请求LMS...";
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, message + "参数:" + JSON.toJSONString(request)));
if (StrUtil.equals(resp.result, "true")) {
this.writing(this.mode);
this.setRequireSucess(true);
} else {
this.writing(400);
message = RequestMethodEnum.getName("barcode_sucess_apply") + "barcode_sucess_apply 接口请求失败" + resp.getComment();;
}
return true;
} else {
message = RequestMethodEnum.getName("barcode_sucess_apply") + "barcode_sucess_apply 设备无货未请求LMS...";
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, message));
return false;
}
}
/**
* 获取组盘信息
*
* @param
*/
public synchronized boolean get_vehicle_info() {
if(move > 0) {
ApplyTaskRequest request = new ApplyTaskRequest();
request.setDevice_code(this.getDevice_code());
request.setRequest_medthod_code(this.getClass().getName());
request.setRequest_medthod_name(RequestMethodEnum.getName(this.getClass().getName()));
request.setWeight(String.valueOf(weight));
request.setVehicle_code(String.valueOf(barcode));
Resp resp = acsToWmsService.applyTask(request);
message = RequestMethodEnum.getName("get_vehicle_info") + "get_vehicle_info 接口请求LMS...";
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, message + "参数:" + JSON.toJSONString(request)));
if (StrUtil.equals(resp.result, "true")) {
this.writing(this.mode);
this.setRequireSucess(true);
} else {
this.writing(400);
message = RequestMethodEnum.getName("get_vehicle_info") + "get_vehicle_info 接口请求失败" + resp.getComment();;
}
return true;
} else {
message = RequestMethodEnum.getName("get_vehicle_info") + "get_vehicle_info 设备无货未请求LMS...";
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, message));
return false;
}
}
/**
* 强制去包装-不包装
*/
public synchronized boolean force_no_package() {
if(move > 0) {
ApplyTaskRequest request = new ApplyTaskRequest();
request.setDevice_code(this.getDevice_code());
request.setRequest_medthod_code(this.getClass().getName());
request.setRequest_medthod_name(RequestMethodEnum.getName(this.getClass().getName()));
request.setWeight(String.valueOf(weight));
request.setVehicle_code(String.valueOf(barcode));
Resp resp = acsToWmsService.applyTask(request);
message = RequestMethodEnum.getName("force_no_package") + "force_no_package 接口请求LMS...";
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, message + "参数:" + JSON.toJSONString(request)));
if (StrUtil.equals(resp.result, "true")) {
this.writing(this.mode);
this.setRequireSucess(true);
} else {
this.writing(400);
message = RequestMethodEnum.getName("force_no_package") + "force_no_package 接口请求失败" + resp.getComment();;
}
return true;
} else {
message = RequestMethodEnum.getName("force_no_package") + "force_no_package 设备无货未请求LMS...";
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, message));
return false;
}
}
/**
* 申请贴标
*/
public synchronized boolean apply_labelling() {
if(move > 0) {
ApplyTaskRequest request = new ApplyTaskRequest();
request.setDevice_code(this.getDevice_code());
request.setRequest_medthod_code(this.getClass().getName());
request.setRequest_medthod_name(RequestMethodEnum.getName(this.getClass().getName()));
request.setWeight(String.valueOf(weight));
request.setVehicle_code(String.valueOf(barcode));
Resp resp = acsToWmsService.applyTask(request);
message = RequestMethodEnum.getName("apply_labelling") + "apply_labelling 接口请求LMS...";
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, message + "参数:" + JSON.toJSONString(request)));
if (StrUtil.equals(resp.result, "true")) {
this.writing(this.mode);
this.setRequireSucess(true);
} else {
this.writing(400);
message = RequestMethodEnum.getName("apply_labelling") + "apply_labelling 接口请求失败" + resp.getComment();;
}
return true;
} else {
message = RequestMethodEnum.getName("apply_labelling") + "apply_labelling 设备无货未请求LMS...";
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, message));
return false;
}
}
}

62
acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/conveyor_press_station/ConveyorPressStationDefination.java

@ -0,0 +1,62 @@
package org.nl.acs.device_driver.lnsh.conveyor_press_station;
import org.nl.acs.device.device_driver.standard_inspect.ItemDto;
import org.nl.acs.device_driver.DeviceDriver;
import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination;
import org.nl.acs.opc.Device;
import org.nl.acs.opc.DeviceType;
import org.springframework.stereotype.Service;
import java.util.LinkedList;
import java.util.List;
/**
* 晟华-工位(交互模板)
*
*/
@Service
public class ConveyorPressStationDefination implements OpcDeviceDriverDefination {
@Override
public String getDriverCode() {
return "conveyor_press_station";
}
@Override
public String getDriverName() {
return "标准版-压制对接位";
}
@Override
public String getDriverDescription() {
return "标准版-压制对接位";
}
@Override
public DeviceDriver getDriverInstance(Device device) {
return (new ConveyorPressStationDeviceDriver()).setDevice(device).setDriverDefination(this);
}
@Override
public Class<? extends DeviceDriver> getDeviceDriverType() {
return ConveyorPressStationDeviceDriver.class;
}
@Override
public List<DeviceType> getFitDeviceTypes() {
List<DeviceType> types = new LinkedList();
types.add(DeviceType.station);
return types;
}
@Override
public List<ItemDto> getReadableItemDtos() {
return ItemProtocol.getReadableItemDtos();
}
@Override
public List<ItemDto> getWriteableItemDtos() {
return ItemProtocol.getWriteableItemDtos();
}
}

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

@ -0,0 +1,791 @@
package org.nl.acs.device_driver.lnsh.conveyor_press_station;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.nl.acs.device.device_driver.standard_inspect.ReadUtil;
import org.nl.acs.device.service.DeviceService;
import org.nl.acs.device_driver.DeviceDriver;
import org.nl.acs.device_driver.RequestMethodEnum;
import org.nl.acs.device_driver.RouteableDeviceDriver;
import org.nl.acs.device_driver.StandardRequestMethod;
import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver;
import org.nl.acs.device_driver.driver.ExecutableDeviceDriver;
import org.nl.acs.ext.wms.data.AcsToWmsData.applyTask.ApplyTaskRequest;
import org.nl.acs.ext.wms.data.Resp;
import org.nl.acs.ext.wms.service.AcsToWmsService;
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.route.service.RouteLineService;
import org.nl.acs.task.service.TaskService;
import org.nl.modules.lucene.service.LuceneExecuteLogService;
import org.nl.modules.lucene.service.dto.LuceneLogDto;
import org.nl.modules.wql.util.SpringContextHolder;
import org.openscada.opc.lib.da.Server;
import java.lang.reflect.Method;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 晟华-工位(交互模板)
*/
@Slf4j
@Getter
@Setter
@RequiredArgsConstructor
public class ConveyorPressStationDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor, StandardRequestMethod {
protected ItemProtocol itemProtocol = new ItemProtocol(this);
LuceneExecuteLogService lucene = SpringContextHolder.getBean("luceneExecuteLogServiceImpl");
InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl");
DeviceService deviceservice = SpringContextHolder.getBean("deviceServiceImpl");
RouteLineService routelineserver = SpringContextHolder.getBean("routeLineServiceImpl");
TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl");
DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl");
AcsToWmsService acsToWmsService = SpringContextHolder.getBean("acsToWmsServiceImpl");
String device_code;
int mode = 0;
int error = 0;
int move = 0;
int action;
int io_action;
int task = 0;
int last_mode = 0;
int last_error = 0;
int last_move = 0;
int last_task = 0;
int last_action = 0;
int last_ioaction = 0;
Boolean isonline = true;
int hasGoods = 0;
Boolean iserror = false;
protected int instruction_num = 0;
protected int instruction_num_truth = 0;
Integer heartbeat_tag;
private Date instruction_require_time = new Date();
private Date instruction_finished_time = new Date();
private int instruction_require_time_out = 3000;
boolean requireSucess = false;
private int instruction_finished_time_out;
int heartbeat;
int last_heartbeat;
private Date checkHeartbeattime = new Date();
private Date last_checkHeartbeattime = new Date();
int branchProtocol = 0;
//当前指令
Instruction inst = null;
//上次指令
Instruction last_inst = null;
//触摸屏手动触发任务
private Boolean is_has_task = false;
//暂定 0就绪 1请求取货 2取货完成 3请求放货 4放货完成 5取货完成离开 6放货完成离开 7请求进入区域 8请求离开区域
int flag;
String message;
int weight = 0;
int last_weight = 0;
String material;
String last_material;
int barcode;
int last_barcode;
@Override
public Device getDevice() {
return this.device;
}
@Override
public void execute() {
message = null;
try {
device_code = this.getDeviceCode();
mode = this.itemProtocol.getMode();
error = this.itemProtocol.getError();
move = this.itemProtocol.getMove();
task = this.itemProtocol.getTask();
hasGoods = this.itemProtocol.getMove();
io_action = this.itemProtocol.getIoAction();
action = this.itemProtocol.getAction();
weight = this.itemProtocol.getWeight();
material = this.itemProtocol.getMaterial();
barcode = this.itemProtocol.getBarcode();
if (mode != last_mode) {
this.setRequireSucess(false);
logServer.deviceItemValue(this.device_code, "mode", String.valueOf(mode));
logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_mode + " -> " + mode);
}
if (move != last_move) {
logServer.deviceItemValue(this.device_code, "move", String.valueOf(move));
logServer.deviceExecuteLog(this.device_code, "", "", "信号move:" + last_move + " -> " + move);
}
if (error != last_error) {
logServer.deviceItemValue(this.device_code, "error", String.valueOf(error));
logServer.deviceExecuteLog(this.device_code, "", "", "信号error:" + last_error + " -> " + error);
}
if (task != last_task) {
logServer.deviceItemValue(this.device_code, "task", String.valueOf(task));
logServer.deviceExecuteLog(this.device_code, "", "", "信号task:" + last_task + " -> " + task);
}
if (action != last_action) {
logServer.deviceItemValue(this.device_code, "action", String.valueOf(action));
logServer.deviceExecuteLog(this.device_code, "", "", "信号action:" + last_action + " -> " + action);
}
if (io_action != last_ioaction) {
logServer.deviceItemValue(this.device_code, "io_action", String.valueOf(io_action));
logServer.deviceExecuteLog(this.device_code, "", "", "信号io_action: " + last_ioaction + " -> " + io_action);
}
if (weight != last_weight) {
logServer.deviceItemValue(this.device_code, "weight", String.valueOf(weight));
logServer.deviceExecuteLog(this.device_code, "", "", "信号weight: " + last_weight + " -> " + weight);
}
if (!StrUtil.equals(material, last_material)) {
logServer.deviceItemValue(this.device_code, "material", material);
logServer.deviceExecuteLog(this.device_code, "", "", "信号material:" + last_material + " -> " + material);
}
if (barcode != last_barcode) {
logServer.deviceItemValue(this.device_code, "barcode", String.valueOf(barcode));
logServer.deviceExecuteLog(this.device_code, "", "", "信号barcode:" + last_barcode + " -> " + barcode);
}
} catch (Exception var17) {
return;
}
//急停
if (this.isStop()) {
//未联机
} else if (mode == 0) {
this.setIsonline(false);
this.setIserror(true);
message = "未联机";
//有报警
} else if (error != 0) {
this.setIsonline(false);
this.setIserror(true);
message = "有报警";
//无报警
} else {
this.setIsonline(true);
this.setIserror(false);
message = "";
Instruction instruction = null;
List toInstructions;
if (mode > 2) {
if (ObjectUtil.isNotEmpty(this.device.getExtraValue().get(String.valueOf(mode)))) {
String modethod = this.device.getExtraValue().get(String.valueOf(mode)).toString();
try {
applyRequest(modethod);
} catch (Exception e) {
message = "错误:" + e.getMessage();
this.setIserror(true);
}
} else {
message = "无效模式请求,驱动未配置此请求方法";
}
} else {
message = "无请求";
}
Object ignore_pickup_check = this.getExtraValue().get("ignore_pickup_check");
}
last_mode = mode;
last_error = error;
last_move = move;
last_task = task;
last_action = action;
last_ioaction = io_action;
last_weight = weight;
last_material = material;
last_barcode = barcode;
}
public boolean exe_error() {
if (this.error == 0) {
return true;
} else {
log.debug("设备报警");
return false;
}
}
public boolean exe_business() {
return true;
}
protected void executing(Instruction instruction) {
this.executing(1, instruction, "");
}
public void executing(int command, Instruction instruction, String appendMessage) {
String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
+ "." + ItemProtocol.item_to_command;
String to_target = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
+ "." + ItemProtocol.item_to_target;
String to_task = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
+ "." + ItemProtocol.item_to_task;
if (appendMessage == null) {
appendMessage = "";
}
if (instruction != null) {
instruction_num = Integer.parseInt(instruction.getInstruction_code());
}
String opcservcerid = this.getDevice().getOpc_server_id();
Server server = ReadUtil.getServer(opcservcerid);
Map<String, Object> itemMap = new HashMap<String, Object>();
itemMap.put(to_command, 1);
itemMap.put(to_task, instruction_num);
ReadUtil.write(itemMap, server);
server.disconnect();
}
public void executing(Server server, Map<String, Object> itemMap) {
ReadUtil.write(itemMap, server);
server.disconnect();
}
public void writing(int type, int command) {
String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
+ "." + ItemProtocol.item_to_command;
String to_target = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
+ "." + ItemProtocol.item_to_target;
String to_task = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
+ "." + ItemProtocol.item_to_task;
String opcservcerid = this.getDevice().getOpc_server_id();
Server server = ReadUtil.getServer(opcservcerid);
Map<String, Object> itemMap = new HashMap<String, Object>();
if (type == 1) {
itemMap.put(to_command, command);
logServer.deviceExecuteLog(this.device_code, "", "", "to_command 写入 " + command);
} else if (type == 2) {
itemMap.put(to_target, command);
logServer.deviceExecuteLog(this.device_code, "", "", "to_target 写入 " + command);
} else if (type == 3) {
itemMap.put(to_task, command);
logServer.deviceExecuteLog(this.device_code, "", "", "to_task 写入 " + command);
}
ReadUtil.write(itemMap, server);
server.disconnect();
}
public void writing(int command) {
String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
+ "." + ItemProtocol.item_to_command;
String opcservcerid = this.getDevice().getOpc_server_id();
Server server = ReadUtil.getServer(opcservcerid);
Map<String, Object> itemMap = new HashMap<String, Object>();
itemMap.put(to_command, command);
ReadUtil.write(itemMap, server);
ReadUtil.write(itemMap, server);
server.disconnect();
logServer.deviceExecuteLog(this.device_code, "", "", "to_command 写入 " + command);
}
public synchronized void OpenOrClose(String type) {
//进入区域
if ("1".equals(type)) {
writing(5);
} else {
//离开区域
writing(6);
}
}
public String toString() {
return "";
}
@Override
public JSONObject getDeviceStatusName() throws Exception {
String mode;
String move;
String action;
String io_action;
boolean hasGoods;
switch (this.mode) {
case 0:
mode = "脱机";
break;
case 2:
mode = "待机";
break;
case 4:
mode = "叫料";
break;
case 5:
mode = "申请空盘";
break;
case 6:
mode = "申请入库";
break;
case 11:
mode = "半托缓存强制去包装";
break;
case 15:
mode = "送空托盘";
break;
default:
mode = String.valueOf(this.mode);
}
if (this.move == 0) {
move = "无货";
hasGoods = false;
} else {
move = "有货";
hasGoods = true;
}
switch (this.action) {
case 1:
action = "允许取货";
break;
case 2:
action = "允许放货";
break;
case 3:
action = "允许取放";
break;
default:
action = "禁止取放";
}
switch (this.io_action) {
case 1:
io_action = "允许进入";
break;
case 2:
io_action = "允许离开";
break;
case 3:
io_action = "允许进入离开";
break;
default:
io_action = "禁止进入离开";
}
String error;
switch (this.error) {
case 1:
error = "急停中";
break;
case 2:
error = "光幕报警";
break;
case 3:
error = "本体报警";
break;
case 4:
error = "未排产报警";
break;
case 5:
error = "扫码故障";
break;
default:
error = String.valueOf(this.error);
}
JSONObject jo = new JSONObject();
jo.put("device_name", this.getDevice().getDevice_name());
jo.put("mode", mode);
jo.put("move", move);
jo.put("action", action);
jo.put("io_action", io_action);
jo.put("error", error);
jo.put("task", task);
jo.put("weight", weight);
jo.put("barcode", barcode);
jo.put("isError", iserror);
jo.put("isOnline", isonline);
jo.put("hasGoods", hasGoods);
jo.put("message", message);
return jo;
}
@Override
public void setDeviceStatus(JSONObject data) {
}
/**
* 请求
*
* @param
*/
public synchronized boolean applyRequest(String modethod) throws Exception {
Object obj1 = this;
Date date = new Date();
if (date.getTime() - this.instruction_require_time.getTime() < (long) this.instruction_require_time_out) {
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out);
return false;
} else {
this.instruction_require_time = date;
Object obj = this.getClass().getDeclaredConstructor().newInstance();
Method method1 = this.getClass().getMethod(modethod, null);
method1.invoke(this, null);
return true;
}
}
/**
* 申请补满料盅托盘
*
* @param
*/
public synchronized boolean apply_put_full_vehicle() {
if(move == 0) {
ApplyTaskRequest request = new ApplyTaskRequest();
request.setDevice_code(this.getDevice_code());
request.setRequest_medthod_code(Thread.currentThread().getStackTrace()[1].getMethodName());
request.setRequest_medthod_name(RequestMethodEnum.getName(Thread.currentThread().getStackTrace()[1].getMethodName()));
request.setWeight(String.valueOf(weight));
request.setVehicle_code(String.valueOf(barcode));
message = RequestMethodEnum.getName("apply_put_full_vehicle") + "apply_put_full_vehicle 接口请求LMS...";
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, message + "参数:" + JSON.toJSONString(request)));
Resp resp = acsToWmsService.applyTask(request);
if (StrUtil.equals(resp.result, "true")) {
this.writing(this.mode);
this.setRequireSucess(true);
} else {
this.writing(400);
message = RequestMethodEnum.getName("apply_put_full_vehicle") + "apply_put_full_vehicle 接口请求失败" + resp.getComment();;
}
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, message));
return true;
} else {
message = RequestMethodEnum.getName("apply_put_full_vehicle") + "apply_put_full_vehicle 设备有货未请求LMS...";
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, message));
return false;
}
}
/**
* 申请补空料盅托盘
*
* @param
*/
public synchronized boolean apply_put_empty_vehicle() {
if(move == 0) {
ApplyTaskRequest request = new ApplyTaskRequest();
request.setDevice_code(this.getDevice_code());
request.setRequest_medthod_code(this.getClass().getName());
request.setRequest_medthod_name(RequestMethodEnum.getName(this.getClass().getName()));
request.setWeight(String.valueOf(weight));
request.setVehicle_code(String.valueOf(barcode));
Resp resp = acsToWmsService.applyTask(request);
message = RequestMethodEnum.getName("apply_put_empty_vehicle") + "apply_put_empty_vehicle 接口请求LMS...";
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, message + "参数:" + JSON.toJSONString(request)));
if (StrUtil.equals(resp.result, "true")) {
this.writing(this.mode);
this.setRequireSucess(true);
} else {
this.writing(400);
message = RequestMethodEnum.getName("apply_put_empty_vehicle") + "apply_put_empty_vehicle 接口请求失败" + resp.getComment();;
}
return true;
} else {
message = RequestMethodEnum.getName("apply_put_empty_vehicle") + "apply_put_empty_vehicle 设备有货未请求LMS...";
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, message));
return false;
}
}
/**
* 申请取走空料盅托盘
*
* @param
*/
public synchronized boolean apply_take_empty_vehicle() {
if(move == 0) {
ApplyTaskRequest request = new ApplyTaskRequest();
request.setDevice_code(this.getDevice_code());
request.setRequest_medthod_code(this.getClass().getName());
request.setRequest_medthod_name(RequestMethodEnum.getName(this.getClass().getName()));
request.setWeight(String.valueOf(weight));
request.setVehicle_code(String.valueOf(barcode));
Resp resp = acsToWmsService.applyTask(request);
message = RequestMethodEnum.getName("apply_take_empty_vehicle") + "apply_take_empty_vehicle 接口请求LMS...";
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, message + "参数:" + JSON.toJSONString(request)));
if (StrUtil.equals(resp.result, "true")) {
this.writing(this.mode);
this.setRequireSucess(true);
} else {
this.writing(400);
message = RequestMethodEnum.getName("apply_take_empty_vehicle") + "apply_take_empty_vehicle 接口请求失败" + resp.getComment();;
}
return true;
} else {
message = RequestMethodEnum.getName("apply_take_empty_vehicle") + "apply_take_empty_vehicle 设备有货未请求LMS...";
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, message));
return false;
}
}
/**
* 申请取走满料盅托盘
*
* @param
*/
public synchronized boolean apply_take_full_vehicle() {
if(move > 0) {
ApplyTaskRequest request = new ApplyTaskRequest();
request.setDevice_code(this.getDevice_code());
request.setRequest_medthod_code(this.getClass().getName());
request.setRequest_medthod_name(RequestMethodEnum.getName(this.getClass().getName()));
request.setWeight(String.valueOf(weight));
request.setVehicle_code(String.valueOf(barcode));
Resp resp = acsToWmsService.applyTask(request);
message = RequestMethodEnum.getName("apply_take_full_vehicle") + "apply_take_full_vehicle 接口请求LMS...";
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, message + "参数:" + JSON.toJSONString(request)));
if (StrUtil.equals(resp.result, "true")) {
this.writing(this.mode);
this.setRequireSucess(true);
} else {
this.writing(400);
message = RequestMethodEnum.getName("apply_take_full_vehicle") + "apply_take_full_vehicle 接口请求失败" + resp.getComment();;
}
return true;
} else {
message = RequestMethodEnum.getName("apply_take_full_vehicle") + "apply_take_full_vehicle 设备无货未请求LMS...";
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, message));
return false;
}
}
/**
* 申请强制取走满料盅托盘
*
* @param
*/
public synchronized boolean apply_force_take_full_vehicle() {
if(move > 0) {
ApplyTaskRequest request = new ApplyTaskRequest();
request.setDevice_code(this.getDevice_code());
request.setRequest_medthod_code(this.getClass().getName());
request.setRequest_medthod_name(RequestMethodEnum.getName(this.getClass().getName()));
request.setWeight(String.valueOf(weight));
request.setVehicle_code(String.valueOf(barcode));
Resp resp = acsToWmsService.applyTask(request);
message = RequestMethodEnum.getName("apply_force_take_full_vehicle") + "apply_force_take_full_vehicle 接口请求LMS...";
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, message + "参数:" + JSON.toJSONString(request)));
if (StrUtil.equals(resp.result, "true")) {
this.writing(this.mode);
this.setRequireSucess(true);
} else {
this.writing(400);
message = RequestMethodEnum.getName("apply_force_take_full_vehicle") + "apply_force_take_full_vehicle 接口请求失败" + resp.getComment();;
}
return true;
} else {
message = RequestMethodEnum.getName("apply_force_take_full_vehicle") + "apply_force_take_full_vehicle 设备无货未请求LMS...";
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, message));
return false;
}
}
/**
* 申请强制满托入缓存
*
* @param
*/
public synchronized boolean apply_force_take_full_vehicle_in_storage() {
if(move > 0) {
ApplyTaskRequest request = new ApplyTaskRequest();
request.setDevice_code(this.getDevice_code());
request.setRequest_medthod_code(this.getClass().getName());
request.setRequest_medthod_name(RequestMethodEnum.getName(this.getClass().getName()));
request.setWeight(String.valueOf(weight));
request.setVehicle_code(String.valueOf(barcode));
Resp resp = acsToWmsService.applyTask(request);
message = RequestMethodEnum.getName("apply_force_take_full_vehicle_in_storage") + "apply_force_take_full_vehicle_in_storage 接口请求LMS...";
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, message + "参数:" + JSON.toJSONString(request)));
if (StrUtil.equals(resp.result, "true")) {
this.writing(this.mode);
this.setRequireSucess(true);
} else {
this.writing(400);
message = RequestMethodEnum.getName("apply_force_take_full_vehicle_in_storage") + "apply_force_take_full_vehicle_in_storage 接口请求失败" + resp.getComment();;
}
return true;
} else {
message = RequestMethodEnum.getName("apply_force_take_full_vehicle_in_storage") + "apply_force_take_full_vehicle_in_storage 设备无货未请求LMS...";
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, message));
return false;
}
}
/**
* 扫码成功申请
*
* @param
*/
public synchronized boolean barcode_sucess_apply() {
if(move > 0) {
ApplyTaskRequest request = new ApplyTaskRequest();
request.setDevice_code(this.getDevice_code());
request.setRequest_medthod_code(this.getClass().getName());
request.setRequest_medthod_name(RequestMethodEnum.getName(this.getClass().getName()));
request.setWeight(String.valueOf(weight));
request.setVehicle_code(String.valueOf(barcode));
Resp resp = acsToWmsService.applyTask(request);
message = RequestMethodEnum.getName("barcode_sucess_apply") + "barcode_sucess_apply 接口请求LMS...";
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, message + "参数:" + JSON.toJSONString(request)));
if (StrUtil.equals(resp.result, "true")) {
this.writing(this.mode);
this.setRequireSucess(true);
} else {
this.writing(400);
message = RequestMethodEnum.getName("barcode_sucess_apply") + "barcode_sucess_apply 接口请求失败" + resp.getComment();;
}
return true;
} else {
message = RequestMethodEnum.getName("barcode_sucess_apply") + "barcode_sucess_apply 设备无货未请求LMS...";
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, message));
return false;
}
}
/**
* 获取组盘信息
*
* @param
*/
public synchronized boolean get_vehicle_info() {
if(move > 0) {
ApplyTaskRequest request = new ApplyTaskRequest();
request.setDevice_code(this.getDevice_code());
request.setRequest_medthod_code(this.getClass().getName());
request.setRequest_medthod_name(RequestMethodEnum.getName(this.getClass().getName()));
request.setWeight(String.valueOf(weight));
request.setVehicle_code(String.valueOf(barcode));
Resp resp = acsToWmsService.applyTask(request);
message = RequestMethodEnum.getName("get_vehicle_info") + "get_vehicle_info 接口请求LMS...";
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, message + "参数:" + JSON.toJSONString(request)));
if (StrUtil.equals(resp.result, "true")) {
this.writing(this.mode);
this.setRequireSucess(true);
} else {
this.writing(400);
message = RequestMethodEnum.getName("get_vehicle_info") + "get_vehicle_info 接口请求失败" + resp.getComment();;
}
return true;
} else {
message = RequestMethodEnum.getName("get_vehicle_info") + "get_vehicle_info 设备无货未请求LMS...";
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, message));
return false;
}
}
/**
* 强制去包装-不包装
*/
public synchronized boolean force_no_package() {
if(move > 0) {
ApplyTaskRequest request = new ApplyTaskRequest();
request.setDevice_code(this.getDevice_code());
request.setRequest_medthod_code(this.getClass().getName());
request.setRequest_medthod_name(RequestMethodEnum.getName(this.getClass().getName()));
request.setWeight(String.valueOf(weight));
request.setVehicle_code(String.valueOf(barcode));
Resp resp = acsToWmsService.applyTask(request);
message = RequestMethodEnum.getName("force_no_package") + "force_no_package 接口请求LMS...";
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, message + "参数:" + JSON.toJSONString(request)));
if (StrUtil.equals(resp.result, "true")) {
this.writing(this.mode);
this.setRequireSucess(true);
} else {
this.writing(400);
message = RequestMethodEnum.getName("force_no_package") + "force_no_package 接口请求失败" + resp.getComment();;
}
return true;
} else {
message = RequestMethodEnum.getName("force_no_package") + "force_no_package 设备无货未请求LMS...";
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, message));
return false;
}
}
/**
* 申请贴标
*/
public synchronized boolean apply_labelling() {
if(move > 0) {
ApplyTaskRequest request = new ApplyTaskRequest();
request.setDevice_code(this.getDevice_code());
request.setRequest_medthod_code(this.getClass().getName());
request.setRequest_medthod_name(RequestMethodEnum.getName(this.getClass().getName()));
request.setWeight(String.valueOf(weight));
request.setVehicle_code(String.valueOf(barcode));
Resp resp = acsToWmsService.applyTask(request);
message = RequestMethodEnum.getName("apply_labelling") + "apply_labelling 接口请求LMS...";
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, message + "参数:" + JSON.toJSONString(request)));
if (StrUtil.equals(resp.result, "true")) {
this.writing(this.mode);
this.setRequireSucess(true);
} else {
this.writing(400);
message = RequestMethodEnum.getName("apply_labelling") + "apply_labelling 接口请求失败" + resp.getComment();;
}
return true;
} else {
message = RequestMethodEnum.getName("apply_labelling") + "apply_labelling 设备无货未请求LMS...";
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, message));
return false;
}
}
}

147
acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/conveyor_press_station/ItemProtocol.java

@ -0,0 +1,147 @@
package org.nl.acs.device_driver.lnsh.conveyor_press_station;
import cn.hutool.core.util.StrUtil;
import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.nl.acs.device.device_driver.standard_inspect.ItemDto;
import java.util.ArrayList;
import java.util.List;
@Slf4j
@Getter
@Setter
public class ItemProtocol {
public static String item_heartbeat = "heartbeat";
public static String item_mode = "mode";
public static String item_move = "move";
public static String item_action = "action";
public static String item_ioaction = "ioaction";
public static String item_error = "error";
public static String item_task = "task";
public static String item_weight = "weight";
public static String item_material = "material";
public static String item_barcode = "barcode";
public static String item_to_command = "to_command";
public static String item_to_target = "to_target";
public static String item_to_task = "to_task";
public static String item_to_barcode = "to_barcode";
public static String item_to_mix_num = "to_mix_num";
Boolean isonline;
private ConveyorPressStationDeviceDriver driver;
public ItemProtocol(ConveyorPressStationDeviceDriver driver) {
this.driver = driver;
}
public int getHeartbeat() {
return this.getOpcIntegerValue(item_heartbeat);
}
public int getMode() {
return this.getOpcIntegerValue(item_mode);
}
public int getMove() {
return this.getOpcIntegerValue(item_move);
}
public int getAction() {
return this.getOpcIntegerValue(item_action);
}
public int getIoAction() {
return this.getOpcIntegerValue(item_ioaction);
}
public int getError() {
return this.getOpcIntegerValue(item_error);
}
public int getTask() {
return this.getOpcIntegerValue(item_task);
}
public int getWeight() {
return this.getOpcIntegerValue(item_weight);
}
public String getMaterial() {
return this.getOpcStringValue(item_material);
}
public int getBarcode() {
return this.getOpcIntegerValue(item_barcode);
}
public int getToCommand() {
return this.getOpcIntegerValue(item_to_command);
}
public int getToTarget() {
return this.getOpcIntegerValue(item_to_target);
}
public int getToTask() {
return this.getOpcIntegerValue(item_to_task);
}
//是否有货
public int hasGoods(int move) {
return move;
}
public int getOpcIntegerValue(String protocol) {
Integer value = this.driver.getIntegeregerValue(protocol);
if (value == null) {
// log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!");
setIsonline(false);
} else {
setIsonline(true);
return value;
}
return 0;
}
public String getOpcStringValue(String protocol) {
String value = this.driver.getStringValue(protocol);
if (StrUtil.isBlank(value)) {
// log.error("读取错误!");
} else {
return value;
}
return "0";
}
public static List<ItemDto> getReadableItemDtos() {
ArrayList list = new ArrayList();
list.add(new ItemDto(item_heartbeat, "心跳", "DB8.B0"));
list.add(new ItemDto(item_mode, "工作模式", "DB8.B1", Boolean.valueOf(true)));
list.add(new ItemDto(item_move, "光电开关信号", "DB8.B2"));
list.add(new ItemDto(item_action, "取放信号", "DB8.B3"));
list.add(new ItemDto(item_ioaction, "进出信号", "DB8.B4"));
list.add(new ItemDto(item_error, "报警信号", "DB8.B5"));
list.add(new ItemDto(item_task, "任务号", "DB8.D6"));
list.add(new ItemDto(item_weight, "重量", "DB8.D10"));
list.add(new ItemDto(item_material, "物料", "DB8.STRING14.50"));
list.add(new ItemDto(item_barcode, "条码", "DB8.W66"));
return list;
}
public static List<ItemDto> getWriteableItemDtos() {
ArrayList list = new ArrayList();
list.add(new ItemDto(item_to_command, "作业命令", "DB9.W0", Boolean.valueOf(true)));
list.add(new ItemDto(item_to_target, "目标站", "DB9.W2"));
list.add(new ItemDto(item_to_task, "任务号", "DB9.D4"));
list.add(new ItemDto(item_to_barcode, "条码", "DB9.W8"));
list.add(new ItemDto(item_to_mix_num, "碾次", "DB9.W10"));
return list;
}
}

5
acs/nladmin-ui/src/views/acs/device/config.vue

@ -99,6 +99,9 @@ import lnsh_Laminating_machine from '@/views/acs/device/driver/lnsh/lnsh_Laminat
import lnsh_package_site from '@/views/acs/device/driver/lnsh/lnsh_package_site'
import lnsh_crusher from '@/views/acs/device/driver/lnsh/lnsh_crusher'
import lnsh_palletizing_manipulator_site from '@/views/acs/device/driver/lnsh/lnsh_palletizing_manipulator_site'
import conveyor_ssx_barcode from '@/views/acs/device/driver/lnsh/conveyor_ssx_barcode'
import conveyor_press_station from '@/views/acs/device/driver/lnsh/conveyor_press_station'
export default {
name: 'DeviceConfig',
@ -106,7 +109,7 @@ export default {
lamp_three_color, standard_storage, standard_scanner, standard_conveyor_control_with_scanner,
standard_conveyor_control, standard_conveyor_monitor, lnsh_mixing_mill, lnsh_press, lnsh_palletizing_manipulator, lnsh_fold_disc_site, lnsh_kiln_lane, lnsh_kiln_truss,
lnsh_package_line, lnsh_out_kiln_truss, lnsh_package_pallet_manipulator, lnsh_pallet_storage, lnsh_labeling_machine, lnsh_split_manipulator, lnsh_rgv,
lnsh_station, lnsh_Laminating_machine, lnsh_package_site, lnsh_crusher, lnsh_palletizing_manipulator_site },
lnsh_station, lnsh_Laminating_machine, lnsh_package_site, lnsh_crusher, lnsh_palletizing_manipulator_site,conveyor_ssx_barcode, conveyor_press_station },
dicts: ['device_type'],
mixins: [crud],
data() {

623
acs/nladmin-ui/src/views/acs/device/driver/lnsh/conveyor_press_station.vue

@ -0,0 +1,623 @@
<template>
<!--压制对接位-->
<div>
<el-card class="box-card" shadow="never">
<div slot="header" class="clearfix">
<span class="role-span">设备协议</span>
</div>
<el-row>
<el-col :span="12">
OpcServer:
<el-select
v-model="opc_id"
placeholder="无"
clearable
filterable
@change="changeOpc"
>
<el-option
v-for="item in dataOpcservers"
:key="item.opc_id"
:label="item.opc_name"
:value="item.opc_id"
/>
</el-select>
</el-col>
<el-col :span="12">
PLC:
<el-select
v-model="plc_id"
placeholder="无"
clearable
@change="changePlc"
>
<el-option
v-for="item in dataOpcPlcs"
:key="item.plc_id"
:label="item.plc_name"
:value="item.plc_id"
/>
</el-select>
</el-col>
</el-row>
</el-card>
<el-card class="box-card" shadow="never">
<div slot="header" class="clearfix">
<span class="role-span">输送系统</span>
</div>
<el-form ref="form" :inline="true" :model="form" :rules="rules" size="small" label-width="78px">
<el-row>
<el-col :span="8">
<el-form-item label="电气调度号" label-width="150px">
<el-input v-model="form.OPCServer" />
</el-form-item>
</el-col>
</el-row>
</el-form>
</el-card>
<el-card class="box-card" shadow="never">
<div slot="header" class="clearfix">
<span class="role-span">指令相关</span>
</div>
<el-form ref="form" :inline="true" :model="form" :rules="rules" size="small" label-width="78px">
<el-row>
<el-col :span="8">
<el-form-item label="检验有货">
<el-switch v-model="form.inspect_in_stocck" />
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="忽视取货校验" label-width="150px">
<el-switch v-model="form.ignore_pickup_check" />
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="忽视放货校验" label-width="150px">
<el-switch v-model="form.ignore_release_check" />
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="8">
<el-form-item label="申请任务">
<el-switch v-model="form.apply_task" />
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="手动生成任务" label-width="150px">
<el-switch v-model="form.manual_create_task" />
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="8">
<el-form-item label="申请空盘" prop="device_code">
<el-select
v-model="form.apply_empty"
filterable
multiple
placeholder="请选择"
>
<el-option
v-for="item in deviceList"
:key="item.device_code"
:label="item.device_name"
:value="item.device_code"
/>
</el-select>
</el-form-item>
</el-col>
</el-row>
</el-form>
</el-card>
<el-card class="box-card" shadow="never">
<div slot="header" class="clearfix">
<span class="role-span">AGV相关</span>
</div>
<el-form ref="form" :inline="true" :model="form" :rules="rules" size="small" label-width="78px">
<el-row>
<el-col :span="8">
<el-form-item label="取货">
<el-switch v-model="form.pickup" />
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="放货">
<el-switch v-model="form.is_release" />
</el-form-item>
</el-col>
</el-row>
</el-form>
</el-card>
<el-card class="box-card" shadow="never">
<div slot="header" class="clearfix">
<span class="role-span">交互相关</span>
</div>
<div class="crud-opts2" style="margin-bottom: 5px;">
<span class="crud-opts-right2">
<!--左侧插槽-->
<slot name="left" />
<el-button
slot="left"
class="filter-item"
type="primary"
icon="el-icon-plus"
size="mini"
@click="insertdtl()"
>
新增一行
</el-button>
</span>
</div>
<div class="app-container">
<el-table :data="modeform.tableData" border fit highlight-current-row style="width: 100%;" class="tb-edit">
<el-table-column label="mode" prop="模式" width="180">
<template scope="scope">
<el-input-number value="3" :min="3" v-model="scope.row.mode" size="mini" />
<span v-show="scope.row.edit">{{ scope.row.mode }}</span>
</template>
</el-table-column>
<el-table-column label="request" prop="请求方法" width="180">
<template scope="scope">
<el-select
v-model="scope.row.request"
filterable
clearable
placeholder="请选择"
>
<el-option
v-for="item in requestMethodList"
:key="item.code"
:label="item.name"
:value="item.code"
/>
</el-select>
</template>
</el-table-column>
<el-table-column align="center" label="操作" width="170" >
<template scope="scope">
<el-button
type="danger"
class="filter-item"
size="mini"
icon="el-icon-delete"
@click.native.prevent="deleteRow(scope.$index, modeform.tableData)"
/>
</template>
</el-table-column>
</el-table>
</div>
</el-card>
<el-card class="box-card" shadow="never">
<div slot="header" class="clearfix">
<span class="role-span">PLC读取字段</span>
</div>
<el-form ref="form" :inline="true" :model="form" :rules="rules" size="small" label-width="78px">
<el-table
v-loading="false"
:data="data1"
:max-height="550"
size="small"
style="width: 100%;margin-bottom: 15px"
>
<el-table-column prop="name" label="用途" />
<el-table-column prop="code" label="别名要求" />
<el-table-column prop="db" label="DB块">
<template slot-scope="scope">
<el-input v-model="data1[scope.$index].db" size="mini" class="edit-input" @input="finishReadEdit(data1[scope.$index])" />
</template>
</el-table-column>
<el-table-column prop="dbr_value">
<template slot="header">
<el-link type="primary" :underline="false" @click.native="test_read1()">测试读</el-link>
</template>
<template slot-scope="scope">
<el-input v-model="data1[scope.$index].dbr_value" size="mini" class="edit-input" />
</template>
</el-table-column>
</el-table>
</el-form>
</el-card>
<el-card class="box-card" shadow="never">
<div slot="header" class="clearfix">
<span class="role-span">PLC写入字段</span>
</div>
<el-form ref="form" :inline="true" :model="form" :rules="rules" size="small" label-width="78px">
<el-table
v-loading="false"
:data="data2"
:max-height="550"
size="small"
style="width: 100%;margin-bottom: 15px"
>
<el-table-column prop="name" label="用途" />
<el-table-column prop="code" label="别名要求" />
<el-table-column prop="db" label="DB块">
<template slot-scope="scope">
<el-input v-model="data2[scope.$index].db" size="mini" class="edit-input" @input="finishWriteEdit(data2[scope.$index])" />
</template>
</el-table-column>
<el-table-column prop="dbr_value2">
<template slot="header">
<el-link type="primary" :underline="false" @click.native="test_read2()">测试读</el-link>
</template>
<template slot-scope="scope">
<el-input v-model="data2[scope.$index].dbr_value" size="mini" class="edit-input" />
</template>
</el-table-column>
<el-table-column prop="dbw_value">
<template slot="header">
<el-link type="primary" :underline="false" @click.native="test_write1()">测试写</el-link>
</template>
<template slot-scope="scope">
<el-input v-model="data2[scope.$index].dbw_value" size="mini" class="edit-input" />
</template>
</el-table-column>
</el-table>
</el-form>
</el-card>
<el-card class="box-card" shadow="never">
<div slot="header" class="clearfix">
<span class="role-span" />
<el-button
:loading="false"
icon="el-icon-check"
size="mini"
style="float: right; padding: 6px 9px"
type="primary"
@click="doSubmit"
>保存
</el-button>
</div>
</el-card>
</div>
</template>
<script>
import {
queryDriverConfig,
updateConfig,
testRead,
testwrite
} from '@/api/acs/device/driverConfig'
import { selectOpcList } from '@/api/acs/device/opc'
import { selectPlcList } from '@/api/acs/device/opcPlc'
import { selectListByOpcID } from '@/api/acs/device/opcPlc'
import crud from '@/mixins/crud'
import deviceCrud from '@/api/acs/device/device'
export default {
name: 'LnshStation',
mixins: [crud],
props: {
parentForm: {
type: Object,
require: true,
default() {
return {}
}
}
},
data() {
return {
device_code: '',
device_id: '',
plc_id: '',
plc_code: '',
opc_id: '',
opc_code: '',
configLoading: false,
dataOpcservers: [],
dataOpcPlcs: [],
requestMethodList: [],
data1: [],
data2: [],
modeform: {
tableData: [
// {
// mode: '3',
// request: 'order_verify'
// },
// {
// mode: '4',
// request: 'order_finish'
// },
{
mode: '5',
request: 'apply_put_full_vehicle'
},
{
mode: '6',
request: 'apply_put_empty_vehicle'
},
{
mode: '7',
request: 'apply_take_empty_vehicle'
},
{
mode: '8',
request: 'apply_take_full_vehicle'
},
{
mode: '9',
request: 'apply_force_take_full_vehicle'
},
{
mode: '10',
request: 'apply_force_take_full_vehicle_in_storage'
},
{
mode: '11',
request: 'barcode_sucess_apply'
},
{
mode: '12',
request: 'get_vehicle_info'
},
{
mode: '13',
request: 'force_no_package'
},
{
mode: '14',
request: 'apply_labelling'
}
]
},
form: {
inspect_in_stocck: true,
ignore_pickup_check: true,
ignore_release_check: true,
apply_task: true,
apply_empty: [],
manual_create_task: true,
is_pickup: true,
is_release: true
},
rules: {}
}
},
created() {
this.$nextTick(() => {
//
this.device_id = this.$props.parentForm.device_id
this.device_code = this.$props.parentForm.device_code
queryDriverConfig(this.device_id, this.$props.parentForm.driver_code).then(data => {
//
if (data.form) {
const arr = Object.keys(data.form)
//
if (arr.length > 0) {
this.form = data.form
}
}
//
if (data.parentForm) {
const arr = Object.keys(data.parentForm)
//
if (arr.length > 0) {
this.opc_code = data.parentForm.opc_code
this.plc_code = data.parentForm.plc_code
}
}
this.data1 = data.rs
this.data2 = data.ws
if (data.modeform) {
const arr = Object.keys(data.modeform)
//
if (arr.length > 0) {
this.modeform.tableData = data.modeform
}
}
this.sliceItem()
})
selectPlcList().then(data => {
this.dataOpcPlcs = data
this.plc_id = this.$props.parentForm.opc_plc_id
})
selectOpcList().then(data => {
this.dataOpcservers = data
this.opc_id = this.$props.parentForm.opc_server_id
})
deviceCrud.selectDeviceList().then(data => {
this.deviceList = data
})
deviceCrud.selectRequestMethodList().then(data => {
this.requestMethodList = data
})
})
},
methods: {
insertdtl() {
this.modeform.tableData.push({mode: '', request: '' })
},
deleteRow(index, rows) {
debugger
rows.splice(index, 1)
},
finishReadEdit(data) {
// code,mode
if (data.code.indexOf('mode') !== -1) {
const dbValue = data.db
// .
const beforeStr = dbValue.match(/(\S*)\./)[1]
// .
const afterStr = dbValue.match(/\.(\S*)/)[1]
//
const endNumber = afterStr.substring(1)
//
if (isNaN(parseInt(endNumber))) {
return
}
for (const val in this.data1) {
if (this.data1[val].code.indexOf('heartbeat') !== -1) {
this.data1[val].db = beforeStr + '.' + afterStr.substring(0, 1) + (parseInt(endNumber) - 1)
}
if (this.data1[val].code.indexOf('move') !== -1) {
this.data1[val].db = beforeStr + '.' + afterStr.substring(0, 1) + (parseInt(endNumber) + 1)
}
if (this.data1[val].code.indexOf('action') !== -1) {
this.data1[val].db = beforeStr + '.' + afterStr.substring(0, 1) + (parseInt(endNumber) + 2)
}
if (this.data1[val].code.indexOf('ioaction') !== -1) {
this.data1[val].db = beforeStr + '.' + afterStr.substring(0, 1) + (parseInt(endNumber) + 3)
}
if (this.data1[val].code.indexOf('error') !== -1) {
this.data1[val].db = beforeStr + '.' + afterStr.substring(0, 1) + (parseInt(endNumber) + 4)
}
if (this.data1[val].code.indexOf('task') !== -1) {
this.data1[val].db = beforeStr + '.' + 'D' + (parseInt(endNumber) + 5)
}
if (this.data1[val].code.indexOf('weight') !== -1) {
this.data1[val].db = beforeStr + '.' + 'D' + (parseInt(endNumber) + 9)
}
if (this.data1[val].code.indexOf('material') !== -1) {
this.data1[val].db = beforeStr + '.' + 'STRING' + (parseInt(endNumber) + 13) + '.50'
}
if (this.data1[val].code.indexOf('barcode') !== -1) {
this.data1[val].db = beforeStr + '.' + 'W' + (parseInt(endNumber) + 63)
}
}
}
},
finishWriteEdit(data) {
// code,mode
if (data.code.indexOf('to_command') !== -1) {
const dbValue = data.db
// .
const beforeStr = dbValue.match(/(\S*)\./)[1]
// .
const afterStr = dbValue.match(/\.(\S*)/)[1]
//
const endNumber = afterStr.substring(1)
//
if (isNaN(parseInt(endNumber))) {
return
}
for (const val in this.data2) {
if (this.data2[val].code.indexOf('to_target') !== -1) {
this.data2[val].db = beforeStr + '.' + afterStr.substring(0, 1) + (parseInt(endNumber) + 2)
}
if (this.data2[val].code.indexOf('to_task') !== -1) {
this.data2[val].db = beforeStr + '.' + 'D' + (parseInt(endNumber) + 4)
}
}
}
},
changeOpc(val) {
this.dataOpcservers.forEach(item => {
if (item.opc_id === val) {
this.opc_code = item.opc_code
}
})
selectListByOpcID(val).then(data => {
this.dataOpcPlcs = data
this.plc_id = ''
this.plc_code = ''
if (this.dataOpcPlcs && this.dataOpcPlcs.length > 0) {
this.plc_id = this.dataOpcPlcs[0].plc_id
this.plc_code = this.dataOpcPlcs[0].plc_code
}
this.sliceItem()
})
},
changePlc(val) {
this.dataOpcPlcs.forEach(item => {
if (item.plc_id === val) {
this.plc_code = item.plc_code
this.sliceItem()
return
}
})
},
test_read1() {
testRead(this.data1, this.opc_id).then(data => {
this.data1 = data
this.notify('操作成功!', 'success')
}).catch(err => {
console.log(err.response.data.message)
})
},
test_write1() {
testwrite(this.data2, this.opc_id).then(data => {
this.notify('操作成功!', 'success')
}).catch(err => {
console.log(err.response.data.message)
})
},
test_read2() {
testRead(this.data2, this.opc_id).then(data => {
this.data2 = data
console.log(this.data2)
this.notify('操作成功!', 'success')
}).catch(err => {
console.log(err.response.data.message)
})
},
doSubmit() {
this.$refs['form'].validate((valid) => {
if (valid) {
this.configLoading = true
//
const parentForm = this.parentForm
parentForm.is_route = true
parentForm.plc_id = this.plc_id
parentForm.opc_id = this.opc_id
updateConfig(parentForm, this.form, this.modeform, this.data1, this.data2).then(res => {
this.notify('保存成功', 'success')
this.configLoading = false
}).catch(err => {
this.configLoading = false
console.log(err.response.data.message)
})
}
})
},
sliceItem() { // DBItem
this.data1.forEach(item => {
const str = item.code
// .
if (str.search('.') !== -1) {
//
item.code = this.opc_code + '.' + this.plc_code + '.' + this.device_code + '.' + str.slice(str.lastIndexOf('.') + 1)
} else {
item.code = this.opc_code + '.' + this.plc_code + '.' + this.device_code + '.' + item.code
}
})
this.data2.forEach(item => {
const str = item.code
// .
if (str.search('.') !== -1) {
//
item.code = this.opc_code + '.' + this.plc_code + '.' + this.device_code + '.' + str.slice(str.lastIndexOf('.') + 1)
} else {
item.code = this.opc_code + '.' + this.plc_code + '.' + this.device_code + '.' + item.code
}
})
}
}
}
</script>
<style scoped>
</style>

623
acs/nladmin-ui/src/views/acs/device/driver/lnsh/conveyor_ssx_barcode.vue

@ -0,0 +1,623 @@
<template>
<!--输送线对接位-下发条码-->
<div>
<el-card class="box-card" shadow="never">
<div slot="header" class="clearfix">
<span class="role-span">设备协议</span>
</div>
<el-row>
<el-col :span="12">
OpcServer:
<el-select
v-model="opc_id"
placeholder="无"
clearable
filterable
@change="changeOpc"
>
<el-option
v-for="item in dataOpcservers"
:key="item.opc_id"
:label="item.opc_name"
:value="item.opc_id"
/>
</el-select>
</el-col>
<el-col :span="12">
PLC:
<el-select
v-model="plc_id"
placeholder="无"
clearable
@change="changePlc"
>
<el-option
v-for="item in dataOpcPlcs"
:key="item.plc_id"
:label="item.plc_name"
:value="item.plc_id"
/>
</el-select>
</el-col>
</el-row>
</el-card>
<el-card class="box-card" shadow="never">
<div slot="header" class="clearfix">
<span class="role-span">输送系统</span>
</div>
<el-form ref="form" :inline="true" :model="form" :rules="rules" size="small" label-width="78px">
<el-row>
<el-col :span="8">
<el-form-item label="电气调度号" label-width="150px">
<el-input v-model="form.OPCServer" />
</el-form-item>
</el-col>
</el-row>
</el-form>
</el-card>
<el-card class="box-card" shadow="never">
<div slot="header" class="clearfix">
<span class="role-span">指令相关</span>
</div>
<el-form ref="form" :inline="true" :model="form" :rules="rules" size="small" label-width="78px">
<el-row>
<el-col :span="8">
<el-form-item label="检验有货">
<el-switch v-model="form.inspect_in_stocck" />
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="忽视取货校验" label-width="150px">
<el-switch v-model="form.ignore_pickup_check" />
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="忽视放货校验" label-width="150px">
<el-switch v-model="form.ignore_release_check" />
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="8">
<el-form-item label="申请任务">
<el-switch v-model="form.apply_task" />
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="手动生成任务" label-width="150px">
<el-switch v-model="form.manual_create_task" />
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="8">
<el-form-item label="申请空盘" prop="device_code">
<el-select
v-model="form.apply_empty"
filterable
multiple
placeholder="请选择"
>
<el-option
v-for="item in deviceList"
:key="item.device_code"
:label="item.device_name"
:value="item.device_code"
/>
</el-select>
</el-form-item>
</el-col>
</el-row>
</el-form>
</el-card>
<el-card class="box-card" shadow="never">
<div slot="header" class="clearfix">
<span class="role-span">AGV相关</span>
</div>
<el-form ref="form" :inline="true" :model="form" :rules="rules" size="small" label-width="78px">
<el-row>
<el-col :span="8">
<el-form-item label="取货">
<el-switch v-model="form.pickup" />
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="放货">
<el-switch v-model="form.is_release" />
</el-form-item>
</el-col>
</el-row>
</el-form>
</el-card>
<el-card class="box-card" shadow="never">
<div slot="header" class="clearfix">
<span class="role-span">交互相关</span>
</div>
<div class="crud-opts2" style="margin-bottom: 5px;">
<span class="crud-opts-right2">
<!--左侧插槽-->
<slot name="left" />
<el-button
slot="left"
class="filter-item"
type="primary"
icon="el-icon-plus"
size="mini"
@click="insertdtl()"
>
新增一行
</el-button>
</span>
</div>
<div class="app-container">
<el-table :data="modeform.tableData" border fit highlight-current-row style="width: 100%;" class="tb-edit">
<el-table-column label="mode" prop="模式" width="180">
<template scope="scope">
<el-input-number value="3" :min="3" v-model="scope.row.mode" size="mini" />
<span v-show="scope.row.edit">{{ scope.row.mode }}</span>
</template>
</el-table-column>
<el-table-column label="request" prop="请求方法" width="180">
<template scope="scope">
<el-select
v-model="scope.row.request"
filterable
clearable
placeholder="请选择"
>
<el-option
v-for="item in requestMethodList"
:key="item.code"
:label="item.name"
:value="item.code"
/>
</el-select>
</template>
</el-table-column>
<el-table-column align="center" label="操作" width="170" >
<template scope="scope">
<el-button
type="danger"
class="filter-item"
size="mini"
icon="el-icon-delete"
@click.native.prevent="deleteRow(scope.$index, modeform.tableData)"
/>
</template>
</el-table-column>
</el-table>
</div>
</el-card>
<el-card class="box-card" shadow="never">
<div slot="header" class="clearfix">
<span class="role-span">PLC读取字段</span>
</div>
<el-form ref="form" :inline="true" :model="form" :rules="rules" size="small" label-width="78px">
<el-table
v-loading="false"
:data="data1"
:max-height="550"
size="small"
style="width: 100%;margin-bottom: 15px"
>
<el-table-column prop="name" label="用途" />
<el-table-column prop="code" label="别名要求" />
<el-table-column prop="db" label="DB块">
<template slot-scope="scope">
<el-input v-model="data1[scope.$index].db" size="mini" class="edit-input" @input="finishReadEdit(data1[scope.$index])" />
</template>
</el-table-column>
<el-table-column prop="dbr_value">
<template slot="header">
<el-link type="primary" :underline="false" @click.native="test_read1()">测试读</el-link>
</template>
<template slot-scope="scope">
<el-input v-model="data1[scope.$index].dbr_value" size="mini" class="edit-input" />
</template>
</el-table-column>
</el-table>
</el-form>
</el-card>
<el-card class="box-card" shadow="never">
<div slot="header" class="clearfix">
<span class="role-span">PLC写入字段</span>
</div>
<el-form ref="form" :inline="true" :model="form" :rules="rules" size="small" label-width="78px">
<el-table
v-loading="false"
:data="data2"
:max-height="550"
size="small"
style="width: 100%;margin-bottom: 15px"
>
<el-table-column prop="name" label="用途" />
<el-table-column prop="code" label="别名要求" />
<el-table-column prop="db" label="DB块">
<template slot-scope="scope">
<el-input v-model="data2[scope.$index].db" size="mini" class="edit-input" @input="finishWriteEdit(data2[scope.$index])" />
</template>
</el-table-column>
<el-table-column prop="dbr_value2">
<template slot="header">
<el-link type="primary" :underline="false" @click.native="test_read2()">测试读</el-link>
</template>
<template slot-scope="scope">
<el-input v-model="data2[scope.$index].dbr_value" size="mini" class="edit-input" />
</template>
</el-table-column>
<el-table-column prop="dbw_value">
<template slot="header">
<el-link type="primary" :underline="false" @click.native="test_write1()">测试写</el-link>
</template>
<template slot-scope="scope">
<el-input v-model="data2[scope.$index].dbw_value" size="mini" class="edit-input" />
</template>
</el-table-column>
</el-table>
</el-form>
</el-card>
<el-card class="box-card" shadow="never">
<div slot="header" class="clearfix">
<span class="role-span" />
<el-button
:loading="false"
icon="el-icon-check"
size="mini"
style="float: right; padding: 6px 9px"
type="primary"
@click="doSubmit"
>保存
</el-button>
</div>
</el-card>
</div>
</template>
<script>
import {
queryDriverConfig,
updateConfig,
testRead,
testwrite
} from '@/api/acs/device/driverConfig'
import { selectOpcList } from '@/api/acs/device/opc'
import { selectPlcList } from '@/api/acs/device/opcPlc'
import { selectListByOpcID } from '@/api/acs/device/opcPlc'
import crud from '@/mixins/crud'
import deviceCrud from '@/api/acs/device/device'
export default {
name: 'LnshStation',
mixins: [crud],
props: {
parentForm: {
type: Object,
require: true,
default() {
return {}
}
}
},
data() {
return {
device_code: '',
device_id: '',
plc_id: '',
plc_code: '',
opc_id: '',
opc_code: '',
configLoading: false,
dataOpcservers: [],
dataOpcPlcs: [],
requestMethodList: [],
data1: [],
data2: [],
modeform: {
tableData: [
// {
// mode: '3',
// request: 'order_verify'
// },
// {
// mode: '4',
// request: 'order_finish'
// },
{
mode: '5',
request: 'apply_put_full_vehicle'
},
{
mode: '6',
request: 'apply_put_empty_vehicle'
},
{
mode: '7',
request: 'apply_take_empty_vehicle'
},
{
mode: '8',
request: 'apply_take_full_vehicle'
},
{
mode: '9',
request: 'apply_force_take_full_vehicle'
},
{
mode: '10',
request: 'apply_force_take_full_vehicle_in_storage'
},
{
mode: '11',
request: 'barcode_sucess_apply'
},
{
mode: '12',
request: 'get_vehicle_info'
},
{
mode: '13',
request: 'force_no_package'
},
{
mode: '14',
request: 'apply_labelling'
}
]
},
form: {
inspect_in_stocck: true,
ignore_pickup_check: true,
ignore_release_check: true,
apply_task: true,
apply_empty: [],
manual_create_task: true,
is_pickup: true,
is_release: true
},
rules: {}
}
},
created() {
this.$nextTick(() => {
//
this.device_id = this.$props.parentForm.device_id
this.device_code = this.$props.parentForm.device_code
queryDriverConfig(this.device_id, this.$props.parentForm.driver_code).then(data => {
//
if (data.form) {
const arr = Object.keys(data.form)
//
if (arr.length > 0) {
this.form = data.form
}
}
//
if (data.parentForm) {
const arr = Object.keys(data.parentForm)
//
if (arr.length > 0) {
this.opc_code = data.parentForm.opc_code
this.plc_code = data.parentForm.plc_code
}
}
this.data1 = data.rs
this.data2 = data.ws
if (data.modeform) {
const arr = Object.keys(data.modeform)
//
if (arr.length > 0) {
this.modeform.tableData = data.modeform
}
}
this.sliceItem()
})
selectPlcList().then(data => {
this.dataOpcPlcs = data
this.plc_id = this.$props.parentForm.opc_plc_id
})
selectOpcList().then(data => {
this.dataOpcservers = data
this.opc_id = this.$props.parentForm.opc_server_id
})
deviceCrud.selectDeviceList().then(data => {
this.deviceList = data
})
deviceCrud.selectRequestMethodList().then(data => {
this.requestMethodList = data
})
})
},
methods: {
insertdtl() {
this.modeform.tableData.push({mode: '', request: '' })
},
deleteRow(index, rows) {
debugger
rows.splice(index, 1)
},
finishReadEdit(data) {
// code,mode
if (data.code.indexOf('mode') !== -1) {
const dbValue = data.db
// .
const beforeStr = dbValue.match(/(\S*)\./)[1]
// .
const afterStr = dbValue.match(/\.(\S*)/)[1]
//
const endNumber = afterStr.substring(1)
//
if (isNaN(parseInt(endNumber))) {
return
}
for (const val in this.data1) {
if (this.data1[val].code.indexOf('heartbeat') !== -1) {
this.data1[val].db = beforeStr + '.' + afterStr.substring(0, 1) + (parseInt(endNumber) - 1)
}
if (this.data1[val].code.indexOf('move') !== -1) {
this.data1[val].db = beforeStr + '.' + afterStr.substring(0, 1) + (parseInt(endNumber) + 1)
}
if (this.data1[val].code.indexOf('action') !== -1) {
this.data1[val].db = beforeStr + '.' + afterStr.substring(0, 1) + (parseInt(endNumber) + 2)
}
if (this.data1[val].code.indexOf('ioaction') !== -1) {
this.data1[val].db = beforeStr + '.' + afterStr.substring(0, 1) + (parseInt(endNumber) + 3)
}
if (this.data1[val].code.indexOf('error') !== -1) {
this.data1[val].db = beforeStr + '.' + afterStr.substring(0, 1) + (parseInt(endNumber) + 4)
}
if (this.data1[val].code.indexOf('task') !== -1) {
this.data1[val].db = beforeStr + '.' + 'D' + (parseInt(endNumber) + 5)
}
if (this.data1[val].code.indexOf('weight') !== -1) {
this.data1[val].db = beforeStr + '.' + 'D' + (parseInt(endNumber) + 9)
}
if (this.data1[val].code.indexOf('material') !== -1) {
this.data1[val].db = beforeStr + '.' + 'STRING' + (parseInt(endNumber) + 13) + '.50'
}
if (this.data1[val].code.indexOf('barcode') !== -1) {
this.data1[val].db = beforeStr + '.' + 'W' + (parseInt(endNumber) + 63)
}
}
}
},
finishWriteEdit(data) {
// code,mode
if (data.code.indexOf('to_command') !== -1) {
const dbValue = data.db
// .
const beforeStr = dbValue.match(/(\S*)\./)[1]
// .
const afterStr = dbValue.match(/\.(\S*)/)[1]
//
const endNumber = afterStr.substring(1)
//
if (isNaN(parseInt(endNumber))) {
return
}
for (const val in this.data2) {
if (this.data2[val].code.indexOf('to_target') !== -1) {
this.data2[val].db = beforeStr + '.' + afterStr.substring(0, 1) + (parseInt(endNumber) + 2)
}
if (this.data2[val].code.indexOf('to_task') !== -1) {
this.data2[val].db = beforeStr + '.' + 'D' + (parseInt(endNumber) + 4)
}
}
}
},
changeOpc(val) {
this.dataOpcservers.forEach(item => {
if (item.opc_id === val) {
this.opc_code = item.opc_code
}
})
selectListByOpcID(val).then(data => {
this.dataOpcPlcs = data
this.plc_id = ''
this.plc_code = ''
if (this.dataOpcPlcs && this.dataOpcPlcs.length > 0) {
this.plc_id = this.dataOpcPlcs[0].plc_id
this.plc_code = this.dataOpcPlcs[0].plc_code
}
this.sliceItem()
})
},
changePlc(val) {
this.dataOpcPlcs.forEach(item => {
if (item.plc_id === val) {
this.plc_code = item.plc_code
this.sliceItem()
return
}
})
},
test_read1() {
testRead(this.data1, this.opc_id).then(data => {
this.data1 = data
this.notify('操作成功!', 'success')
}).catch(err => {
console.log(err.response.data.message)
})
},
test_write1() {
testwrite(this.data2, this.opc_id).then(data => {
this.notify('操作成功!', 'success')
}).catch(err => {
console.log(err.response.data.message)
})
},
test_read2() {
testRead(this.data2, this.opc_id).then(data => {
this.data2 = data
console.log(this.data2)
this.notify('操作成功!', 'success')
}).catch(err => {
console.log(err.response.data.message)
})
},
doSubmit() {
this.$refs['form'].validate((valid) => {
if (valid) {
this.configLoading = true
//
const parentForm = this.parentForm
parentForm.is_route = true
parentForm.plc_id = this.plc_id
parentForm.opc_id = this.opc_id
updateConfig(parentForm, this.form, this.modeform, this.data1, this.data2).then(res => {
this.notify('保存成功', 'success')
this.configLoading = false
}).catch(err => {
this.configLoading = false
console.log(err.response.data.message)
})
}
})
},
sliceItem() { // DBItem
this.data1.forEach(item => {
const str = item.code
// .
if (str.search('.') !== -1) {
//
item.code = this.opc_code + '.' + this.plc_code + '.' + this.device_code + '.' + str.slice(str.lastIndexOf('.') + 1)
} else {
item.code = this.opc_code + '.' + this.plc_code + '.' + this.device_code + '.' + item.code
}
})
this.data2.forEach(item => {
const str = item.code
// .
if (str.search('.') !== -1) {
//
item.code = this.opc_code + '.' + this.plc_code + '.' + this.device_code + '.' + str.slice(str.lastIndexOf('.') + 1)
} else {
item.code = this.opc_code + '.' + this.plc_code + '.' + this.device_code + '.' + item.code
}
})
}
}
}
</script>
<style scoped>
</style>
Loading…
Cancel
Save