更新
This commit is contained in:
@@ -39,7 +39,9 @@ public enum DriverTypeEnum {
|
|||||||
|
|
||||||
INSPECT_CONVEYOR_CONTROL_WITH_SCANNER(14, "standard_conveyor_control_with_scanner", "标准版-输送机-控制点-关联扫码", "conveyor"),
|
INSPECT_CONVEYOR_CONTROL_WITH_SCANNER(14, "standard_conveyor_control_with_scanner", "标准版-输送机-控制点-关联扫码", "conveyor"),
|
||||||
|
|
||||||
PLUG_PULL_DEVICE_SITE(15, "plug_pull_device_site", "插拔轴站点", "conveyor");
|
PLUG_PULL_DEVICE_SITE(15, "plug_pull_device_site", "插拔轴站点", "conveyor"),
|
||||||
|
|
||||||
|
SIEMENS_CONVEYOR_LABELING(16, "siemens_conveyor_labeling", "西门子-输送机驱动-贴标", "conveyor");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -149,26 +149,6 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme
|
|||||||
requireApplyLaStrangulationSuccess =false;
|
requireApplyLaStrangulationSuccess =false;
|
||||||
requireEmptyInSuccess =false;
|
requireEmptyInSuccess =false;
|
||||||
requireEmptyOutSuccess =false;
|
requireEmptyOutSuccess =false;
|
||||||
if (mode == 2) {
|
|
||||||
logServer.deviceExecuteLog(device_code, "", "", "开始请求标记复位`此时请求标记值为requireSucess:" + requireSucess);
|
|
||||||
logServer.deviceExecuteLog(device_code, "", "", "请求标记复位成功`此时请求标记值为requireSucess:" + requireSucess);
|
|
||||||
}
|
|
||||||
if (mode == 4) {
|
|
||||||
logServer.deviceExecuteLog(device_code, "", "", "开始请求标记复位`此时请求标记值为requireApplyLabelingSuccess:" + requireApplyLabelingSuccess);
|
|
||||||
logServer.deviceExecuteLog(device_code, "", "", "请求标记复位成功`此时请求标记值为requireApplyLabelingSuccess:" + requireApplyLabelingSuccess);
|
|
||||||
}
|
|
||||||
if (mode == 5) {
|
|
||||||
logServer.deviceExecuteLog(device_code, "", "", "开始请求标记复位`此时请求标记值为requireApplyLaStrangulationSuccess:" + requireApplyLaStrangulationSuccess);
|
|
||||||
logServer.deviceExecuteLog(device_code, "", "", "请求标记复位成功`此时请求标记值为requireApplyLaStrangulationSuccess:" + requireApplyLaStrangulationSuccess);
|
|
||||||
}
|
|
||||||
if (mode == 6) {
|
|
||||||
logServer.deviceExecuteLog(device_code, "", "", "开始请求标记复位`此时请求标记值为requireEmptyInSuccess:" + requireEmptyInSuccess);
|
|
||||||
logServer.deviceExecuteLog(device_code, "", "", "请求标记复位成功`此时请求标记值为requireEmptyInSuccess:" + requireEmptyInSuccess);
|
|
||||||
}
|
|
||||||
if (mode == 7) {
|
|
||||||
logServer.deviceExecuteLog(device_code, "", "", "开始请求标记复位`此时请求标记值为requireEmptyOutSuccess:" + requireEmptyOutSuccess);
|
|
||||||
logServer.deviceExecuteLog(device_code, "", "", "请求标记复位成功`此时请求标记值为requireEmptyOutSuccess:" + requireEmptyOutSuccess);
|
|
||||||
}
|
|
||||||
logServer.deviceItemValue(this.device_code, "mode", String.valueOf(mode));
|
logServer.deviceItemValue(this.device_code, "mode", String.valueOf(mode));
|
||||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_mode + "->" + mode);
|
logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_mode + "->" + mode);
|
||||||
}
|
}
|
||||||
@@ -424,8 +404,13 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme
|
|||||||
|
|
||||||
if (this.getMove() == 0) {
|
if (this.getMove() == 0) {
|
||||||
move = "无货";
|
move = "无货";
|
||||||
|
jo.put("hasGoods", false);
|
||||||
} else if (this.getMove() == 1) {
|
} else if (this.getMove() == 1) {
|
||||||
move = "有货";
|
move = "有货";
|
||||||
|
jo.put("hasGoods", true);
|
||||||
|
} else if (this.getMove() == 2) {
|
||||||
|
move = "有托盘有货";
|
||||||
|
jo.put("hasGoods", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.carrier_direction == 1) {
|
if (this.carrier_direction == 1) {
|
||||||
@@ -493,13 +478,13 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme
|
|||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
this.instruction_require_time = date;
|
this.instruction_require_time = date;
|
||||||
//container_code
|
//判断是否存在起点相同 任务状态就绪的任务
|
||||||
TaskDto taskdto = taskserver.findByStartCodeAndReady(device_code);
|
TaskDto taskdto = taskserver.findByStartCodeAndReady(device_code);
|
||||||
if (!ObjectUtil.isEmpty(taskdto)) {
|
if (!ObjectUtil.isEmpty(taskdto)) {
|
||||||
// if (!ObjectUtils.isEmpty(instructionService.findByBarcodeFromCache(container_code))) {
|
// if (!ObjectUtils.isEmpty(instructionService.findByBarcodeFromCache(container_code))) {
|
||||||
// return false;
|
// return false;
|
||||||
// }
|
// }
|
||||||
|
//需要判断当前设备是否已经存在就绪的指令 如果存在就直接下发 不存在则创建
|
||||||
Instruction inst = instructionService.findByTaskcodeAndStatus(taskdto.getTask_code());
|
Instruction inst = instructionService.findByTaskcodeAndStatus(taskdto.getTask_code());
|
||||||
if(ObjectUtil.isNotEmpty(inst)){
|
if(ObjectUtil.isNotEmpty(inst)){
|
||||||
List list = new ArrayList();
|
List list = new ArrayList();
|
||||||
@@ -536,6 +521,7 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// type 5 输送任务
|
||||||
if(!StrUtil.equals(taskdto.getTask_type(),"5")){
|
if(!StrUtil.equals(taskdto.getTask_type(),"5")){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -559,9 +545,7 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme
|
|||||||
String path = routeLineDto.getPath();
|
String path = routeLineDto.getPath();
|
||||||
String type = routeLineDto.getType();
|
String type = routeLineDto.getType();
|
||||||
String[] str = path.split("->");
|
String[] str = path.split("->");
|
||||||
// if (!StrUtil.equals(type, "0")) {
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
List<String> pathlist = Arrays.asList(str);
|
List<String> pathlist = Arrays.asList(str);
|
||||||
int index = 0;
|
int index = 0;
|
||||||
for (int m = 0; m < pathlist.size(); m++) {
|
for (int m = 0; m < pathlist.size(); m++) {
|
||||||
@@ -633,6 +617,7 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme
|
|||||||
logServer.deviceExecuteLog(device_code, "", "", inst.getInstruction_code() + "再次下发电气信号");
|
logServer.deviceExecuteLog(device_code, "", "", inst.getInstruction_code() + "再次下发电气信号");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
//如果不存在则直接找对应指令
|
||||||
Instruction inst = instructionService.findByDeviceCodeFromCache(this.device_code);
|
Instruction inst = instructionService.findByDeviceCodeFromCache(this.device_code);
|
||||||
if(ObjectUtil.isEmpty(inst)){
|
if(ObjectUtil.isEmpty(inst)){
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -0,0 +1,134 @@
|
|||||||
|
package org.nl.acs.device_driver.basedriver.siemens_conveyor_labeling;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
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_carrier_direction = "carrier_direction";
|
||||||
|
//报警
|
||||||
|
public static String item_error = "error";
|
||||||
|
//任务号
|
||||||
|
public static String item_task = "task";
|
||||||
|
//重量
|
||||||
|
public static String item_weight = "weight";
|
||||||
|
|
||||||
|
//下发命令
|
||||||
|
public static String item_to_command = "to_command";
|
||||||
|
//下发目标站
|
||||||
|
public static String item_to_target = "to_target";
|
||||||
|
//下发托盘类型
|
||||||
|
public static String item_to_container_type = "to_container_type";
|
||||||
|
//下发任务号
|
||||||
|
public static String item_to_task = "to_task";
|
||||||
|
//困扎次数
|
||||||
|
public static String item_to_strap_times = "to_strap_times";
|
||||||
|
//木箱长度
|
||||||
|
public static String item_to_length = "to_length";
|
||||||
|
//木箱宽度
|
||||||
|
public static String item_to_weight = "to_weight";
|
||||||
|
//木箱高度
|
||||||
|
public static String item_to_height = "to_height";
|
||||||
|
|
||||||
|
|
||||||
|
private SiemensConveyorLabelingDeviceDriver driver;
|
||||||
|
|
||||||
|
public ItemProtocol(SiemensConveyorLabelingDeviceDriver 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 getCarrier_direction() {
|
||||||
|
return this.getOpcIntegerValue(item_carrier_direction);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getError() {
|
||||||
|
return this.getOpcIntegerValue(item_error);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getTask() {
|
||||||
|
return this.getOpcIntegerValue(item_task);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getWeight() {
|
||||||
|
return this.getOpcIntegerValue(item_weight);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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 String getOpcStringValue(String protocol) {
|
||||||
|
String value = this.driver.getStringValue(protocol);
|
||||||
|
if (StrUtil.isEmpty(value)) {
|
||||||
|
|
||||||
|
} else {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
return "0";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<ItemDto> getReadableItemDtos() {
|
||||||
|
ArrayList list = new ArrayList();
|
||||||
|
list.add(new ItemDto(item_heartbeat, "心跳", "DB101.B0"));
|
||||||
|
list.add(new ItemDto(item_mode, "工作模式", "DB101.B152"));
|
||||||
|
list.add(new ItemDto(item_move, "光电信号", "DB101.B153"));
|
||||||
|
list.add(new ItemDto(item_carrier_direction, "托盘方向", "DB101.B154"));
|
||||||
|
list.add(new ItemDto(item_error, "报警信号", "DB101.B156"));
|
||||||
|
list.add(new ItemDto(item_task, "任务号", "DB101.D160"));
|
||||||
|
list.add(new ItemDto(item_weight, "重量", "DB101.D160"));
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<ItemDto> getWriteableItemDtos() {
|
||||||
|
ArrayList list = new ArrayList();
|
||||||
|
list.add(new ItemDto(item_to_command, "下发命令", "DB102.W152"));
|
||||||
|
list.add(new ItemDto(item_to_target, "下发目标站", "DB601.W154"));
|
||||||
|
list.add(new ItemDto(item_to_task, "下发任务号", "DB102.D158"));
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
package org.nl.acs.device_driver.basedriver.siemens_conveyor_labeling;
|
||||||
|
|
||||||
|
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 SiemensConveyorLabelingDefination implements OpcDeviceDriverDefination {
|
||||||
|
@Override
|
||||||
|
public String getDriverCode() {
|
||||||
|
return "siemens_conveyor_labeling";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDriverName() {
|
||||||
|
return "西门子-输送机驱动-贴标";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDriverDescription() {
|
||||||
|
return "西门子-输送机驱动-贴标";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DeviceDriver getDriverInstance(Device device) {
|
||||||
|
return (new SiemensConveyorLabelingDeviceDriver()).setDevice(device).setDriverDefination(this);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<? extends DeviceDriver> getDeviceDriverType() {
|
||||||
|
return SiemensConveyorLabelingDeviceDriver.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();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,864 @@
|
|||||||
|
package org.nl.acs.device_driver.basedriver.siemens_conveyor_labeling;
|
||||||
|
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
import cn.hutool.core.util.IdUtil;
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.lang3.ObjectUtils;
|
||||||
|
import org.nl.acs.AcsConfig;
|
||||||
|
import org.nl.acs.agv.server.NDCAgvService;
|
||||||
|
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.ext.wms.data.ApplyLabelingAndBindingRequest;
|
||||||
|
import org.nl.acs.ext.wms.data.ApplyLabelingAndBindingResponse;
|
||||||
|
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.opc.DeviceAppService;
|
||||||
|
import org.nl.acs.route.service.RouteLineService;
|
||||||
|
import org.nl.acs.route.service.dto.RouteLineDto;
|
||||||
|
import org.nl.acs.task.service.TaskService;
|
||||||
|
import org.nl.acs.task.service.dto.TaskDto;
|
||||||
|
import org.nl.modules.system.service.ParamService;
|
||||||
|
import org.nl.modules.wql.core.bean.WQLObject;
|
||||||
|
import org.nl.modules.wql.util.SpringContextHolder;
|
||||||
|
import org.openscada.opc.lib.da.Server;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 西门子-输送机驱动-贴标
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Data
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class SiemensConveyorLabelingDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor {
|
||||||
|
protected ItemProtocol itemProtocol = new ItemProtocol(this);
|
||||||
|
@Autowired
|
||||||
|
InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class);
|
||||||
|
@Autowired
|
||||||
|
DeviceService deviceservice = SpringContextHolder.getBean(DeviceService.class);
|
||||||
|
@Autowired
|
||||||
|
RouteLineService routelineserver = SpringContextHolder.getBean(RouteLineService.class);
|
||||||
|
@Autowired
|
||||||
|
TaskService taskserver = SpringContextHolder.getBean(TaskService.class);
|
||||||
|
@Autowired
|
||||||
|
DeviceAppService deviceAppservice = SpringContextHolder.getBean(DeviceAppService.class);
|
||||||
|
@Autowired
|
||||||
|
RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class);
|
||||||
|
@Autowired
|
||||||
|
ParamService paramService = SpringContextHolder.getBean(ParamService.class);
|
||||||
|
@Autowired
|
||||||
|
AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsService.class);
|
||||||
|
@Autowired
|
||||||
|
DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl");
|
||||||
|
@Autowired
|
||||||
|
NDCAgvService agvService = SpringContextHolder.getBean(NDCAgvService.class);
|
||||||
|
//当前指令
|
||||||
|
Instruction inst = null;
|
||||||
|
|
||||||
|
//工作模式
|
||||||
|
int mode = 0;
|
||||||
|
int last_mode = 0;
|
||||||
|
//光电信号
|
||||||
|
int move = 0;
|
||||||
|
int last_move = 0;
|
||||||
|
//托盘方向
|
||||||
|
int carrier_direction = 0;
|
||||||
|
int last_carrier_direction = 0;
|
||||||
|
//报警信号
|
||||||
|
int error = 0;
|
||||||
|
int last_error = 0;
|
||||||
|
//任务号
|
||||||
|
int task = 0;
|
||||||
|
int weight = 0;
|
||||||
|
int last_task = 0;
|
||||||
|
int agvphase = 0;
|
||||||
|
|
||||||
|
int phase = 0;
|
||||||
|
int index = 0;
|
||||||
|
Boolean isonline = true;
|
||||||
|
int hasGoods = 0;
|
||||||
|
String message = null;
|
||||||
|
Boolean iserror = false;
|
||||||
|
|
||||||
|
Integer heartbeat_tag;
|
||||||
|
private Date instruction_require_time = new Date();
|
||||||
|
private Date require_apply_labeling_time = new Date();
|
||||||
|
private Date require_apply_strangulation_time = new Date();
|
||||||
|
private Date require_empty_in_time = new Date();
|
||||||
|
private Date require_empty_out_time = new Date();
|
||||||
|
|
||||||
|
private int instruction_require_time_out;
|
||||||
|
//行架机械手申请任务成功标识
|
||||||
|
boolean requireSucess = false;
|
||||||
|
boolean requireApplyLabelingSuccess = false;
|
||||||
|
boolean requireApplyLaStrangulationSuccess = false;
|
||||||
|
boolean requireEmptyInSuccess = false;
|
||||||
|
boolean requireEmptyOutSuccess = false;
|
||||||
|
private int instruction_finished_time_out;
|
||||||
|
|
||||||
|
int branchProtocol = 0;
|
||||||
|
String inst_message;
|
||||||
|
|
||||||
|
//当前指令
|
||||||
|
|
||||||
|
//暂定 0就绪 1请求取货 2取货完成 3请求放货 4放货完成 5取货完成离开 6放货完成离开 7请求进入区域 8请求离开区域
|
||||||
|
int flag;
|
||||||
|
|
||||||
|
String device_code;
|
||||||
|
|
||||||
|
String vehicle_code;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Device getDevice() {
|
||||||
|
return this.device;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute() throws Exception {
|
||||||
|
String message = null;
|
||||||
|
try {
|
||||||
|
device_code = this.getDeviceCode();
|
||||||
|
mode = this.itemProtocol.getMode();
|
||||||
|
move = this.itemProtocol.getMove();
|
||||||
|
carrier_direction = this.itemProtocol.getCarrier_direction();
|
||||||
|
error = this.itemProtocol.getError();
|
||||||
|
task = this.itemProtocol.getTask();
|
||||||
|
weight = this.itemProtocol.getWeight();
|
||||||
|
if (mode != last_mode) {
|
||||||
|
requireSucess = false;
|
||||||
|
requireApplyLabelingSuccess = false;
|
||||||
|
requireApplyLaStrangulationSuccess =false;
|
||||||
|
requireEmptyInSuccess =false;
|
||||||
|
requireEmptyOutSuccess =false;
|
||||||
|
logServer.deviceItemValue(this.device_code, "mode", String.valueOf(mode));
|
||||||
|
logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_mode + "->" + mode);
|
||||||
|
}
|
||||||
|
if (move != last_move) {
|
||||||
|
if(move == 0 ){
|
||||||
|
this.clearWrite();
|
||||||
|
}
|
||||||
|
logServer.deviceItemValue(this.device_code, "move", String.valueOf(move));
|
||||||
|
logServer.deviceExecuteLog(this.device_code, "", "", "信号move:" + last_move + "->" + move);
|
||||||
|
}
|
||||||
|
if (carrier_direction != last_carrier_direction) {
|
||||||
|
logServer.deviceItemValue(this.device_code, "carrier_direction", String.valueOf(carrier_direction));
|
||||||
|
logServer.deviceExecuteLog(this.device_code, "", "", "信号carrier_direction:" + last_carrier_direction + "->" + carrier_direction);
|
||||||
|
}
|
||||||
|
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 (mode == 2 && move != 0 && task > 0) {
|
||||||
|
//inst_message
|
||||||
|
inst = instructionService.findByCodeFromCache(String.valueOf(task));
|
||||||
|
if (inst != null) {
|
||||||
|
inst_message = "指令号:" + inst.getInstruction_code() + " " + inst.getStart_point_code() + "->" + inst.getNext_point_code() + " 载具号:" + inst.getVehicle_code();
|
||||||
|
if (StrUtil.equals(inst.getInstruction_status(), "1") && StrUtil.equals(this.getDeviceCode(), inst.getNext_device_code())) {
|
||||||
|
vehicle_code = inst.getVehicle_code();
|
||||||
|
finish_instruction();
|
||||||
|
}
|
||||||
|
if (StrUtil.equals(inst.getInstruction_status(), "0") && StrUtil.equals(this.getDeviceCode(), inst.getStart_device_code())) {
|
||||||
|
inst.setInstruction_status("1");
|
||||||
|
instructionService.update(inst);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (Exception var17) {
|
||||||
|
inst_message = var17.getMessage();
|
||||||
|
logServer.deviceExecuteLog(this.getDevice_code(), "", "", "读取信号值时出现异常:" + var17.getMessage());
|
||||||
|
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("设备运转模式:等待工作");
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
//申请任务
|
||||||
|
if (move > 0 && !requireSucess) {
|
||||||
|
instruction_require();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
//申请捆扎
|
||||||
|
if (move > 0 && !requireApplyLaStrangulationSuccess) {
|
||||||
|
applyLaStrangulation();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
//申请贴标
|
||||||
|
if (move > 0 && !requireApplyLabelingSuccess) {
|
||||||
|
applyLabeling();
|
||||||
|
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
//空托盘满垛入库申请
|
||||||
|
if (move > 0 && !requireEmptyInSuccess) {
|
||||||
|
emptyIn();
|
||||||
|
}
|
||||||
|
if (move > 0 && !requireSucess) {
|
||||||
|
instruction_require();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 7:
|
||||||
|
//空盘出库申请
|
||||||
|
if (move == 0 && !requireEmptyOutSuccess) {
|
||||||
|
emptyOut();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 8:
|
||||||
|
//申请AGV任务
|
||||||
|
if (move == 0 && !requireSucess) {
|
||||||
|
applyAgvTask();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
last_mode = mode;
|
||||||
|
last_move = move;
|
||||||
|
last_carrier_direction = carrier_direction;
|
||||||
|
last_error = error;
|
||||||
|
last_task = task;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public boolean exe_error() {
|
||||||
|
if (this.error == 0) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
log.debug("设备报警");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clearWrite() {
|
||||||
|
|
||||||
|
List list = new ArrayList();
|
||||||
|
Map map = new HashMap();
|
||||||
|
map.put("code","to_target");
|
||||||
|
map.put("value","0");
|
||||||
|
list.add(map);
|
||||||
|
Map map2 = new HashMap();
|
||||||
|
map2.put("code","to_task");
|
||||||
|
map2.put("value","0");
|
||||||
|
list.add(map2);
|
||||||
|
Map map3 = new HashMap();
|
||||||
|
map3.put("code","to_command");
|
||||||
|
map3.put("value","0");
|
||||||
|
list.add(map3);
|
||||||
|
Map map4 = new HashMap();
|
||||||
|
map4.put("code","to_strap_times");
|
||||||
|
map4.put("value","0");
|
||||||
|
list.add(map4);
|
||||||
|
Map map5 = new HashMap();
|
||||||
|
map5.put("code","to_length");
|
||||||
|
map5.put("value","0");
|
||||||
|
list.add(map5);
|
||||||
|
Map map6 = new HashMap();
|
||||||
|
map6.put("code","to_weight");
|
||||||
|
map6.put("value","0");
|
||||||
|
list.add(map6);
|
||||||
|
Map map7 = new HashMap();
|
||||||
|
map7.put("code","to_height");
|
||||||
|
map7.put("value","0");
|
||||||
|
list.add(map7);
|
||||||
|
this.writing(list);
|
||||||
|
message = null;
|
||||||
|
vehicle_code = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean exe_business() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized boolean finish_instruction() throws Exception {
|
||||||
|
instructionService.finish(inst);
|
||||||
|
// requireSucess = false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected void thingToNothing() throws Exception {
|
||||||
|
requireSucess = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void writing(String param, String value) {
|
||||||
|
|
||||||
|
String to_param = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
|
||||||
|
+ "." + param;
|
||||||
|
String opcservcerid = this.getDevice().getOpc_server_id();
|
||||||
|
Server server = ReadUtil.getServer(opcservcerid);
|
||||||
|
Map<String, Object> itemMap = new HashMap<String, Object>();
|
||||||
|
|
||||||
|
itemMap.put(to_param, Integer.parseInt(value));
|
||||||
|
// itemMap.put(to_param, Integer.parseInt(value));
|
||||||
|
ReadUtil.write(itemMap, server);
|
||||||
|
logServer.deviceExecuteLog(device_code, "", "", "下发电气信号设备号:" + device_code + ",下发电气:" + to_param + ",下发电气值:" + value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void executing(Server server, Map<String, Object> itemMap) {
|
||||||
|
ReadUtil.write(itemMap, server);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void writing(int command) {
|
||||||
|
|
||||||
|
String opcservcerid = this.getDevice().getOpc_server_id();
|
||||||
|
Server server = ReadUtil.getServer(opcservcerid);
|
||||||
|
Map<String, Object> itemMap = new HashMap<String, Object>();
|
||||||
|
ReadUtil.write(itemMap, server);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public JSONObject getDeviceStatusName() {
|
||||||
|
JSONObject jo = new JSONObject();
|
||||||
|
String mode = "";
|
||||||
|
String move = "";
|
||||||
|
String carrier_direction = "";
|
||||||
|
if (this.getMode() == 0) {
|
||||||
|
mode = "脱机";
|
||||||
|
} else if (this.getMode() == 1) {
|
||||||
|
mode = "单机";
|
||||||
|
} else if (this.getMode() == 2) {
|
||||||
|
mode = "待机";
|
||||||
|
} else if (this.getMode() == 3) {
|
||||||
|
mode = "运行中";
|
||||||
|
} else if (this.getMode() == 4) {
|
||||||
|
mode = "申请捆扎中";
|
||||||
|
} else if (this.getMode() == 5) {
|
||||||
|
mode = "申请贴标中";
|
||||||
|
} else if (this.getMode() == 6) {
|
||||||
|
mode = "申请空盘入库中";
|
||||||
|
} else if (this.getMode() == 7) {
|
||||||
|
mode = "申请空盘出库中";
|
||||||
|
} else if (this.getMode() == 8) {
|
||||||
|
mode = "申请AGV任务中";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.getMove() == 0) {
|
||||||
|
move = "无货";
|
||||||
|
jo.put("hasGoods", false);
|
||||||
|
} else if (this.getMove() == 1) {
|
||||||
|
move = "有货";
|
||||||
|
jo.put("hasGoods", true);
|
||||||
|
} else if (this.getMove() == 2) {
|
||||||
|
move = "有托盘有货";
|
||||||
|
jo.put("hasGoods", true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.carrier_direction == 1) {
|
||||||
|
carrier_direction = "正转";
|
||||||
|
} else if (this.carrier_direction == 2) {
|
||||||
|
carrier_direction = "反转";
|
||||||
|
}
|
||||||
|
String requireSucess = "0";
|
||||||
|
if (this.requireSucess) {
|
||||||
|
requireSucess = "1";
|
||||||
|
}
|
||||||
|
|
||||||
|
jo.put("device_name", this.getDevice().getDevice_name());
|
||||||
|
jo.put("mode", mode);
|
||||||
|
jo.put("move", move);
|
||||||
|
jo.put("carrier_direction", carrier_direction);
|
||||||
|
jo.put("task", task);
|
||||||
|
jo.put("isOnline", this.getIsonline());
|
||||||
|
jo.put("error", this.getError());
|
||||||
|
jo.put("isError", this.getIserror());
|
||||||
|
jo.put("message", this.getMessage());
|
||||||
|
jo.put("is_click", true);
|
||||||
|
jo.put("requireSucess", requireSucess);
|
||||||
|
jo.put("driver_type", "siemens_conveyor");
|
||||||
|
return jo;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setDeviceStatus(JSONObject data) {
|
||||||
|
String requestSucess = data.getString("requireSucess");
|
||||||
|
if (StrUtil.equals(requestSucess, "0")) {
|
||||||
|
this.requireSucess = false;
|
||||||
|
} else if(StrUtil.equals(requestSucess, "1")) {
|
||||||
|
this.requireSucess = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void writing(List list) {
|
||||||
|
|
||||||
|
String opcservcerid = this.getDevice().getOpc_server_id();
|
||||||
|
Server server = ReadUtil.getServer(opcservcerid);
|
||||||
|
Map<String, Object> itemMap = new HashMap<String, Object>();
|
||||||
|
for (int i = 0; i < list.size(); i++) {
|
||||||
|
Object ob = list.get(i);
|
||||||
|
JSONObject json = (JSONObject) JSONObject.toJSON(ob);
|
||||||
|
if (!StrUtil.isEmpty(json.getString("value"))) {
|
||||||
|
String to_param = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
|
||||||
|
+ "." + json.getString("code");
|
||||||
|
itemMap.put(to_param, json.getString("value"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
logServer.deviceExecuteLog(device_code, "", "", "下发电气信号:" + itemMap);
|
||||||
|
ReadUtil.write(itemMap, server);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 请求指令
|
||||||
|
*/
|
||||||
|
public synchronized boolean instruction_require() throws Exception {
|
||||||
|
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;
|
||||||
|
//判断是否存在起点相同 任务状态就绪的任务
|
||||||
|
TaskDto taskdto = taskserver.findByStartCodeAndReady(device_code);
|
||||||
|
if (!ObjectUtil.isEmpty(taskdto)) {
|
||||||
|
// if (!ObjectUtils.isEmpty(instructionService.findByBarcodeFromCache(container_code))) {
|
||||||
|
// return false;
|
||||||
|
// }
|
||||||
|
//需要判断当前设备是否已经存在就绪的指令 如果存在就直接下发 不存在则创建
|
||||||
|
Instruction inst = instructionService.findByTaskcodeAndStatus(taskdto.getTask_code());
|
||||||
|
if(ObjectUtil.isNotEmpty(inst)){
|
||||||
|
List list = new ArrayList();
|
||||||
|
Map map = new HashMap();
|
||||||
|
|
||||||
|
if(StrUtil.isNotEmpty(taskdto.getTo_z())){
|
||||||
|
if(StrUtil.equals(taskdto.getTo_z(),"01")){
|
||||||
|
map.put("code","to_target");
|
||||||
|
map.put("value","102");
|
||||||
|
} else if(StrUtil.equals(taskdto.getTo_z(),"02")){
|
||||||
|
map.put("code","to_target");
|
||||||
|
map.put("value","201");
|
||||||
|
} else if(StrUtil.equals(taskdto.getTo_z(),"03")){
|
||||||
|
map.put("code","to_target");
|
||||||
|
map.put("value","301");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
list.add(map);
|
||||||
|
Map map2 = new HashMap();
|
||||||
|
map2.put("code","to_task");
|
||||||
|
map2.put("value",inst.getInstruction_code());
|
||||||
|
list.add(map2);
|
||||||
|
Map map3 = new HashMap();
|
||||||
|
map3.put("code","to_command");
|
||||||
|
map3.put("value","1");
|
||||||
|
list.add(map3);
|
||||||
|
this.writing(list);
|
||||||
|
if( task != Integer.parseInt(inst.getInstruction_code())){
|
||||||
|
this.writing(list);
|
||||||
|
logServer.deviceExecuteLog(device_code, "", "", inst.getInstruction_code() + "再次下发电气信号");
|
||||||
|
}
|
||||||
|
message = "下发电气任务号成功";
|
||||||
|
requireSucess = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// type 5 输送任务
|
||||||
|
if(!StrUtil.equals(taskdto.getTask_type(),"5")){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
String taskid = taskdto.getTask_id();
|
||||||
|
String taskcode = taskdto.getTask_code();
|
||||||
|
String vehiclecode = taskdto.getVehicle_code();
|
||||||
|
String priority = taskdto.getPriority();
|
||||||
|
String start_point_code = taskdto.getStart_point_code();
|
||||||
|
String start_device_code = taskdto.getStart_device_code();
|
||||||
|
String route_plan_code = taskdto.getRoute_plan_code();
|
||||||
|
String next_device_code = "";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 开始平均分配
|
||||||
|
*/
|
||||||
|
String this_coevice_code = taskserver.queryAssignedByDevice(device_code, taskdto.getNext_device_code());
|
||||||
|
if (StrUtil.isEmpty(this_coevice_code)) {
|
||||||
|
List<RouteLineDto> shortPathsList = routeLineService.getShortPathLines(start_device_code, taskdto.getNext_device_code(), route_plan_code);
|
||||||
|
RouteLineDto routeLineDto = shortPathsList.get(0);
|
||||||
|
|
||||||
|
String path = routeLineDto.getPath();
|
||||||
|
String type = routeLineDto.getType();
|
||||||
|
String[] str = path.split("->");
|
||||||
|
|
||||||
|
List<String> pathlist = Arrays.asList(str);
|
||||||
|
int index = 0;
|
||||||
|
for (int m = 0; m < pathlist.size(); m++) {
|
||||||
|
if (pathlist.get(m).equals(start_device_code)) {
|
||||||
|
index = m + 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
next_device_code = pathlist.get(index);
|
||||||
|
} else {
|
||||||
|
next_device_code = this_coevice_code;
|
||||||
|
}
|
||||||
|
//校验路由关系
|
||||||
|
List<RouteLineDto> shortPathsList = routeLineService.getShortPathLines(start_device_code, next_device_code, route_plan_code);
|
||||||
|
if (ObjectUtils.isEmpty(shortPathsList)) {
|
||||||
|
throw new RuntimeException("路由不通!");
|
||||||
|
}
|
||||||
|
|
||||||
|
Device startdevice = deviceAppservice.findDeviceByCode(start_device_code);
|
||||||
|
Device nextdevice = deviceAppservice.findDeviceByCode(next_device_code);
|
||||||
|
String next_point_code;
|
||||||
|
if (StrUtil.equals(deviceAppservice.findDeviceTypeByCode(next_device_code), "storage")) {
|
||||||
|
next_point_code = taskdto.getTo_x() + "-" + taskdto.getTo_y() + "-" + taskdto.getTo_z();
|
||||||
|
} else {
|
||||||
|
next_point_code = next_device_code;
|
||||||
|
}
|
||||||
|
Instruction instdto = new Instruction();
|
||||||
|
instdto.setInstruction_id(IdUtil.simpleUUID());
|
||||||
|
instdto.setRoute_plan_code(route_plan_code);
|
||||||
|
instdto.setRemark(taskdto.getRemark());
|
||||||
|
instdto.setMaterial(taskdto.getMaterial());
|
||||||
|
instdto.setQuantity(taskdto.getQuantity());
|
||||||
|
instdto.setTask_id(taskid);
|
||||||
|
instdto.setTask_code(taskcode);
|
||||||
|
instdto.setVehicle_code(vehiclecode);
|
||||||
|
String now = DateUtil.now();
|
||||||
|
instdto.setCreate_time(now);
|
||||||
|
instdto.setCreate_by("auto");
|
||||||
|
instdto.setStart_device_code(start_device_code);
|
||||||
|
instdto.setNext_device_code(next_device_code);
|
||||||
|
instdto.setStart_point_code(start_point_code);
|
||||||
|
instdto.setNext_point_code(next_point_code);
|
||||||
|
instdto.setPriority(priority);
|
||||||
|
instdto.setInstruction_status("0");
|
||||||
|
instdto.setExecute_device_code(start_point_code);
|
||||||
|
instructionService.create(instdto);
|
||||||
|
//创建指令后修改任务状态
|
||||||
|
taskdto.setTask_status("1");
|
||||||
|
taskserver.update(taskdto);
|
||||||
|
requireSucess = true;
|
||||||
|
String next_addr = nextdevice.getExtraValue().get("address").toString();
|
||||||
|
|
||||||
|
List list = new ArrayList();
|
||||||
|
Map map = new HashMap();
|
||||||
|
map.put("code","to_target");
|
||||||
|
map.put("value",next_addr);
|
||||||
|
list.add(map);
|
||||||
|
Map map2 = new HashMap();
|
||||||
|
map2.put("code","to_task");
|
||||||
|
map2.put("value",instdto.getInstruction_code());
|
||||||
|
list.add(map2);
|
||||||
|
Map map3 = new HashMap();
|
||||||
|
map3.put("code","to_command");
|
||||||
|
map3.put("value","1");
|
||||||
|
list.add(map3);
|
||||||
|
this.writing(list);
|
||||||
|
if( task != Integer.parseInt(inst.getInstruction_code())){
|
||||||
|
this.writing(list);
|
||||||
|
logServer.deviceExecuteLog(device_code, "", "", inst.getInstruction_code() + "再次下发电气信号");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
//如果不存在则直接找对应指令
|
||||||
|
Instruction inst = instructionService.findByDeviceCodeFromCache(this.device_code);
|
||||||
|
if(ObjectUtil.isEmpty(inst)){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
//当起点为行架任务的时候不需要请求下发
|
||||||
|
if(StrUtil.equals(inst.getInstruction_type(),"6")){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
Device nextdevice = deviceAppservice.findDeviceByCode(inst.getNext_device_code());
|
||||||
|
String next_addr = nextdevice.getExtraValue().get("address").toString();
|
||||||
|
|
||||||
|
List list = new ArrayList();
|
||||||
|
Map map = new HashMap();
|
||||||
|
map.put("code","to_target");
|
||||||
|
map.put("value",next_addr);
|
||||||
|
list.add(map);
|
||||||
|
Map map2 = new HashMap();
|
||||||
|
map2.put("code","to_task");
|
||||||
|
map2.put("value",inst.getInstruction_code());
|
||||||
|
list.add(map2);
|
||||||
|
Map map3 = new HashMap();
|
||||||
|
map3.put("code","to_command");
|
||||||
|
map3.put("value","1");
|
||||||
|
list.add(map3);
|
||||||
|
this.writing(list);
|
||||||
|
if( task != Integer.parseInt(inst.getInstruction_code())){
|
||||||
|
this.writing(list);
|
||||||
|
logServer.deviceExecuteLog(device_code, "", "", inst.getInstruction_code() + "再次下发电气信号");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//申请贴标
|
||||||
|
public synchronized void applyLabeling() {
|
||||||
|
Date date = new Date();
|
||||||
|
if (date.getTime() - this.require_apply_labeling_time.getTime() < (long) this.instruction_require_time_out) {
|
||||||
|
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out);
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
this.require_apply_labeling_time = date;
|
||||||
|
String vehicle_code = "";
|
||||||
|
if(weight == 0 ){
|
||||||
|
logServer.deviceExecuteLog(device_code, "", "", "申请贴标电气设备重量:"+weight+"异常");
|
||||||
|
message = "申请贴标电气设备重量:"+weight+"异常";
|
||||||
|
throw new RuntimeException("重量为空!");
|
||||||
|
}
|
||||||
|
if(task >0 ){
|
||||||
|
Instruction instruction = instructionService.findByCodeFromCache(String.valueOf(task));
|
||||||
|
vehicle_code = instruction.getVehicle_code();
|
||||||
|
} else {
|
||||||
|
logServer.deviceExecuteLog(device_code, "", "", "申请贴标电气设备任务号:"+task+"异常");
|
||||||
|
message = "申请贴标电气设备任务号:"+task+"异常";
|
||||||
|
throw new RuntimeException("任务号为空!");
|
||||||
|
}
|
||||||
|
if(StrUtil.isEmpty(vehicle_code)){
|
||||||
|
logServer.deviceExecuteLog(device_code, "", "", "申请贴标电气设备任务号:"+task+"未找到载具号");
|
||||||
|
message = "申请贴标电气设备任务号:"+task+"未找到载具号";
|
||||||
|
throw new RuntimeException("载具号为空!");
|
||||||
|
}
|
||||||
|
ApplyLabelingAndBindingRequest applyLabelingAndBindingRequest =
|
||||||
|
new ApplyLabelingAndBindingRequest();
|
||||||
|
JSONObject device_json = WQLObject.getWQLObject("acs_storage_cell").query("storage_code ='" + this.device_code + "'").uniqueResult(0);
|
||||||
|
String start_point_code = null;
|
||||||
|
if (!ObjectUtil.isEmpty(device_json)) {
|
||||||
|
start_point_code = (String) device_json.get("parent_storage_code") == null ? this.device_code : (String) device_json.get("parent_storage_code");
|
||||||
|
}
|
||||||
|
applyLabelingAndBindingRequest.setDevice_code(start_point_code);
|
||||||
|
applyLabelingAndBindingRequest.setType("1");
|
||||||
|
applyLabelingAndBindingRequest.setVehicle_code(vehicle_code);
|
||||||
|
applyLabelingAndBindingRequest.setWeight(String.valueOf(weight/10));
|
||||||
|
ApplyLabelingAndBindingResponse applyLabelingAndBindingResponse = acsToWmsService.applyLabelingAndBindingRequest(applyLabelingAndBindingRequest);
|
||||||
|
|
||||||
|
if(applyLabelingAndBindingResponse.getstatus() == 200){
|
||||||
|
message ="申请贴标成功";
|
||||||
|
List list = new ArrayList();
|
||||||
|
Map map = new HashMap();
|
||||||
|
map.put("code","to_command");
|
||||||
|
map.put("value","5");
|
||||||
|
list.add(map);
|
||||||
|
this.writing(list);
|
||||||
|
this.writing(list);
|
||||||
|
message ="申请贴标下发电气信号成功";
|
||||||
|
requireApplyLabelingSuccess = true;
|
||||||
|
} else {
|
||||||
|
message = "申请贴标失败,"+applyLabelingAndBindingResponse.getMessage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//申请捆扎
|
||||||
|
public synchronized void applyLaStrangulation() {
|
||||||
|
Date date = new Date();
|
||||||
|
if (date.getTime() - this.require_apply_strangulation_time.getTime() < (long) this.instruction_require_time_out) {
|
||||||
|
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out);
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
this.require_apply_strangulation_time = date;
|
||||||
|
String vehicle_code = "";
|
||||||
|
if(task >0 ){
|
||||||
|
Instruction instruction = instructionService.findByCodeFromCache(String.valueOf(task));
|
||||||
|
vehicle_code = instruction.getVehicle_code();
|
||||||
|
} else {
|
||||||
|
logServer.deviceExecuteLog(device_code, "", "", "申请捆扎电气设备任务号:"+task+"异常");
|
||||||
|
message = "申请捆扎电气设备任务号:"+task+"异常";
|
||||||
|
throw new RuntimeException("任务号为空!");
|
||||||
|
}
|
||||||
|
if(StrUtil.isEmpty(vehicle_code)){
|
||||||
|
logServer.deviceExecuteLog(device_code, "", "", "申请捆扎电气设备任务号:"+task+"未找到载具号");
|
||||||
|
message = "申请捆扎电气设备任务号:"+task+"未找到载具号";
|
||||||
|
throw new RuntimeException("载具号为空!");
|
||||||
|
}
|
||||||
|
ApplyLabelingAndBindingRequest applyLabelingAndBindingRequest =
|
||||||
|
new ApplyLabelingAndBindingRequest();
|
||||||
|
JSONObject device_json = WQLObject.getWQLObject("acs_storage_cell").query("storage_code ='" + this.device_code + "'").uniqueResult(0);
|
||||||
|
String start_point_code = null;
|
||||||
|
if (!ObjectUtil.isEmpty(device_json)) {
|
||||||
|
start_point_code = (String) device_json.get("parent_storage_code") == null ? this.device_code : (String) device_json.get("parent_storage_code");
|
||||||
|
}
|
||||||
|
applyLabelingAndBindingRequest.setDevice_code(start_point_code);
|
||||||
|
applyLabelingAndBindingRequest.setType("2");
|
||||||
|
applyLabelingAndBindingRequest.setVehicle_code(vehicle_code);
|
||||||
|
ApplyLabelingAndBindingResponse applyLabelingAndBindingResponse = acsToWmsService.applyLabelingAndBindingRequest(applyLabelingAndBindingRequest);
|
||||||
|
if(applyLabelingAndBindingResponse.getstatus() == 200) {
|
||||||
|
if(ObjectUtil.isNotEmpty( applyLabelingAndBindingResponse.getData())){
|
||||||
|
Map datas = applyLabelingAndBindingResponse.getData();
|
||||||
|
String length = datas.get("box_length").toString();
|
||||||
|
String width = datas.get("box_width").toString();
|
||||||
|
String box_high = datas.get("box_high").toString();
|
||||||
|
String bundle_times = datas.get("bundle_times").toString();
|
||||||
|
|
||||||
|
List list = new ArrayList();
|
||||||
|
Map map = new HashMap();
|
||||||
|
map.put("code","to_length");
|
||||||
|
map.put("value",length);
|
||||||
|
list.add(map);
|
||||||
|
Map map2 = new HashMap();
|
||||||
|
map2.put("code","to_weight");
|
||||||
|
map2.put("value",width);
|
||||||
|
list.add(map2);
|
||||||
|
Map map3 = new HashMap();
|
||||||
|
map3.put("code","to_height");
|
||||||
|
map3.put("value",box_high);
|
||||||
|
list.add(map3);
|
||||||
|
Map map4 = new HashMap();
|
||||||
|
map4.put("code","to_strap_times");
|
||||||
|
map4.put("value",bundle_times);
|
||||||
|
list.add(map4);
|
||||||
|
Map map5 = new HashMap();
|
||||||
|
map5.put("code","to_command");
|
||||||
|
map5.put("value","4");
|
||||||
|
list.add(map5);
|
||||||
|
this.writing(list);
|
||||||
|
this.writing(list);
|
||||||
|
message ="申请贴标成功";
|
||||||
|
requireApplyLaStrangulationSuccess = true;
|
||||||
|
} else {
|
||||||
|
message = "未返回尺寸信息";
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
message = applyLabelingAndBindingResponse.getMessage();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized void emptyIn() {
|
||||||
|
Date date = new Date();
|
||||||
|
if (date.getTime() - this.require_empty_in_time.getTime() < (long) this.instruction_require_time_out) {
|
||||||
|
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out);
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
this.require_empty_in_time = date;
|
||||||
|
|
||||||
|
if (StrUtil.equals(paramService.findByCode(AcsConfig.HASWMS).getValue(), "1")) {
|
||||||
|
message = "申请空盘入库任务中...";
|
||||||
|
JSONObject apply = new JSONObject();
|
||||||
|
apply.put("device_code", device_code);
|
||||||
|
apply.put("type","2");
|
||||||
|
String str = acsToWmsService.applyTaskToWms(apply);
|
||||||
|
JSONObject jo = JSON.parseObject(str);
|
||||||
|
if (ObjectUtil.isEmpty(jo)) {
|
||||||
|
message = "申请空盘入库接口不通";
|
||||||
|
} else {
|
||||||
|
if (jo.getInteger("status") == 200) {
|
||||||
|
message = "申请空盘入库成功";
|
||||||
|
requireEmptyInSuccess = true;
|
||||||
|
} else {
|
||||||
|
requireEmptyInSuccess = false;
|
||||||
|
message = "申请空盘入库失败,"+jo.get("message").toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized void applyAgvTask() {
|
||||||
|
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;
|
||||||
|
} else {
|
||||||
|
this.instruction_require_time = date;
|
||||||
|
if (StrUtil.equals(paramService.findByCode(AcsConfig.HASWMS).getValue(), "1")) {
|
||||||
|
message = "申请AGV搬运任务中...";
|
||||||
|
JSONObject apply = new JSONObject();
|
||||||
|
apply.put("device_code", device_code);
|
||||||
|
apply.put("type","1");
|
||||||
|
String str = acsToWmsService.applyTaskToWms(apply);
|
||||||
|
JSONObject jo = JSON.parseObject(str);
|
||||||
|
if (ObjectUtil.isEmpty(jo)) {
|
||||||
|
message = "申请AGV搬运任务接口不通";
|
||||||
|
} else {
|
||||||
|
if (jo.getInteger("status") == 200) {
|
||||||
|
message = "申请AGV搬运任务成功";
|
||||||
|
requireEmptyOutSuccess = true;
|
||||||
|
} else {
|
||||||
|
requireEmptyOutSuccess = false;
|
||||||
|
message = "申请AGV搬运任务失败,"+jo.get("message").toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized void emptyOut() {
|
||||||
|
Date date = new Date();
|
||||||
|
if (date.getTime() - this.require_empty_out_time.getTime() < (long) this.instruction_require_time_out) {
|
||||||
|
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out);
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
this.require_empty_out_time = date;
|
||||||
|
if (StrUtil.equals(paramService.findByCode(AcsConfig.HASWMS).getValue(), "1")) {
|
||||||
|
message = "申请空盘出库任务中...";
|
||||||
|
JSONObject apply = new JSONObject();
|
||||||
|
apply.put("device_code", device_code);
|
||||||
|
apply.put("type","3");
|
||||||
|
String str = acsToWmsService.applyTaskToWms(apply);
|
||||||
|
JSONObject jo = JSON.parseObject(str);
|
||||||
|
if (ObjectUtil.isEmpty(jo)) {
|
||||||
|
message = "申请空盘出库接口不通";
|
||||||
|
} else {
|
||||||
|
if (jo.getInteger("status") == 200) {
|
||||||
|
message = "申请空盘出库成功";
|
||||||
|
requireEmptyOutSuccess = true;
|
||||||
|
} else {
|
||||||
|
requireEmptyOutSuccess = false;
|
||||||
|
message = "申请空盘出库失败,"+jo.get("message").toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
package org.nl.acs.device_driver.basedriver.standard_conveyor_control_with_scanner;
|
package org.nl.acs.device_driver.basedriver.standard_conveyor_control_with_scanner;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.nl.acs.device.device_driver.standard_inspect.ItemDto;
|
import org.nl.acs.device.device_driver.standard_inspect.ItemDto;
|
||||||
@@ -24,6 +25,11 @@ public class ItemProtocol {
|
|||||||
public static String item_error = "error";
|
public static String item_error = "error";
|
||||||
//任务号
|
//任务号
|
||||||
public static String item_task = "task";
|
public static String item_task = "task";
|
||||||
|
//条码长度
|
||||||
|
public static String item_barcode_length = "barcode_length";
|
||||||
|
//条码
|
||||||
|
public static String item_barcode = "barcode";
|
||||||
|
|
||||||
|
|
||||||
//下发命令
|
//下发命令
|
||||||
public static String item_to_command = "to_command";
|
public static String item_to_command = "to_command";
|
||||||
@@ -73,6 +79,14 @@ public class ItemProtocol {
|
|||||||
return this.getOpcIntegerValue(item_task);
|
return this.getOpcIntegerValue(item_task);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getBarCode_length() {
|
||||||
|
return this.getOpcIntegerValue(item_barcode_length);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getplcBarCode() {
|
||||||
|
return this.getOpcStringValue(item_barcode);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Boolean isonline;
|
Boolean isonline;
|
||||||
|
|
||||||
@@ -89,27 +103,39 @@ public class ItemProtocol {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getOpcStringValue(String protocol) {
|
||||||
|
String value = this.driver.getStringValue(protocol);
|
||||||
|
if (StrUtil.isEmpty(value)) {
|
||||||
|
|
||||||
|
} else {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
return "0";
|
||||||
|
}
|
||||||
|
|
||||||
public static List<ItemDto> getReadableItemDtos() {
|
public static List<ItemDto> getReadableItemDtos() {
|
||||||
ArrayList list = new ArrayList();
|
ArrayList list = new ArrayList();
|
||||||
list.add(new ItemDto(item_heartbeat, "心跳", "DB600.B0"));
|
list.add(new ItemDto(item_heartbeat, "心跳", "DB101.B0"));
|
||||||
list.add(new ItemDto(item_mode, "工作模式", "DB600.B2"));
|
list.add(new ItemDto(item_mode, "工作模式", "DB101.B252"));
|
||||||
list.add(new ItemDto(item_move, "光电信号", "DB600.B3"));
|
list.add(new ItemDto(item_move, "光电信号", "DB101.B253"));
|
||||||
list.add(new ItemDto(item_carrier_direction, "托盘方向", "DB600.B4"));
|
list.add(new ItemDto(item_carrier_direction, "托盘方向", "DB101.B254"));
|
||||||
list.add(new ItemDto(item_error, "报警信号", "DB600.B6"));
|
list.add(new ItemDto(item_error, "报警信号", "DB101.B256"));
|
||||||
list.add(new ItemDto(item_task, "任务号", "DB600.D10"));
|
list.add(new ItemDto(item_task, "任务号", "DB101.D260"));
|
||||||
|
list.add(new ItemDto(item_barcode_length, "条码长度", "DB101.B800"));
|
||||||
|
list.add(new ItemDto(item_barcode, "条码", "DB101.STRING802.50"));
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<ItemDto> getWriteableItemDtos() {
|
public static List<ItemDto> getWriteableItemDtos() {
|
||||||
ArrayList list = new ArrayList();
|
ArrayList list = new ArrayList();
|
||||||
list.add(new ItemDto(item_to_command, "下发命令", "DB601.W2"));
|
list.add(new ItemDto(item_to_command, "下发命令", "DB102.W252"));
|
||||||
list.add(new ItemDto(item_to_target, "下发目标站", "DB601.W4"));
|
list.add(new ItemDto(item_to_target, "下发目标站", "DB102.W254"));
|
||||||
list.add(new ItemDto(item_to_task, "下发任务号", "DB601.D8"));
|
list.add(new ItemDto(item_to_task, "下发任务号", "DB102.D258"));
|
||||||
list.add(new ItemDto(item_to_strap_times, "捆扎次数", "DB601.W12"));
|
// list.add(new ItemDto(item_to_strap_times, "捆扎次数", "DB102.W12"));
|
||||||
list.add(new ItemDto(item_to_length, "木箱长度", "DB601.W14"));
|
// list.add(new ItemDto(item_to_length, "木箱长度", "DB102.W14"));
|
||||||
list.add(new ItemDto(item_to_weight, "木箱宽度", "DB601.W16"));
|
// list.add(new ItemDto(item_to_weight, "木箱宽度", "DB102.W16"));
|
||||||
list.add(new ItemDto(item_to_height, "木箱高度", "DB601.W18"));
|
// list.add(new ItemDto(item_to_height, "木箱高度", "DB102.W18"));
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -84,6 +84,8 @@ public class StandardCoveyorControlWithScannerDeviceDriver extends AbstractOpcDe
|
|||||||
int action = 0;
|
int action = 0;
|
||||||
int error = 0;
|
int error = 0;
|
||||||
int task = 0;
|
int task = 0;
|
||||||
|
String plcbarcode = null;
|
||||||
|
int plcbarcode_length = 0;
|
||||||
|
|
||||||
Boolean isonline = true;
|
Boolean isonline = true;
|
||||||
|
|
||||||
@@ -178,6 +180,8 @@ public class StandardCoveyorControlWithScannerDeviceDriver extends AbstractOpcDe
|
|||||||
move = this.itemProtocol.getMove();
|
move = this.itemProtocol.getMove();
|
||||||
error = this.itemProtocol.getError();
|
error = this.itemProtocol.getError();
|
||||||
task = this.itemProtocol.getTask();
|
task = this.itemProtocol.getTask();
|
||||||
|
plcbarcode = this.itemProtocol.getplcBarCode();
|
||||||
|
plcbarcode_length = this.itemProtocol.getBarCode_length();
|
||||||
|
|
||||||
if (mode != last_mode) {
|
if (mode != last_mode) {
|
||||||
this.setRequireSucess(false);
|
this.setRequireSucess(false);
|
||||||
@@ -230,11 +234,22 @@ public class StandardCoveyorControlWithScannerDeviceDriver extends AbstractOpcDe
|
|||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
//申请任务
|
//申请任务
|
||||||
if (move > 0 && !StrUtil.isEmpty(barcode()) && !requireSucess) {
|
String newBarcode = null;
|
||||||
instruction_require(barcode());
|
if(!StrUtil.equals(plcbarcode,"0")){
|
||||||
|
newBarcode = plcbarcode;
|
||||||
|
} else {
|
||||||
|
if(!StrUtil.isEmpty(barcode())){
|
||||||
|
newBarcode = barcode();
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (move > 0 && !StrUtil.isEmpty(barcode()) && !applySucess) {
|
|
||||||
instruction_apply(barcode());
|
if (move > 0 && !StrUtil.isEmpty(newBarcode) && !requireSucess) {
|
||||||
|
instruction_require(newBarcode);
|
||||||
|
}
|
||||||
|
if (move > 0 && !StrUtil.isEmpty(newBarcode) && !applySucess) {
|
||||||
|
instruction_apply(newBarcode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
switch (flag) {
|
switch (flag) {
|
||||||
|
|||||||
@@ -12,4 +12,7 @@ public class ApplyLabelingAndBindingRequest extends BaseRequest {
|
|||||||
* 3:烘箱
|
* 3:烘箱
|
||||||
*/
|
*/
|
||||||
private String type;
|
private String type;
|
||||||
|
|
||||||
|
private String weight;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -231,11 +231,13 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Instruction findByTaskcodeAndStatus(String code) {
|
public Instruction findByTaskcodeAndStatus(String code) {
|
||||||
WQLObject wo = WQLObject.getWQLObject("acs_instruction");
|
Iterator var3 = instructions.iterator();
|
||||||
JSONObject json = wo.query("task_code ='" + code + "' and instruction_status = '0'").uniqueResult(0);
|
while (var3.hasNext()) {
|
||||||
if (ObjectUtil.isNotEmpty(json)){
|
Instruction instruction = (Instruction) var3.next();
|
||||||
final Instruction obj = json.toJavaObject(Instruction.class);
|
if (StrUtil.equals(instruction.getTask_code(), code)
|
||||||
return obj;
|
&& StrUtil.equals(instruction.getInstruction_status(), "0")) {
|
||||||
|
return instruction;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ public class DeviceOpcProtocolRunable implements Runnable {
|
|||||||
log.trace("{} 读取耗时:{}", tag, duration);
|
log.trace("{} 读取耗时:{}", tag, duration);
|
||||||
if (duration > 1000L) {
|
if (duration > 1000L) {
|
||||||
if (!time_out) {
|
if (!time_out) {
|
||||||
log.warn("{} 读取超时 : {}", tag, duration);
|
log.warn(" {} 读取超时 : {} ", tag, duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
time_out = true;
|
time_out = true;
|
||||||
|
|||||||
@@ -93,6 +93,7 @@ import slit_two_manipulator from '@/views/acs/device/driver/slit_two_manipulator
|
|||||||
import hongxiang_device from '@/views/acs/device/driver/hongxiang_device'
|
import hongxiang_device from '@/views/acs/device/driver/hongxiang_device'
|
||||||
import hongxiang_conveyor from '@/views/acs/device/driver/hongxiang_conveyor'
|
import hongxiang_conveyor from '@/views/acs/device/driver/hongxiang_conveyor'
|
||||||
import plug_pull_device_site from '@/views/acs/device/driver/plug_pull_device_site'
|
import plug_pull_device_site from '@/views/acs/device/driver/plug_pull_device_site'
|
||||||
|
import siemens_conveyor_labeling from '@/views/acs/device/driver/siemens_conveyor_labeling'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'DeviceConfig',
|
name: 'DeviceConfig',
|
||||||
@@ -116,7 +117,8 @@ export default {
|
|||||||
oven_manipulator,
|
oven_manipulator,
|
||||||
siemens_conveyor,
|
siemens_conveyor,
|
||||||
slit_two_manipulator,
|
slit_two_manipulator,
|
||||||
plug_pull_device_site
|
plug_pull_device_site,
|
||||||
|
siemens_conveyor_labeling
|
||||||
},
|
},
|
||||||
dicts: ['device_type'],
|
dicts: ['device_type'],
|
||||||
mixins: [crud],
|
mixins: [crud],
|
||||||
|
|||||||
@@ -0,0 +1,513 @@
|
|||||||
|
<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.address" />
|
||||||
|
</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: 'StandardConveyorControl',
|
||||||
|
mixins: [crud],
|
||||||
|
props: {
|
||||||
|
parentForm: {
|
||||||
|
type: Object,
|
||||||
|
require: true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
device_code: '',
|
||||||
|
device_id: '',
|
||||||
|
plc_id: '',
|
||||||
|
plc_code: '',
|
||||||
|
address: '',
|
||||||
|
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) {
|
||||||
|
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('mode') !== -1) {
|
||||||
|
this.data1[val].db = beforeStr + '.' + afterStr.substring(0, 1) + (parseInt(endNumber) + 0)
|
||||||
|
}
|
||||||
|
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('carrier_direction') !== -1) {
|
||||||
|
this.data1[val].db = beforeStr + '.' + afterStr.substring(0, 1) + (parseInt(endNumber) + 2)
|
||||||
|
}
|
||||||
|
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) + 8)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
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
|
||||||
|
}
|
||||||
|
console.log(endNumber)
|
||||||
|
for (const val in this.data2) {
|
||||||
|
if (this.data2[val].code.indexOf('to_command') !== -1) {
|
||||||
|
this.data2[val].db = beforeStr + '.' + afterStr.substring(0, 1) + (parseInt(endNumber) + 0)
|
||||||
|
}
|
||||||
|
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_container_type') !== -1) {
|
||||||
|
this.data2[val].db = beforeStr + '.' + afterStr.substring(0, 1) + (parseInt(endNumber) + 4)
|
||||||
|
}
|
||||||
|
if (this.data2[val].code.indexOf('to_task') !== -1) {
|
||||||
|
this.data2[val].db = beforeStr + '.' + 'D' + (parseInt(endNumber) + 6)
|
||||||
|
}
|
||||||
|
if (this.data2[val].code.indexOf('to_strap_times') !== -1) {
|
||||||
|
this.data2[val].db = beforeStr + '.' + afterStr.substring(0, 1) + (parseInt(endNumber) + 10)
|
||||||
|
}
|
||||||
|
if (this.data2[val].code.indexOf('to_length') !== -1) {
|
||||||
|
this.data2[val].db = beforeStr + '.' + afterStr.substring(0, 1) + (parseInt(endNumber) + 12)
|
||||||
|
}
|
||||||
|
if (this.data2[val].code.indexOf('to_weight') !== -1) {
|
||||||
|
this.data2[val].db = beforeStr + '.' + afterStr.substring(0, 1) + (parseInt(endNumber) + 14)
|
||||||
|
}
|
||||||
|
if (this.data2[val].code.indexOf('to_height') !== -1) {
|
||||||
|
this.data2[val].db = beforeStr + '.' + afterStr.substring(0, 1) + (parseInt(endNumber) + 16)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
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