Browse Source

add 包装线

master
周俊杰 1 year ago
parent
commit
433abd04c6
  1. 4
      acs/nladmin-system/src/main/java/org/nl/acs/device/device_driver/DriverTypeEnum.java
  2. 162
      acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/package_site/ItemProtocol.java
  3. 62
      acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/package_site/PackageSiteDefination.java
  4. 343
      acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/package_site/PackageSiteDeviceDriver.java
  5. 4
      acs/nladmin-ui/src/views/acs/device/config.vue
  6. 491
      acs/nladmin-ui/src/views/acs/device/driver/lnsh/package_site.vue

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

@ -85,9 +85,9 @@ public enum DriverTypeEnum {
CONVEYOR_SSX_BARCODE(54, "conveyor_ssx_barcode", "标准版-下发条码输送线", "station"),
CONVEYOR_PRESS_STATION(54, "conveyor_press_station", "标准版-压制对接位", "station");
CONVEYOR_PRESS_STATION(54, "conveyor_press_station", "标准版-压制对接位", "station"),
PACKAGE_SITE(55, "package_site", "包装线工位", "station");
//驱动索引
private int index;
//驱动编码

162
acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/package_site/ItemProtocol.java

@ -0,0 +1,162 @@
package org.nl.acs.device_driver.lnsh.package_site;
import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.nl.acs.device.device_driver.standard_inspect.ItemDto;
import org.nl.acs.device_driver.lnsh.lnsh_package_site.LnshPackageSiteDeviceDriver;
import java.util.ArrayList;
import java.util.List;
@Slf4j
@Getter
@Setter
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_action = "action";
public static String item_ioaction = "ioaction";
public static String item_error = "error";
public static String item_vehicle_code = "vehicle_code";
public static String item_vehicle_type = "vehicle_type";
public static String item_task = "task";
public static String item_to_command = "to_command";
public static String item_to_vehicle_code = "to_vehicle_code";
public static String item_to_vehicle_type = "to_vehicle_type";
public static String item_to_is_package = "to_is_package";
public static String item_is_weight = "is_weight";
public static String item_material = "material";
public static String item_barcode = "barcode";
public static String item_to_target = "to_target";
public static String item_to_task= "to_task";
public static String item_is_message= "is_message";
Boolean isonline;
private PackageSiteDeviceDriver driver;
public ItemProtocol(PackageSiteDeviceDriver driver) {
this.driver = driver;
}
public int getTo_target() {
return this.getOpcIntegerValue(item_to_target);
}
public int getTo_task() {
return this.getOpcIntegerValue(item_to_task);
}
public int getHeartbeat() {
return this.getOpcIntegerValue(item_heartbeat);
}
public int getMode() {
return this.getOpcIntegerValue(item_mode);
}
public int getBarcode() {
return this.getOpcIntegerValue(item_barcode);
}
public String getMaterial() {
return this.getOpcStringValue(item_material);
}
public String getmessage() {
return this.getOpcStringValue(item_is_message);
}
public int getTask() { return this.getOpcIntegerValue(item_task); }
public int getWeight() { return this.getOpcIntegerValue(item_is_weight);}
public int getMove() {
return this.getOpcIntegerValue(item_move);
}
public int getAction() {
return this.getOpcIntegerValue(item_action);
}
public int getIoaction() {
return this.getOpcIntegerValue(item_ioaction);
}
public int getError() {
return this.getOpcIntegerValue(item_error);
}
public int getVehicle_code() {
return this.getOpcIntegerValue(item_vehicle_code);
}
public int getVehicle_type() {
return this.getOpcIntegerValue(item_vehicle_type);
}
public int getTo_command() {
return this.getOpcIntegerValue(item_to_command);
}
public int getTo_vehicle_code() {
return this.getOpcIntegerValue(item_to_vehicle_code);
}
public int getTo_vehicle_type() {
return this.getOpcIntegerValue(item_to_vehicle_type);
}
//是否有货
public int hasGoods(int move) {
return move;
}
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 (value == null) {
// log.error("读取错误!");
} else {
return value;
}
return "";
}
public static List<ItemDto> getReadableItemDtos() {
ArrayList<ItemDto> list = new ArrayList<>();
list.add(new ItemDto(item_heartbeat, "心跳", "DB51.B0"));
list.add(new ItemDto(item_mode, "工作模式", "DB51.B1", Boolean.valueOf(true)));
list.add(new ItemDto(item_move, "光电开关信号", "DB51.B2"));
list.add(new ItemDto(item_action, "取放信号", "DB51.B3"));
list.add(new ItemDto(item_ioaction, "进出信号", "DB51.B4"));
list.add(new ItemDto(item_error, "报警信号", "DB51.B5"));
list.add(new ItemDto(item_task, "任务号", "DB51.D6"));
list.add(new ItemDto(item_is_weight, "重量", "DB51.D10"));
list.add(new ItemDto(item_material, "物料", "DB51.STRING14.50"));
list.add(new ItemDto(item_barcode, "条码", "DB51.W66"));
return list;
}
public static List<ItemDto> getWriteableItemDtos() {
ArrayList<ItemDto> list = new ArrayList<>();
list.add(new ItemDto(item_to_command, "下发指令", "DB51.B0", Boolean.TRUE));
list.add(new ItemDto(item_to_target, "下发目标站", "DB51.B2"));
list.add(new ItemDto(item_to_task, "下发任务号", "DB51.B4"));
list.add(new ItemDto(item_to_is_package, "下发是否包装", "DB51.B8"));
list.add(new ItemDto(item_is_message, "下发信息反馈", "DB62.STRING10.50"));
return list;
}
}

62
acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/package_site/PackageSiteDefination.java

@ -0,0 +1,62 @@
package org.nl.acs.device_driver.lnsh.package_site;
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 PackageSiteDefination implements OpcDeviceDriverDefination {
@Override
public String getDriverCode() {
return "package_site";
}
@Override
public String getDriverName() {
return "包装线工位";
}
@Override
public String getDriverDescription() {
return "包装线工位";
}
@Override
public DeviceDriver getDriverInstance(Device device) {
return (new PackageSiteDeviceDriver()).setDevice(device).setDriverDefination(this);
}
@Override
public Class<? extends DeviceDriver> getDeviceDriverType() {
return PackageSiteDeviceDriver.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();
}
}

343
acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/package_site/PackageSiteDeviceDriver.java

@ -0,0 +1,343 @@
package org.nl.acs.device_driver.lnsh.package_site;
import com.alibaba.fastjson.JSONObject;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.nl.acs.device.device_driver.standard_inspect.ReadUtil;
import org.nl.acs.device.service.DeviceService;
import org.nl.acs.device_driver.DeviceDriver;
import org.nl.acs.device_driver.RouteableDeviceDriver;
import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver;
import org.nl.acs.device_driver.driver.ExecutableDeviceDriver;
import org.nl.acs.ext.wms.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.route.service.RouteLineService;
import org.nl.acs.task.service.TaskService;
import org.nl.modules.wql.util.SpringContextHolder;
import org.openscada.opc.lib.da.Server;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 晟华-包装线工位
*/
@Slf4j
@Getter
@Setter
@RequiredArgsConstructor
public class PackageSiteDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor {
// protected org.nl.acs.device_driver.lnsh.lnsh_package_site.ItemProtocol itemProtocol = new ItemProtocol(this);
protected ItemProtocol itemProtocol=new ItemProtocol(this);
InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl");
DeviceService deviceservice = SpringContextHolder.getBean("deviceServiceImpl");
RouteLineService routelineserver = SpringContextHolder.getBean("routeLineServiceImpl");
TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl");
DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl");
AcsToWmsService acsToWmsService = SpringContextHolder.getBean("acsToWmsServiceImpl");
//放货准备锁
String putReadyLock = null;
//有货标记
protected boolean has_goods_tag = false;
String device_code;
Boolean isonline = true;
int hasGoods = 0;
Boolean iserror = false;
boolean hasVehicle = false;
boolean isReady = false;
protected int instruction_num = 0;
protected int instruction_num_truth = 0;
private Date instruction_require_time = new Date();
private Date instruction_finished_time = new Date();
private int instruction_require_time_out = 3000;
boolean requireSucess = false;
private int instruction_finished_time_out;
private Date checkHeartbeattime = new Date();
private Date last_checkHeartbeattime = new Date();
int branchProtocol = 0;
//当前指令
Instruction inst = null;
//上次指令
Instruction last_inst = null;
//触摸屏手动触发任务
private Boolean is_has_task = false;
//暂定 0就绪 1请求取货 2取货完成 3请求放货 4放货完成 5取货完成离开 6放货完成离开 7请求进入区域 8请求离开区域
int flag;
String message;
int heartbeat = 0;
int last_heartbeat = 0;
int mode = 0;
int last_mode = 0;
int move = 0;
int last_move = 0;
int action = 0;
int last_action = 0;
int ioaction = 0;
int last_ioaction = 0;
int error = 0;
int last_error = 0;
int vehicle_code = 0;
int last_vehicle_code = 0;
int vehicle_type = 0;
int last_vehicle_type = 0;
int to_command = 0;
int last_to_command = 0;
int to_vehicle_code = 0;
int last_to_vehicle_code = 0;
int to_vehicle_type = 0;
int last_to_vehicle_type = 0;
@Override
public Device getDevice() {
return this.device;
}
@Override
public void execute() {
String message = null;
try {
device_code = this.getDeviceCode();
mode = this.itemProtocol.getMode();
move = this.itemProtocol.getMove();
action = this.itemProtocol.getAction();
ioaction = this.itemProtocol.getIoaction();
error = this.itemProtocol.getError();
vehicle_code = this.itemProtocol.getVehicle_code();
vehicle_type = this.itemProtocol.getVehicle_type();
if (mode != last_mode) {
this.setRequireSucess(false);
logServer.deviceItemValue(this.device_code, "mode", String.valueOf(mode));
logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_mode + " -> " + mode);
}
if (move != last_move) {
logServer.deviceItemValue(this.device_code, "move", String.valueOf(move));
logServer.deviceExecuteLog(this.device_code, "", "", "信号move:" + last_move + " -> " + move);
}
if (action != last_action) {
logServer.deviceItemValue(this.device_code, "action", String.valueOf(action));
logServer.deviceExecuteLog(this.device_code, "", "", "信号action:" + last_action + " -> " + action);
}
if (ioaction != last_ioaction) {
logServer.deviceItemValue(this.device_code, "ioaction", String.valueOf(ioaction));
logServer.deviceExecuteLog(this.device_code, "", "", "信号ioaction:" + last_ioaction + " -> " + ioaction);
}
if (error != last_error) {
logServer.deviceItemValue(this.device_code, "error", String.valueOf(error));
logServer.deviceExecuteLog(this.device_code, "", "", "信号error:" + last_error + " -> " + error);
}
if (vehicle_code != last_vehicle_code) {
logServer.deviceItemValue(this.device_code, "vehicle_code", String.valueOf(vehicle_code));
logServer.deviceExecuteLog(this.device_code, "", "", "信号vehicle_code:" + last_vehicle_code + " -> " + vehicle_code);
}
if (vehicle_type != last_vehicle_type) {
logServer.deviceItemValue(this.device_code, "vehicle_type", String.valueOf(vehicle_type));
logServer.deviceExecuteLog(this.device_code, "", "", "信号vehicle_type:" + last_vehicle_type + " -> " + vehicle_type);
}
} catch (Exception var17) {
return;
}
if (mode == 0) {
this.setIsonline(false);
this.setIserror(true);
message = "未联机";
//有报警
} else if (error != 0) {
this.setIsonline(false);
this.setIserror(true);
message = "有报警";
//无报警
} else {
this.setIsonline(true);
this.setIserror(false);
message = "";
Instruction instruction = null;
List toInstructions;
switch (mode) {
case 1:
log.debug("设备运转模式:等待工作");
break;
case 2:
break;
case 5:
}
}
last_mode = mode;
last_move = move;
last_action = action;
last_ioaction = ioaction;
last_error = error;
last_vehicle_code = vehicle_code;
last_vehicle_type = vehicle_type;
last_to_command = to_command;
last_to_vehicle_code = to_vehicle_code;
last_to_vehicle_type = to_vehicle_type;
}
public void writing(int command) {
String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
+ "." + org.nl.acs.device_driver.lnsh.lnsh_station.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);
ReadUtil.write(itemMap, server);
server.disconnect();
logServer.deviceExecuteLog(this.device_code, "", "", "to_command 写入 " + command);
}
public void writing(String param, String value) {
String to_param = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
+ "." + param;
String opcservcerid = this.getDevice().getOpc_server_id();
Server server = ReadUtil.getServer(opcservcerid);
Map<String, Object> itemMap = new HashMap<>();
itemMap.put(to_param, value);
ReadUtil.write(itemMap, server);
logServer.deviceExecuteLog(this.device_code, "", "", param + " 写入 " + value);
}
public String toString() {
return "";
}
@Override
public JSONObject getDeviceStatusName() throws Exception {
String mode;
String move;
String action;
String io_action;
boolean hasGoods;
switch (this.mode) {
case 0:
mode = "脱机";
break;
case 2:
mode = "待机";
break;
case 3:
mode = "运行中";
break;
default:
mode = String.valueOf(this.mode);
}
if (this.move == 0) {
move = "无货";
hasGoods = false;
} else {
move = "有货";
hasGoods = true;
}
switch (this.action) {
case 1:
action = "允许取货";
break;
case 2:
action = "允许放货";
break;
case 3:
action = "允许取放";
break;
default:
action = "禁止取放";
}
switch (this.ioaction) {
case 1:
io_action = "允许进入";
break;
case 2:
io_action = "允许离开";
break;
case 3:
io_action = "允许进入离开";
break;
default:
io_action = "禁止进入离开";
}
String error;
switch (this.error) {
case 1:
error = "急停中";
break;
case 2:
error = "光幕报警";
break;
case 3:
error = "本体报警";
break;
case 4:
error = "未排产报警";
break;
case 5:
error = "扫码故障";
break;
default:
error = String.valueOf(this.error);
}
JSONObject jo = new JSONObject();
jo.put("device_name", this.getDevice().getDevice_name());
jo.put("mode", mode);
jo.put("move", move);
jo.put("action", action);
jo.put("io_action", io_action);
jo.put("error", error);
jo.put("barcode", vehicle_code);
jo.put("container_type", vehicle_type);
jo.put("isError", iserror);
jo.put("isOnline", isonline);
jo.put("hasGoods", hasGoods);
jo.put("message", message);
return jo;
}
@Override
public void setDeviceStatus(JSONObject data) {
}
}

4
acs/nladmin-ui/src/views/acs/device/config.vue

@ -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 package_site from './driver/lnsh/package_site.vue'
export default {
name: 'DeviceConfig',
@ -112,7 +112,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},
agv_ndc_one, agv_ndc_two,package_site},
dicts: ['device_type'],
mixins: [crud],
data() {

491
acs/nladmin-ui/src/views/acs/device/driver/lnsh/package_site.vue

@ -0,0 +1,491 @@
<template>
<!--晟华-包装机工位-->
<div>
<el-card class="box-card" shadow="never">
<div slot="header" class="clearfix">
<span class="role-span">设备协议</span>
</div>
<el-row>
<el-col :span="12">
OpcServer:
<el-select
v-model="opc_id"
placeholder="无"
clearable
filterable
@change="changeOpc"
>
<el-option
v-for="item in dataOpcservers"
:key="item.opc_id"
:label="item.opc_name"
:value="item.opc_id"
/>
</el-select>
</el-col>
<el-col :span="12">
PLC:
<el-select
v-model="plc_id"
placeholder="无"
clearable
@change="changePlc"
>
<el-option
v-for="item in dataOpcPlcs"
:key="item.plc_id"
:label="item.plc_name"
:value="item.plc_id"
/>
</el-select>
</el-col>
</el-row>
</el-card>
<el-card class="box-card" shadow="never">
<div slot="header" class="clearfix">
<span class="role-span">输送系统</span>
</div>
<el-form ref="form" :inline="true" :model="form" :rules="rules" size="small" label-width="78px">
<el-row>
<el-col :span="8">
<el-form-item label="电气调度号" label-width="150px">
<el-input v-model="form.OPCServer" />
</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.apply_empty"
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-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.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: 'LnshPackageSite',
mixins: [crud],
props: {
parentForm: {
type: Object,
require: true
}
},
data() {
return {
device_code: '',
device_id: '',
plc_id: '',
plc_code: '',
opc_id: '',
opc_code: '',
configLoading: false,
dataOpcservers: [],
dataOpcPlcs: [],
data1: [],
data2: [],
form: {
inspect_in_stocck: true,
ignore_pickup_check: true,
ignore_release_check: true,
apply_task: true,
apply_empty: [],
manual_create_task: true,
is_pickup: true,
is_release: true
},
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('heartbeat') !== -1) {
this.data1[val].db = beforeStr + '.' + afterStr.substring(0, 1) + (parseInt(endNumber) - 1)
}
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('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) + 5)
}
if (this.data1[val].code.indexOf('weight') !== -1) {
this.data1[val].db = beforeStr + '.' + 'D' + (parseInt(endNumber) + 9)
}
if (this.data1[val].code.indexOf('material') !== -1) {
this.data1[val].db = beforeStr + '.' + 'STRING' + (parseInt(endNumber) + 13) + '.50'
}
if (this.data1[val].code.indexOf('barcode') !== -1) {
this.data1[val].db = beforeStr + '.' + 'W' + (parseInt(endNumber) + 65)
}
}
}
},
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) + 4)
}
if (this.data2[val].code.indexOf('to_is_package') !== -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)
})
},
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() { // 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