驱动更新
This commit is contained in:
@@ -21,8 +21,6 @@ public class HailiangFoldingDiscSmartDevice extends AbstractDriverService {
|
||||
mode = "脱机";
|
||||
} else if (hailiangFoldingDiscSmartDeviceDriver.getMode() == 2) {
|
||||
mode = "待机";
|
||||
} else if (hailiangFoldingDiscSmartDeviceDriver.getMode() == 3) {
|
||||
mode = "运行中";
|
||||
}
|
||||
if (hailiangFoldingDiscSmartDeviceDriver.getMove() == 0) {
|
||||
move = "无货";
|
||||
@@ -32,6 +30,7 @@ public class HailiangFoldingDiscSmartDevice extends AbstractDriverService {
|
||||
jo.put("mode", mode);
|
||||
jo.put("move", move);
|
||||
jo.put("number", hailiangFoldingDiscSmartDeviceDriver.getNumber());
|
||||
jo.put("container_type", hailiangFoldingDiscSmartDeviceDriver.getContainer_type());
|
||||
jo.put("hasGoods", hailiangFoldingDiscSmartDeviceDriver.getHasGoods());
|
||||
jo.put("isOnline", hailiangFoldingDiscSmartDeviceDriver.getIsonline());
|
||||
jo.put("error", hailiangFoldingDiscSmartDeviceDriver.getError());
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
package org.nl.acs.common;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_paint_line.HailiangPaintLineDeviceDriver;
|
||||
import org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_threeStation_smart.HailiangThreestationSmartDeviceDriver;
|
||||
import org.nl.acs.opc.Device;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service("hailiang_paint_line")
|
||||
public class HailiangPaintLineDevice extends AbstractDriverService {
|
||||
|
||||
@Override
|
||||
public JSONObject getDeviceInfo(Device device) {
|
||||
HailiangPaintLineDeviceDriver hailiangPaintLineDeviceDriver = (HailiangPaintLineDeviceDriver) device.getDeviceDriver();
|
||||
JSONObject jo = super.getCommonDeviceInfo(hailiangPaintLineDeviceDriver);
|
||||
|
||||
String mode = "";
|
||||
String move = "";
|
||||
String action = "";
|
||||
if (hailiangPaintLineDeviceDriver.getMode() == 0) {
|
||||
mode = "脱机";
|
||||
} else if (hailiangPaintLineDeviceDriver.getMode() == 2) {
|
||||
mode = "待机";
|
||||
} else if (hailiangPaintLineDeviceDriver.getMode() == 3) {
|
||||
mode = "运行中";
|
||||
} else if (hailiangPaintLineDeviceDriver.getMode() == 5) {
|
||||
mode = "下料位申请空盘";
|
||||
} else if (hailiangPaintLineDeviceDriver.getMode() == 6) {
|
||||
mode = "下料位满拖申请";
|
||||
} else if (hailiangPaintLineDeviceDriver.getMode() == 7) {
|
||||
mode = "上料位满拖申请";
|
||||
} else if (hailiangPaintLineDeviceDriver.getMode() == 8) {
|
||||
mode = "上料位空托入库";
|
||||
} else if (hailiangPaintLineDeviceDriver.getMode() == 9) {
|
||||
mode = "强制满垛入库请求";
|
||||
}
|
||||
if (hailiangPaintLineDeviceDriver.getMove() == 0) {
|
||||
move = "无货";
|
||||
} else if (hailiangPaintLineDeviceDriver.getMove() == 1) {
|
||||
move = "有货";
|
||||
}
|
||||
if (hailiangPaintLineDeviceDriver.getAction() == 1) {
|
||||
action = "允许取货";
|
||||
} else if (hailiangPaintLineDeviceDriver.getAction() == 2) {
|
||||
action = "允许放货";
|
||||
} else if (hailiangPaintLineDeviceDriver.getAction() == 3) {
|
||||
action = "允许取放";
|
||||
}
|
||||
jo.put("mode", mode);
|
||||
jo.put("move", move);
|
||||
jo.put("action", action);
|
||||
jo.put("number", hailiangPaintLineDeviceDriver.getNumber());
|
||||
jo.put("hasGoods", hailiangPaintLineDeviceDriver.getHasGoods());
|
||||
jo.put("isOnline", hailiangPaintLineDeviceDriver.getIsonline());
|
||||
jo.put("error", hailiangPaintLineDeviceDriver.getError());
|
||||
jo.put("isError", hailiangPaintLineDeviceDriver.getIserror());
|
||||
jo.put("message", hailiangPaintLineDeviceDriver.getMessage());
|
||||
return jo;
|
||||
}
|
||||
}
|
||||
@@ -23,6 +23,8 @@ public class HailiangThreestationSmartDevice extends AbstractDriverService {
|
||||
mode = "待机";
|
||||
} else if (threestationSmartDeviceDriver.getMode() == 3) {
|
||||
mode = "运行中";
|
||||
} else if (threestationSmartDeviceDriver.getMode() == 4) {
|
||||
mode = "申请空盘";
|
||||
}
|
||||
if (threestationSmartDeviceDriver.getMove() == 0) {
|
||||
move = "无货";
|
||||
@@ -41,6 +43,8 @@ public class HailiangThreestationSmartDevice extends AbstractDriverService {
|
||||
jo.put("mode", mode);
|
||||
jo.put("move", move);
|
||||
jo.put("action", action);
|
||||
jo.put("number", threestationSmartDeviceDriver.getNumber());
|
||||
jo.put("container_type", threestationSmartDeviceDriver.getContainer_type());
|
||||
jo.put("hasGoods", threestationSmartDeviceDriver.getHasGoods());
|
||||
jo.put("isOnline", threestationSmartDeviceDriver.getIsonline());
|
||||
jo.put("error", threestationSmartDeviceDriver.getError());
|
||||
|
||||
@@ -69,7 +69,9 @@ public enum DriverTypeEnum {
|
||||
|
||||
HAILIANG_FOLDINGDISC_SMART(30, "hailiang_foldingDisc_smart", "海亮-叠盘位Smart200", "conveyor"),
|
||||
|
||||
HAILIANG_ELEVATOR_WIRING(31, "hailiang_elevator_wiring", "海亮-货梯对接线", "conveyor");
|
||||
HAILIANG_ELEVATOR_WIRING(31, "hailiang_elevator_wiring", "海亮-货梯对接线", "conveyor"),
|
||||
|
||||
HAILIANG_PAINT_LINE(32, "hailiang_paint_line", "海亮-油漆线", "conveyor");
|
||||
|
||||
//驱动索引
|
||||
private int index;
|
||||
|
||||
@@ -60,6 +60,7 @@ public class HailiangFoldingDiscSmartDefination implements OpcDeviceDriverDefina
|
||||
list.add(new ItemDto(ItemProtocol.item_mode, "工作状态", "VW2", Boolean.valueOf(true)));
|
||||
list.add(new ItemDto(ItemProtocol.item_move, "光电信号", "VW4"));
|
||||
list.add(new ItemDto(ItemProtocol.item_number, "数量", "VW6"));
|
||||
list.add(new ItemDto(ItemProtocol.item_container_type, "托盘类型", "VW8"));
|
||||
list.add(new ItemDto(ItemProtocol.item_error, "报警信号", "VW10"));
|
||||
list.add(new ItemDto(ItemProtocol.item_task, "任务号", "VD12"));
|
||||
return list;
|
||||
|
||||
@@ -42,10 +42,7 @@ public class HailiangFoldingDiscSmartDeviceDriver extends AbstractOpcDeviceDrive
|
||||
TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl");
|
||||
@Autowired
|
||||
LogServer logServer = SpringContextHolder.getBean(LogServer.class);
|
||||
String container;
|
||||
String container_type_desc;
|
||||
String last_container_type_desc;
|
||||
String last_container;
|
||||
|
||||
//放货准备锁
|
||||
String putReadyLock = null;
|
||||
//有货标记
|
||||
@@ -56,11 +53,13 @@ public class HailiangFoldingDiscSmartDeviceDriver extends AbstractOpcDeviceDrive
|
||||
int move = 0;
|
||||
int task = 0;
|
||||
int number = 0;
|
||||
int container_type = 0;
|
||||
int last_mode = 0;
|
||||
int last_error = 0;
|
||||
int last_move = 0;
|
||||
int last_task = 0;
|
||||
int last_number = 0;
|
||||
int last_container_type = 0;
|
||||
Boolean isonline = true;
|
||||
int hasGoods = 0;
|
||||
String message = null;
|
||||
@@ -125,6 +124,7 @@ public class HailiangFoldingDiscSmartDeviceDriver extends AbstractOpcDeviceDrive
|
||||
move = this.itemProtocol.getMove();
|
||||
task = this.itemProtocol.getTask();
|
||||
hasGoods = this.itemProtocol.getMove();
|
||||
container_type = this.itemProtocol.getContainer_type();
|
||||
|
||||
if (mode != last_mode) {
|
||||
this.setRequireSucess(false);
|
||||
@@ -140,9 +140,13 @@ public class HailiangFoldingDiscSmartDeviceDriver extends AbstractOpcDeviceDrive
|
||||
logServer.deviceLogToacs(this.device_code,"","","信号error:" + last_error + "->" + error);
|
||||
}
|
||||
if (number != last_number) {
|
||||
logServer.deviceLog(this.device_code,"action" ,String.valueOf(number));
|
||||
logServer.deviceLog(this.device_code,"number" ,String.valueOf(number));
|
||||
logServer.deviceLogToacs(this.device_code,"","","信号number:" + last_number + "->" + number);
|
||||
}
|
||||
if (container_type != last_container_type) {
|
||||
logServer.deviceLog(this.device_code,"container_type" ,String.valueOf(container_type));
|
||||
logServer.deviceLogToacs(this.device_code,"","","信号container_type:" + last_container_type + "->" + container_type);
|
||||
}
|
||||
|
||||
} catch (Exception var17) {
|
||||
return;
|
||||
@@ -195,6 +199,7 @@ public class HailiangFoldingDiscSmartDeviceDriver extends AbstractOpcDeviceDrive
|
||||
last_move = move;
|
||||
last_task = task;
|
||||
last_number = number;
|
||||
last_container_type = container_type;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ public class ItemProtocol {
|
||||
public static String item_mode = "mode";
|
||||
public static String item_move = "move";
|
||||
public static String item_number = "number";
|
||||
public static String item_container_type = "container_type";
|
||||
public static String item_error = "error";
|
||||
public static String item_task = "task";
|
||||
public static String item_to_command = "to_command";
|
||||
@@ -44,6 +45,10 @@ public class ItemProtocol {
|
||||
return this.getOpcIntegerValue(item_number);
|
||||
}
|
||||
|
||||
public int getContainer_type() {
|
||||
return this.getOpcIntegerValue(item_container_type);
|
||||
}
|
||||
|
||||
public int getError() {
|
||||
return this.getOpcIntegerValue(item_error);
|
||||
}
|
||||
@@ -90,6 +95,7 @@ public class ItemProtocol {
|
||||
list.add(new ItemDto(item_mode, "工作状态", "VW2", Boolean.valueOf(true)));
|
||||
list.add(new ItemDto(item_move, "光电信号", "VW4"));
|
||||
list.add(new ItemDto(item_number, "数量", "VW6"));
|
||||
list.add(new ItemDto(item_container_type, "托盘类型", "VW8"));
|
||||
list.add(new ItemDto(item_error, "报警信号", "VW10"));
|
||||
list.add(new ItemDto(item_task, "任务号", "VD12"));
|
||||
return list;
|
||||
@@ -97,9 +103,9 @@ public class ItemProtocol {
|
||||
|
||||
public static List<ItemDto> getWriteableItemDtos() {
|
||||
ArrayList list = new ArrayList();
|
||||
list.add(new ItemDto(item_to_command, "作业命令", "VW102", Boolean.valueOf(true)));
|
||||
list.add(new ItemDto(item_to_target, "目标站", "VW104"));
|
||||
list.add(new ItemDto(item_to_task, "任务号", "VD108"));
|
||||
list.add(new ItemDto(item_to_command, "作业命令", "VW52", Boolean.valueOf(true)));
|
||||
list.add(new ItemDto(item_to_target, "目标站", "VW54"));
|
||||
list.add(new ItemDto(item_to_task, "任务号", "VD58"));
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
package org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_paint_line;
|
||||
|
||||
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.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 海亮-油漆线
|
||||
*/
|
||||
@Service
|
||||
public class HailiangPaintLineDefination implements OpcDeviceDriverDefination {
|
||||
@Override
|
||||
public String getDriverCode() {
|
||||
return "hailiang_paint_line";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDriverName() {
|
||||
return "海亮-油漆线";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDriverDescription() {
|
||||
return "海亮-油漆线";
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeviceDriver getDriverInstance(Device device) {
|
||||
return (new HailiangPaintLineDeviceDriver()).setDevice(device).setDriverDefination(this);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends DeviceDriver> getDeviceDriverType() {
|
||||
return HailiangPaintLineDeviceDriver.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DeviceType> getFitDeviceTypes() {
|
||||
List<DeviceType> types = new LinkedList();
|
||||
types.add(DeviceType.conveyor);
|
||||
return types;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemDto> getReadableItemDtos() {
|
||||
return getReadableItemDtos2();
|
||||
}
|
||||
|
||||
public static List<ItemDto> getReadableItemDtos2() {
|
||||
List<ItemDto> list = new ArrayList();
|
||||
list.add(new ItemDto(ItemProtocol.item_heartbeat, "心跳", "DB600.B0"));
|
||||
list.add(new ItemDto(ItemProtocol.item_mode, "工作状态", "DB600.B2", Boolean.valueOf(true)));
|
||||
list.add(new ItemDto(ItemProtocol.item_move, "光电信号", "DB600.B3"));
|
||||
list.add(new ItemDto(ItemProtocol.item_action, "取放信号", "DB600.B4"));
|
||||
list.add(new ItemDto(ItemProtocol.item_error, "报警信号", "DB600.B6"));
|
||||
list.add(new ItemDto(ItemProtocol.item_number, "数量", "DB600.B7"));
|
||||
list.add(new ItemDto(ItemProtocol.item_task, "任务号", "DB600.D8"));
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemDto> getWriteableItemDtos() {
|
||||
return ItemProtocol.getWriteableItemDtos();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,257 @@
|
||||
package org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_paint_line;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
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.RouteableDeviceDriver;
|
||||
import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver;
|
||||
import org.nl.acs.device_driver.driver.ExecutableDeviceDriver;
|
||||
import org.nl.acs.instruction.service.InstructionService;
|
||||
import org.nl.acs.instruction.service.dto.Instruction;
|
||||
import org.nl.acs.log.service.LogServer;
|
||||
import org.nl.acs.opc.Device;
|
||||
import org.nl.acs.route.service.RouteLineService;
|
||||
import org.nl.acs.task.service.TaskService;
|
||||
import org.nl.utils.SpringContextHolder;
|
||||
import org.openscada.opc.lib.da.Server;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 海亮-油漆线
|
||||
*/
|
||||
@Slf4j
|
||||
@Data
|
||||
@RequiredArgsConstructor
|
||||
public class HailiangPaintLineDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver {
|
||||
protected ItemProtocol itemProtocol = new ItemProtocol(this);
|
||||
@Autowired
|
||||
InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl");
|
||||
@Autowired
|
||||
DeviceService deviceservice = SpringContextHolder.getBean("deviceServiceImpl");
|
||||
@Autowired
|
||||
RouteLineService routelineserver = SpringContextHolder.getBean("routeLineServiceImpl");
|
||||
@Autowired
|
||||
TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl");
|
||||
@Autowired
|
||||
LogServer logServer = SpringContextHolder.getBean(LogServer.class);
|
||||
|
||||
//放货准备锁
|
||||
String putReadyLock = null;
|
||||
//有货标记
|
||||
protected boolean has_goods_tag = false;
|
||||
|
||||
int mode = 0;
|
||||
int error = 0;
|
||||
int move = 0;
|
||||
int task = 0;
|
||||
int action = 0;
|
||||
int number = 0;
|
||||
int last_mode = 0;
|
||||
int last_error = 0;
|
||||
int last_move = 0;
|
||||
int last_task = 0;
|
||||
int last_action = 0;
|
||||
int last_number = 0;
|
||||
Boolean isonline = true;
|
||||
int hasGoods = 0;
|
||||
String message = null;
|
||||
Boolean iserror = false;
|
||||
|
||||
|
||||
boolean hasVehicle = false;
|
||||
boolean isReady = false;
|
||||
protected int instruction_num = 0;
|
||||
protected int instruction_num_truth = 0;
|
||||
boolean isFold = false;
|
||||
private String assemble_check_tag;
|
||||
|
||||
protected String current_stage_instruction_message;
|
||||
protected String last_stage_instruction_message;
|
||||
Integer heartbeat_tag;
|
||||
private Date instruction_require_time = new Date();
|
||||
private Date instruction_finished_time = new Date();
|
||||
|
||||
private int instruction_require_time_out;
|
||||
boolean requireSucess = false;
|
||||
|
||||
private int instruction_finished_time_out;
|
||||
|
||||
int branchProtocol = 0;
|
||||
//备注
|
||||
String remark;
|
||||
//物料
|
||||
String material;
|
||||
//当前指令
|
||||
Instruction inst = null;
|
||||
//上次指令
|
||||
Instruction last_inst = null;
|
||||
|
||||
//触摸屏手动触发任务
|
||||
private Boolean is_has_task = false;
|
||||
|
||||
//申请搬运任务
|
||||
private Boolean apply_handling = false;
|
||||
//申请物料
|
||||
private Boolean apply_material = false;
|
||||
|
||||
//暂定 0就绪 1请求取货 2取货完成 3请求放货 4放货完成 5取货完成离开 6放货完成离开 7请求进入区域 8请求离开区域
|
||||
int flag;
|
||||
|
||||
String device_code;
|
||||
|
||||
@Override
|
||||
public Device getDevice() {
|
||||
return this.device;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
String message = null;
|
||||
try {
|
||||
device_code = this.getDeviceCode();
|
||||
mode = this.itemProtocol.getMode();
|
||||
error = this.itemProtocol.getError();
|
||||
action = this.itemProtocol.getAction();
|
||||
move = this.itemProtocol.getMove();
|
||||
number = this.itemProtocol.getNumber();
|
||||
task = this.itemProtocol.getTask();
|
||||
hasGoods = this.itemProtocol.getMove();
|
||||
|
||||
if (mode != last_mode) {
|
||||
this.setRequireSucess(false);
|
||||
logServer.deviceLog(this.device_code,"mode" ,String.valueOf(mode));
|
||||
logServer.deviceLogToacs(this.device_code,"","","信号mode:" + last_mode + "->" + mode);
|
||||
}
|
||||
if (move != last_move) {
|
||||
logServer.deviceLog(this.device_code,"move" ,String.valueOf(move));
|
||||
logServer.deviceLogToacs(this.device_code,"","","信号move:" + last_move + "->" + move);
|
||||
}
|
||||
if (error != last_error) {
|
||||
logServer.deviceLog(this.device_code,"error" ,String.valueOf(error));
|
||||
logServer.deviceLogToacs(this.device_code,"","","信号error:" + last_error + "->" + error);
|
||||
}
|
||||
if (action != last_action) {
|
||||
logServer.deviceLog(this.device_code,"action" ,String.valueOf(action));
|
||||
logServer.deviceLogToacs(this.device_code,"","","信号action:" + last_action + "->" + action);
|
||||
}
|
||||
if (number != last_number) {
|
||||
logServer.deviceLog(this.device_code,"number" ,String.valueOf(number));
|
||||
logServer.deviceLogToacs(this.device_code,"","","信号number:" + last_number + "->" + number);
|
||||
}
|
||||
|
||||
} catch (Exception var17) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.itemProtocol.getIsonline()) {
|
||||
this.setIsonline(false);
|
||||
this.setIserror(true);
|
||||
message = "信号量同步异常";
|
||||
//未联机
|
||||
} 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;
|
||||
switch (mode) {
|
||||
case 1:
|
||||
log.debug("设备运转模式:等待工作");
|
||||
return;
|
||||
case 2:
|
||||
break;
|
||||
}
|
||||
|
||||
switch (flag) {
|
||||
//取货完成
|
||||
case 1:
|
||||
writing(2);
|
||||
return;
|
||||
//放货完成
|
||||
case 2:
|
||||
writing(3);
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
last_mode = mode;
|
||||
last_error = error;
|
||||
last_move = move;
|
||||
last_task = task;
|
||||
last_action = action;
|
||||
last_number = number;
|
||||
}
|
||||
|
||||
|
||||
public boolean exe_error() {
|
||||
if (this.error == 0) {
|
||||
return true;
|
||||
} else {
|
||||
log.debug("设备报警");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public boolean exe_business() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void executing(Server server, Map<String, Object> itemMap) {
|
||||
ReadUtil.write(itemMap, server);
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
}
|
||||
|
||||
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);
|
||||
} else if (type == 2) {
|
||||
itemMap.put(to_target, command);
|
||||
|
||||
} else if (type == 3) {
|
||||
itemMap.put(to_task, command);
|
||||
}
|
||||
ReadUtil.write(itemMap, server);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
package org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_paint_line;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.acs.device.device_driver.standard_inspect.ItemDto;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Data
|
||||
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_error = "error";
|
||||
public static String item_number = "number";
|
||||
public static String item_task = "task";
|
||||
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_weight = "weight";
|
||||
|
||||
private HailiangPaintLineDeviceDriver driver;
|
||||
|
||||
public ItemProtocol(HailiangPaintLineDeviceDriver 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 getError() {
|
||||
return this.getOpcIntegerValue(item_error);
|
||||
}
|
||||
|
||||
public int getNumber() {
|
||||
return this.getOpcIntegerValue(item_number);
|
||||
}
|
||||
|
||||
public int getTask() {
|
||||
return this.getOpcIntegerValue(item_task);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
Boolean isonline;
|
||||
|
||||
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 static List<ItemDto> getReadableItemDtos() {
|
||||
ArrayList list = new ArrayList();
|
||||
list.add(new ItemDto(item_heartbeat, "心跳", "DB600.B0"));
|
||||
list.add(new ItemDto(item_mode, "工作状态", "DB600.B2", Boolean.valueOf(true)));
|
||||
list.add(new ItemDto(item_move, "光电信号", "DB600.B3"));
|
||||
list.add(new ItemDto(item_action, "取放信号", "DB600.B4"));
|
||||
list.add(new ItemDto(item_error, "报警信号", "DB600.B6"));
|
||||
list.add(new ItemDto(item_number, "数量", "DB600.B7"));
|
||||
list.add(new ItemDto(item_task, "任务号", "DB600.D8"));
|
||||
return list;
|
||||
}
|
||||
|
||||
public static List<ItemDto> getWriteableItemDtos() {
|
||||
ArrayList list = new ArrayList();
|
||||
list.add(new ItemDto(item_to_command, "作业命令", "DB601.W2", Boolean.valueOf(true)));
|
||||
list.add(new ItemDto(item_to_target, "目标站", "DB601.W4"));
|
||||
list.add(new ItemDto(item_to_task, "任务号", "DB601.D8"));
|
||||
return list;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -61,7 +61,9 @@ public class HailiangThreestationSmartDefination implements OpcDeviceDriverDefin
|
||||
list.add(new ItemDto(ItemProtocol.item_move, "光电信号", "VW4"));
|
||||
list.add(new ItemDto(ItemProtocol.item_action, "取放信号", "VW6"));
|
||||
list.add(new ItemDto(ItemProtocol.item_error, "报警信号", "VW8"));
|
||||
list.add(new ItemDto(ItemProtocol.item_task, "任务号", "VD10"));
|
||||
list.add(new ItemDto(ItemProtocol.item_number, "数量", "VW10"));
|
||||
list.add(new ItemDto(ItemProtocol.item_container_type, "托盘类型", "VW12"));
|
||||
list.add(new ItemDto(ItemProtocol.item_task, "任务号", "VD14"));
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
@@ -53,10 +53,8 @@ public class HailiangThreestationSmartDeviceDriver extends AbstractOpcDeviceDriv
|
||||
TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl");
|
||||
@Autowired
|
||||
LogServer logServer = SpringContextHolder.getBean(LogServer.class);
|
||||
String container;
|
||||
String container_type_desc;
|
||||
String last_container_type_desc;
|
||||
String last_container;
|
||||
//放货准备锁
|
||||
String putReadyLock = null;
|
||||
//有货标记
|
||||
@@ -67,11 +65,15 @@ public class HailiangThreestationSmartDeviceDriver extends AbstractOpcDeviceDriv
|
||||
int move = 0;
|
||||
int task = 0;
|
||||
int action = 0;
|
||||
int number = 0;
|
||||
int container_type = 0;
|
||||
int last_mode = 0;
|
||||
int last_error = 0;
|
||||
int last_move = 0;
|
||||
int last_task = 0;
|
||||
int last_action = 0;
|
||||
int last_number = 0;
|
||||
int last_container_type = 0;
|
||||
Boolean isonline = true;
|
||||
int hasGoods = 0;
|
||||
String message = null;
|
||||
@@ -134,6 +136,8 @@ public class HailiangThreestationSmartDeviceDriver extends AbstractOpcDeviceDriv
|
||||
error = this.itemProtocol.getError();
|
||||
action = this.itemProtocol.getAction();
|
||||
move = this.itemProtocol.getMove();
|
||||
number = this.itemProtocol.getNumber();
|
||||
container_type = this.itemProtocol.getContainer_type();
|
||||
task = this.itemProtocol.getTask();
|
||||
hasGoods = this.itemProtocol.getMove();
|
||||
|
||||
@@ -154,6 +158,14 @@ public class HailiangThreestationSmartDeviceDriver extends AbstractOpcDeviceDriv
|
||||
logServer.deviceLog(this.device_code,"action" ,String.valueOf(action));
|
||||
logServer.deviceLogToacs(this.device_code,"","","信号action:" + last_action + "->" + action);
|
||||
}
|
||||
if (container_type != last_container_type) {
|
||||
logServer.deviceLog(this.device_code,"container_type" ,String.valueOf(container_type));
|
||||
logServer.deviceLogToacs(this.device_code,"","","信号container_type:" + last_container_type + "->" + container_type);
|
||||
}
|
||||
if (number != last_number) {
|
||||
logServer.deviceLog(this.device_code,"number" ,String.valueOf(number));
|
||||
logServer.deviceLogToacs(this.device_code,"","","信号number:" + last_number + "->" + number);
|
||||
}
|
||||
|
||||
} catch (Exception var17) {
|
||||
return;
|
||||
@@ -206,6 +218,8 @@ public class HailiangThreestationSmartDeviceDriver extends AbstractOpcDeviceDriv
|
||||
last_move = move;
|
||||
last_task = task;
|
||||
last_action = action;
|
||||
last_number = number;
|
||||
last_container_type = container_type;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -16,6 +16,8 @@ public class ItemProtocol {
|
||||
public static String item_move = "move";
|
||||
public static String item_action = "action";
|
||||
public static String item_error = "error";
|
||||
public static String item_number = "number";
|
||||
public static String item_container_type = "container_type";
|
||||
public static String item_task = "task";
|
||||
public static String item_to_command = "to_command";
|
||||
public static String item_to_target = "to_target";
|
||||
@@ -48,6 +50,14 @@ public class ItemProtocol {
|
||||
return this.getOpcIntegerValue(item_error);
|
||||
}
|
||||
|
||||
public int getNumber() {
|
||||
return this.getOpcIntegerValue(item_number);
|
||||
}
|
||||
|
||||
public int getContainer_type() {
|
||||
return this.getOpcIntegerValue(item_container_type);
|
||||
}
|
||||
|
||||
public int getTask() {
|
||||
return this.getOpcIntegerValue(item_task);
|
||||
}
|
||||
@@ -91,7 +101,9 @@ public class ItemProtocol {
|
||||
list.add(new ItemDto(item_move, "光电信号", "VW4"));
|
||||
list.add(new ItemDto(item_action, "取放信号", "VW6"));
|
||||
list.add(new ItemDto(item_error, "报警信号", "VW8"));
|
||||
list.add(new ItemDto(item_task, "任务号", "VD10"));
|
||||
list.add(new ItemDto(item_number, "数量", "VW10"));
|
||||
list.add(new ItemDto(item_container_type, "托盘类型", "VW12"));
|
||||
list.add(new ItemDto(item_task, "任务号", "VD14"));
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
@@ -275,76 +275,6 @@ public class StageActorServiceImpl implements StageActorService {
|
||||
continue;
|
||||
}
|
||||
|
||||
String move = "";
|
||||
String mode = "";
|
||||
String action = "";
|
||||
|
||||
//海亮-三工位Smart200
|
||||
HailiangThreestationSmartDeviceDriver hailiangThreestationSmartDeviceDriver;
|
||||
//海亮-叠盘位Smart200
|
||||
HailiangFoldingDiscSmartDeviceDriver hailiangFoldingDiscSmartDeviceDriver;
|
||||
//海亮-货梯对接线
|
||||
HailiangElevatorWiringDeviceDriver hailiangElevatorWiringDeviceDriver;
|
||||
|
||||
if (device.getDeviceDriver() instanceof HailiangThreestationSmartDeviceDriver) {
|
||||
hailiangThreestationSmartDeviceDriver = (HailiangThreestationSmartDeviceDriver) device.getDeviceDriver();
|
||||
if (hailiangThreestationSmartDeviceDriver.getMode() == 0) {
|
||||
mode = "脱机";
|
||||
} else if (hailiangThreestationSmartDeviceDriver.getMode() == 2) {
|
||||
mode = "待机";
|
||||
} else if (hailiangThreestationSmartDeviceDriver.getMode() == 3) {
|
||||
mode = "运行中";
|
||||
}
|
||||
if (hailiangThreestationSmartDeviceDriver.getMove() == 0) {
|
||||
move = "无货";
|
||||
} else if (hailiangThreestationSmartDeviceDriver.getMove() == 1) {
|
||||
move = "有货";
|
||||
}
|
||||
if (hailiangThreestationSmartDeviceDriver.getAction() == 0) {
|
||||
action = "禁止取放";
|
||||
} else if (hailiangThreestationSmartDeviceDriver.getAction() == 1) {
|
||||
action = "允许取货";
|
||||
} else if (hailiangThreestationSmartDeviceDriver.getAction() == 2) {
|
||||
action = "允许放货";
|
||||
} else if (hailiangThreestationSmartDeviceDriver.getAction() == 3) {
|
||||
action = "允许取放";
|
||||
}
|
||||
obj.put("device_name", hailiangThreestationSmartDeviceDriver.getDevice().getDevice_name());
|
||||
jo.put("mode", mode);
|
||||
jo.put("move", move);
|
||||
jo.put("action", action);
|
||||
jo.put("hasGoods", hailiangThreestationSmartDeviceDriver.getHasGoods());
|
||||
jo.put("isOnline", hailiangThreestationSmartDeviceDriver.getIsonline());
|
||||
jo.put("error", hailiangThreestationSmartDeviceDriver.getError());
|
||||
jo.put("isError", hailiangThreestationSmartDeviceDriver.getIserror());
|
||||
jo.put("container", hailiangThreestationSmartDeviceDriver.getContainer());
|
||||
jo.put("message", hailiangThreestationSmartDeviceDriver.getMessage());
|
||||
} else if (device.getDeviceDriver() instanceof HailiangFoldingDiscSmartDeviceDriver) {
|
||||
hailiangFoldingDiscSmartDeviceDriver = (HailiangFoldingDiscSmartDeviceDriver) device.getDeviceDriver();
|
||||
if (hailiangFoldingDiscSmartDeviceDriver.getMode() == 0) {
|
||||
mode = "脱机";
|
||||
} else if (hailiangFoldingDiscSmartDeviceDriver.getMode() == 2) {
|
||||
mode = "待机";
|
||||
} else if (hailiangFoldingDiscSmartDeviceDriver.getMode() == 3) {
|
||||
mode = "运行中";
|
||||
}
|
||||
if (hailiangFoldingDiscSmartDeviceDriver.getMove() == 0) {
|
||||
move = "无货";
|
||||
} else if (hailiangFoldingDiscSmartDeviceDriver.getMove() == 1) {
|
||||
move = "有货";
|
||||
}
|
||||
|
||||
obj.put("device_name", hailiangFoldingDiscSmartDeviceDriver.getDevice().getDevice_name());
|
||||
jo.put("mode", mode);
|
||||
jo.put("move", move);
|
||||
jo.put("number", hailiangFoldingDiscSmartDeviceDriver.getNumber());
|
||||
jo.put("hasGoods", hailiangFoldingDiscSmartDeviceDriver.getHasGoods());
|
||||
jo.put("isOnline", hailiangFoldingDiscSmartDeviceDriver.getIsonline());
|
||||
jo.put("error", hailiangFoldingDiscSmartDeviceDriver.getError());
|
||||
jo.put("isError", hailiangFoldingDiscSmartDeviceDriver.getIserror());
|
||||
jo.put("container", hailiangFoldingDiscSmartDeviceDriver.getContainer());
|
||||
jo.put("message", hailiangFoldingDiscSmartDeviceDriver.getMessage());
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(device.getDeviceDriver())) {
|
||||
IDriverService driverService = applicationContext.getBean(device.getDeviceDriverDefination().getDriverCode(), IDriverService.class);
|
||||
obj.put("device_name", device.getDevice_name());
|
||||
|
||||
@@ -114,6 +114,7 @@ import hailiang_smart_plc_test from '@/views/acs/device/driver/hailiang_one/hail
|
||||
import hailiang_threestation_smart from '@/views/acs/device/driver/hailiang_one/hailiang_threestation_smart'
|
||||
import hailiang_foldingDisc_smart from '@/views/acs/device/driver/hailiang_one/hailiang_foldingDisc_smart'
|
||||
import hailiang_elevator_wiring from '@/views/acs/device/driver/hailiang_one/hailiang_elevator_wiring'
|
||||
import hailiang_paint_line from '@/views/acs/device/driver/hailiang_one/hailiang_paint_line'
|
||||
|
||||
export default {
|
||||
name: 'DeviceConfig',
|
||||
@@ -125,7 +126,8 @@ export default {
|
||||
standard_photoelectric_inspect_site, agv_ndc_two, agv_ndc_one, hailiang_packer_station, hailiang_engraving_cache,
|
||||
hailiang_special_pick_station, hailiang_special_empty_station, hailiang_special_full_station, hailiang_special_pour_station, hailiang_special_device,
|
||||
hailiang_engraving_machine, hailiang_auto_cache_line, hailiang_cleaning_feeding_line, hailiang_cleaning_machine, hailiang_cleaning_machine_storage_station,
|
||||
hailiang_xj_plc_test, hailiang_smart_plc_test, hailiang_threestation_smart, hailiang_foldingDisc_smart,hailiang_elevator_wiring },
|
||||
hailiang_xj_plc_test, hailiang_smart_plc_test, hailiang_threestation_smart, hailiang_foldingDisc_smart,hailiang_elevator_wiring,
|
||||
hailiang_paint_line },
|
||||
dicts: ['device_type'],
|
||||
mixins: [crud],
|
||||
data() {
|
||||
|
||||
@@ -0,0 +1,487 @@
|
||||
<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
|
||||
@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.link_device_code"
|
||||
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-col :span="8">
|
||||
<el-form-item label="关联三色灯" prop="device_code" label-width="100px">
|
||||
<el-select
|
||||
v-model="form.link_three_lamp"
|
||||
filterable
|
||||
clearable
|
||||
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-col :span="8">
|
||||
<el-form-item label="是否输入物料" label-width="150px">
|
||||
<el-switch v-model="form.input_material" />
|
||||
</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.is_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">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="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: 'HailiangPaintLine',
|
||||
mixins: [crud],
|
||||
props: {
|
||||
parentForm: {
|
||||
type: Object,
|
||||
require: true
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
device_code: '',
|
||||
device_id: '',
|
||||
plc_id: '',
|
||||
plc_code: '',
|
||||
opc_id: '',
|
||||
opc_code: '',
|
||||
configLoading: false,
|
||||
dataOpcservers: [],
|
||||
dataOpcPlcs: [],
|
||||
deviceList: [],
|
||||
data1: [],
|
||||
data2: [],
|
||||
form: {
|
||||
inspect_in_stocck: true,
|
||||
ignore_pickup_check: true,
|
||||
ignore_release_check: true,
|
||||
apply_task: true,
|
||||
link_three_lamp: '',
|
||||
manual_create_task: true,
|
||||
is_pickup: true,
|
||||
is_release: true,
|
||||
link_device_code: []
|
||||
},
|
||||
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
|
||||
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
|
||||
})
|
||||
})
|
||||
},
|
||||
methods: {
|
||||
finishReadEdit(data) {
|
||||
// 编辑的是code列,并且值包含mode
|
||||
if (data.code.indexOf('mode') !== -1) {
|
||||
debugger
|
||||
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('move') !== -1) {
|
||||
this.data1[val].db = beforeStr + '.' + afterStr.substring(0, 1) + (parseInt(endNumber) + 1)
|
||||
}
|
||||
if (this.data1[val].code.indexOf('error') !== -1) {
|
||||
this.data1[val].db = beforeStr + '.' + afterStr.substring(0, 1) + (parseInt(endNumber) + 5)
|
||||
}
|
||||
if (this.data1[val].code.indexOf('task') !== -1) {
|
||||
this.data1[val].db = beforeStr + '.' + 'D' + (parseInt(endNumber) + 7)
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
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) + 6)
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
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)
|
||||
})
|
||||
},
|
||||
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.data1, this.data2).then(res => {
|
||||
this.notify('保存成功', 'success')
|
||||
this.configLoading = false
|
||||
}).catch(err => {
|
||||
this.configLoading = false
|
||||
console.log(err.response.data.message)
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
sliceItem() { // 拼接DB的Item值
|
||||
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>
|
||||
Reference in New Issue
Block a user