Browse Source

更新

master
gengby 2 years ago
parent
commit
363d6b7f0d
  1. 6
      hd/nladmin-system/src/main/java/org/nl/acs/agv/server/AgvService.java
  2. 43
      hd/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/AgvServiceImpl.java
  3. 44
      hd/nladmin-system/src/main/java/org/nl/acs/common/deviceInfo/PauseOrResumeDevice.java
  4. 3
      hd/nladmin-system/src/main/java/org/nl/acs/device/device_driver/DriverTypeEnum.java
  5. 59
      hd/nladmin-system/src/main/java/org/nl/acs/device_driver/tianneng/ItemProtocol.java
  6. 63
      hd/nladmin-system/src/main/java/org/nl/acs/device_driver/tianneng/PauseOrResumeDefination.java
  7. 279
      hd/nladmin-system/src/main/java/org/nl/acs/device_driver/tianneng/PauseOrResumeDeviceDriver.java
  8. 3
      qd/src/views/acs/device/config.vue
  9. 538
      qd/src/views/acs/device/driver/pauseOrResume.vue

6
hd/nladmin-system/src/main/java/org/nl/acs/agv/server/AgvService.java

@ -147,6 +147,11 @@ public interface AgvService {
*/
public HttpResponse sendOrderSequencesToXZ(Instruction inst) throws Exception;
public HttpResponse pauseVehicleToXZ(JSONObject jsonObject) throws Exception;
public HttpResponse resumeVehicleToXZ(JSONObject jsonObject) throws Exception;
public HttpResponse addOrderSequences(Instruction inst) throws Exception;
/**
@ -161,6 +166,7 @@ public interface AgvService {
public JSONObject createOrederData(Instruction inst, String type);
public JSONArray createBlocksData(Instruction inst);
/**
* magic 全部暂停车辆
*/

43
hd/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/AgvServiceImpl.java

@ -5,6 +5,7 @@ import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import com.alibaba.fastjson.JSON;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import net.sf.json.JSONArray;
@ -1521,6 +1522,48 @@ public class AgvServiceImpl implements AgvService {
}
}
@Override
public HttpResponse pauseVehicleToXZ(JSONObject jsonObject) throws Exception {
if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.FORKAGV).toString(), "1")) {
String agvurl = acsConfigService.findConfigFromCache().get(AcsConfig.AGVURL);
String agvport = acsConfigService.findConfigFromCache().get(AcsConfig.AGVPORT);
agvurl = agvurl + ":" + agvport + "/gotoSitePause";
System.out.println("请求地址为:" + agvurl);
HttpResponse result = HttpRequest.post(agvurl)
.body(JSON.toJSONString(jsonObject))//表单内容
.timeout(20000)//超时,毫秒
.execute();
System.out.println("返回结果为:" + result);
log.info(agvurl);
logServer.log("pauseVehicle", "pauseVehicleToXZ", "info", String.valueOf(jsonObject), result.body(), String.valueOf(result.getStatus()), agvurl, String.valueOf(jsonObject));
return result;
} else {
return null;
}
}
@Override
public HttpResponse resumeVehicleToXZ(JSONObject jsonObject) throws Exception {
if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.FORKAGV).toString(), "1")) {
String agvurl = acsConfigService.findConfigFromCache().get(AcsConfig.AGVURL);
String agvport = acsConfigService.findConfigFromCache().get(AcsConfig.AGVPORT);
agvurl = agvurl + ":" + agvport + "/gotoSiteResume";
System.out.println("请求地址为:" + agvurl);
HttpResponse result = HttpRequest.post(agvurl)
.body(JSON.toJSONString(jsonObject))//表单内容
.timeout(20000)//超时,毫秒
.execute();
System.out.println("返回结果为:" + result);
log.info(agvurl);
logServer.log("resumeVehicle", "resumeVehicleToXZ", "info", String.valueOf(jsonObject), result.body(), String.valueOf(result.getStatus()), agvurl, String.valueOf(jsonObject));
return result;
} else {
return null;
}
}
@Override
public HttpResponse addOrderSequences(Instruction inst) throws Exception {
JSONObject orderjo = createOrederData(inst, "1");

44
hd/nladmin-system/src/main/java/org/nl/acs/common/deviceInfo/PauseOrResumeDevice.java

@ -0,0 +1,44 @@
package org.nl.acs.common.deviceInfo;
import net.sf.json.JSONObject;
import org.nl.acs.common.AbstractDriverService;
import org.nl.acs.device_driver.tianneng.PauseOrResumeDeviceDriver;
import org.nl.acs.opc.Device;
import org.nl.acs.task.service.dto.TaskDto;
import org.springframework.stereotype.Component;
/**
* @author geng by
* 输送线
*/
@Component("pauseOrResume")
public class PauseOrResumeDevice extends AbstractDriverService {
PauseOrResumeDeviceDriver pauseOrResumeDeviceDriver;
@Override
public JSONObject getDeviceInfo(Device device) {
pauseOrResumeDeviceDriver = (PauseOrResumeDeviceDriver) device.getDeviceDriver();
JSONObject jo = this.getCommonDeviceInfo(pauseOrResumeDeviceDriver);
return jo;
}
@Override
public Boolean createInstCheckStartPoint(Device device, TaskDto taskDto) throws Exception {
//standardConveyorLineDeviceDriver = (StandardConveyorLineDeviceDriver) device.getDeviceDriver();
//return this.checkStartPoint(standardConveyorLineDeviceDriver, taskDto, InstEnum.standard_conveyor_line_start.getMode(), InstEnum.standard_conveyor_line_start.getMove());
return true;
}
@Override
public Boolean createInstCheckNextPoint(Device device, TaskDto taskDto) throws Exception {
//standardConveyorLineDeviceDriver = (StandardConveyorLineDeviceDriver) device.getDeviceDriver();
// return this.checkNextPoint(standardConveyorLineDeviceDriver, taskDto,InstEnum.standard_conveyor_line_next.getMode(), InstEnum.standard_conveyor_line_next.getMove());
return true;
}
@Override
public void changeDeviceStatus(Device device, JSONObject form) {
pauseOrResumeDeviceDriver = (PauseOrResumeDeviceDriver) device.getDeviceDriver();
this.changeDeviceStatus(pauseOrResumeDeviceDriver, form, false);
}
}

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

@ -82,7 +82,8 @@ public enum DriverTypeEnum {
//
// ssj_cache_site(37, "ssj_cache_site", "三时纪-缓存站点", "conveyor"),
STANDARDCONVEYORLINE(38, "standard_conveyor_line", "缓存架", "conveyor");
STANDARDCONVEYORLINE(38, "standard_conveyor_line", "缓存架", "conveyor"),
PAUSEorresume(39, "pauseOrResume", "agv暂停或继续", "conveyor");
//驱动索引

59
hd/nladmin-system/src/main/java/org/nl/acs/device_driver/tianneng/ItemProtocol.java

@ -0,0 +1,59 @@
package org.nl.acs.device_driver.tianneng;
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_agv_action = "agv_action";
private PauseOrResumeDeviceDriver driver;
public ItemProtocol(PauseOrResumeDeviceDriver driver) {
this.driver = driver;
}
public int getAgv_action() {
return this.getOpcIntegerValue(item_agv_action);
}
//是否有货
public int hasGoods(int move) {
return move;
}
Boolean isonline;
public int getOpcIntegerValue(String protocol) {
Integer value = this.driver.getIntegerValue(protocol);
if (value == null) {
log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!");
setIsonline(false);
} else {
setIsonline(true);
return value;
}
return 0;
}
public static List<ItemDto> getReadableItemDtos() {
ArrayList list = new ArrayList();
list.add(new ItemDto(item_agv_action, "agv工作状态", "DB600.B502"));
return list;
}
public static List<ItemDto> getWriteableItemDtos() {
ArrayList list = new ArrayList();
list.add(new ItemDto(item_agv_action, "agv工作状态", "DB600.B502"));
return list;
}
}

63
hd/nladmin-system/src/main/java/org/nl/acs/device_driver/tianneng/PauseOrResumeDefination.java

@ -0,0 +1,63 @@
package org.nl.acs.device_driver.tianneng;
import org.nl.acs.device.device_driver.standard_inspect.ItemDto;
import org.nl.acs.device_driver.DeviceDriver;
import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination;
import org.nl.acs.opc.Device;
import org.nl.acs.opc.DeviceType;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
/**
* agv-暂停或恢复
*/
@Service
public class PauseOrResumeDefination implements OpcDeviceDriverDefination {
@Override
public String getDriverCode() {
return "pauseOrResume";
}
@Override
public String getDriverName() {
return "agv-暂停或恢复";
}
@Override
public String getDriverDescription() {
return "agv-暂停或恢复";
}
@Override
public DeviceDriver getDriverInstance(Device device) {
return (new PauseOrResumeDeviceDriver()).setDevice(device).setDriverDefination(this);
}
@Override
public Class<? extends DeviceDriver> getDeviceDriverType() {
return PauseOrResumeDeviceDriver.class;
}
@Override
public List<DeviceType> getFitDeviceTypes() {
List<DeviceType> types = new LinkedList();
types.add(DeviceType.conveyor);
return types;
}
@Override
public List<ItemDto> getReadableItemDtos() {
return ItemProtocol.getReadableItemDtos();
}
@Override
public List<ItemDto> getWriteableItemDtos() {
return ItemProtocol.getWriteableItemDtos();
}
}

279
hd/nladmin-system/src/main/java/org/nl/acs/device_driver/tianneng/PauseOrResumeDeviceDriver.java

@ -0,0 +1,279 @@
package org.nl.acs.device_driver.tianneng;
import lombok.Data;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.nl.acs.agv.server.AgvService;
import org.nl.acs.agv.server.impl.AgvServiceImpl;
import org.nl.acs.device.device_driver.standard_inspect.ReadUtil;
import org.nl.acs.device.service.DeviceService;
import org.nl.acs.device_driver.DeviceDriver;
import org.nl.acs.device_driver.RouteableDeviceDriver;
import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver;
import org.nl.acs.device_driver.driver.ExecutableDeviceDriver;
import org.nl.acs.instruction.service.InstructionService;
import org.nl.acs.instruction.service.dto.Instruction;
import org.nl.acs.opc.Device;
import org.nl.acs.opc.DeviceAppService;
import org.nl.acs.opc.DeviceAppServiceImpl;
import org.nl.acs.route.service.RouteLineService;
import org.nl.acs.task.service.TaskService;
import org.nl.utils.SpringContextHolder;
import org.openscada.opc.lib.da.Server;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* agv暂停或恢复驱动
*/
@Slf4j
@Data
@RequiredArgsConstructor
public class PauseOrResumeDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver {
protected ItemProtocol itemProtocol = new ItemProtocol(this);
@Autowired
InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl");
@Autowired
DeviceService deviceservice = SpringContextHolder.getBean("deviceServiceImpl");
@Autowired
RouteLineService routelineserver = SpringContextHolder.getBean("routeLineServiceImpl");
@Autowired
TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl");
@Autowired
RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class);
@Autowired
DeviceAppService deviceAppservice = SpringContextHolder.getBean(DeviceAppService.class);
@Autowired
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
@Autowired
AgvService agvService = SpringContextHolder.getBean(AgvServiceImpl.class);
private Date instruction_require_time = new Date();
private Date instruction_finished_time = new Date();
private Date instruction_apply_time = new Date();
private int instruction_require_time_out = 3000;
//请求暂停成功标记
Boolean requirePauseSuccess = false;
//请求继续成功标记
Boolean requireResumeSuccess = false;
int agv_action = 0;
int last_agv_action = 0;
Boolean isonline = true;
int hasGoods = 0;
String message = null;
Boolean iserror = false;
String Container = null;
String device_code = null;
int branchProtocol = 0;
//备注
String remark;
//数量
String qty;
//物料
String material;
//当前指令
Instruction inst = null;
//上次指令
Instruction last_inst = null;
//暂定 0就绪 1请求取货 2取货完成 3请求放货 4放货完成 5取货完成离开 6放货完成离开 7请求进入区域 8请求离开区域
int flag;
@Override
public Device getDevice() {
return this.device;
}
@Override
public void execute() throws Exception {
String message = null;
try {
device_code = this.getDeviceCode();
agv_action = this.itemProtocol.getAgv_action();
if (agv_action != last_agv_action) {
if (agv_action == 1) {
this.setRequirePauseSuccess(false);
}
if (agv_action == 2) {
this.setRequireResumeSuccess(false);
}
this.execute_log.setResource(this.device_code, this.device.getDevice_name());
this.execute_log.log("设备:" + device_code + ",last_agv_action -> agv_action:" + last_agv_action + "->" + agv_action);
}
} catch (Exception var17) {
return;
}
if (!this.itemProtocol.getIsonline()) {
this.setIsonline(false);
this.setIserror(true);
message = "信号量同步异常";
//未联机
} else {
this.setIsonline(true);
this.setIserror(false);
message = "";
Instruction instruction = null;
List toInstructions;
switch (agv_action) {
case 1:
if (!requirePauseSuccess) {
JSONObject map = new JSONObject();
JSONArray vehicles = new JSONArray();
map.put("vehicles", vehicles);
agvService.pauseVehicleToXZ(map);
this.setRequirePauseSuccess(true);
}
break;
case 2:
if (!requireResumeSuccess) {
JSONObject map = new JSONObject();
JSONArray vehicles = new JSONArray();
map.put("vehicles", vehicles);
agvService.resumeVehicleToXZ(map);
this.setRequireResumeSuccess(true);
}
break;
}
// switch (flag) {
// //取货完成
// case 1:
// writing(2);
// return;
// //放货完成
// case 2:
// writing(3);
// return;
//
// }
last_agv_action = agv_action;
}
}
public boolean exe_error() {
// if (this.error == 0) {
// return true;
// } else {
// log.debug("设备报警");
// return false;
// }
return true;
}
protected void thingToNothing() {
log.debug("从有货到无货 清理数据");
}
public void set_last_container(String barcode, String type_desc) {
this.set_last_container(barcode);
this.set_last_container_type_desc(type_desc);
}
public void set_last_container(String barcode) {
}
public void set_last_container_type_desc(String type) {
}
public boolean exe_business() {
return true;
}
protected void executing(Instruction instruction) {
this.executing(1, instruction, "");
}
public void executing(int command, Instruction instruction, String appendMessage) {
// String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
// + "." + ItemProtocol.item_to_command;
// String to_target = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
// + "." + ItemProtocol.item_to_target;
// String to_task = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
// + "." + ItemProtocol.item_to_task;
// if (appendMessage == null) {
// appendMessage = "";
// }
}
public void executing(Server server, Map<String, Object> itemMap) {
ReadUtil.write(itemMap, server);
}
public void writing(int command) {
// String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
// + "." + ItemProtocol.item_to_command;
//
// String opcservcerid = this.getDevice().getOpc_server_id();
// Server server = ReadUtil.getServer(opcservcerid);
// Map<String, Object> itemMap = new HashMap<String, Object>();
// itemMap.put(to_command, command);
// ReadUtil.write(itemMap, server);
}
public void writing(int type, int command) {
// String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
// + "." + ItemProtocol.item_to_command;
// String to_target = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
// + "." + ItemProtocol.item_to_target;
// String to_onset = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
// + "." + ItemProtocol.item_to_onset;
// String to_task = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
// + "." + ItemProtocol.item_to_task;
// String opcservcerid = this.getDevice().getOpc_server_id();
// Server server = ReadUtil.getServer(opcservcerid);
// Map<String, Object> itemMap = new HashMap<String, Object>();
// if (type == 1) {
// itemMap.put(to_command, command);
// } else if (type == 2) {
// itemMap.put(to_target, command);
//
// } else if (type == 3) {
// itemMap.put(to_task, command);
// }
// ReadUtil.write(itemMap, server);
}
public void writing(Instruction inst) {
// String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
// + "." + ItemProtocol.item_to_command;
// String to_target = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
// + "." + ItemProtocol.item_to_target;
// String to_onset = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
// + "." + ItemProtocol.item_to_onset;
// String to_task = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
// + "." + ItemProtocol.item_to_task;
// String opcservcerid = this.getDevice().getOpc_server_id();
// Server server = ReadUtil.getServer(opcservcerid);
// Map<String, Object> itemMap = new HashMap<String, Object>();
// itemMap.put(to_command, 1);
// itemMap.put(to_onset, appService.findDeviceByCode(inst.getStart_device_code()).getAddress());
// itemMap.put(to_target, appService.findDeviceByCode(inst.getNext_device_code()).getAddress());
// itemMap.put(to_task, inst.getInstruction_code());
// ReadUtil.write(itemMap, server);
// this.execute_log.setResource(this.device_code, device_code);
// this.execute_log.log("设备:{},下发作业命令:{},起始站{},目标站:{},任务号:{}", device_code, to_command, to_onset, to_target, to_task);
// }
}
}

3
qd/src/views/acs/device/config.vue

@ -109,6 +109,7 @@ import standard_rgv from '@/views/acs/device/driver/standard_rgv'
import ykbk_special from '@/views/acs/device/driver/ykbk_special'
import ssj_cache_site from '@/views/acs/device/driver/ssj_cache_site'
import standard_conveyor_line from '@/views/acs/device/driver/standard_conveyor_line'
import pauseOrResume from '@/views/acs/device/driver/pauseOrResume'
export default {
name: 'DeviceConfig',
@ -118,7 +119,7 @@ export default {
standard_conveyor_control_with_plcscanner, standard_conveyor_control, standard_conveyor_monitor, weighing_site, machines_site, non_line_manipulator_inspect_site,
non_line_inspect_site, manipulator_inspect_site_NDC, feedback_agv_status_site, standard_manipulator_stacking_site,
standard_photoelectric_inspect_site, ndxy_special, hailiang_labeling, ndxy_special_two, whxr_storage_conveyor, whxr_ball_mill, whxr_spary_tower, whxr_weight,
electric_fence, oumulong_plc, traffic_light, standard_rgv, ykbk_special, ssj_cache_site, standard_conveyor_line },
electric_fence, oumulong_plc, traffic_light, standard_rgv, ykbk_special, ssj_cache_site, standard_conveyor_line, pauseOrResume },
dicts: ['device_type'],
mixins: [crud],
data() {

538
qd/src/views/acs/device/driver/pauseOrResume.vue

@ -0,0 +1,538 @@
<template>
<!--RGV-->
<div>
<el-card class="box-card" shadow="never">
<div slot="header" class="clearfix">
<span class="role-span">设备协议</span>
</div>
<el-row>
<el-col :span="12">
OpcServer:
<el-select
v-model="opc_id"
placeholder="无"
clearable
@change="changeOpc"
>
<el-option
v-for="item in dataOpcservers"
:key="item.opc_id"
:label="item.opc_name"
:value="item.opc_id"
/>
</el-select>
</el-col>
<el-col :span="12">
PLC:
<el-select
v-model="plc_id"
placeholder="无"
clearable
@change="changePlc"
>
<el-option
v-for="item in dataOpcPlcs"
:key="item.plc_id"
:label="item.plc_name"
:value="item.plc_id"
/>
</el-select>
</el-col>
</el-row>
</el-card>
<el-card class="box-card" shadow="never">
<div slot="header" class="clearfix">
<span class="role-span">输送系统</span>
</div>
<el-form ref="form" :inline="true" :model="form" :rules="rules" size="small" label-width="78px">
<el-row>
<el-col :span="8">
<el-form-item label="电气调度号" label-width="150px">
<el-input v-model="form.OPCServer" />
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="8">
<el-form-item label="取货点" prop="device_code">
<el-select
v-model="form.get_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-form-item label="放货点" prop="device_code">
<el-select
v-model="form.put_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-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: 'StandardInspectSite',
mixins: [crud],
props: {
parentForm: {
type: Object,
require: true
}
},
data() {
return {
device_code: '',
device_id: '',
plc_id: '',
plc_code: '',
opc_id: '',
opc_code: '',
get_device_code: '',
put_device_code: '',
configLoading: false,
dataOpcservers: [],
dataOpcPlcs: [],
deviceList: [],
data1: [],
data2: [],
form: {
inspect_in_stocck: true,
ignore_pickup_check: true,
ignore_release_check: true,
apply_task: true,
link_three_lamp: '',
manual_create_task: true,
is_pickup: true,
is_release: true,
link_device_code: []
},
rules: {}
}
},
created() {
this.$nextTick(() => {
//
this.device_id = this.$props.parentForm.device_id
this.device_code = this.$props.parentForm.device_code
queryDriverConfig(this.device_id, this.$props.parentForm.driver_code).then(data => {
//
if (data.form) {
const arr = Object.keys(data.form)
//
if (arr.length > 0) {
this.form = data.form
}
}
//
if (data.parentForm) {
const arr = Object.keys(data.parentForm)
//
if (arr.length > 0) {
this.opc_code = data.parentForm.opc_code
this.plc_code = data.parentForm.plc_code
}
}
this.data1 = data.rs
this.data2 = data.ws
this.sliceItem()
})
selectPlcList().then(data => {
this.dataOpcPlcs = data
this.plc_id = this.$props.parentForm.opc_plc_id
})
selectOpcList().then(data => {
this.dataOpcservers = data
this.opc_id = this.$props.parentForm.opc_server_id
})
deviceCrud.selectDeviceList().then(data => {
this.deviceList = data
})
})
},
methods: {
finishReadEdit(data) {
// code,mode
if (data.code.indexOf('mode') !== -1) {
debugger
const dbValue = data.db
// .
const beforeStr = dbValue.match(/(\S*)\./)[1]
// .
const afterStr = dbValue.match(/\.(\S*)/)[1]
//
const endNumber = afterStr.substring(1)
//
if (isNaN(parseInt(endNumber))) {
return
}
for (const val in this.data1) {
if (this.data1[val].code.indexOf('move') !== -1) {
this.data1[val].db = beforeStr + '.' + afterStr.substring(0, 1) + (parseInt(endNumber) + 1)
}
if (this.data1[val].code.indexOf('action') !== -1) {
this.data1[val].db = beforeStr + '.' + afterStr.substring(0, 1) + (parseInt(endNumber) + 2)
}
if (this.data1[val].code.indexOf('walk_y') !== -1) {
this.data1[val].db = beforeStr + '.' + afterStr.substring(0, 1) + (parseInt(endNumber) + 3)
}
if (this.data1[val].code.indexOf('container_type') !== -1) {
this.data1[val].db = beforeStr + '.' + afterStr.substring(0, 1) + (parseInt(endNumber) + 4)
}
if (this.data1[val].code.indexOf('error') !== -1) {
this.data1[val].db = beforeStr + '.' + afterStr.substring(0, 1) + (parseInt(endNumber) + 5)
}
if (this.data1[val].code.indexOf('task') !== -1) {
this.data1[val].db = beforeStr + '.' + 'D' + (parseInt(endNumber) + 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
}
for (const val in this.data2) {
if (this.data2[val].code.indexOf('to_onset') !== -1) {
this.data2[val].db = beforeStr + '.' + afterStr.substring(0, 1) + (parseInt(endNumber) + 2)
}
if (this.data2[val].code.indexOf('to_target') !== -1) {
this.data2[val].db = beforeStr + '.' + afterStr.substring(0, 1) + (parseInt(endNumber) + 4)
}
if (this.data2[val].code.indexOf('to_container_type') !== -1) {
this.data2[val].db = beforeStr + '.' + afterStr.substring(0, 1) + (parseInt(endNumber) + 6)
}
if (this.data2[val].code.indexOf('to_task') !== -1) {
this.data2[val].db = beforeStr + '.' + 'D' + (parseInt(endNumber) + 8)
}
}
}
},
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() { // DBItem
this.data1.forEach(item => {
const str = item.code
// .
if (str.search('.') !== -1) {
//
item.code = this.opc_code + '.' + this.plc_code + '.' + this.device_code + '.' + str.slice(str.lastIndexOf('.') + 1)
} else {
item.code = this.opc_code + '.' + this.plc_code + '.' + this.device_code + '.' + item.code
}
})
this.data2.forEach(item => {
const str = item.code
// .
if (str.search('.') !== -1) {
//
item.code = this.opc_code + '.' + this.plc_code + '.' + this.device_code + '.' + str.slice(str.lastIndexOf('.') + 1)
} else {
item.code = this.opc_code + '.' + this.plc_code + '.' + this.device_code + '.' + item.code
}
})
}
}
}
</script>
<style scoped>
</style>
Loading…
Cancel
Save