41 changed files with 1120 additions and 64 deletions
@ -0,0 +1,145 @@ |
|||||
|
package org.nl.acs.device_driver.lnsh.lnsh_crusher; |
||||
|
|
||||
|
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_status = "status"; |
||||
|
public static String item_error = "error"; |
||||
|
public static String item_open_time = "open_time"; |
||||
|
public static String item_standby_time = "standby_time"; |
||||
|
public static String item_production_time = "production_time"; |
||||
|
public static String item_error_time = "error_time"; |
||||
|
public static String item_close_time = "close_time"; |
||||
|
public static String item_material = "material"; |
||||
|
public static String item_waitBroken_weight = "waitBroken_weight"; |
||||
|
public static String item_alreadyBroken_weight = "alreadyBroken_weight"; |
||||
|
public static String item_to_command = "to_command"; |
||||
|
public static String item_to_error = "to_error"; |
||||
|
Boolean isonline; |
||||
|
|
||||
|
private LnshCrusherDeviceDriver driver; |
||||
|
|
||||
|
public ItemProtocol(LnshCrusherDeviceDriver driver) { |
||||
|
this.driver = driver; |
||||
|
} |
||||
|
|
||||
|
public int getHeartbeat() { |
||||
|
return this.getOpcIntegerValue(item_heartbeat); |
||||
|
} |
||||
|
|
||||
|
public int getMode() { |
||||
|
return this.getOpcIntegerValue(item_mode); |
||||
|
} |
||||
|
|
||||
|
public int getStatus() { |
||||
|
return this.getOpcIntegerValue(item_status); |
||||
|
} |
||||
|
|
||||
|
public int getError() { |
||||
|
return this.getOpcIntegerValue(item_error); |
||||
|
} |
||||
|
|
||||
|
public int getOpen_time() { |
||||
|
return this.getOpcIntegerValue(item_open_time); |
||||
|
} |
||||
|
|
||||
|
public int getStandby_time() { |
||||
|
return this.getOpcIntegerValue(item_standby_time); |
||||
|
} |
||||
|
|
||||
|
public int getProduction_time() { |
||||
|
return this.getOpcIntegerValue(item_production_time); |
||||
|
} |
||||
|
|
||||
|
public int getError_time() { |
||||
|
return this.getOpcIntegerValue(item_error_time); |
||||
|
} |
||||
|
|
||||
|
public int getClose_time() { |
||||
|
return this.getOpcIntegerValue(item_close_time); |
||||
|
} |
||||
|
|
||||
|
public String getMaterial() { |
||||
|
return this.getOpcStringValue(item_material); |
||||
|
} |
||||
|
|
||||
|
public int getWaitBroken_weight() { |
||||
|
return this.getOpcIntegerValue(item_waitBroken_weight); |
||||
|
} |
||||
|
|
||||
|
public int getAlreadyBroken_weight() { |
||||
|
return this.getOpcIntegerValue(item_alreadyBroken_weight); |
||||
|
} |
||||
|
|
||||
|
public int getTo_command() { |
||||
|
return this.getOpcIntegerValue(item_to_command); |
||||
|
} |
||||
|
|
||||
|
public int getTo_error() { |
||||
|
return this.getOpcIntegerValue(item_to_error); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
//是否有货
|
||||
|
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 "0"; |
||||
|
} |
||||
|
|
||||
|
public static List<ItemDto> getReadableItemDtos() { |
||||
|
ArrayList list = new ArrayList(); |
||||
|
list.add(new ItemDto(item_heartbeat, "心跳", "DB1.B0")); |
||||
|
list.add(new ItemDto(item_mode, "工作状态", "DB1.B1", Boolean.valueOf(true))); |
||||
|
list.add(new ItemDto(item_status, "设备状态", "DB1.B2")); |
||||
|
list.add(new ItemDto(item_error, "故障", "DB1.B3")); |
||||
|
list.add(new ItemDto(item_open_time, "开机时间", "DB1.D4")); |
||||
|
list.add(new ItemDto(item_standby_time, "待机时间", "DB1.D8")); |
||||
|
list.add(new ItemDto(item_production_time, "生产时间", "DB1.D12")); |
||||
|
list.add(new ItemDto(item_error_time, "故障时间", "DB1.D16")); |
||||
|
list.add(new ItemDto(item_close_time, "关机时间", "DB1.D20")); |
||||
|
list.add(new ItemDto(item_material, "当前生产物料", "DB1.S24")); |
||||
|
list.add(new ItemDto(item_waitBroken_weight, "待破碎重量", "DB1.D280")); |
||||
|
list.add(new ItemDto(item_alreadyBroken_weight, "已破碎重量", "DB1.D284")); |
||||
|
return list; |
||||
|
} |
||||
|
|
||||
|
public static List<ItemDto> getWriteableItemDtos() { |
||||
|
ArrayList list = new ArrayList(); |
||||
|
list.add(new ItemDto(item_to_command, "下发命令", "DB2.W0", Boolean.valueOf(true))); |
||||
|
list.add(new ItemDto(item_to_error, "下发故障", "DB2.W2")); |
||||
|
return list; |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
|
@ -0,0 +1,78 @@ |
|||||
|
package org.nl.acs.device_driver.lnsh.lnsh_crusher; |
||||
|
|
||||
|
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; |
||||
|
|
||||
|
/** |
||||
|
* 晟华破碎机 |
||||
|
*/ |
||||
|
@Service |
||||
|
public class LnshCrusherDefination implements OpcDeviceDriverDefination { |
||||
|
@Override |
||||
|
public String getDriverCode() { |
||||
|
return "lnsh_crusher"; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public String getDriverName() { |
||||
|
return "晟华-破碎机"; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public String getDriverDescription() { |
||||
|
return "晟华-破碎机"; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public DeviceDriver getDriverInstance(Device device) { |
||||
|
return (new LnshCrusherDeviceDriver()).setDevice(device).setDriverDefination(this); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public Class<? extends DeviceDriver> getDeviceDriverType() { |
||||
|
return LnshCrusherDeviceDriver.class; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public List<DeviceType> getFitDeviceTypes() { |
||||
|
List<DeviceType> types = new LinkedList(); |
||||
|
types.add(DeviceType.station); |
||||
|
return types; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public List<ItemDto> getReadableItemDtos() { |
||||
|
return getReadableItemDtos2(); |
||||
|
} |
||||
|
|
||||
|
public static List<ItemDto> getReadableItemDtos2() { |
||||
|
ArrayList list = new ArrayList(); |
||||
|
list.add(new ItemDto(ItemProtocol.item_heartbeat, "心跳", "DB1.B0")); |
||||
|
list.add(new ItemDto(ItemProtocol.item_mode, "工作状态", "DB1.B1", Boolean.valueOf(true))); |
||||
|
list.add(new ItemDto(ItemProtocol.item_status, "设备状态", "DB1.B2")); |
||||
|
list.add(new ItemDto(ItemProtocol.item_error, "故障", "DB1.B3")); |
||||
|
list.add(new ItemDto(ItemProtocol.item_open_time, "开机时间", "DB1.D4")); |
||||
|
list.add(new ItemDto(ItemProtocol.item_standby_time, "待机时间", "DB1.D8")); |
||||
|
list.add(new ItemDto(ItemProtocol.item_production_time, "生产时间", "DB1.D12")); |
||||
|
list.add(new ItemDto(ItemProtocol.item_error_time, "故障时间", "DB1.D16")); |
||||
|
list.add(new ItemDto(ItemProtocol.item_close_time, "关机时间", "DB1.D20")); |
||||
|
list.add(new ItemDto(ItemProtocol.item_material, "当前生产物料", "DB1.S24")); |
||||
|
list.add(new ItemDto(ItemProtocol.item_waitBroken_weight, "待破碎重量", "DB1.D280")); |
||||
|
list.add(new ItemDto(ItemProtocol.item_alreadyBroken_weight, "已破碎重量", "DB1.D284")); |
||||
|
return list; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public List<ItemDto> getWriteableItemDtos() { |
||||
|
return ItemProtocol.getWriteableItemDtos(); |
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,251 @@ |
|||||
|
package org.nl.acs.device_driver.lnsh.lnsh_crusher; |
||||
|
|
||||
|
import cn.hutool.core.util.StrUtil; |
||||
|
import lombok.Data; |
||||
|
import lombok.RequiredArgsConstructor; |
||||
|
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.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.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; |
||||
|
|
||||
|
/** |
||||
|
* 晟华破碎机 |
||||
|
*/ |
||||
|
@Slf4j |
||||
|
@Data |
||||
|
@RequiredArgsConstructor |
||||
|
public class LnshCrusherDeviceDriver 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 |
||||
|
LogServer logServer = SpringContextHolder.getBean("logServerImpl"); |
||||
|
|
||||
|
String device_code; |
||||
|
int mode = 0; |
||||
|
int error = 0; |
||||
|
int last_mode = 0; |
||||
|
int last_error = 0; |
||||
|
Boolean isonline = true; |
||||
|
Boolean iserror = false; |
||||
|
|
||||
|
boolean requireSucess = false; |
||||
|
|
||||
|
int heartbeat; |
||||
|
int last_heartbeat; |
||||
|
private Date checkHeartbeattime = new Date(); |
||||
|
private Date last_checkHeartbeattime = new Date(); |
||||
|
|
||||
|
String message; |
||||
|
int status = 0; |
||||
|
int last_status = 0; |
||||
|
//开机时间
|
||||
|
int open_time = 0; |
||||
|
int last_open_time = 0; |
||||
|
//待机时间
|
||||
|
int standby_time = 0; |
||||
|
int last_standby_time = 0; |
||||
|
//生产时间
|
||||
|
int production_time = 0; |
||||
|
int last_production_time = 0; |
||||
|
//故障时间
|
||||
|
int error_time = 0; |
||||
|
int last_error_time = 0; |
||||
|
//关机时间
|
||||
|
int close_time = 0; |
||||
|
int last_close_time = 0; |
||||
|
//待破碎重量
|
||||
|
int waitBroken_weight = 0; |
||||
|
int last_waitBroken_weight = 0; |
||||
|
|
||||
|
//已破碎重量
|
||||
|
int alreadyBroken_weight = 0; |
||||
|
int last_alreadyBroken_weight = 0; |
||||
|
|
||||
|
String material; |
||||
|
String last_material; |
||||
|
|
||||
|
@Override |
||||
|
public Device getDevice() { |
||||
|
return this.device; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
@Override |
||||
|
public void execute() { |
||||
|
String message = null; |
||||
|
try { |
||||
|
device_code = this.getDeviceCode(); |
||||
|
mode = this.itemProtocol.getMode(); |
||||
|
status = this.itemProtocol.getStatus(); |
||||
|
error = this.itemProtocol.getError(); |
||||
|
open_time = this.itemProtocol.getOpen_time(); |
||||
|
standby_time = this.itemProtocol.getStandby_time(); |
||||
|
production_time = this.itemProtocol.getProduction_time(); |
||||
|
error_time = this.itemProtocol.getError_time(); |
||||
|
close_time = this.itemProtocol.getClose_time(); |
||||
|
material = this.itemProtocol.getMaterial(); |
||||
|
waitBroken_weight = this.itemProtocol.getWaitBroken_weight(); |
||||
|
alreadyBroken_weight = this.itemProtocol.getAlreadyBroken_weight(); |
||||
|
|
||||
|
if (mode != last_mode) { |
||||
|
this.setRequireSucess(false); |
||||
|
logServer.deviceLog(this.device_code,"mode" ,String.valueOf(mode)); |
||||
|
logServer.deviceLogToacs(this.device_code,"","","信号mode:" + last_mode + "->" + mode); |
||||
|
} |
||||
|
if (status != last_status) { |
||||
|
logServer.deviceLog(this.device_code,"status" ,String.valueOf(status)); |
||||
|
logServer.deviceLogToacs(this.device_code,"","","信号status:" + last_status + "->" + status); |
||||
|
} |
||||
|
if (error != last_error) { |
||||
|
logServer.deviceLog(this.device_code,"error" ,String.valueOf(error)); |
||||
|
logServer.deviceLogToacs(this.device_code,"","","信号error:" + last_error + "->" + error); |
||||
|
} |
||||
|
if (open_time != last_open_time) { |
||||
|
logServer.deviceLog(this.device_code,"open_time" ,String.valueOf(open_time)); |
||||
|
logServer.deviceLogToacs(this.device_code,"","","信号open_time:" + last_open_time + "->" + open_time); |
||||
|
} |
||||
|
if (standby_time != last_standby_time) { |
||||
|
logServer.deviceLog(this.device_code,"standby_time" ,String.valueOf(standby_time)); |
||||
|
logServer.deviceLogToacs(this.device_code,"","","信号standby_time:" + last_standby_time + "->" + standby_time); |
||||
|
} |
||||
|
if (production_time != last_production_time) { |
||||
|
logServer.deviceLog(this.device_code,"production_time" ,String.valueOf(production_time)); |
||||
|
logServer.deviceLogToacs(this.device_code,"","","信号production_time:" + last_production_time + "->" + production_time); |
||||
|
} |
||||
|
if (error_time != last_error_time) { |
||||
|
logServer.deviceLog(this.device_code,"error_time" ,String.valueOf(error_time)); |
||||
|
logServer.deviceLogToacs(this.device_code,"","","信号error_time:" + last_error_time + "->" + error_time); |
||||
|
} |
||||
|
if (close_time != last_close_time) { |
||||
|
logServer.deviceLog(this.device_code,"close_time" ,String.valueOf(close_time)); |
||||
|
logServer.deviceLogToacs(this.device_code,"","","信号close_time:" + last_close_time + "->" + close_time); |
||||
|
} |
||||
|
if (!StrUtil.equals(material,last_material)) { |
||||
|
logServer.deviceLog(this.device_code,"barcode", material); |
||||
|
logServer.deviceLogToacs(this.device_code,"","","信号material:" + last_material + "->" + material); |
||||
|
} |
||||
|
if (waitBroken_weight != last_waitBroken_weight) { |
||||
|
logServer.deviceLog(this.device_code,"waitBroken_weight" ,String.valueOf(waitBroken_weight)); |
||||
|
logServer.deviceLogToacs(this.device_code,"","","信号waitBroken_weight:" + last_waitBroken_weight + "->" + waitBroken_weight); |
||||
|
} |
||||
|
if (alreadyBroken_weight != last_alreadyBroken_weight) { |
||||
|
logServer.deviceLog(this.device_code,"alreadyBroken_weight" ,String.valueOf(alreadyBroken_weight)); |
||||
|
logServer.deviceLogToacs(this.device_code,"","","信号alreadyBroken_weight:" + last_alreadyBroken_weight + "->" + alreadyBroken_weight); |
||||
|
} |
||||
|
|
||||
|
} catch (Exception var17) { |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
//急停
|
||||
|
if (this.isStop()) { |
||||
|
|
||||
|
//未在线无心跳
|
||||
|
} else if (!this.itemProtocol.getIsonline()) { |
||||
|
this.setIsonline(false); |
||||
|
this.setIserror(true); |
||||
|
message = "信号量同步异常"; |
||||
|
//未联机
|
||||
|
} else 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 3: |
||||
|
|
||||
|
break; |
||||
|
case 4: |
||||
|
break; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
last_mode = mode; |
||||
|
last_status = status; |
||||
|
last_error = error; |
||||
|
last_open_time = open_time; |
||||
|
last_standby_time = standby_time; |
||||
|
last_production_time = production_time; |
||||
|
last_error_time = error_time; |
||||
|
last_close_time = close_time; |
||||
|
last_material = material; |
||||
|
last_waitBroken_weight = waitBroken_weight; |
||||
|
last_alreadyBroken_weight = alreadyBroken_weight; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
protected void thingToNothing() throws Exception { |
||||
|
this.setRequireSucess(false); |
||||
|
} |
||||
|
|
||||
|
public boolean exe_error() { |
||||
|
if (this.error == 0) { |
||||
|
return true; |
||||
|
} else { |
||||
|
log.debug("设备报警"); |
||||
|
return false; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public boolean exe_business() { |
||||
|
return true; |
||||
|
} |
||||
|
|
||||
|
public void executing(Server server, Map<String, Object> itemMap) { |
||||
|
ReadUtil.write(itemMap, server); |
||||
|
} |
||||
|
|
||||
|
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<String, Object>(); |
||||
|
|
||||
|
itemMap.put(to_param, value); |
||||
|
ReadUtil.write(itemMap, server); |
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,474 @@ |
|||||
|
<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="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: 'LnshCrusher', |
||||
|
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('status') !== -1) { |
||||
|
this.data1[val].db = beforeStr + '.' + afterStr.substring(0, 1) + (parseInt(endNumber) + 1) |
||||
|
} |
||||
|
if (this.data1[val].code.indexOf('error') !== -1) { |
||||
|
this.data1[val].db = beforeStr + '.' + afterStr.substring(0, 1) + (parseInt(endNumber) + 2) |
||||
|
} |
||||
|
if (this.data1[val].code.indexOf('open_time') !== -1) { |
||||
|
this.data1[val].db = beforeStr + '.' + 'D' + (parseInt(endNumber) + 3) |
||||
|
} |
||||
|
if (this.data1[val].code.indexOf('standby_time') !== -1) { |
||||
|
this.data1[val].db = beforeStr + '.' + 'D' + (parseInt(endNumber) + 7) |
||||
|
} |
||||
|
if (this.data1[val].code.indexOf('production_time') !== -1) { |
||||
|
this.data1[val].db = beforeStr + '.' + 'D' + (parseInt(endNumber) + 11) |
||||
|
} |
||||
|
if (this.data1[val].code.indexOf('error_time') !== -1) { |
||||
|
this.data1[val].db = beforeStr + '.' + 'D' + (parseInt(endNumber) + 15) |
||||
|
} |
||||
|
if (this.data1[val].code.indexOf('close_time') !== -1) { |
||||
|
this.data1[val].db = beforeStr + '.' + 'D' + (parseInt(endNumber) + 19) |
||||
|
} |
||||
|
if (this.data1[val].code.indexOf('material') !== -1) { |
||||
|
this.data1[val].db = beforeStr + '.' + 'S' + (parseInt(endNumber) + 23) |
||||
|
} |
||||
|
if (this.data1[val].code.indexOf('waitBroken_weight') !== -1) { |
||||
|
this.data1[val].db = beforeStr + '.' + 'D' + (parseInt(endNumber) + 279) |
||||
|
} |
||||
|
if (this.data1[val].code.indexOf('alreadyBroken_weight') !== -1) { |
||||
|
this.data1[val].db = beforeStr + '.' + 'D' + (parseInt(endNumber) + 283) |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
}, |
||||
|
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_error') !== -1) { |
||||
|
this.data2[val].db = beforeStr + '.' + afterStr.substring(0, 1) + (parseInt(endNumber) + 2) |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
}, |
||||
|
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> |
Loading…
Reference in new issue