更新
This commit is contained in:
@@ -43,7 +43,9 @@ public enum DriverTypeEnum {
|
||||
|
||||
SIEMENS_CONVEYOR_LABELING(16, "siemens_conveyor_labeling", "西门子-输送机驱动-贴标", "conveyor"),
|
||||
|
||||
SIEMENS_CONVEYOR_CKK(17, "siemens_conveyor_ckk", "西门子-输送机驱动-出库口", "conveyor");
|
||||
SIEMENS_CONVEYOR_CKK(17, "siemens_conveyor_ckk", "西门子-输送机驱动-出库口", "conveyor"),
|
||||
|
||||
SIEMENS_ONEFLOOR_AGV_CONVEYOR(17, "siemens_onefloor_agv_conveyor", "西门子-1LAGV-输送机驱动", "conveyor");
|
||||
|
||||
|
||||
//驱动索引
|
||||
|
||||
@@ -20,6 +20,7 @@ import org.nl.acs.device.device_driver.standard_inspect.ItemDto;
|
||||
import org.nl.acs.device.device_driver.standard_inspect.ReadUtil;
|
||||
import org.nl.acs.device.service.*;
|
||||
import org.nl.acs.device.service.dto.*;
|
||||
import org.nl.acs.device_driver.DeviceDriver;
|
||||
import org.nl.acs.device_driver.DeviceDriverDefination;
|
||||
import org.nl.acs.device_driver.ScannerDeviceDriver;
|
||||
import org.nl.acs.device_driver.basedriver.oven_manipulator.OvenGantryManipulatorDeviceDriver;
|
||||
@@ -32,9 +33,7 @@ import org.nl.acs.device_driver.basedriver.standard_inspect_site.StandardInspect
|
||||
import org.nl.acs.device_driver.basedriver.standard_ordinary_site.StandardOrdinarySiteDeviceDriver;
|
||||
import org.nl.acs.device_driver.basedriver.standard_scanner.StandardScannerDeviceDriver;
|
||||
import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination;
|
||||
import org.nl.acs.opc.Device;
|
||||
import org.nl.acs.opc.DeviceAppService;
|
||||
import org.nl.acs.opc.DeviceAppServiceImpl;
|
||||
import org.nl.acs.opc.*;
|
||||
import org.nl.modules.common.exception.BadRequestException;
|
||||
import org.nl.modules.common.utils.FileUtil;
|
||||
import org.nl.modules.common.utils.RedisUtils;
|
||||
@@ -76,6 +75,7 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial
|
||||
private final DeviceDriverDefinationAppService deviceDriverDefinationAppService;
|
||||
private final DeviceAppService deviceAppService;
|
||||
private final ParamService paramService;
|
||||
private final DeviceManageService deviceManageService;
|
||||
List<StorageCellDto> storageCells = new ArrayList<>();
|
||||
private Map<String, Integer> storage_address = new HashMap();
|
||||
|
||||
@@ -629,27 +629,6 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// for(int i=0; i<result.size(); i++) {
|
||||
// JSONObject jo = (JSONObject) result.get(i);
|
||||
// JSONObject devicejo = new JSONObject();
|
||||
// String device_id = jo.getString("device_id");
|
||||
// String device_code = jo.getString("device_code");
|
||||
// String device_name = jo.getString("device_name");
|
||||
// Device device = appService.findDeviceByCode(device_code);
|
||||
// if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
|
||||
// standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver();
|
||||
// int branchProtocol = standardOrdinarySiteDeviceDriver.getBranchProtocol();
|
||||
// devicejo.put("device_code",device_code);
|
||||
// devicejo.put("branchProtocol",branchProtocol);
|
||||
// devicejo.put("qty",standardOrdinarySiteDeviceDriver.getQty());
|
||||
// devicejo.put("material",standardOrdinarySiteDeviceDriver.getMaterial());
|
||||
// devicejo.put("status",standardOrdinarySiteDeviceDriver.isRequireSucess());
|
||||
//
|
||||
// deviceInfo.add(devicejo);
|
||||
// }
|
||||
// }
|
||||
|
||||
return deviceInfo;
|
||||
|
||||
}
|
||||
@@ -847,8 +826,25 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial
|
||||
}
|
||||
|
||||
}
|
||||
deviceAppService.removeDevice(device_code);
|
||||
|
||||
//deviceAppService.reload();
|
||||
deviceAppService.addDevice(device_code);
|
||||
|
||||
// if (!StrUtil.isEmpty(device.getDriver_code())) {
|
||||
// DeviceDriverDefination defination = this.deviceDriverDefinationAppService.getDeviceDriverDefination(deviceManage.getDriver_code());
|
||||
// if (defination != null) {
|
||||
// device.setDeviceDriverDefination(defination);
|
||||
// DeviceDriver driver = defination.getDriverInstance(device);
|
||||
// device.setDeviceDriver(driver);
|
||||
//
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// deviceAppService.reload();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -10,6 +10,7 @@ import org.nl.acs.auto.run.OneNDCSocketConnectionAutoRun;
|
||||
import org.nl.acs.device.service.DeviceService;
|
||||
import org.nl.acs.device_driver.DeviceDriver;
|
||||
import org.nl.acs.device_driver.basedriver.siemens_conveyor.SiemensConveyorDeviceDriver;
|
||||
import org.nl.acs.device_driver.basedriver.siemens_onefloor_agv_conveyor.SiemensOneFloorAGVConveyorDeviceDriver;
|
||||
import org.nl.acs.device_driver.basedriver.standard_ordinary_site.StandardOrdinarySiteDeviceDriver;
|
||||
import org.nl.acs.device_driver.basedriver.standard_storage.StandardStorageDeviceDriver;
|
||||
import org.nl.acs.device_driver.driver.AbstractDeviceDriver;
|
||||
@@ -117,6 +118,8 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
|
||||
StandardStorageDeviceDriver standardStorageDeviceDriver;
|
||||
//
|
||||
SiemensConveyorDeviceDriver siemensConveyorDeviceDriver;
|
||||
//1LAGV取货
|
||||
SiemensOneFloorAGVConveyorDeviceDriver siemensOneFloorAGVConveyorDeviceDriver;
|
||||
|
||||
//分配 车id
|
||||
//(不需要WCS反馈)
|
||||
@@ -179,6 +182,23 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
|
||||
}
|
||||
}
|
||||
|
||||
if (device.getDeviceDriver() instanceof SiemensConveyorDeviceDriver) {
|
||||
siemensConveyorDeviceDriver = (SiemensConveyorDeviceDriver) device.getDeviceDriver();
|
||||
if (siemensConveyorDeviceDriver.getMove() == 1) {
|
||||
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0);
|
||||
} else {
|
||||
log.info("请求取货条件不满足待机有货");
|
||||
}
|
||||
}
|
||||
|
||||
if (device.getDeviceDriver() instanceof SiemensOneFloorAGVConveyorDeviceDriver) {
|
||||
siemensOneFloorAGVConveyorDeviceDriver = (SiemensOneFloorAGVConveyorDeviceDriver) device.getDeviceDriver();
|
||||
if (siemensOneFloorAGVConveyorDeviceDriver.getMove() == 1) {
|
||||
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0);
|
||||
} else {
|
||||
log.info("请求取货条件不满足待机有货");
|
||||
}
|
||||
}
|
||||
if (device.getDeviceDriver() instanceof StandardStorageDeviceDriver) {
|
||||
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0);
|
||||
}
|
||||
@@ -247,6 +267,24 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
|
||||
}
|
||||
}
|
||||
|
||||
if (device.getDeviceDriver() instanceof SiemensOneFloorAGVConveyorDeviceDriver) {
|
||||
siemensOneFloorAGVConveyorDeviceDriver = (SiemensOneFloorAGVConveyorDeviceDriver) device.getDeviceDriver();
|
||||
if(siemensOneFloorAGVConveyorDeviceDriver.getTo_command() == 2){
|
||||
log.info("取货完成请求离开,当前输送to_command:"+siemensOneFloorAGVConveyorDeviceDriver.getTo_command());
|
||||
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0);
|
||||
} else {
|
||||
log.info("取货完成请求离开下发输送信号,当前输送to_command:"+siemensOneFloorAGVConveyorDeviceDriver.getTo_command());
|
||||
List list = new ArrayList();
|
||||
Map map = new HashMap();
|
||||
map.put("code", "to_command");
|
||||
map.put("value", "2");
|
||||
list.add(map);
|
||||
siemensOneFloorAGVConveyorDeviceDriver.writing(list);
|
||||
siemensOneFloorAGVConveyorDeviceDriver.writing(list);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (device.getDeviceDriver() instanceof StandardStorageDeviceDriver) {
|
||||
standardStorageDeviceDriver = (StandardStorageDeviceDriver) device.getDeviceDriver();
|
||||
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0);
|
||||
|
||||
@@ -158,6 +158,9 @@ public class HongXiangConveyorDeviceDriver extends AbstractOpcDeviceDriver imple
|
||||
currentB = this.itemProtocol.getItem_currentB();
|
||||
currentC = this.itemProtocol.getItem_currentC();
|
||||
to_temperature = this.itemProtocol.getItem_to_temperature();
|
||||
if(door != last_door){
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号door:" + last_door + "->" + door);
|
||||
}
|
||||
if (mode != last_mode) {
|
||||
//this.setRequireSucess(false);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,128 @@
|
||||
package org.nl.acs.device_driver.basedriver.siemens_onefloor_agv_conveyor;
|
||||
|
||||
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_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 SiemensOneFloorAGVConveyorDeviceDriver driver;
|
||||
|
||||
public ItemProtocol(SiemensOneFloorAGVConveyorDeviceDriver 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 getTo_command() {
|
||||
return this.getOpcIntegerValue(item_to_command);
|
||||
}
|
||||
|
||||
|
||||
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_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"));
|
||||
return list;
|
||||
}
|
||||
|
||||
public static List<ItemDto> getWriteableItemDtos() {
|
||||
ArrayList list = new ArrayList();
|
||||
list.add(new ItemDto(item_to_command, "下发命令", "DB102.W152"));
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
package org.nl.acs.device_driver.basedriver.siemens_onefloor_agv_conveyor;
|
||||
|
||||
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 SiemensOneFloorAGVConveyorDefination implements OpcDeviceDriverDefination {
|
||||
@Override
|
||||
public String getDriverCode() {
|
||||
return "siemens_onefloor_agv_conveyor";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDriverName() {
|
||||
return "西门子-1LAGV-输送机驱动";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDriverDescription() {
|
||||
return "西门子-1LAGV-输送机驱动";
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeviceDriver getDriverInstance(Device device) {
|
||||
return (new SiemensOneFloorAGVConveyorDeviceDriver()).setDevice(device).setDriverDefination(this);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends DeviceDriver> getDeviceDriverType() {
|
||||
return SiemensOneFloorAGVConveyorDeviceDriver.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,341 @@
|
||||
package org.nl.acs.device_driver.basedriver.siemens_onefloor_agv_conveyor;
|
||||
|
||||
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 cn.hutool.http.HttpResponse;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.Data;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.SneakyThrows;
|
||||
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.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.*;
|
||||
|
||||
/**
|
||||
* 西门子-1LAGV-输送机驱动
|
||||
*/
|
||||
@Slf4j
|
||||
@Data
|
||||
@RequiredArgsConstructor
|
||||
public class SiemensOneFloorAGVConveyorDeviceDriver 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 last_task = 0;
|
||||
int agvphase = 0;
|
||||
String task_code = null;
|
||||
int to_command = 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 = 3000;
|
||||
//行架机械手申请任务成功标识
|
||||
boolean requireSucess = false;
|
||||
boolean requireApplyLabelingSuccess = false;
|
||||
boolean requireApplyLaStrangulationSuccess = false;
|
||||
boolean requireEmptyInSuccess = false;
|
||||
boolean requireEmptyOutSuccess = false;
|
||||
boolean requiresShipDeviceUpdate = true;
|
||||
private int instruction_finished_time_out;
|
||||
|
||||
int branchProtocol = 0;
|
||||
String inst_message;
|
||||
String last_inst_message;
|
||||
|
||||
//当前指令
|
||||
|
||||
//暂定 0就绪 1请求取货 2取货完成 3请求放货 4放货完成 5取货完成离开 6放货完成离开 7请求进入区域 8请求离开区域
|
||||
int flag;
|
||||
|
||||
String device_code;
|
||||
|
||||
String vehicle_code;
|
||||
String last_vehicle_code;
|
||||
|
||||
@Override
|
||||
public Device getDevice() {
|
||||
return this.device;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
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();
|
||||
to_command = this.itemProtocol.getTo_command();
|
||||
|
||||
} catch (Exception var17) {
|
||||
inst_message = var17.getMessage();
|
||||
logServer.deviceExecuteLog(this.getDevice_code(), "", "", "读取信号值时出现异常:" + var17.getMessage());
|
||||
}
|
||||
|
||||
if (mode == 0) {
|
||||
this.setIsonline(false);
|
||||
message = "未联机";
|
||||
|
||||
} else {
|
||||
this.setIsonline(true);
|
||||
this.setIserror(false);
|
||||
if (error != 0) {
|
||||
this.setIserror(true);
|
||||
message = "有报警";
|
||||
}
|
||||
|
||||
}
|
||||
last_mode = mode;
|
||||
last_move = move;
|
||||
last_carrier_direction = carrier_direction;
|
||||
last_error = error;
|
||||
last_task = task;
|
||||
}
|
||||
|
||||
|
||||
|
||||
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;
|
||||
Map<String, Object> itemMap = new HashMap<String, Object>();
|
||||
|
||||
itemMap.put(to_param, Integer.parseInt(value));
|
||||
this.control(itemMap);
|
||||
logServer.deviceExecuteLog(device_code, "", "", "下发电气信号设备号:" + device_code + ",下发电气:" + to_param + ",下发电气值:" + value);
|
||||
}
|
||||
|
||||
public void executing(Server server, Map<String, Object> itemMap) {
|
||||
this.control(itemMap);
|
||||
}
|
||||
|
||||
public void writing(int command) {
|
||||
|
||||
Map<String, Object> itemMap = new HashMap<String, Object>();
|
||||
this.control(itemMap);
|
||||
|
||||
}
|
||||
|
||||
@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("last_task", last_task);
|
||||
jo.put("task_code", task_code);
|
||||
jo.put("inst_message", this.inst_message);
|
||||
jo.put("last_inst_message", this.last_inst_message);
|
||||
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) {
|
||||
|
||||
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);
|
||||
this.control(itemMap);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -112,6 +112,13 @@ public class ItemProtocol {
|
||||
return this.getOpcIntegerValue(item_task2);
|
||||
}
|
||||
|
||||
public int getTo_command1() {
|
||||
return this.getOpcIntegerValue(item_to_command1);
|
||||
}
|
||||
|
||||
public int getTo_command2() {
|
||||
return this.getOpcIntegerValue(item_to_command2);
|
||||
}
|
||||
|
||||
//是否有货
|
||||
public int hasGoods(int move) {
|
||||
|
||||
@@ -91,7 +91,8 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl
|
||||
int last_task1 = 0;
|
||||
int task2 = 0;
|
||||
int last_task2 = 0;
|
||||
|
||||
int to_command1 = 0;
|
||||
int to_command2 = 0;
|
||||
|
||||
Boolean isonline = true;
|
||||
//前工位申请任务请求标记
|
||||
@@ -155,6 +156,8 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl
|
||||
type = this.itemProtocol.getType();
|
||||
task1 = this.itemProtocol.getTask1();
|
||||
task2 = this.itemProtocol.getTask2();
|
||||
to_command1 = this.itemProtocol.getTo_command1();
|
||||
to_command2 = this.itemProtocol.getTo_command2();
|
||||
|
||||
if (mode != last_mode) {
|
||||
if (mode == 2) {
|
||||
@@ -243,19 +246,6 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl
|
||||
inst2.setInstruction_status("1");
|
||||
inst2.setExecute_device_code(this.device_code);
|
||||
instructionService.update(inst2);
|
||||
// TaskDto taskDto = taskserver.findByCodeFromCache(inst2.getTask_code());
|
||||
// if (!ObjectUtil.isEmpty(taskDto)) {
|
||||
// if (StrUtil.isNotEmpty(taskDto.getExt_task_id())) {
|
||||
// JSONArray array = new JSONArray();
|
||||
// JSONObject map = new JSONObject();
|
||||
// map.put("task_id", taskDto.getExt_task_id());
|
||||
// map.put("task_status", "1");
|
||||
// array.add(map);
|
||||
// acsToWmsService.feedbackTaskStatusToWms(array);
|
||||
// }
|
||||
// }
|
||||
;
|
||||
// this.setNow_steps_type2(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -270,18 +260,6 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl
|
||||
inst2.setInstruction_status("1");
|
||||
inst2.setExecute_device_code(this.device_code);
|
||||
instructionService.update(inst2);
|
||||
// TaskDto taskDto = taskserver.findByCodeFromCache(inst2.getTask_code());
|
||||
// if (!ObjectUtil.isEmpty(taskDto)) {
|
||||
// if (StrUtil.isNotEmpty(taskDto.getExt_task_id())) {
|
||||
// JSONArray array = new JSONArray();
|
||||
// JSONObject map = new JSONObject();
|
||||
// map.put("task_id", taskDto.getExt_task_id());
|
||||
// map.put("task_status", "1");
|
||||
// array.add(map);
|
||||
// acsToWmsService.feedbackTaskStatusToWms(array);
|
||||
// }
|
||||
// }
|
||||
;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -302,7 +280,9 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl
|
||||
int move = siemensConveyorDeviceDriver.getMove();
|
||||
int mode = siemensConveyorDeviceDriver.getMode();
|
||||
if (mode == 2 && move == 1) {
|
||||
this.writing("to_command2", "2");
|
||||
if(to_command2 != 2){
|
||||
this.writing("to_command2", "2");
|
||||
}
|
||||
if (type == 2) {
|
||||
this.setNow_steps_type2(3);
|
||||
} else if (type == 3) {
|
||||
@@ -340,7 +320,9 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl
|
||||
|
||||
//单任务/或双任务 后工位收到取货完成信号并反馈
|
||||
if (mode == 3 && action2 == 2 && move2 == 1 && task2 > 0) {
|
||||
this.writing("to_command2", "3");
|
||||
if(to_command2 != 3){
|
||||
this.writing("to_command2", "3");
|
||||
}
|
||||
if (type == 2) {
|
||||
this.setNow_steps_type2(4);
|
||||
}
|
||||
@@ -367,7 +349,9 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl
|
||||
|
||||
//单任务/双任务 前工位取货时判断动作信号并反馈
|
||||
if (mode == 3 && action1 == 1 && move1 == 0 && task1 > 0) {
|
||||
this.writing("to_command1", "2");
|
||||
if(to_command1 != 2){
|
||||
this.writing("to_command1", "2");
|
||||
}
|
||||
if (type == 1) {
|
||||
this.setNow_steps_type1(3);
|
||||
} else if (type == 3) {
|
||||
@@ -393,7 +377,9 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl
|
||||
|
||||
//单任务/双任务 前工位取货完成并反馈
|
||||
if (mode == 3 && action1 == 2 && move1 == 1 && task1 > 0) {
|
||||
this.writing("to_command1", "3");
|
||||
if(to_command1 != 3){
|
||||
this.writing("to_command1", "3");
|
||||
}
|
||||
if (type == 1) {
|
||||
this.setNow_steps_type1(4);
|
||||
}
|
||||
@@ -421,7 +407,9 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl
|
||||
|
||||
//单任务/双任务 后工位放货时判断信号并反馈
|
||||
if (mode == 3 && action2 == 3 && move2 == 1 && task2 > 0) {
|
||||
this.writing("to_command2", "4");
|
||||
if(to_command2 != 4){
|
||||
this.writing("to_command2", "4");
|
||||
}
|
||||
if (type == 2) {
|
||||
this.setNow_steps_type2(5);
|
||||
} else if (type == 3) {
|
||||
@@ -452,19 +440,9 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl
|
||||
if (inst2 != null) {
|
||||
if (StrUtil.equals(inst2.getInstruction_status(), "1")) {
|
||||
finish_instruction(inst2);
|
||||
TaskDto taskDto = taskserver.findByCodeFromCache(inst2.getTask_code());
|
||||
if (!ObjectUtil.isEmpty(taskDto)) {
|
||||
if (StrUtil.isNotEmpty(taskDto.getExt_task_id())) {
|
||||
JSONArray array = new JSONArray();
|
||||
JSONObject map = new JSONObject();
|
||||
map.put("task_id", taskDto.getExt_task_id());
|
||||
map.put("task_status", "2");
|
||||
array.add(map);
|
||||
acsToWmsService.feedbackTaskStatusToWms(array);
|
||||
}
|
||||
if(to_command2 != 5){
|
||||
this.writing("to_command2", "5");
|
||||
}
|
||||
;
|
||||
this.writing("to_command2", "5");
|
||||
this.setNow_steps_type2(6);
|
||||
this.setNow_steps_type2(0);
|
||||
}
|
||||
@@ -492,7 +470,9 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl
|
||||
|
||||
//双任务 后工位反馈任务完成 并反馈
|
||||
if (mode == 3 && action2 == 4 && move2 == 0 && task1 > 0 && task2 > 0 && type == 3) {
|
||||
this.writing("to_command2", "5");
|
||||
if(to_command2 != 5){
|
||||
this.writing("to_command2", "5");
|
||||
}
|
||||
this.setNow_steps_type3(8);
|
||||
} else {
|
||||
if (this.getNow_steps_type3() == 7) {
|
||||
@@ -538,7 +518,9 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl
|
||||
int move = siemensConveyorDeviceDriver.getMove();
|
||||
int mode = siemensConveyorDeviceDriver.getMode();
|
||||
if (move == 1 && mode == 2) {
|
||||
this.writing("to_command1", "4");
|
||||
if(to_command1 != 4){
|
||||
this.writing("to_command1", "4");
|
||||
}
|
||||
if (type == 1) {
|
||||
this.setNow_steps_type1(5);
|
||||
} else if (type == 3) {
|
||||
@@ -582,19 +564,9 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl
|
||||
if (inst1 != null) {
|
||||
if (StrUtil.equals(inst1.getInstruction_status(), "1")) {
|
||||
this.finish_instruction(inst1);
|
||||
TaskDto taskDto = taskserver.findByCodeFromCache(inst1.getTask_code());
|
||||
if (!ObjectUtil.isEmpty(taskDto)) {
|
||||
if (StrUtil.isNotEmpty(taskDto.getExt_task_id())) {
|
||||
JSONArray array = new JSONArray();
|
||||
JSONObject map = new JSONObject();
|
||||
map.put("task_id", taskDto.getExt_task_id());
|
||||
map.put("task_status", "2");
|
||||
array.add(map);
|
||||
acsToWmsService.feedbackTaskStatusToWms(array);
|
||||
}
|
||||
if(to_command1 != 5){
|
||||
this.writing("to_command1", "5");
|
||||
}
|
||||
;
|
||||
this.writing("to_command1", "5");
|
||||
this.setNow_steps_type1(6);
|
||||
this.setNow_steps_type1(0);
|
||||
}
|
||||
@@ -628,19 +600,9 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl
|
||||
if (inst1 != null) {
|
||||
if (StrUtil.equals(inst1.getInstruction_status(), "1")) {
|
||||
this.finish_instruction(inst1);
|
||||
TaskDto taskDto = taskserver.findByCodeFromCache(inst1.getTask_code());
|
||||
if (!ObjectUtil.isEmpty(taskDto)) {
|
||||
if (StrUtil.isNotEmpty(taskDto.getExt_task_id())) {
|
||||
JSONArray array = new JSONArray();
|
||||
JSONObject map = new JSONObject();
|
||||
map.put("task_id", taskDto.getExt_task_id());
|
||||
map.put("task_status", "2");
|
||||
array.add(map);
|
||||
acsToWmsService.feedbackTaskStatusToWms(array);
|
||||
}
|
||||
if(to_command1 != 5){
|
||||
this.writing("to_command1", "5");
|
||||
}
|
||||
;
|
||||
this.writing("to_command1", "5");
|
||||
this.setNow_steps_type3(10);
|
||||
this.setNow_steps_type3(0);
|
||||
}
|
||||
@@ -673,16 +635,9 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl
|
||||
} catch (Exception var17) {
|
||||
feedMessage = var17.getMessage();
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "读取信号值时出现异常:" + var17.getMessage());
|
||||
// return;
|
||||
}
|
||||
|
||||
// if (!this.itemProtocol.getIsonline()) {
|
||||
// this.setIsonline(false);
|
||||
// this.setIserror(true);
|
||||
// message = "信号量同步异常";
|
||||
// //未联机
|
||||
// } else
|
||||
if (mode == 0) {
|
||||
if (mode == 0) {
|
||||
this.setIsonline(false);
|
||||
message = "未联机";
|
||||
//有报警
|
||||
@@ -725,11 +680,8 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl
|
||||
feedMessage = "";
|
||||
notCreateInstMessage = "";
|
||||
notCreateTaskMessage = "";
|
||||
logServer.deviceExecuteLog(device_code, "", String.valueOf(task1), "move2:" + move2 + ",action2:" + action2 + ",move1:" + move1 + ",action1:" + action1 + ",requireSucess:" + requireSucess);
|
||||
} else {
|
||||
// if (!requireSucess) {
|
||||
// remark = remark + "请求标记为true,请检查mode是否由其他值变为2!";
|
||||
// }
|
||||
|
||||
if (!requireSucess) {
|
||||
String remark = "";
|
||||
if (mode != 2) {
|
||||
@@ -1140,12 +1092,6 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl
|
||||
list.add(map6);
|
||||
this.writing(list);
|
||||
logServer.deviceExecuteLog(device_code, "", "", dto.getInstruction_code() + "下发前工位任务");
|
||||
|
||||
// this.writing("to_onset1", start_addr);
|
||||
// this.writing("to_target1", next_addr);
|
||||
// this.writing("to_task1", dto.getInstruction_code());
|
||||
// this.writing("to_command1", "1");
|
||||
// this.writing("to_type", "1");
|
||||
this.setNow_steps_type1(2);
|
||||
} else if (StrUtil.equals(type, "2")) {
|
||||
Map map1 = new HashMap();
|
||||
@@ -1175,12 +1121,6 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl
|
||||
list.add(map6);
|
||||
this.writing(list);
|
||||
logServer.deviceExecuteLog(device_code, "", "", dto.getInstruction_code() + "下发后工位任务");
|
||||
|
||||
// this.writing("to_onset2", start_addr);
|
||||
// this.writing("to_target2", next_addr);
|
||||
// this.writing("to_task2", dto.getInstruction_code());
|
||||
// this.writing("to_command2", "1");
|
||||
// this.writing("to_type", "2");
|
||||
this.setNow_steps_type2(2);
|
||||
} else if (StrUtil.equals(type, "3")) {
|
||||
String start_device_code2 = dto.getStart_device_code2();
|
||||
@@ -1230,16 +1170,6 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl
|
||||
this.writing(list);
|
||||
logServer.deviceExecuteLog(device_code, "", "", dto.getInstruction_code() + "下发双工位任务");
|
||||
|
||||
|
||||
// this.writing("to_onset1", start_addr2);
|
||||
// this.writing("to_target1", next_addr2);
|
||||
// this.writing("to_task1", dto.getInstruction_code());
|
||||
// this.writing("to_command1", "1");
|
||||
// this.writing("to_onset2", start_addr);
|
||||
// this.writing("to_target2", next_addr);
|
||||
// this.writing("to_task2", dto.getInstruction_code());
|
||||
// this.writing("to_command2", "1");
|
||||
// this.writing("to_type", "3");
|
||||
this.setNow_steps_type3(2);
|
||||
}
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ public class WmsToAcsController {
|
||||
}
|
||||
|
||||
@PostMapping("/querydevice")
|
||||
@Log(value = "WMS查询设备状态",isInterfaceLog = true,interfaceLogType= InterfaceLogType.LMS_TO_ACS)
|
||||
// @Log(value = "WMS查询设备状态",isInterfaceLog = true,interfaceLogType= InterfaceLogType.LMS_TO_ACS)
|
||||
@ApiOperation("WMS查询设备状态")
|
||||
@SaIgnore
|
||||
public ResponseEntity<Object> queryDevice(@RequestBody String whereJson) throws Exception {
|
||||
|
||||
@@ -81,4 +81,9 @@ public interface DeviceAppService {
|
||||
*/
|
||||
String findDeviceTypeByCode(String deviceCode);
|
||||
|
||||
|
||||
void removeDevice(String deviceCode);
|
||||
|
||||
void addDevice(String deviceCode);
|
||||
|
||||
}
|
||||
|
||||
@@ -302,6 +302,51 @@ public class DeviceAppServiceImpl implements DeviceAppService, ApplicationAutoIn
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeDevice(String deviceCode) {
|
||||
|
||||
Iterator<Device> iterator = devices.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Device device = iterator.next();
|
||||
if (StrUtil.equals(device.getDevice_code(), deviceCode)) {
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
Iterator<String> iterator2 = code_indexs.iterator();
|
||||
while (iterator2.hasNext()) {
|
||||
String str = iterator2.next();
|
||||
if (StrUtil.equals(str, deviceCode)) {
|
||||
iterator2.remove();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addDevice(String deviceCode) {
|
||||
List<DeviceManageDto> deviceManageDtos = this.deviceManageService.queryAllWithExtra(deviceCode);
|
||||
int i = 0;
|
||||
|
||||
for (int size = deviceManageDtos.size(); i < size; ++i) {
|
||||
DeviceManageDto deviceManage = (DeviceManageDto) deviceManageDtos.get(i);
|
||||
Device device = new Device();
|
||||
BeanUtil.copyProperties(deviceManage, device);
|
||||
this.devices.add(device);
|
||||
this.code_indexs.add(device.getDevice_code());
|
||||
|
||||
if (!StrUtil.isEmpty(device.getDriver_code())) {
|
||||
DeviceDriverDefination defination = this.deviceDriverDefinationAppService.getDeviceDriverDefination(deviceManage.getDriver_code());
|
||||
if (defination != null) {
|
||||
device.setDeviceDriverDefination(defination);
|
||||
DeviceDriver driver = defination.getDriverInstance(device);
|
||||
device.setDeviceDriver(driver);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public List<LinewayDeviceDriver> findLaneway() {
|
||||
return this.findDeviceDriver(LinewayDeviceDriver.class);
|
||||
}
|
||||
|
||||
@@ -4,4 +4,7 @@ import java.util.List;
|
||||
|
||||
public interface DeviceManageService {
|
||||
List<DeviceManageDto> queryAllWithExtra();
|
||||
|
||||
List<DeviceManageDto> queryAllWithExtra(String device_code);
|
||||
|
||||
}
|
||||
|
||||
@@ -78,4 +78,69 @@ public class DeviceManageServiceImpl implements DeviceManageService {
|
||||
|
||||
return devices;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DeviceManageDto> queryAllWithExtra(String device_code) {
|
||||
JSONArray arr = WQLObject.getWQLObject("acs_device").query("device_code = '" + device_code + " '").getResultJSONArray(0);
|
||||
|
||||
JSONArray extArr = WQLObject.getWQLObject("acs_device_extra").query("device_code = '" + device_code + " '").getResultJSONArray(0);
|
||||
|
||||
List<DeviceExtraManageDto> extras = extArr.toJavaList(DeviceExtraManageDto.class);
|
||||
|
||||
WQLObject runpointTab = WQLObject.getWQLObject("acs_device_runpoint");
|
||||
|
||||
WQLObject opcTab = WQLObject.getWQLObject("acs_opc");
|
||||
//OPC_PLC表【acs_opc_plc】
|
||||
WQLObject plcTab = WQLObject.getWQLObject("acs_opc_plc");
|
||||
List<DeviceManageDto> devices = new ArrayList<>();
|
||||
for (int i = 0; i < arr.size(); i++) {
|
||||
JSONObject json = arr.getJSONObject(i);
|
||||
DeviceManageDto device = json.toJavaObject(DeviceManageDto.class);
|
||||
String opc_server_id = json.getString("opc_server_id");
|
||||
String opc_plc_id = json.getString("opc_plc_id");
|
||||
if (StrUtil.isNotEmpty(opc_plc_id) && StrUtil.isNotEmpty(opc_server_id)) {
|
||||
//OPC表【acs_opc】
|
||||
JSONObject rb = opcTab.query("is_delete= '0' AND is_active= '1' AND opc_id = '" + opc_server_id + "'").uniqueResult(0);
|
||||
if(ObjectUtil.isEmpty(rb)){
|
||||
System.out.println(device.getDevice_code());
|
||||
continue;
|
||||
}
|
||||
String opc_code= rb.getString("opc_code");
|
||||
device.setOpc_server_code(opc_code);
|
||||
if(ObjectUtil.isEmpty(plcTab.query("is_delete= '0' AND is_active= '1' AND plc_id = '" + opc_plc_id + "'").uniqueResult(0)))
|
||||
{
|
||||
System.out.println(device.getDevice_code());
|
||||
continue;
|
||||
}
|
||||
String plc_code = plcTab.query("is_delete= '0' AND is_active= '1' AND plc_id = '" + opc_plc_id + "'").uniqueResult(0).getString("plc_code");
|
||||
device.setOpc_plc_code(plc_code);
|
||||
}
|
||||
devices.add(device);
|
||||
}
|
||||
|
||||
Iterator it = devices.iterator();
|
||||
|
||||
while (it.hasNext()) {
|
||||
DeviceManageDto device = (DeviceManageDto) it.next();
|
||||
Iterator var5 = extras.iterator();
|
||||
while (var5.hasNext()) {
|
||||
DeviceExtraManageDto extra = (DeviceExtraManageDto) var5.next();
|
||||
if (extra.getDevice_id().equals(device.getDevice_id())) {
|
||||
device.getExtra().add(extra);
|
||||
if (StrUtil.equals(extra.getExtra_code(), "station_manager") && StrUtil.equals(extra.getExtra_value().toString(), "true")) {
|
||||
String has_goods = runpointTab.query("is_delete= '0' AND is_active= '1' AND device_id = '" + extra.getDevice_id() + "'").uniqueResult(0).getString("hasgoods");
|
||||
String material_type = runpointTab.query("is_delete= '0' AND is_active= '1' AND device_id = '" + extra.getDevice_id() + "'").uniqueResult(0).getString("material_type");
|
||||
String batch = runpointTab.query("is_delete= '0' AND is_active= '1' AND device_id = '" + extra.getDevice_id() + "'").uniqueResult(0).getString("batch");
|
||||
String islock = runpointTab.query("is_delete= '0' AND is_active= '1' AND device_id = '" + extra.getDevice_id() + "'").uniqueResult(0).getString("islock");
|
||||
device.setMaterial_type(material_type);
|
||||
device.setHas_goods(Integer.parseInt(has_goods));
|
||||
device.setBatch(batch);
|
||||
device.setIslock(islock);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return devices;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,8 +120,8 @@ public class DeviceOpcProtocolRunable implements Runnable {
|
||||
try {
|
||||
itemStatus = group.read(true, (Item[]) itemsMap.values().toArray(new Item[0]));
|
||||
} catch (Exception e){
|
||||
// System.out.println("数据同步异常:"+itemsMap);
|
||||
e.printStackTrace();
|
||||
System.out.println("数据同步异常:"+ this.getOpcServer().getOpc_code());
|
||||
//e.printStackTrace();
|
||||
}
|
||||
long end = System.currentTimeMillis();
|
||||
log.trace("{} 开始记时{}", tag, DateUtil.now());
|
||||
@@ -138,7 +138,7 @@ public class DeviceOpcProtocolRunable implements Runnable {
|
||||
time_out = false;
|
||||
}
|
||||
|
||||
if(ObjectUtil.isEmpty(itemStatus)) continue label97;
|
||||
// if(ObjectUtil.isEmpty(itemStatus)) continue label97;
|
||||
|
||||
Set<Item> items = itemStatus.keySet();
|
||||
Iterator var18 = items.iterator();
|
||||
|
||||
@@ -95,6 +95,7 @@ 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 siemens_conveyor_labeling from '@/views/acs/device/driver/siemens_conveyor_labeling'
|
||||
import siemens_conveyor_ckk from '@/views/acs/device/driver/siemens_conveyor_ckk'
|
||||
import siemens_onefloor_agv_conveyor from '@/views/acs/device/driver/siemens_onefloor_agv_conveyor'
|
||||
|
||||
export default {
|
||||
name: 'DeviceConfig',
|
||||
@@ -120,7 +121,8 @@ export default {
|
||||
slit_two_manipulator,
|
||||
plug_pull_device_site,
|
||||
siemens_conveyor_labeling,
|
||||
siemens_conveyor_ckk
|
||||
siemens_conveyor_ckk,
|
||||
siemens_onefloor_agv_conveyor
|
||||
},
|
||||
dicts: ['device_type'],
|
||||
mixins: [crud],
|
||||
|
||||
@@ -0,0 +1,530 @@
|
||||
<template>
|
||||
<!--标准版-1LAGV-输送机-->
|
||||
<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="dbr_value2">
|
||||
<template slot="header">
|
||||
<el-link type="primary" :underline="false" @click.native="test_read2()">测试读</el-link>
|
||||
</template>
|
||||
<template slot-scope="scope">
|
||||
<el-input v-model="data2[scope.$index].dbr_value" size="mini" class="edit-input" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="dbw_value">
|
||||
<template slot="header">
|
||||
<el-link type="primary" :underline="false" @click.native="test_write1()">测试写</el-link>
|
||||
</template>
|
||||
<template slot-scope="scope">
|
||||
<el-input v-model="data2[scope.$index].dbw_value" size="mini" class="edit-input" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-form>
|
||||
</el-card>
|
||||
|
||||
<el-card class="box-card" shadow="never">
|
||||
<div slot="header" class="clearfix">
|
||||
<span class="role-span" />
|
||||
<el-button
|
||||
:loading="false"
|
||||
icon="el-icon-check"
|
||||
size="mini"
|
||||
style="float: right; padding: 6px 9px"
|
||||
type="primary"
|
||||
@click="doSubmit"
|
||||
>保存
|
||||
</el-button>
|
||||
</div>
|
||||
</el-card>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {
|
||||
queryDriverConfig,
|
||||
updateConfig,
|
||||
testRead,
|
||||
testwrite
|
||||
} from '@/api/acs/device/driverConfig'
|
||||
import { selectOpcList } from '@/api/acs/device/opc'
|
||||
import { selectPlcList } from '@/api/acs/device/opcPlc'
|
||||
import { selectListByOpcID } from '@/api/acs/device/opcPlc'
|
||||
|
||||
import crud from '@/mixins/crud'
|
||||
import deviceCrud from '@/api/acs/device/device'
|
||||
|
||||
export default {
|
||||
name: '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_read2() {
|
||||
testRead(this.data2, this.opc_id).then(data => {
|
||||
this.data2 = data
|
||||
console.log(this.data2)
|
||||
this.notify('操作成功!', 'success')
|
||||
}).catch(err => {
|
||||
console.log(err.response.data.message)
|
||||
})
|
||||
},
|
||||
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