add:一期扫码器
This commit is contained in:
@@ -67,7 +67,9 @@ public enum DriverTypeEnum {
|
||||
|
||||
PLUGGING_UNPLUGGING_MACHINE(25,"plugging_unplugging_machine","插拔轴机","station"),
|
||||
|
||||
RGV(28,"rgv","rgv","conveyor");
|
||||
RGV(28,"rgv","rgv","conveyor"),
|
||||
|
||||
MODBUS_SCANNER(28,"modbus_scanner","modbus扫码器","scanner");
|
||||
|
||||
|
||||
//驱动索引
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
package org.nl.acs.device_driver.basedriver.modbus_scanner;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
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_trigger_ready = "trigger_ready";
|
||||
//触发完成
|
||||
public static String item_trigger_finish = "trigger_finish";
|
||||
//条码
|
||||
public static String item_barcode = "barcode";
|
||||
//下发触发使能
|
||||
public static String item_to_trigger_enable = "to_trigger_enable";
|
||||
//下发触发
|
||||
public static String item_to_trigger = "to_trigger";
|
||||
|
||||
private ModbusScannerDeviceDriver driver;
|
||||
|
||||
public ItemProtocol(ModbusScannerDeviceDriver driver) {
|
||||
this.driver = driver;
|
||||
}
|
||||
|
||||
public int getTrigger_Ready() {
|
||||
return this.getOpcIntegerValue(item_trigger_ready);
|
||||
}
|
||||
|
||||
public int getTrigger_Finish() {
|
||||
return this.getOpcIntegerValue(item_trigger_finish);
|
||||
}
|
||||
|
||||
public String getBarcode() {
|
||||
return this.getOpcStringValue(item_barcode);
|
||||
}
|
||||
|
||||
public int getTo_trigger_Enable() {
|
||||
return this.getOpcIntegerValue(item_to_trigger_enable);
|
||||
}
|
||||
|
||||
public int getTo_trigger() {
|
||||
return this.getOpcIntegerValue(item_to_trigger);
|
||||
}
|
||||
|
||||
|
||||
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 String getOpcStringValue(String protocol) {
|
||||
String value = this.driver.getStringValue(protocol);
|
||||
if (!StrUtil.isBlank(value)) {
|
||||
return value;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static List<ItemDto> getReadableItemDtos() {
|
||||
ArrayList<ItemDto> list = new ArrayList<>();
|
||||
list.add(new ItemDto(item_trigger_ready, "触发就绪", "10001"));
|
||||
list.add(new ItemDto(item_trigger_finish, "触发完成", "10002"));
|
||||
list.add(new ItemDto(item_barcode, "条码", "32006.30L"));
|
||||
return list;
|
||||
}
|
||||
|
||||
public static List<ItemDto> getWriteableItemDtos() {
|
||||
ArrayList<ItemDto> list = new ArrayList<>();
|
||||
list.add(new ItemDto(item_to_trigger_enable, "下发触发使能", "00001"));
|
||||
list.add(new ItemDto(item_to_trigger, "下发触发", "00002"));
|
||||
return list;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package org.nl.acs.device_driver.basedriver.modbus_scanner;
|
||||
|
||||
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 ModbusScannerDefination implements OpcDeviceDriverDefination {
|
||||
@Override
|
||||
public String getDriverCode() {
|
||||
return "modbus_scanner";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDriverName() {
|
||||
return "modbus扫码器";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDriverDescription() {
|
||||
return "modbus扫码器";
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeviceDriver getDriverInstance(Device device) {
|
||||
return (new ModbusScannerDeviceDriver()).setDevice(device).setDriverDefination(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends DeviceDriver> getDeviceDriverType() {
|
||||
return ModbusScannerDeviceDriver.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DeviceType> getFitDeviceTypes() {
|
||||
List<DeviceType> types = new LinkedList();
|
||||
types.add(DeviceType.scanner);
|
||||
return types;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemDto> getReadableItemDtos() {
|
||||
return ItemProtocol.getReadableItemDtos();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemDto> getWriteableItemDtos() {
|
||||
return ItemProtocol.getWriteableItemDtos();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
package org.nl.acs.device_driver.basedriver.modbus_scanner;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.Data;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.acs.device_driver.DeviceDriver;
|
||||
import org.nl.acs.device_driver.FeedLmsRealFailed;
|
||||
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.log.service.DeviceExecuteLogService;
|
||||
import org.nl.acs.monitor.DeviceStageMonitor;
|
||||
import org.nl.acs.opc.Device;
|
||||
import org.nl.modules.wql.util.SpringContextHolder;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 扫码器
|
||||
*/
|
||||
@Slf4j
|
||||
@Data
|
||||
@RequiredArgsConstructor
|
||||
public class ModbusScannerDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor {
|
||||
|
||||
protected ItemProtocol itemProtocol = new ItemProtocol(this);
|
||||
private final DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl");
|
||||
|
||||
//触发就绪
|
||||
private int trigger_ready = 0;
|
||||
private int last_trigger_ready = 0;
|
||||
//触发完成
|
||||
private int trigger_finish = 0;
|
||||
private int last_trigger_finish = 0;
|
||||
//条码
|
||||
private String barcode = null;
|
||||
private String last_barcode = null;
|
||||
//下发触发使能
|
||||
private int to_trigger_enable = 0;
|
||||
private int last_to_trigger_enable = 0;
|
||||
//下发触发
|
||||
private int to_trigger = 0;
|
||||
private int last_to_trigger = 0;
|
||||
|
||||
String device_code;
|
||||
|
||||
@Override
|
||||
public Device getDevice() {
|
||||
return this.device;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
|
||||
this.device_code = this.getDevice().getDevice_code();
|
||||
this.trigger_ready = this.itemProtocol.getTrigger_Ready();
|
||||
this.trigger_finish = this.itemProtocol.getTrigger_Finish();
|
||||
this.barcode = this.itemProtocol.getBarcode();
|
||||
this.to_trigger_enable = this.itemProtocol.getTo_trigger_Enable();
|
||||
this.to_trigger = this.itemProtocol.getTo_trigger();
|
||||
|
||||
if (this.trigger_ready != this.last_trigger_ready) {
|
||||
if (this.trigger_ready == 0) {
|
||||
this.writing("to_trigger_enable", "1");
|
||||
}
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号trigger_ready:" + last_trigger_ready + "->" + trigger_ready);
|
||||
}
|
||||
if (this.trigger_finish != this.last_trigger_finish) {
|
||||
if (this.trigger_finish == 1) {
|
||||
this.writing("to_trigger", "0");
|
||||
}
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号trigger_finish:" + last_trigger_finish + "->" + trigger_finish);
|
||||
}
|
||||
if (!StrUtil.equals(this.barcode, this.last_barcode)) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号barcode:" + last_barcode + "->" + barcode);
|
||||
}
|
||||
if (this.to_trigger_enable != this.last_to_trigger_enable) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号to_trigger_enable:" + last_to_trigger_enable + "->" + to_trigger_enable);
|
||||
}
|
||||
if (this.to_trigger != this.last_to_trigger) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号to_trigger:" + last_to_trigger + "->" + to_trigger);
|
||||
}
|
||||
this.last_trigger_ready = this.trigger_ready;
|
||||
this.last_trigger_finish = this.trigger_finish;
|
||||
this.last_barcode = this.barcode;
|
||||
this.last_to_trigger_enable = this.to_trigger_enable;
|
||||
this.last_to_trigger = this.to_trigger;
|
||||
}
|
||||
|
||||
|
||||
public void writing(Map<String, Object> map) {
|
||||
DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl");
|
||||
Map<String, Object> itemMap = new LinkedHashMap<>();
|
||||
map.forEach((key, value) -> {
|
||||
if (ObjectUtil.isNotEmpty(value)) {
|
||||
itemMap.put(getToParam() + key, value);
|
||||
}
|
||||
});
|
||||
if (ObjectUtil.isNotEmpty(itemMap)) {
|
||||
this.control(itemMap);
|
||||
logServer.deviceExecuteLog(this.getDevice().getDevice_code(), "", "", "下发多个电气信号:" + itemMap);
|
||||
}
|
||||
}
|
||||
|
||||
public String getToParam() {
|
||||
return this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + ".";
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject getDeviceStatusName() {
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
JSONObject jo = new JSONObject(map);
|
||||
return jo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDeviceStatus(JSONObject data) {
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -167,4 +167,10 @@ public class WmsToAcsController {
|
||||
JSONObject jsonObject = jsonArray.getJSONObject(0);
|
||||
return new ResponseEntity<>(wmstoacsService.finishTask(jsonObject),HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/getBarcode")
|
||||
@SaIgnore
|
||||
public ResponseEntity<Object> getBarcode(@RequestBody JSONObject param){
|
||||
return new ResponseEntity<>(wmstoacsService.getBarcode(param), HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,4 +125,6 @@ public interface WmsToAcsService {
|
||||
* @return
|
||||
*/
|
||||
Map<String, Object> finishTask(JSONObject jsonObject) throws Exception;
|
||||
|
||||
Map<String,Object> getBarcode(JSONObject param);
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ import org.nl.acs.device_driver.basedriver.hongxiang_conveyor.HongXiangStationDe
|
||||
import org.nl.acs.device_driver.basedriver.hongxiang_device.HongXiangConveyorDeviceDriver;
|
||||
import org.nl.acs.device_driver.basedriver.indoor_manipulator.IndoorManipulatorDeviceDriver;
|
||||
import org.nl.acs.device_driver.basedriver.lamp_three_color.LampThreecolorDeviceDriver;
|
||||
import org.nl.acs.device_driver.basedriver.modbus_scanner.ModbusScannerDeviceDriver;
|
||||
import org.nl.acs.device_driver.basedriver.oven_manipulator.OvenGantryManipulatorDeviceDriver;
|
||||
import org.nl.acs.device_driver.basedriver.paper_tube_device.PaperTubeConveyorDeviceDriver;
|
||||
import org.nl.acs.device_driver.basedriver.paper_tube_device2.Paper;
|
||||
@@ -70,6 +71,7 @@ import org.nl.modules.system.service.DictDetailService;
|
||||
import org.nl.modules.system.service.DictService;
|
||||
import org.nl.modules.system.service.ParamService;
|
||||
import org.nl.modules.system.service.dto.DictDetailDto;
|
||||
import org.nl.modules.system.service.dto.ParamDto;
|
||||
import org.nl.modules.wql.core.bean.WQLObject;
|
||||
import org.nl.modules.wql.exception.WDKException;
|
||||
import org.nl.modules.wql.util.SpringContextHolder;
|
||||
@@ -100,6 +102,7 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
|
||||
private final AcsToLiKuService acsToLiKuService;
|
||||
private final DictDetailService dictDetailService;
|
||||
private final DictService dictService;
|
||||
private final ParamService paramService;
|
||||
|
||||
|
||||
private String log_file_type = "log_file_type";
|
||||
@@ -1539,4 +1542,41 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
|
||||
return resp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getBarcode(JSONObject param) {
|
||||
log.info("getBarcode--------------:输入参数" + param.toString());
|
||||
Map<String, Object> resp = new HashMap<>();
|
||||
String device_code = param.getString("device_code");
|
||||
ParamDto paramDto = paramService.findByCode(device_code);
|
||||
if (paramDto == null) {
|
||||
throw new BadRequestException("系统参数未配置IN点对应点扫码器!");
|
||||
}
|
||||
String smDeviceCode = paramDto.getValue();
|
||||
if (StrUtil.isEmpty(smDeviceCode)) {
|
||||
throw new BadRequestException("系统参数配置IN点扫码器为空!");
|
||||
}
|
||||
Device device = deviceAppService.findDeviceByCode(smDeviceCode);
|
||||
if (device != null && device.getDeviceDriver() instanceof ModbusScannerDeviceDriver) {
|
||||
ModbusScannerDeviceDriver modbusScannerDeviceDriver = (ModbusScannerDeviceDriver) device.getDeviceDriver();
|
||||
modbusScannerDeviceDriver.writing("to_trigger", "1");
|
||||
try {
|
||||
Thread.sleep(1500);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
device = deviceAppService.findDeviceByCode(smDeviceCode);
|
||||
modbusScannerDeviceDriver = (ModbusScannerDeviceDriver) device.getDeviceDriver();
|
||||
resp.put("status",200);
|
||||
resp.put("message", "成功");
|
||||
resp.put("vehicle_code", modbusScannerDeviceDriver.getBarcode() == null ? "" : modbusScannerDeviceDriver.getBarcode());
|
||||
log.info("getBarcode--------------:输出参数" + resp.toString());
|
||||
return resp;
|
||||
}
|
||||
resp.put("status",200);
|
||||
resp.put("message", "成功");
|
||||
resp.put("vehicle_code", "");
|
||||
log.info("getBarcode--------------:输出参数" + resp.toString());
|
||||
return resp;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -92,6 +92,7 @@ import siemens_conveyor from '@/views/acs/device/driver/siemens_conveyor'
|
||||
import siemens_weight_conveyor from '@/views/acs/device/driver/siemens_weight_conveyor'
|
||||
import slit_two_manipulator from '@/views/acs/device/driver/slit_two_manipulator'
|
||||
import hongxiang_device from '@/views/acs/device/driver/hongxiang_device'
|
||||
import modbus_scanner from '@/views/acs/device/driver/modbus_scanner'
|
||||
import hongxiang_conveyor from '@/views/acs/device/driver/hongxiang_conveyor'
|
||||
import plug_pull_device_site from '@/views/acs/device/driver/plug_pull_device_site'
|
||||
import siemens_conveyor_labeling from '@/views/acs/device/driver/siemens_conveyor_labeling'
|
||||
@@ -144,7 +145,8 @@ export default {
|
||||
device_status,
|
||||
indoor_manipulator,
|
||||
plugging_unplugging_machine,
|
||||
rgv
|
||||
rgv,
|
||||
modbus_scanner
|
||||
},
|
||||
dicts: ['device_type'],
|
||||
mixins: [crud],
|
||||
|
||||
506
acs/nladmin-ui/src/views/acs/device/driver/modbus_scanner.vue
Normal file
506
acs/nladmin-ui/src/views/acs/device/driver/modbus_scanner.vue
Normal file
@@ -0,0 +1,506 @@
|
||||
<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.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"
|
||||
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-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="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: 'StandardInspectSite',
|
||||
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: [],
|
||||
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: [],
|
||||
address: ''
|
||||
},
|
||||
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) {
|
||||
debugger
|
||||
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('error') !== -1) {
|
||||
this.data1[val].db = beforeStr + '.' + afterStr.substring(0, 1) + (parseInt(endNumber) + 5)
|
||||
}
|
||||
if (this.data1[val].code.indexOf('task') !== -1) {
|
||||
this.data1[val].db = beforeStr + '.' + 'D' + (parseInt(endNumber) + 7)
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
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_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)
|
||||
})
|
||||
},
|
||||
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