This commit is contained in:
USER-20220102CG\noblelift
2022-06-30 09:05:39 +08:00
parent 5cb55f2b79
commit 22fac97060
7 changed files with 1029 additions and 3 deletions

View File

@@ -52,10 +52,17 @@ public enum DriverTypeEnum {
HAILIANG_CLEANING_MACHINE(21, "hailiang_cleaning_machine", "海亮-清洗机", "conveyor"), HAILIANG_CLEANING_MACHINE(21, "hailiang_cleaning_machine", "海亮-清洗机", "conveyor"),
HAILIANG_CLEANING_FEEDING_LINE(22, "hailiang_cleaning_feeding_line", "海亮-清洗上料线体", "conveyor"), HAILIANG_CLEANING_FEEDING_LINE(22, "hailiang_cleaning_feeding_line", "海亮-清洗上料线体", "conveyor"),
AGV_NDC_ONE(23, "agv_ndc_one", "NDC单工位AGV", "agv"), AGV_NDC_ONE(23, "agv_ndc_one", "NDC单工位AGV", "agv"),
AGV_NDC_TWO(24, "agv_ndc_two", "NDC双工位AGV", "agv"), AGV_NDC_TWO(24, "agv_ndc_two", "NDC双工位AGV", "agv"),
HAILIANG_ENGRAVING_CACHE(25, "hailiang_engraving_cache", "海亮-刻字缓存位", "conveyor"), HAILIANG_ENGRAVING_CACHE(25, "hailiang_engraving_cache", "海亮-刻字缓存位", "conveyor"),
HAILIANG_PACKER_STATION(26, "hailiang_packer_station", "海亮-包装机工位", "conveyor");
HAILIANG_PACKER_STATION(26, "hailiang_packer_station", "海亮-包装机工位", "conveyor"),
HAILIANG_XJ_PLC_TEST(27, "hailiang_xj_plc_test", "海亮-信捷PLC", "conveyor");
//驱动索引 //驱动索引
private int index; private int index;

View File

@@ -0,0 +1,226 @@
package org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_xj_plc_test;
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 lombok.Data;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nl.acs.agv.server.AgvService;
import org.nl.acs.config.server.AcsConfigService;
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.basedriver.hailiang_one.hailiang_special_pour_station.HailiangSpecialPourStationDeviceDriver;
import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver;
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.LogServer;
import org.nl.acs.opc.Device;
import org.nl.acs.opc.DeviceAppService;
import org.nl.acs.order.service.ProduceshiftorderService;
import org.nl.acs.order.service.dto.ProduceshiftorderDto;
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.util.CodeUtil;
import org.nl.start.auto.run.NDCSocketConnectionAutoRun;
import org.nl.utils.SpringContextHolder;
import org.openscada.opc.lib.da.Server;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 海亮清洗机储料仓
*/
@Slf4j
@Data
@RequiredArgsConstructor
public class HailiangHailiangxjplcTestDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver {
protected ItemProtocol itemProtocol = new ItemProtocol(this);
@Autowired
DeviceAppService deviceAppservice = SpringContextHolder.getBean(DeviceAppService.class);
@Autowired
InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class);
@Autowired
DeviceService deviceservice = SpringContextHolder.getBean(DeviceService.class);
@Autowired
TaskService taskserver = SpringContextHolder.getBean(TaskService.class);
@Autowired
RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class);
@Autowired
AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsServiceImpl.class);
@Autowired
AcsConfigService acsConfigService = SpringContextHolder.getBean(AcsConfigService.class);
@Autowired
LogServer logServer = SpringContextHolder.getBean(LogServer.class);
@Autowired
ProduceshiftorderService produceshiftorderService = SpringContextHolder.getBean(ProduceshiftorderService.class);
@Autowired
AgvService agvService = SpringContextHolder.getBean(AgvService.class);
String container;
String container_type_desc;
String last_container_type_desc;
String last_container;
//放货准备锁
String putReadyLock = null;
//有货标记
protected boolean has_goods_tag = false;
int mode =0;
int running = 0; //是否运行
int is_open = 0; //是否启动
int error = 0; //报警信号
int silo_weight = 0; //储料仓重量
int full_number = 0; //储料仓总数量
int silo_material_no = 0; //储料仓物物料号
//出入库模式
int operation_type = 0;
int last_running = 0; //是否运行
int last_is_open = 0; //是否启动
int last_error = 0; //报警信号
int last_silo_weight = 0; //储料仓重量
int last_full_number = 0; //储料仓总数量
int last_silo_material_no = 0; //储料仓物物料号
Boolean isonline = true;
int hasGoods = 0;
String message = null;
Boolean iserror = false;
boolean hasVehicle = false;
boolean isReady = false;
protected int instruction_num = 0;
protected int instruction_num_truth = 0;
boolean isFold = false;
private String assemble_check_tag;
protected String current_stage_instruction_message;
protected String last_stage_instruction_message;
Integer heartbeat_tag;
private Date instruction_require_time = new Date();
private Date instruction_finished_time = new Date();
private Date instruction_apply_time = new Date();
private int instruction_require_time_out = 3000;
//请求成功标记
Boolean requireSucess = false;
//申请指令成功标记
Boolean applySucess = false;
String inst_message;
private int instruction_finished_time_out;
int branchProtocol = 0;
//备注
String remark;
//数量
String qty;
//物料
String material;
//当前指令
Instruction inst = null;
//上次指令
Instruction last_inst = null;
//触摸屏手动触发任务
private Boolean is_has_task = false;
//申请搬运任务
private Boolean apply_handling = false;
//申请物料
private Boolean apply_material = false;
//暂定 0就绪 1请求取货 2取货完成 3请求放货 4放货完成 5取货完成离开 6放货完成离开 7请求进入区域 8请求离开区域
int flag = 0;
int agvphase=0;
int index =0;
String device_code;
@Override
public Device getDevice() {
return this.device;
}
@Override
public void execute() throws Exception {
}
public boolean exe_error() {
if (this.error == 0) {
return true;
} else {
log.debug("设备报警");
return false;
}
}
protected void thingToNothing() {
log.debug("从有货到无货 清理数据");
logServer.deviceLogToacs(this.device_code,"","","光电信号切换,刷新请求标记:"+this.requireSucess);
this.setRequireSucess(false);
this.setApplySucess(false);
this.set_last_container(container, container_type_desc);
}
public void set_last_container(String barcode, String type_desc) {
this.setInst_message(null);
this.setContainer(null);
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) {
}
public void executing(Server server, Map<String, Object> itemMap) {
ReadUtil.write(itemMap, server);
}
public void writing(int command) {
}
public void writing(String key, String value) {
String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
+ "." + key;
String opcservcerid = this.getDevice().getOpc_server_id();
Server server = ReadUtil.getServer(opcservcerid);
Map<String, Object> itemMap = new HashMap<String, Object>();
itemMap.put(to_command, value);
ReadUtil.write(itemMap, server);
}
}

View File

@@ -0,0 +1,61 @@
package org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_xj_plc_test;
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;
/**
* 海亮迅捷plc测试
*/
@Service
public class HailiangxjplcTestDefination implements OpcDeviceDriverDefination {
@Override
public String getDriverCode() {
return "hailiang_xj_plc_test";
}
@Override
public String getDriverName() {
return "海亮-海亮迅捷plc测试";
}
@Override
public String getDriverDescription() {
return "海亮-海亮迅捷plc测试";
}
@Override
public DeviceDriver getDriverInstance(Device device) {
return (new HailiangHailiangxjplcTestDeviceDriver()).setDevice(device).setDriverDefination(this);
}
@Override
public Class<? extends DeviceDriver> getDeviceDriverType() {
return HailiangHailiangxjplcTestDeviceDriver.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();
}
}

View File

@@ -0,0 +1,225 @@
package org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_xj_plc_test;
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_error = "error";
public static String item_error_num = "error_num";
public static String item_open_time = "open_time";
public static String item_close_time = "close_time"; //
public static String item_ready_time = "ready_time"; //
public static String item_running_time = "running_time";
public static String item_error_time = "error_time";
public static String item_voltage = "voltage";
public static String item_temperature = "temperature";
public static String item_current = "current";
public static String item_material = "material";
public static String item_lack_material = "lack_material";
public static String item_full_material = "full_material";
public static String item_storage_qty = "storage_qty";
public static String item_feeding_qty = "feeding_qty";
public static String item_blanking_qty = "blanking_qty";
public static String item_qualified_qty = "qualified_qty";
public static String item_unqualified_qty = "unqualified_qty";
public static String item_finish = "finish";
public static String item_task = "task";
public static String item_noload_electricity_consumption = "noload_electricity_consumption";
public static String item_prod_electricity_consumption = "prod_electricity_consumption";
public static String item_gas_consumption = "gas_consumption";
public static String item_water_consumption = "water_consumption";
public static String item_oil_level = "oil_level";
public static String item_monthly_electricity_consumption = "monthly_electricity_consumption";
public static String item_pause = "pause";
public static String item_to_heartbeat = "to_heartbeat";//
public static String item_to_command = "to_command";//
public static String item_to_feeding = "to_feeding";//
public static String item_to_task = "to_task";//
public static String item_to_pause= "to_pause";//
public static String item_to_clear = "to_clear";//
public static String item_to_finish = "to_finish";//
public static String item_to_open = "to_open";//
public static String item_to_close = "to_close";//
public static String item_to_material = "to_material";//
public static String item_to_qty = "to_qty";//
private HailiangHailiangxjplcTestDeviceDriver driver;
public ItemProtocol(HailiangHailiangxjplcTestDeviceDriver driver) {
this.driver = driver;
}
public int getItem_heartbeat() {
return this.getOpcIntegerValue(item_heartbeat);
}
public int getItem_mode() {
return this.getOpcIntegerValue(item_mode);
}
public int getItem_error() {
return this.getOpcIntegerValue(item_error);
}
public int getItem_error_num() {
return this.getOpcIntegerValue(item_error_num);
}
public int getItem_open_time() {
return this.getOpcIntegerValue(item_open_time);
}
public int getItem_close_time() {
return this.getOpcIntegerValue(item_close_time);
}
public int getItem_ready_time() {
return this.getOpcIntegerValue(item_ready_time);
}
public int getItem_running_time() {
return this.getOpcIntegerValue(item_running_time);
}
public int getItem_error_time() {
return this.getOpcIntegerValue(item_error_time);
}
public int getItem_voltage() {
return this.getOpcIntegerValue(item_voltage);
}
public int getItem_temperature() {
return this.getOpcIntegerValue(item_temperature);
}
public int getItem_current() {
return this.getOpcIntegerValue(item_current);
}
public int getItem_material() {
return this.getOpcIntegerValue(item_material);
}
public int getItem_lack_material() {
return this.getOpcIntegerValue(item_lack_material);
}
public int getItem_full_material() {
return this.getOpcIntegerValue(item_full_material);
}
public int getItem_storage_qty() {
return this.getOpcIntegerValue(item_storage_qty);
}
public int getItem_feeding_qty() {
return this.getOpcIntegerValue(item_feeding_qty);
}
public int getItem_blanking_qty() {
return this.getOpcIntegerValue(item_blanking_qty);
}
public int getItem_qualified_qty() {
return this.getOpcIntegerValue(item_qualified_qty);
}
public int getItem_unqualified_qty() {
return this.getOpcIntegerValue(item_unqualified_qty);
}
public int getItem_finish() {
return this.getOpcIntegerValue(item_mode);
}
public int getItem_task() {
return this.getOpcIntegerValue(item_task);
}
public int getItem_noload_electricity_consumption() {
return this.getOpcIntegerValue(item_noload_electricity_consumption);
}
public int getItem_prod_electricity_consumption() {
return this.getOpcIntegerValue(item_prod_electricity_consumption);
}
public int getItem_gas_consumption() {
return this.getOpcIntegerValue(item_gas_consumption);
}
public int getItem_water_consumption() {
return this.getOpcIntegerValue(item_water_consumption);
}
public int getItem_oil_level() {
return this.getOpcIntegerValue(item_oil_level);
}
public int getItem_monthly_electricity_consumption() {
return this.getOpcIntegerValue(item_monthly_electricity_consumption);
}
public int getItem_pause() {
return this.getOpcIntegerValue(item_pause);
}
Boolean isonline;
public int getOpcIntegerValue(String protocol) {
Integer value = this.driver.getIntegeregerValue(protocol);
if (value == null) {
setIsonline(false);
} else {
setIsonline(true);
return value;
}
return 0;
}
public static List<ItemDto> getReadableItemDtos() {
ArrayList list = new ArrayList();
list.add(new ItemDto(item_heartbeat, "心跳", "45202"));
list.add(new ItemDto(item_mode, "模式", "45204"));
list.add(new ItemDto(item_error, "故障", "45206"));
list.add(new ItemDto(item_error_num, "故障次数", "45208"));
list.add(new ItemDto(item_open_time, "开机时间", "45212"));
list.add(new ItemDto(item_close_time, "关机时间", "45216"));
list.add(new ItemDto(item_ready_time, "待机时间", "45220"));
list.add(new ItemDto(item_running_time, "生产时间", "45224"));
list.add(new ItemDto(item_error_time, "故障时间", "45228"));
list.add(new ItemDto(item_temperature, "温度", "45232"));
list.add(new ItemDto(item_voltage, "电压", "45236"));
list.add(new ItemDto(item_current, "电流", "45240"));
list.add(new ItemDto(item_material, "当前生产产品编号", "45244"));
list.add(new ItemDto(item_lack_material, "生产缺料信号", "45248"));
list.add(new ItemDto(item_full_material, "生产满料信号", "45252"));
return list;
}
public static List<ItemDto> getWriteableItemDtos() {
ArrayList list = new ArrayList();
list.add(new ItemDto(item_to_heartbeat, "心跳", "45702"));
list.add(new ItemDto(item_to_command, "下发命令", "45704"));
return list;
}
}

View File

@@ -109,6 +109,8 @@ import hailiang_cleaning_machine from '@/views/acs/device/driver/hailiang_one/ha
import hailiang_cleaning_machine_storage_station from '@/views/acs/device/driver/hailiang_one/hailiang_cleaning_machine_storage_station' import hailiang_cleaning_machine_storage_station from '@/views/acs/device/driver/hailiang_one/hailiang_cleaning_machine_storage_station'
import agv_ndc_one from '@/views/acs/device/driver/agv/agv_ndc_one' 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_ndc_two from '@/views/acs/device/driver/agv/agv_ndc_two'
import hailiang_xj_plc_test from '@/views/acs/device/driver/hailiang_one/hailiang_xj_plc_test'
export default { export default {
name: 'DeviceConfig', name: 'DeviceConfig',
@@ -119,7 +121,8 @@ export default {
non_line_inspect_site, manipulator_inspect_site_NDC, standard_manipulator_stacking_site, non_line_inspect_site, manipulator_inspect_site_NDC, standard_manipulator_stacking_site,
standard_photoelectric_inspect_site, agv_ndc_two, agv_ndc_one, hailiang_packer_station, hailiang_engraving_cache, standard_photoelectric_inspect_site, agv_ndc_two, agv_ndc_one, hailiang_packer_station, hailiang_engraving_cache,
hailiang_special_pick_station, hailiang_special_empty_station, hailiang_special_full_station, hailiang_special_pour_station, hailiang_special_device, hailiang_special_pick_station, hailiang_special_empty_station, hailiang_special_full_station, hailiang_special_pour_station, hailiang_special_device,
hailiang_engraving_machine, hailiang_auto_cache_line, hailiang_cleaning_feeding_line, hailiang_cleaning_machine, hailiang_cleaning_machine_storage_station }, hailiang_engraving_machine, hailiang_auto_cache_line, hailiang_cleaning_feeding_line, hailiang_cleaning_machine, hailiang_cleaning_machine_storage_station,
hailiang_xj_plc_test },
dicts: ['device_type'], dicts: ['device_type'],
mixins: [crud], mixins: [crud],
data() { data() {

View File

@@ -0,0 +1,504 @@
<template>
<!--海亮自动缓存线-->
<div>
<el-card class="box-card" shadow="never">
<div slot="header" class="clearfix">
<span class="role-span">设备协议</span>
</div>
<el-row>
<el-col :span="12">
OpcServer:
<el-select
v-model="opc_id"
placeholder="无"
clearable
filterable
@change="changeOpc"
>
<el-option
v-for="item in dataOpcservers"
:key="item.opc_id"
:label="item.opc_name"
:value="item.opc_id"
/>
</el-select>
</el-col>
<el-col :span="12">
PLC:
<el-select
v-model="plc_id"
placeholder="无"
clearable
@change="changePlc"
filterable
>
<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"
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-col :span="8">
<el-form-item label="是否输入物料" label-width="150px">
<el-switch v-model="form.input_material" />
</el-form-item>
</el-col>
</el-row>
</el-form>
</el-card>
<el-card class="box-card" shadow="never">
<div slot="header" class="clearfix">
<span class="role-span">AGV相关</span>
</div>
<el-form ref="form" :inline="true" :model="form" :rules="rules" size="small" label-width="78px">
<el-row>
<el-col :span="8">
<el-form-item label="取货">
<el-switch v-model="form.is_pickup" />
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="放货">
<el-switch v-model="form.is_release" />
</el-form-item>
</el-col>
</el-row>
</el-form>
</el-card>
<el-card class="box-card" shadow="never">
<div slot="header" class="clearfix">
<span class="role-span">PLC读取字段</span>
</div>
<el-form ref="form" :inline="true" :model="form" :rules="rules" size="small" label-width="78px">
<el-table
v-loading="false"
:data="data1"
:max-height="550"
size="small"
style="width: 100%;margin-bottom: 15px"
>
<el-table-column prop="name" label="用途" />
<el-table-column prop="code" label="别名要求" />
<el-table-column prop="db" label="DB块">
<template slot-scope="scope">
<el-input
v-model="data1[scope.$index].db"
size="mini"
class="edit-input"
@input="finishReadEdit(data1[scope.$index])"
/>
</template>
</el-table-column>
<el-table-column prop="dbr_value">
<template slot="header">
<el-link type="primary" :underline="false" @click.native="test_read1()">测试读</el-link>
</template>
<template slot-scope="scope">
<el-input v-model="data1[scope.$index].dbr_value" size="mini" class="edit-input" />
</template>
</el-table-column>
</el-table>
</el-form>
</el-card>
<el-card class="box-card" shadow="never">
<div slot="header" class="clearfix">
<span class="role-span">PLC写入字段</span>
</div>
<el-form ref="form" :inline="true" :model="form" :rules="rules" size="small" label-width="78px">
<el-table
v-loading="false"
:data="data2"
:max-height="550"
size="small"
style="width: 100%;margin-bottom: 15px"
>
<el-table-column prop="name" label="用途" />
<el-table-column prop="code" label="别名要求" />
<el-table-column prop="db" label="DB块">
<template slot-scope="scope">
<el-input
v-model="data2[scope.$index].db"
size="mini"
class="edit-input"
@input="finishWriteEdit(data2[scope.$index])"
/>
</template>
</el-table-column>
<el-table-column prop="dbw_value">
<template slot="header">
<el-link type="primary" :underline="false" @click.native="test_write1()">测试写</el-link>
</template>
<template slot-scope="scope">
<el-input v-model="data2[scope.$index].dbw_value" size="mini" class="edit-input" />
</template>
</el-table-column>
</el-table>
</el-form>
</el-card>
<el-card class="box-card" shadow="never">
<div slot="header" class="clearfix">
<span class="role-span" />
<el-button
:loading="false"
icon="el-icon-check"
size="mini"
style="float: right; padding: 6px 9px"
type="primary"
@click="doSubmit"
>保存
</el-button>
</div>
</el-card>
</div>
</template>
<script>
import {
queryDriverConfig,
updateConfig,
testRead,
testwrite
} from '@/api/acs/device/driverConfig'
import { selectOpcList } from '@/api/acs/device/opc'
import { selectPlcList } from '@/api/acs/device/opcPlc'
import { selectListByOpcID } from '@/api/acs/device/opcPlc'
import crud from '@/mixins/crud'
import deviceCrud from '@/api/acs/device/device'
export default {
name: 'StandardConveyorControl',
mixins: [crud],
props: {
parentForm: {
type: Object,
require: true
}
},
data() {
return {
device_code: '',
device_id: '',
plc_id: '',
plc_code: '',
address: '',
opc_id: '',
opc_code: '',
configLoading: false,
dataOpcservers: [],
dataOpcPlcs: [],
deviceList: [],
data1: [],
data2: [],
form: {
inspect_in_stocck: true,
ignore_pickup_check: true,
ignore_release_check: true,
apply_task: true,
link_three_lamp: '',
manual_create_task: true,
is_pickup: true,
is_release: true,
link_device_code: ''
},
rules: {}
}
},
created() {
this.$nextTick(() => {
// 从父表单获取设备编码
this.device_id = this.$props.parentForm.device_id
this.device_code = this.$props.parentForm.device_code
queryDriverConfig(this.device_id, this.$props.parentForm.driver_code).then(data => {
// 给表单赋值,并且属性不能为空
if (data.form) {
const arr = Object.keys(data.form)
// 不为空
if (arr.length > 0) {
this.form = data.form
}
}
// 给表单赋值,并且属性不能为空
if (data.parentForm) {
const arr = Object.keys(data.parentForm)
// 不为空
if (arr.length > 0) {
this.opc_code = data.parentForm.opc_code
this.plc_code = data.parentForm.plc_code
}
}
this.data1 = data.rs
this.data2 = data.ws
this.sliceItem()
})
selectPlcList().then(data => {
this.dataOpcPlcs = data
this.plc_id = this.$props.parentForm.opc_plc_id
})
selectOpcList().then(data => {
this.dataOpcservers = data
this.opc_id = this.$props.parentForm.opc_server_id
})
deviceCrud.selectDeviceList().then(data => {
this.deviceList = data
})
})
},
methods: {
finishReadEdit(data) {
// 编辑的是code列,并且值包含mode
if (data.code.indexOf('mode') !== -1) {
const dbValue = data.db
// .之前的字符串
const beforeStr = dbValue.match(/(\S*)\./)[1]
// .之后的字符串
const afterStr = dbValue.match(/\.(\S*)/)[1]
// 取最后数字
const endNumber = afterStr.substring(1)
// 最后为非数字
if (isNaN(parseInt(endNumber))) {
return
}
for (const val in this.data1) {
if (this.data1[val].code.indexOf('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('ioaction') !== -1) {
this.data1[val].db = beforeStr + '.' + afterStr.substring(0, 1) + (parseInt(endNumber) + 3)
}
if (this.data1[val].code.indexOf('height') !== -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('direction') !== -1) {
this.data1[val].db = beforeStr + '.' + afterStr.substring(0, 1) + (parseInt(endNumber) + 6)
}
if (this.data1[val].code.indexOf('operation_type') !== -1) {
this.data1[val].db = beforeStr + '.' + afterStr.substring(0, 1) + (parseInt(endNumber) + 7)
}
if (this.data1[val].code.indexOf('task') !== -1) {
this.data1[val].db = beforeStr + '.' + 'D' + (parseInt(endNumber) + 21)
}
}
}
},
finishWriteEdit(data) {
// 编辑的是code列,并且值包含mode
if (data.code.indexOf('to_command') !== -1) {
const dbValue = data.db
// .之前的字符串
const beforeStr = dbValue.match(/(\S*)\./)[1]
// .之后的字符串
const afterStr = dbValue.match(/\.(\S*)/)[1]
// 取最后数字
const endNumber = afterStr.substring(1)
// 最后为非数字
if (isNaN(parseInt(endNumber))) {
return
}
for (const val in this.data2) {
if (this.data2[val].code.indexOf('to_target') !== -1) {
this.data2[val].db = beforeStr + '.' + afterStr.substring(0, 1) + (parseInt(endNumber) + 2)
}
if (this.data2[val].code.indexOf('to_task') !== -1) {
this.data2[val].db = beforeStr + '.' + 'D' + (parseInt(endNumber) + 6)
}
}
}
},
changeOpc(val) {
this.dataOpcservers.forEach(item => {
if (item.opc_id === val) {
this.opc_code = item.opc_code
}
})
selectListByOpcID(val).then(data => {
this.dataOpcPlcs = data
this.plc_id = ''
this.plc_code = ''
if (this.dataOpcPlcs && this.dataOpcPlcs.length > 0) {
this.plc_id = this.dataOpcPlcs[0].plc_id
this.plc_code = this.dataOpcPlcs[0].plc_code
}
this.sliceItem()
})
},
changePlc(val) {
this.dataOpcPlcs.forEach(item => {
if (item.plc_id === val) {
this.plc_code = item.plc_code
this.sliceItem()
return
}
})
},
test_read1() {
testRead(this.data1, this.opc_id).then(data => {
this.data1 = data
this.notify('操作成功!', 'success')
}).catch(err => {
console.log(err.response.data.message)
})
},
test_write1() {
testwrite(this.data2, this.opc_id).then(data => {
this.notify('操作成功!', 'success')
}).catch(err => {
console.log(err.response.data.message)
})
},
doSubmit() {
this.$refs['form'].validate((valid) => {
if (valid) {
this.configLoading = true
// 根据驱动类型判断是否为路由设备
const parentForm = this.parentForm
parentForm.is_route = true
parentForm.plc_id = this.plc_id
parentForm.opc_id = this.opc_id
updateConfig(parentForm, this.form, this.data1, this.data2).then(res => {
this.notify('保存成功', 'success')
this.configLoading = false
}).catch(err => {
this.configLoading = false
console.log(err.response.data.message)
})
}
})
},
sliceItem() { // 拼接DB的Item值
this.data1.forEach(item => {
const str = item.code
// 是否包含.
if (str.search('.') !== -1) {
// 截取最后一位
item.code = this.opc_code + '.' + this.plc_code + '.' + this.device_code + '.' + str.slice(str.lastIndexOf('.') + 1)
} else {
item.code = this.opc_code + '.' + this.plc_code + '.' + this.device_code + '.' + item.code
}
})
this.data2.forEach(item => {
const str = item.code
// 是否包含.
if (str.search('.') !== -1) {
// 截取最后一位
item.code = this.opc_code + '.' + this.plc_code + '.' + this.device_code + '.' + str.slice(str.lastIndexOf('.') + 1)
} else {
item.code = this.opc_code + '.' + this.plc_code + '.' + this.device_code + '.' + item.code
}
})
}
}
}
</script>
<style scoped>
</style>

View File

@@ -70,7 +70,7 @@
</el-col> </el-col>
<el-col :span="23" style="margin-left: 20px"> <el-col :span="23" style="margin-left: 20px">
<el-scrollbar style="width:1100px;height: 650px;"> <el-scrollbar style="width:1850px;height: 1050px;">
<!--使用draggable组件--> <!--使用draggable组件-->
<draggable <draggable
:list="arr2" :list="arr2"