add:告警灯
This commit is contained in:
@@ -8,6 +8,7 @@ import org.nl.acs.agv.server.NDCAgvService;
|
|||||||
import org.nl.acs.device.domain.Device;
|
import org.nl.acs.device.domain.Device;
|
||||||
import org.nl.acs.device.service.DeviceService;
|
import org.nl.acs.device.service.DeviceService;
|
||||||
import org.nl.acs.device_driver.basedriver.agv.ndcone.AgvNdcOneDeviceDriver;
|
import org.nl.acs.device_driver.basedriver.agv.ndcone.AgvNdcOneDeviceDriver;
|
||||||
|
import org.nl.acs.device_driver.basedriver.guard_lamp.GuardLampDeviceDriver;
|
||||||
import org.nl.acs.device_driver.basedriver.standard_autodoor.StandardAutodoorDeviceDriver;
|
import org.nl.acs.device_driver.basedriver.standard_autodoor.StandardAutodoorDeviceDriver;
|
||||||
import org.nl.acs.ext.wms.service.AcsToWmsService;
|
import org.nl.acs.ext.wms.service.AcsToWmsService;
|
||||||
import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl;
|
import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl;
|
||||||
@@ -248,41 +249,45 @@ public class OneNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (phase == 0x50) {
|
} else if (phase == 0x50) {
|
||||||
if (ObjectUtil.isEmpty(device_code)) {
|
log.info("进入告警区域");
|
||||||
log.info(agvaddr + "对应设备号为空!");
|
if (agvaddr == 0) {
|
||||||
|
log.info("BJD" + agvaddr + "对应设备号为空!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (ObjectUtil.isNotEmpty(device)) {
|
Device bjdDevice = deviceAppService.findDeviceByCode("BJD" + agvaddr);
|
||||||
if (device.getDeviceDriver() instanceof StandardAutodoorDeviceDriver) {
|
if (ObjectUtil.isNotEmpty(bjdDevice)) {
|
||||||
standardAutodoorDeviceDriver = (StandardAutodoorDeviceDriver) device.getDeviceDriver();
|
if (bjdDevice.getDeviceDriver() instanceof GuardLampDeviceDriver) {
|
||||||
String is_enter = standardAutodoorDeviceDriver.getExtraValue().get("is_enter").toString();
|
try {
|
||||||
if (StrUtil.isNotBlank(is_enter) && "false".equals(is_enter)) {
|
GuardLampDeviceDriver guardLampDeviceDriver = (GuardLampDeviceDriver) bjdDevice.getDeviceDriver();
|
||||||
|
guardLampDeviceDriver.writing("to_open", "1");
|
||||||
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0, 0, 0, 0, 0);
|
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0, 0, 0, 0, 0);
|
||||||
} else {
|
} catch (Exception e) {
|
||||||
log.info("区域已锁定,请释放后在进入");
|
log.info("下发告警灯告警信号失败");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
log.info(agvaddr + "对应设备号为空!");
|
log.info("BJD" + agvaddr + "对应设备号为空!");
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (phase == 0x51) {
|
} else if (phase == 0x51) {
|
||||||
if (ObjectUtil.isEmpty(device_code)) {
|
log.info("离开告警区域");
|
||||||
log.info(agvaddr + "对应设备号为空!");
|
if (agvaddr == 0) {
|
||||||
|
log.info("BJD" + agvaddr + "对应设备号为空!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (ObjectUtil.isNotEmpty(device)) {
|
Device bjdDevice = deviceAppService.findDeviceByCode("BJD" + agvaddr);
|
||||||
if (device.getDeviceDriver() instanceof StandardAutodoorDeviceDriver) {
|
if (ObjectUtil.isNotEmpty(bjdDevice)) {
|
||||||
standardAutodoorDeviceDriver = (StandardAutodoorDeviceDriver) device.getDeviceDriver();
|
if (bjdDevice.getDeviceDriver() instanceof GuardLampDeviceDriver) {
|
||||||
String is_enter = standardAutodoorDeviceDriver.getExtraValue().get("is_enter").toString();
|
try {
|
||||||
if (StrUtil.isNotBlank(is_enter) && "false".equals(is_enter)) {
|
GuardLampDeviceDriver guardLampDeviceDriver = (GuardLampDeviceDriver) bjdDevice.getDeviceDriver();
|
||||||
|
guardLampDeviceDriver.writing("to_open", "0");
|
||||||
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0, 0, 0, 0, 0);
|
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0, 0, 0, 0, 0);
|
||||||
} else {
|
} catch (Exception e) {
|
||||||
log.info("区域已锁定,请释放后在进入");
|
log.info("下发告警灯取消告警信号失败");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
log.info(device_code + "对应设备号为空!");
|
log.info("BJD" + agvaddr + "对应设备号为空!");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
//上报异常信息
|
//上报异常信息
|
||||||
|
|||||||
@@ -38,7 +38,10 @@ public enum DriverTypeEnum {
|
|||||||
GUHUASHI_SITE(12, "guhuashi_site", "固化室", "conveyor"),
|
GUHUASHI_SITE(12, "guhuashi_site", "固化室", "conveyor"),
|
||||||
TIANNENG_SITE(13, "tianneng_site", "天能-检测站点", "conveyor"),
|
TIANNENG_SITE(13, "tianneng_site", "天能-检测站点", "conveyor"),
|
||||||
|
|
||||||
BAOSHIJIAN_SITE(14,"baoshijian_site","保湿间","conveyor");
|
|
||||||
|
BAOSHIJIAN_SITE(14,"baoshijian_site","保湿间","conveyor"),
|
||||||
|
|
||||||
|
GUARD_LAMP(15, "guard_lamp", "告警灯", "guard_lamp");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import org.nl.acs.auto.run.OneNDCSocketConnectionAutoRun;
|
|||||||
import org.nl.acs.device.domain.Device;
|
import org.nl.acs.device.domain.Device;
|
||||||
import org.nl.acs.device.service.DeviceService;
|
import org.nl.acs.device.service.DeviceService;
|
||||||
import org.nl.acs.device_driver.DeviceDriver;
|
import org.nl.acs.device_driver.DeviceDriver;
|
||||||
|
import org.nl.acs.device_driver.basedriver.guard_lamp.GuardLampDeviceDriver;
|
||||||
import org.nl.acs.device_driver.basedriver.plc_to_agv.PlcToAgvDeviceDriver;
|
import org.nl.acs.device_driver.basedriver.plc_to_agv.PlcToAgvDeviceDriver;
|
||||||
import org.nl.acs.device_driver.basedriver.siemens_conveyor.SiemensConveyorDeviceDriver;
|
import org.nl.acs.device_driver.basedriver.siemens_conveyor.SiemensConveyorDeviceDriver;
|
||||||
import org.nl.acs.device_driver.basedriver.standard_inspect_site.StandardInspectSiteDeviceDriver;
|
import org.nl.acs.device_driver.basedriver.standard_inspect_site.StandardInspectSiteDeviceDriver;
|
||||||
@@ -528,9 +529,29 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
|
|||||||
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0, 0, 0, 0, 0);
|
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0, 0, 0, 0, 0);
|
||||||
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data);
|
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data);
|
||||||
} else if (phase == 0x50) {//进入交通灯区域
|
} else if (phase == 0x50) {//进入交通灯区域
|
||||||
|
log.info("进入告警区域");
|
||||||
|
try {
|
||||||
|
Device guardLamp = deviceAppService.findDeviceByCode("BJD" + agvaddr);
|
||||||
|
if (guardLamp != null) {
|
||||||
|
GuardLampDeviceDriver guardLampDeviceDriver = (GuardLampDeviceDriver) device.getDeviceDriver();
|
||||||
|
guardLampDeviceDriver.writing("to_open", "1");
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.info("下发告警灯告警信号失败");
|
||||||
|
}
|
||||||
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0, 0, 0, 0, 0);
|
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0, 0, 0, 0, 0);
|
||||||
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data);
|
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data);
|
||||||
} else if (phase == 0x51) {//离开交通灯区域
|
} else if (phase == 0x51) {//离开交通灯区域
|
||||||
|
log.info("离开告警区域");
|
||||||
|
try {
|
||||||
|
Device guardLamp = deviceAppService.findDeviceByCode("BJD" + agvaddr);
|
||||||
|
if (guardLamp != null) {
|
||||||
|
GuardLampDeviceDriver guardLampDeviceDriver = (GuardLampDeviceDriver) device.getDeviceDriver();
|
||||||
|
guardLampDeviceDriver.writing("to_open", "0");
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.info("下发告警灯取消告警信号失败");
|
||||||
|
}
|
||||||
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0, 0, 0, 0, 0);
|
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0, 0, 0, 0, 0);
|
||||||
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data);
|
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data);
|
||||||
} else if (phase == 0x70) {
|
} else if (phase == 0x70) {
|
||||||
|
|||||||
@@ -0,0 +1,63 @@
|
|||||||
|
package org.nl.acs.device_driver.basedriver.guard_lamp;
|
||||||
|
|
||||||
|
import org.nl.acs.device.device_driver.standard_inspect.ItemDto;
|
||||||
|
import org.nl.acs.device.domain.Device;
|
||||||
|
import org.nl.acs.device.enums.DeviceType;
|
||||||
|
import org.nl.acs.device_driver.DeviceDriver;
|
||||||
|
import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 告警灯驱动定义
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class GuardLampDefination implements OpcDeviceDriverDefination {
|
||||||
|
@Override
|
||||||
|
public String getDriverCode() {
|
||||||
|
return "guard_lamp";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDriverName() {
|
||||||
|
return "标准版-告警灯";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDriverDescription() {
|
||||||
|
return "标准版-告警灯";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DeviceDriver getDriverInstance(Device device) {
|
||||||
|
return (new GuardLampDeviceDriver()).setDevice(device).setDriverDefination(this);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<? extends DeviceDriver> getDeviceDriverType() {
|
||||||
|
return GuardLampDeviceDriver.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();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,97 @@
|
|||||||
|
package org.nl.acs.device_driver.basedriver.guard_lamp;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.nl.acs.device.domain.Device;
|
||||||
|
import org.nl.acs.device_driver.DeviceDriver;
|
||||||
|
import org.nl.acs.device_driver.basedriver.guard_lamp.ItemProtocol;
|
||||||
|
import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver;
|
||||||
|
import org.nl.acs.device_driver.driver.ExecutableDeviceDriver;
|
||||||
|
import org.nl.acs.log.service.DeviceExecuteLogService;
|
||||||
|
import org.nl.acs.monitor.DeviceStageMonitor;
|
||||||
|
import org.nl.config.SpringContextHolder;
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 告警灯驱动
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Data
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class GuardLampDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, DeviceStageMonitor {
|
||||||
|
protected org.nl.acs.device_driver.basedriver.guard_lamp.ItemProtocol itemProtocol = new ItemProtocol(this);
|
||||||
|
DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl");
|
||||||
|
|
||||||
|
int open = 0;
|
||||||
|
int last_open = 0;
|
||||||
|
|
||||||
|
int toOpen = 0;
|
||||||
|
int last_toOpen = 0;
|
||||||
|
|
||||||
|
String device_code = null;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Device getDevice() {
|
||||||
|
return this.device;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute() {
|
||||||
|
String message = null;
|
||||||
|
|
||||||
|
device_code = this.getDevice().getDevice_code();
|
||||||
|
open = this.itemProtocol.getOpen();
|
||||||
|
toOpen = this.itemProtocol.getToOpen();
|
||||||
|
if (open != last_open) {
|
||||||
|
logServer.deviceExecuteLog(this.device_code, "", "", "信号open:" + last_open + "->" + open);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (toOpen != last_toOpen) {
|
||||||
|
logServer.deviceExecuteLog(this.device_code, "", "", "信号toOpen:" + last_toOpen + "->" + toOpen);
|
||||||
|
}
|
||||||
|
last_open = open;
|
||||||
|
last_toOpen = toOpen;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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;
|
||||||
|
Map<String, Object> itemMap = new HashMap<String, Object>();
|
||||||
|
itemMap.put(to_param, Integer.parseInt(value));
|
||||||
|
|
||||||
|
this.control(itemMap);
|
||||||
|
logServer.deviceExecuteLog(device_code, "", "", "下发电气信号设备号:" + device_code + ",下发电气:" + to_param + ",下发电气值:" + value);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public JSONObject getDeviceStatusName() {
|
||||||
|
JSONObject jo = new JSONObject();
|
||||||
|
String open = "";
|
||||||
|
if (this.getOpen() == 0) {
|
||||||
|
open = "未警戒";
|
||||||
|
} else if (this.getOpen() == 1) {
|
||||||
|
open = "警戒";
|
||||||
|
}
|
||||||
|
jo.put("device_name", this.getDevice().getDevice_name());
|
||||||
|
jo.put("open", open);
|
||||||
|
jo.put("isOnline", true);
|
||||||
|
|
||||||
|
return jo;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setDeviceStatus(JSONObject data) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,72 @@
|
|||||||
|
package org.nl.acs.device_driver.basedriver.guard_lamp;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.nl.acs.device.device_driver.standard_inspect.ItemDto;
|
||||||
|
import org.nl.acs.device_driver.basedriver.standard_autodoor.StandardAutodoorDeviceDriver;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
public class ItemProtocol {
|
||||||
|
public static String item_open = "open";
|
||||||
|
public static String item_to_open = "to_open";
|
||||||
|
|
||||||
|
|
||||||
|
private GuardLampDeviceDriver driver;
|
||||||
|
|
||||||
|
public ItemProtocol(GuardLampDeviceDriver driver) {
|
||||||
|
this.driver = driver;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getOpen() {
|
||||||
|
return this.getOpcIntegerValue(item_open);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public int getToOpen() {
|
||||||
|
return this.getOpcIntegerValue(item_to_open);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public int getOpcIntegerValue(String protocol) {
|
||||||
|
Integer value = this.driver.getIntegeregerValue(protocol);
|
||||||
|
if (value == null) {
|
||||||
|
// log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!");
|
||||||
|
} else {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getOpcStringValue(String protocol) {
|
||||||
|
String value = this.driver.getStringValue(protocol);
|
||||||
|
if (StrUtil.isEmpty(value)) {
|
||||||
|
|
||||||
|
} else {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
return "0";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<ItemDto> getReadableItemDtos() {
|
||||||
|
ArrayList list = new ArrayList();
|
||||||
|
list.add(new ItemDto(item_open, "是否告警", "10001"));
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<ItemDto> getWriteableItemDtos() {
|
||||||
|
ArrayList list = new ArrayList();
|
||||||
|
list.add(new ItemDto(item_to_open, "下发告警", "00001"));
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -77,6 +77,7 @@ import standard_autodoor from '@/views/acs/device/driver/standard_autodoor'
|
|||||||
import standard_inspect_site from './driver/standard_inspect_site'
|
import standard_inspect_site from './driver/standard_inspect_site'
|
||||||
import plc_to_agv from './driver/plc_to_agv'
|
import plc_to_agv from './driver/plc_to_agv'
|
||||||
import sorting from './driver/sorting'
|
import sorting from './driver/sorting'
|
||||||
|
import guard_lamp from './driver/guard_lamp'
|
||||||
import standard_ordinary_site from './driver/standard_ordinary_site'
|
import standard_ordinary_site from './driver/standard_ordinary_site'
|
||||||
import standard_storage from '@/views/acs/device/driver/standard_storage'
|
import standard_storage from '@/views/acs/device/driver/standard_storage'
|
||||||
import standard_scanner from '@/views/acs/device/driver/standard_scanner'
|
import standard_scanner from '@/views/acs/device/driver/standard_scanner'
|
||||||
@@ -117,7 +118,8 @@ export default {
|
|||||||
agv_ndc_two,
|
agv_ndc_two,
|
||||||
agv_ndc_one,
|
agv_ndc_one,
|
||||||
xg_agv,
|
xg_agv,
|
||||||
sorting
|
sorting,
|
||||||
|
guard_lamp
|
||||||
},
|
},
|
||||||
dicts: ['device_type'],
|
dicts: ['device_type'],
|
||||||
mixins: [crud],
|
mixins: [crud],
|
||||||
|
|||||||
352
acs/nladmin-ui/src/views/acs/device/driver/guard_lamp.vue
Normal file
352
acs/nladmin-ui/src/views/acs/device/driver/guard_lamp.vue
Normal file
@@ -0,0 +1,352 @@
|
|||||||
|
<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
|
||||||
|
@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-switch 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">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'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'GuardLamp',
|
||||||
|
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,
|
||||||
|
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
|
||||||
|
})
|
||||||
|
})
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
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()
|
||||||
|
})
|
||||||
|
},
|
||||||
|
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('action') !== -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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
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>
|
||||||
Reference in New Issue
Block a user