add: agv上下料开发
This commit is contained in:
3
acs/nladmin-system/package-lock.json
generated
3
acs/nladmin-system/package-lock.json
generated
@@ -1,3 +0,0 @@
|
||||
{
|
||||
"lockfileVersion": 1
|
||||
}
|
||||
@@ -7,7 +7,7 @@ import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.acs.common.StandardOrdinarySiteDevice;
|
||||
import org.nl.acs.device_driver.RequestMethodEnum;
|
||||
import org.nl.acs.device_driver.basedriver.agv.agv_conveyor.AgvConveyorConveyorDeviceDriver;
|
||||
import org.nl.acs.device_driver.basedriver.agv_conveyor.AgvConveyorDeviceDriver;
|
||||
import org.nl.acs.device_driver.nl4.station.NL4StationDeviceDriver;
|
||||
import org.nl.acs.log.service.DeviceExecuteLogService;
|
||||
import org.nl.acs.opc.Device;
|
||||
@@ -123,8 +123,8 @@ public class AgvWaitUtil {
|
||||
String executeCode = task.getExecute_code();
|
||||
if (StrUtil.isNotEmpty(executeCode)) {
|
||||
Device executeDevice = this.deviceAppService.findDeviceByCode(executeCode);
|
||||
if (executeDevice.getDeviceDriver() instanceof AgvConveyorConveyorDeviceDriver) {
|
||||
AgvConveyorConveyorDeviceDriver driver = (AgvConveyorConveyorDeviceDriver) executeDevice.getDeviceDriver();
|
||||
if (executeDevice.getDeviceDriver() instanceof AgvConveyorDeviceDriver) {
|
||||
AgvConveyorDeviceDriver driver = (AgvConveyorDeviceDriver) executeDevice.getDeviceDriver();
|
||||
if ("down".equals(task.getExecute_message())) {
|
||||
driver.writing("to_down_finished", 1);
|
||||
}
|
||||
@@ -312,8 +312,8 @@ public class AgvWaitUtil {
|
||||
String executeCode = task.getExecute_code();
|
||||
if (StrUtil.isNotEmpty(executeCode)) {
|
||||
Device executeDevice = this.deviceAppService.findDeviceByCode(executeCode);
|
||||
if (executeDevice.getDeviceDriver() instanceof AgvConveyorConveyorDeviceDriver) {
|
||||
AgvConveyorConveyorDeviceDriver driver = (AgvConveyorConveyorDeviceDriver) executeDevice.getDeviceDriver();
|
||||
if (executeDevice.getDeviceDriver() instanceof AgvConveyorDeviceDriver) {
|
||||
AgvConveyorDeviceDriver driver = (AgvConveyorDeviceDriver) executeDevice.getDeviceDriver();
|
||||
if ("up".equals(task.getExecute_message())) {
|
||||
driver.writing("to_up_finished", 1);
|
||||
}
|
||||
|
||||
@@ -11,7 +11,9 @@ import com.alibaba.fastjson.JSONObject;
|
||||
public enum DriverTypeEnum {
|
||||
ORDINARY_SITE(1, "standard_ordinary_site", "普通站点", "station"),
|
||||
|
||||
NL4_STATION(2, "nl4_station", "诺力四期-对接位", "station");
|
||||
NL4_STATION(2, "nl4_station", "诺力四期-对接位", "station"),
|
||||
AGV_CONVEYOR(3, "agv_conveyor", "上下料任务管理驱动", "conveyor"),
|
||||
STANDAR_ORDINARY_SITE(4, "standard_ordinary_site", "上下料agv对接位", "conveyor");
|
||||
//驱动索引
|
||||
private int index;
|
||||
//驱动编码
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package org.nl.acs.device_driver.basedriver.agv.agv_conveyor;
|
||||
package org.nl.acs.device_driver.basedriver.agv_conveyor;
|
||||
|
||||
import org.nl.acs.device.device_driver.standard_inspect.ItemDTO;
|
||||
import org.nl.acs.device_driver.DeviceDriver;
|
||||
@@ -32,12 +32,12 @@ public class AgvConveyorDefinition implements OpcDeviceDriverDefinition {
|
||||
|
||||
@Override
|
||||
public DeviceDriver getDriverInstance(Device device) {
|
||||
return (new AgvConveyorConveyorDeviceDriver()).setDevice(device).setDriverDefinition(this);
|
||||
return (new AgvConveyorDeviceDriver()).setDevice(device).setDriverDefinition(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends DeviceDriver> getDeviceDriverType() {
|
||||
return AgvConveyorConveyorDeviceDriver.class;
|
||||
return AgvConveyorDeviceDriver.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1,19 +1,14 @@
|
||||
package org.nl.acs.device_driver.basedriver.agv.agv_conveyor;
|
||||
package org.nl.acs.device_driver.basedriver.agv_conveyor;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
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.core.map.MapUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.nl.acs.agv.server.AgvService;
|
||||
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;
|
||||
@@ -22,7 +17,6 @@ import org.nl.acs.device_driver.driver.ExecutableDeviceDriver;
|
||||
import org.nl.acs.ext.wms.service.AcsToWmsService;
|
||||
import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl;
|
||||
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;
|
||||
@@ -32,8 +26,8 @@ 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 java.util.*;
|
||||
|
||||
@@ -44,7 +38,7 @@ import java.util.*;
|
||||
@Getter
|
||||
@Setter
|
||||
@RequiredArgsConstructor
|
||||
public class AgvConveyorConveyorDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor {
|
||||
public class AgvConveyorDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor {
|
||||
|
||||
protected ItemProtocol itemProtocol = new ItemProtocol(this);
|
||||
|
||||
@@ -140,11 +134,18 @@ public class AgvConveyorConveyorDeviceDriver extends AbstractOpcDeviceDriver imp
|
||||
return false;
|
||||
} else {
|
||||
this.instruction_require_time = date;
|
||||
WQLObject wo = WQLObject.getWQLObject("acs_device_runpoint");
|
||||
JSONObject json = wo.query("device_code ='" + on_off_site + "'").uniqueResult(0);
|
||||
if (MapUtil.isNotEmpty(json) && "0".equals(json.get("hasgoods"))){
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", on_off_site + "无上下料货物");
|
||||
return false;
|
||||
}
|
||||
//请求下料
|
||||
if (down_request == 1){
|
||||
List<RouteLineDto> routeLineDtos = routeLineService.getPathLinesByCode(on_off_site,"normal");
|
||||
List<RouteLineDto> routeLineDtos = routeLineService.getsByCode(on_off_site,"normal");
|
||||
if (CollUtil.isEmpty(routeLineDtos) || routeLineDtos.size() < 1) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "没有"+ on_off_site + "的路由");
|
||||
return false;
|
||||
}
|
||||
RouteLineDto routeLineDto = routeLineDtos.get(0);
|
||||
TaskDto taskDto = new TaskDto();
|
||||
@@ -158,7 +159,7 @@ public class AgvConveyorConveyorDeviceDriver extends AbstractOpcDeviceDriver imp
|
||||
}
|
||||
//请求上料
|
||||
if (up_request == 1){
|
||||
List<RouteLineDto> routeLineDtos = routeLineService.getsByCode(on_off_site,"normal");
|
||||
List<RouteLineDto> routeLineDtos = routeLineService.getPathLinesByCode(on_off_site,"normal");
|
||||
if (CollUtil.isEmpty(routeLineDtos) || routeLineDtos.size() < 1) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "没有"+ on_off_site + "的路由");
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package org.nl.acs.device_driver.basedriver.agv.agv_conveyor;
|
||||
package org.nl.acs.device_driver.basedriver.agv_conveyor;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
@@ -23,9 +23,9 @@ public class ItemProtocol {
|
||||
|
||||
|
||||
|
||||
private AgvConveyorConveyorDeviceDriver driver;
|
||||
private AgvConveyorDeviceDriver driver;
|
||||
|
||||
public ItemProtocol(AgvConveyorConveyorDeviceDriver driver) {
|
||||
public ItemProtocol(AgvConveyorDeviceDriver driver) {
|
||||
this.driver = driver;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,9 @@
|
||||
package org.nl.hand.amb.service.impl;
|
||||
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
@@ -28,6 +30,7 @@ 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.route.service.dto.RouteLineDto;
|
||||
import org.nl.acs.task.service.TaskService;
|
||||
import org.nl.acs.task.service.dto.TaskDto;
|
||||
import org.nl.acs.task.service.impl.TaskServiceImpl;
|
||||
@@ -44,10 +47,7 @@ import org.nl.modules.wql.core.bean.WQLObject;
|
||||
import org.nl.modules.wql.util.SpringContextHolder;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.*;
|
||||
|
||||
|
||||
/**
|
||||
@@ -63,6 +63,10 @@ public class HFHandServiceImpl implements HFHandService {
|
||||
private final DeviceService deviceService;
|
||||
private final DeviceAppService deviceAppService;
|
||||
private final DictService dictService;
|
||||
private final TaskService taskserver;
|
||||
private final RouteLineService routeLineService;
|
||||
|
||||
|
||||
InstructionService instructionService = null;
|
||||
|
||||
|
||||
@@ -83,7 +87,7 @@ public class HFHandServiceImpl implements HFHandService {
|
||||
throw new BadRequestException("区域不能为空!");
|
||||
}
|
||||
|
||||
JSONArray devices = WQLObject.getWQLObject("acs_device").query("region = '" + region + "' AND device_type = 'station' AND is_config = 'true' ", "seq_num").getResultJSONArray(0);
|
||||
JSONArray devices = WQLObject.getWQLObject("acs_device").query("region = '" + region + "' AND (device_type = 'station' || device_type = 'conveyor') AND is_config = 'true' ", "seq_num").getResultJSONArray(0);
|
||||
JSONArray resultArr = new JSONArray();
|
||||
for (int i = 0; i < devices.size(); i++) {
|
||||
JSONObject device = devices.getJSONObject(i);
|
||||
|
||||
@@ -103,7 +103,7 @@ import conveyor_ssx_barcode from '@/views/acs/device/driver/lnsh/conveyor_ssx_ba
|
||||
import conveyor_press_station from '@/views/acs/device/driver/lnsh/conveyor_press_station'
|
||||
import agv_ndc_one from '@/views/acs/device/driver/agv/agv_ndc_one'
|
||||
import agv_ndc_two from '@/views/acs/device/driver/agv/agv_ndc_two'
|
||||
import agv_conveyor from '@/views/acs/device/driver/agv/agv_conveyor'
|
||||
import agv_conveyor from './driver/agv_conveyor.vue'
|
||||
import package_site from './driver/lnsh/package_site.vue'
|
||||
import nl4_station from '@/views/acs/device/driver/nl4/nl4_station.vue'
|
||||
|
||||
@@ -114,7 +114,7 @@ export default {
|
||||
standard_conveyor_control, standard_conveyor_monitor, lnsh_mixing_mill, lnsh_press, lnsh_palletizing_manipulator, lnsh_fold_disc_site, lnsh_kiln_lane, lnsh_kiln_truss,
|
||||
lnsh_package_line, lnsh_out_kiln_truss, lnsh_package_pallet_manipulator, lnsh_pallet_storage, lnsh_labeling_machine, lnsh_split_manipulator, lnsh_rgv,
|
||||
lnsh_station, lnsh_Laminating_machine, lnsh_package_site, lnsh_crusher, lnsh_palletizing_manipulator_site, conveyor_ssx_barcode, conveyor_press_station,
|
||||
agv_ndc_one, agv_ndc_two, package_site, nl4_station,agv_conveyor },
|
||||
agv_ndc_one, agv_ndc_two, package_site, nl4_station, agv_conveyor },
|
||||
dicts: ['device_type'],
|
||||
mixins: [crud],
|
||||
data() {
|
||||
|
||||
@@ -1,102 +0,0 @@
|
||||
<template>
|
||||
<!--AGV上料下料-->
|
||||
<div>
|
||||
<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" size="small" label-width="95px">
|
||||
<el-row>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="ip地址" prop="ip_address">
|
||||
<el-input
|
||||
v-model="form.ip_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" />
|
||||
<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
|
||||
} from '@/api/acs/device/driverConfig'
|
||||
import crud from '@/mixins/crud'
|
||||
|
||||
export default {
|
||||
name: 'StandardConveyorControl',
|
||||
mixins: [crud],
|
||||
props: {
|
||||
parentForm: {
|
||||
type: Object,
|
||||
require: true
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
form: {
|
||||
ip_address: ''
|
||||
}
|
||||
}
|
||||
},
|
||||
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
|
||||
}
|
||||
}
|
||||
this.sliceItem()
|
||||
})
|
||||
})
|
||||
},
|
||||
methods: {
|
||||
doSubmit() {
|
||||
this.$refs['form'].validate((valid) => {
|
||||
if (valid) {
|
||||
this.configLoading = true
|
||||
// 根据驱动类型判断是否为路由设备
|
||||
const parentForm = this.parentForm
|
||||
parentForm.is_route = true
|
||||
updateConfig(parentForm, this.form, this.modeform, this.data1, this.data2).then(res => {
|
||||
this.notify('保存成功', 'success')
|
||||
this.configLoading = false
|
||||
}).catch(err => {
|
||||
this.configLoading = false
|
||||
console.log(err.response.data.message)
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
487
acs/nladmin-ui/src/views/acs/device/driver/agv_conveyor.vue
Normal file
487
acs/nladmin-ui/src/views/acs/device/driver/agv_conveyor.vue
Normal file
@@ -0,0 +1,487 @@
|
||||
<template>
|
||||
<!--上下料位-->
|
||||
<div>
|
||||
<el-card class="box-card" shadow="never">
|
||||
<div slot="header" class="clearfix">
|
||||
<span class="role-span">设备协议:</span>
|
||||
</div>
|
||||
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
OpcServer:
|
||||
<el-select
|
||||
v-model="opc_id"
|
||||
placeholder="无"
|
||||
clearable
|
||||
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
|
||||
filterable
|
||||
@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-input v-model="form.max_emptypalletnum" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="关联设备" prop="device_code">
|
||||
<el-select
|
||||
v-model="form.link_device_code"
|
||||
clearable
|
||||
filterable
|
||||
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-row>
|
||||
<el-row>
|
||||
<el-tooltip class="item" effect="dark" content="创建设备点位记录有无货信号" placement="bottom-end">
|
||||
<el-form-item label="站点管理" label-width="150px">
|
||||
<el-switch v-model="form.station_manager" />
|
||||
</el-form-item>
|
||||
</el-tooltip>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="清除" label-width="80px">
|
||||
<el-switch v-model="form.auto_clean_task" />
|
||||
</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.substring(0, 2)
|
||||
// .之后的字符串
|
||||
const afterStr = dbValue.substring(2)
|
||||
for (const val in this.data1) {
|
||||
if (this.data1[val].code.indexOf('move') !== -1) {
|
||||
this.data1[val].db = beforeStr + (parseInt(afterStr) + 2)
|
||||
}
|
||||
if (this.data1[val].code.indexOf('number') !== -1) {
|
||||
this.data1[val].db = beforeStr + (parseInt(afterStr) + 4)
|
||||
}
|
||||
if (this.data1[val].code.indexOf('container_type') !== -1) {
|
||||
this.data1[val].db = beforeStr + (parseInt(afterStr) + 6)
|
||||
}
|
||||
if (this.data1[val].code.indexOf('error') !== -1) {
|
||||
this.data1[val].db = beforeStr + (parseInt(afterStr) + 8)
|
||||
}
|
||||
if (this.data1[val].code.indexOf('task') !== -1) {
|
||||
this.data1[val].db = beforeStr + (parseInt(afterStr) + 10)
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
finishWriteEdit(data) {
|
||||
// 编辑的是code列,并且值包含mode
|
||||
if (data.code.indexOf('to_command') !== -1) {
|
||||
const dbValue = data.db
|
||||
// .之前的字符串
|
||||
const beforeStr = dbValue.substring(0, 2)
|
||||
// .之后的字符串
|
||||
const afterStr = dbValue.substring(2)
|
||||
for (const val in this.data2) {
|
||||
if (this.data2[val].code.indexOf('to_target') !== -1) {
|
||||
this.data2[val].db = beforeStr + (parseInt(afterStr) + 2)
|
||||
}
|
||||
if (this.data2[val].code.indexOf('to_task') !== -1) {
|
||||
this.data2[val].db = beforeStr + (parseInt(afterStr) + 4)
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
changeOpc(val) {
|
||||
this.dataOpcservers.forEach(item => {
|
||||
if (item.opc_id === val) {
|
||||
this.opc_code = item.opc_code
|
||||
}
|
||||
})
|
||||
|
||||
selectListByOpcID(val).then(data => {
|
||||
this.dataOpcPlcs = data
|
||||
this.plc_id = ''
|
||||
this.plc_code = ''
|
||||
if (this.dataOpcPlcs && this.dataOpcPlcs.length > 0) {
|
||||
this.plc_id = this.dataOpcPlcs[0].plc_id
|
||||
this.plc_code = this.dataOpcPlcs[0].plc_code
|
||||
}
|
||||
this.sliceItem()
|
||||
})
|
||||
},
|
||||
changePlc(val) {
|
||||
this.dataOpcPlcs.forEach(item => {
|
||||
if (item.plc_id === val) {
|
||||
this.plc_code = item.plc_code
|
||||
this.sliceItem()
|
||||
return
|
||||
}
|
||||
})
|
||||
},
|
||||
test_read1() {
|
||||
testRead(this.data1, this.opc_id).then(data => {
|
||||
this.data1 = data
|
||||
this.notify('操作成功!', 'success')
|
||||
}).catch(err => {
|
||||
console.log(err.response.data.message)
|
||||
})
|
||||
},
|
||||
test_write1() {
|
||||
testwrite(this.data2, this.opc_id).then(data => {
|
||||
this.notify('操作成功!', 'success')
|
||||
}).catch(err => {
|
||||
console.log(err.response.data.message)
|
||||
})
|
||||
},
|
||||
test_read2() {
|
||||
testRead(this.data2, this.opc_id).then(data => {
|
||||
this.data2 = data
|
||||
console.log(this.data2)
|
||||
this.notify('操作成功!', 'success')
|
||||
}).catch(err => {
|
||||
console.log(err.response.data.message)
|
||||
})
|
||||
},
|
||||
doSubmit() {
|
||||
this.$refs['form'].validate((valid) => {
|
||||
if (valid) {
|
||||
this.configLoading = true
|
||||
// 根据驱动类型判断是否为路由设备
|
||||
const parentForm = this.parentForm
|
||||
parentForm.is_route = true
|
||||
parentForm.plc_id = this.plc_id
|
||||
parentForm.opc_id = this.opc_id
|
||||
updateConfig(parentForm, this.form, this.modeform, this.data1, this.data2).then(res => {
|
||||
this.notify('保存成功', 'success')
|
||||
this.configLoading = false
|
||||
}).catch(err => {
|
||||
this.configLoading = false
|
||||
console.log(err.response.data.message)
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
sliceItem() { // 拼接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