更新
This commit is contained in:
@@ -61,7 +61,10 @@ public enum DriverTypeEnum {
|
||||
|
||||
HAILIANG_PACKER_STATION(26, "hailiang_packer_station", "海亮-包装机工位", "conveyor"),
|
||||
|
||||
HAILIANG_XJ_PLC_TEST(27, "hailiang_xj_plc_test", "海亮-信捷PLC", "conveyor");
|
||||
HAILIANG_XJ_PLC_TEST(27, "hailiang_xj_plc_test", "海亮-信捷PLC", "conveyor"),
|
||||
|
||||
HAILIANG_SMART_PLC_TEST(28, "hailiang_smart_plc_test", "海亮-西门子SMART200PLC", "conveyor");
|
||||
|
||||
|
||||
|
||||
//驱动索引
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
package org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_smart_plc_test;
|
||||
|
||||
import org.nl.acs.device.device_driver.standard_inspect.ItemDto;
|
||||
import org.nl.acs.device_driver.DeviceDriver;
|
||||
import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination;
|
||||
import org.nl.acs.opc.Device;
|
||||
import org.nl.acs.opc.DeviceType;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 海亮迅捷plc测试
|
||||
*/
|
||||
@Service
|
||||
public class HailiangSmartplcTestDefination implements OpcDeviceDriverDefination {
|
||||
@Override
|
||||
public String getDriverCode() {
|
||||
return "hailiang_smart_plc_test";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDriverName() {
|
||||
return "海亮-西门子plc测试";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDriverDescription() {
|
||||
return "海亮-西门子plc测试";
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeviceDriver getDriverInstance(Device device) {
|
||||
return (new HailiangSmartplcTestDeviceDriver()).setDevice(device).setDriverDefination(this);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends DeviceDriver> getDeviceDriverType() {
|
||||
return HailiangSmartplcTestDeviceDriver.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,289 @@
|
||||
package org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_smart_plc_test;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.acs.agv.server.AgvService;
|
||||
import org.nl.acs.config.server.AcsConfigService;
|
||||
import org.nl.acs.device.device_driver.standard_inspect.ReadUtil;
|
||||
import org.nl.acs.device.service.DeviceService;
|
||||
import org.nl.acs.device_driver.DeviceDriver;
|
||||
import org.nl.acs.device_driver.RouteableDeviceDriver;
|
||||
import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver;
|
||||
import org.nl.acs.device_driver.driver.ExecutableDeviceDriver;
|
||||
import org.nl.acs.ext.wms.service.AcsToWmsService;
|
||||
import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl;
|
||||
import org.nl.acs.instruction.service.InstructionService;
|
||||
import org.nl.acs.instruction.service.dto.Instruction;
|
||||
import org.nl.acs.log.service.LogServer;
|
||||
import org.nl.acs.opc.Device;
|
||||
import org.nl.acs.opc.DeviceAppService;
|
||||
import org.nl.acs.order.service.ProduceshiftorderService;
|
||||
import org.nl.acs.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.Map;
|
||||
|
||||
/**
|
||||
* 海亮清洗机储料仓
|
||||
*/
|
||||
@Slf4j
|
||||
@Data
|
||||
@RequiredArgsConstructor
|
||||
public class HailiangSmartplcTestDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver {
|
||||
protected ItemProtocol itemProtocol = new ItemProtocol(this);
|
||||
@Autowired
|
||||
DeviceAppService deviceAppservice = SpringContextHolder.getBean(DeviceAppService.class);
|
||||
@Autowired
|
||||
InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class);
|
||||
@Autowired
|
||||
DeviceService deviceservice = SpringContextHolder.getBean(DeviceService.class);
|
||||
@Autowired
|
||||
TaskService taskserver = SpringContextHolder.getBean(TaskService.class);
|
||||
@Autowired
|
||||
RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class);
|
||||
@Autowired
|
||||
AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsServiceImpl.class);
|
||||
@Autowired
|
||||
AcsConfigService acsConfigService = SpringContextHolder.getBean(AcsConfigService.class);
|
||||
@Autowired
|
||||
LogServer logServer = SpringContextHolder.getBean(LogServer.class);
|
||||
@Autowired
|
||||
ProduceshiftorderService produceshiftorderService = SpringContextHolder.getBean(ProduceshiftorderService.class);
|
||||
@Autowired
|
||||
AgvService agvService = SpringContextHolder.getBean(AgvService.class);
|
||||
|
||||
String container;
|
||||
String container_type_desc;
|
||||
String last_container_type_desc;
|
||||
String last_container;
|
||||
//放货准备锁
|
||||
String putReadyLock = null;
|
||||
//有货标记
|
||||
protected boolean has_goods_tag = false;
|
||||
|
||||
int heartbeat = 0;
|
||||
int mode =0;
|
||||
int error =0;
|
||||
int error_num =0;
|
||||
int open_time =0;
|
||||
int close_time =0;
|
||||
int ready_time =0;
|
||||
int running_time =0;
|
||||
int error_time =0;
|
||||
int voltage =0;
|
||||
int temperature =0;
|
||||
int current =0;
|
||||
int material =0;
|
||||
int lack_material =0;
|
||||
int full_material =0;
|
||||
int storage_qty =0;
|
||||
int feeding_qty =0;
|
||||
int blanking_qty =0;
|
||||
int qualified_qty =0;
|
||||
int unqualified_qty =0;
|
||||
int finish =0;
|
||||
int task =0;
|
||||
int noload_electricity_consumption =0;
|
||||
int prod_electricity_consumption =0;
|
||||
int gas_consumption =0;
|
||||
int water_consumption =0;
|
||||
int oil_level =0;
|
||||
int monthly_electricity_consumption =0;
|
||||
int pause =0;
|
||||
|
||||
|
||||
int last_mode =0;
|
||||
int last_error =0;
|
||||
int last_error_num =0;
|
||||
int last_open_time =0;
|
||||
int last_close_time =0;
|
||||
int last_ready_time =0;
|
||||
int last_running_time =0;
|
||||
int last_error_time =0;
|
||||
int last_voltage =0;
|
||||
int last_temperature =0;
|
||||
int last_current =0;
|
||||
int last_material =0;
|
||||
int last_lack_material =0;
|
||||
int last_full_material =0;
|
||||
int last_storage_qty =0;
|
||||
int last_feeding_qty =0;
|
||||
int last_blanking_qty =0;
|
||||
int last_qualified_qty =0;
|
||||
int last_unqualified_qty =0;
|
||||
int last_finish =0;
|
||||
int last_task =0;
|
||||
int last_noload_electricity_consumption =0;
|
||||
int last_prod_electricity_consumption =0;
|
||||
int last_gas_consumption =0;
|
||||
int last_water_consumption =0;
|
||||
int last_oil_level =0;
|
||||
int last_monthly_electricity_consumption =0;
|
||||
int last_pause =0;
|
||||
|
||||
|
||||
Boolean isonline = true;
|
||||
int hasGoods = 0;
|
||||
String message = null;
|
||||
Boolean iserror = false;
|
||||
|
||||
|
||||
boolean hasVehicle = false;
|
||||
boolean isReady = false;
|
||||
protected int instruction_num = 0;
|
||||
protected int instruction_num_truth = 0;
|
||||
boolean isFold = false;
|
||||
private String assemble_check_tag;
|
||||
|
||||
private Date instruction_require_time = new Date();
|
||||
private Date instruction_finished_time = new Date();
|
||||
private Date instruction_apply_time = new Date();
|
||||
private int instruction_require_time_out = 3000;
|
||||
//请求成功标记
|
||||
Boolean requireSucess = false;
|
||||
//申请指令成功标记
|
||||
Boolean applySucess = false;
|
||||
String inst_message;
|
||||
|
||||
private int instruction_finished_time_out;
|
||||
|
||||
int branchProtocol = 0;
|
||||
//备注
|
||||
String remark;
|
||||
//数量
|
||||
String qty;
|
||||
|
||||
//当前指令
|
||||
Instruction inst = null;
|
||||
//上次指令
|
||||
Instruction last_inst = null;
|
||||
|
||||
|
||||
//暂定 0就绪 1请求取货 2取货完成 3请求放货 4放货完成 5取货完成离开 6放货完成离开 7请求进入区域 8请求离开区域
|
||||
int flag = 0;
|
||||
|
||||
|
||||
int agvphase=0;
|
||||
int index =0;
|
||||
|
||||
String device_code;
|
||||
|
||||
@Override
|
||||
public Device getDevice() {
|
||||
return this.device;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void execute() throws Exception {
|
||||
device_code = this.getDeviceCode();
|
||||
heartbeat = this.itemProtocol.getItem_heartbeat();
|
||||
mode = this.itemProtocol.getItem_mode();
|
||||
error = this.itemProtocol.getItem_error();
|
||||
error_num = this.itemProtocol.getItem_error_num();
|
||||
open_time = this.itemProtocol.getItem_open_time();
|
||||
close_time = this.itemProtocol.getItem_close_time();
|
||||
ready_time = this.itemProtocol.getItem_ready_time();
|
||||
running_time = this.itemProtocol.getItem_running_time();
|
||||
error_time = this.itemProtocol.getItem_error_time();
|
||||
voltage = this.itemProtocol.getItem_voltage();
|
||||
temperature = this.itemProtocol.getItem_temperature();
|
||||
current = this.itemProtocol.getItem_current();
|
||||
material = this.itemProtocol.getItem_material();
|
||||
lack_material = this.itemProtocol.getItem_lack_material();
|
||||
full_material = this.itemProtocol.getItem_full_material();
|
||||
storage_qty = this.itemProtocol.getItem_storage_qty();
|
||||
feeding_qty = this.itemProtocol.getItem_feeding_qty();
|
||||
blanking_qty = this.itemProtocol.getItem_blanking_qty();
|
||||
qualified_qty = this.itemProtocol.getItem_qualified_qty();
|
||||
unqualified_qty = this.itemProtocol.getItem_unqualified_qty();
|
||||
finish = this.itemProtocol.getItem_finish();
|
||||
task = this.itemProtocol.getItem_task();
|
||||
noload_electricity_consumption = this.itemProtocol.getItem_noload_electricity_consumption();
|
||||
prod_electricity_consumption = this.itemProtocol.getItem_prod_electricity_consumption();
|
||||
gas_consumption = this.itemProtocol.getItem_gas_consumption();
|
||||
water_consumption = this.itemProtocol.getItem_water_consumption();
|
||||
oil_level = this.itemProtocol.getItem_oil_level();
|
||||
monthly_electricity_consumption = this.itemProtocol.getItem_monthly_electricity_consumption();
|
||||
pause = this.itemProtocol.getItem_pause();
|
||||
|
||||
if (mode != last_mode) {
|
||||
this.setRequireSucess(false);
|
||||
logServer.deviceLogToacs(this.device_code,"","","工作模式切换,刷新请求标记:"+this.requireSucess);
|
||||
logServer.deviceLog(this.device_code,"mode" ,String.valueOf(mode));
|
||||
logServer.deviceLogToacs(this.device_code,"","","信号mode:" + last_mode + "->" + mode);
|
||||
}
|
||||
if (error != last_error) {
|
||||
logServer.deviceLog(this.device_code,"error" ,String.valueOf(error));
|
||||
logServer.deviceLogToacs(this.device_code,"","","信号error:" + last_error + "->" + error);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean exe_error() {
|
||||
if (this.error == 0) {
|
||||
return true;
|
||||
} else {
|
||||
log.debug("设备报警");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
protected void thingToNothing() {
|
||||
log.debug("从有货到无货 清理数据");
|
||||
logServer.deviceLogToacs(this.device_code,"","","光电信号切换,刷新请求标记:"+this.requireSucess);
|
||||
|
||||
this.setRequireSucess(false);
|
||||
this.setApplySucess(false);
|
||||
this.set_last_container(container, container_type_desc);
|
||||
}
|
||||
|
||||
public void set_last_container(String barcode, String type_desc) {
|
||||
this.setInst_message(null);
|
||||
this.setContainer(null);
|
||||
this.set_last_container(barcode);
|
||||
this.set_last_container_type_desc(type_desc);
|
||||
}
|
||||
|
||||
public void set_last_container(String barcode) {
|
||||
}
|
||||
|
||||
public void set_last_container_type_desc(String type) {
|
||||
}
|
||||
|
||||
|
||||
public boolean exe_business() {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected void executing(Instruction instruction) {
|
||||
this.executing(1, instruction, "");
|
||||
}
|
||||
|
||||
public void executing(int command, Instruction instruction, String appendMessage) {
|
||||
|
||||
}
|
||||
|
||||
public void executing(Server server, Map<String, Object> itemMap) {
|
||||
ReadUtil.write(itemMap, server);
|
||||
}
|
||||
|
||||
public void writing(int command) {
|
||||
|
||||
}
|
||||
|
||||
public void writing(String key, String value) {
|
||||
String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
|
||||
+ "." + key;
|
||||
String opcservcerid = this.getDevice().getOpc_server_id();
|
||||
Server server = ReadUtil.getServer(opcservcerid);
|
||||
Map<String, Object> itemMap = new HashMap<String, Object>();
|
||||
itemMap.put(to_command, value);
|
||||
ReadUtil.write(itemMap, server);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,248 @@
|
||||
package org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_smart_plc_test;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.acs.device.device_driver.standard_inspect.ItemDto;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Data
|
||||
public class ItemProtocol {
|
||||
|
||||
public static String item_heartbeat = "heartbeat";
|
||||
public static String item_mode = "mode";
|
||||
public static String item_error = "error";
|
||||
public static String item_error_num = "error_num";
|
||||
public static String item_open_time = "open_time";
|
||||
public static String item_close_time = "close_time"; //
|
||||
public static String item_ready_time = "ready_time"; //
|
||||
public static String item_running_time = "running_time";
|
||||
public static String item_error_time = "error_time";
|
||||
public static String item_voltage = "voltage";
|
||||
public static String item_temperature = "temperature";
|
||||
public static String item_current = "current";
|
||||
public static String item_material = "material";
|
||||
public static String item_lack_material = "lack_material";
|
||||
public static String item_full_material = "full_material";
|
||||
public static String item_storage_qty = "storage_qty";
|
||||
public static String item_feeding_qty = "feeding_qty";
|
||||
public static String item_blanking_qty = "blanking_qty";
|
||||
public static String item_qualified_qty = "qualified_qty";
|
||||
public static String item_unqualified_qty = "unqualified_qty";
|
||||
public static String item_finish = "finish";
|
||||
public static String item_task = "task";
|
||||
public static String item_noload_electricity_consumption = "noload_electricity_consumption";
|
||||
public static String item_prod_electricity_consumption = "prod_electricity_consumption";
|
||||
public static String item_gas_consumption = "gas_consumption";
|
||||
public static String item_water_consumption = "water_consumption";
|
||||
public static String item_oil_level = "oil_level";
|
||||
public static String item_monthly_electricity_consumption = "monthly_electricity_consumption";
|
||||
public static String item_pause = "pause";
|
||||
|
||||
|
||||
|
||||
public static String item_to_heartbeat = "to_heartbeat";//
|
||||
public static String item_to_command = "to_command";//
|
||||
public static String item_to_feeding = "to_feeding";//
|
||||
public static String item_to_task = "to_task";//
|
||||
public static String item_to_pause= "to_pause";//
|
||||
public static String item_to_clear = "to_clear";//
|
||||
public static String item_to_finish = "to_finish";//
|
||||
public static String item_to_open = "to_open";//
|
||||
public static String item_to_close = "to_close";//
|
||||
public static String item_to_material = "to_material";//
|
||||
public static String item_to_qty = "to_qty";//
|
||||
|
||||
|
||||
private HailiangSmartplcTestDeviceDriver driver;
|
||||
|
||||
public ItemProtocol(HailiangSmartplcTestDeviceDriver driver) {
|
||||
this.driver = driver;
|
||||
}
|
||||
|
||||
public int getItem_heartbeat() {
|
||||
return this.getOpcIntegerValue(item_heartbeat);
|
||||
}
|
||||
|
||||
public int getItem_mode() {
|
||||
return this.getOpcIntegerValue(item_mode);
|
||||
}
|
||||
|
||||
public int getItem_error() {
|
||||
return this.getOpcIntegerValue(item_error);
|
||||
}
|
||||
|
||||
public int getItem_error_num() {
|
||||
return this.getOpcIntegerValue(item_error_num);
|
||||
}
|
||||
|
||||
public int getItem_open_time() {
|
||||
return this.getOpcIntegerValue(item_open_time);
|
||||
}
|
||||
|
||||
public int getItem_close_time() {
|
||||
return this.getOpcIntegerValue(item_close_time);
|
||||
}
|
||||
|
||||
public int getItem_ready_time() {
|
||||
return this.getOpcIntegerValue(item_ready_time);
|
||||
}
|
||||
|
||||
public int getItem_running_time() {
|
||||
return this.getOpcIntegerValue(item_running_time);
|
||||
}
|
||||
|
||||
public int getItem_error_time() {
|
||||
return this.getOpcIntegerValue(item_error_time);
|
||||
}
|
||||
|
||||
public int getItem_voltage() {
|
||||
return this.getOpcIntegerValue(item_voltage);
|
||||
}
|
||||
|
||||
public int getItem_temperature() {
|
||||
return this.getOpcIntegerValue(item_temperature);
|
||||
}
|
||||
|
||||
public int getItem_current() {
|
||||
return this.getOpcIntegerValue(item_current);
|
||||
}
|
||||
|
||||
public int getItem_material() {
|
||||
return this.getOpcIntegerValue(item_material);
|
||||
}
|
||||
|
||||
public int getItem_lack_material() {
|
||||
return this.getOpcIntegerValue(item_lack_material);
|
||||
}
|
||||
|
||||
public int getItem_full_material() {
|
||||
return this.getOpcIntegerValue(item_full_material);
|
||||
}
|
||||
|
||||
public int getItem_storage_qty() {
|
||||
return this.getOpcIntegerValue(item_storage_qty);
|
||||
}
|
||||
|
||||
public int getItem_feeding_qty() {
|
||||
return this.getOpcIntegerValue(item_feeding_qty);
|
||||
}
|
||||
|
||||
public int getItem_blanking_qty() {
|
||||
return this.getOpcIntegerValue(item_blanking_qty);
|
||||
}
|
||||
|
||||
public int getItem_qualified_qty() {
|
||||
return this.getOpcIntegerValue(item_qualified_qty);
|
||||
}
|
||||
|
||||
public int getItem_unqualified_qty() {
|
||||
return this.getOpcIntegerValue(item_unqualified_qty);
|
||||
}
|
||||
|
||||
public int getItem_finish() {
|
||||
return this.getOpcIntegerValue(item_mode);
|
||||
}
|
||||
|
||||
public int getItem_task() {
|
||||
return this.getOpcIntegerValue(item_task);
|
||||
}
|
||||
|
||||
public int getItem_noload_electricity_consumption() {
|
||||
return this.getOpcIntegerValue(item_noload_electricity_consumption);
|
||||
}
|
||||
|
||||
public int getItem_prod_electricity_consumption() {
|
||||
return this.getOpcIntegerValue(item_prod_electricity_consumption);
|
||||
}
|
||||
|
||||
public int getItem_gas_consumption() {
|
||||
return this.getOpcIntegerValue(item_gas_consumption);
|
||||
}
|
||||
|
||||
public int getItem_water_consumption() {
|
||||
return this.getOpcIntegerValue(item_water_consumption);
|
||||
}
|
||||
|
||||
public int getItem_oil_level() {
|
||||
return this.getOpcIntegerValue(item_oil_level);
|
||||
}
|
||||
|
||||
public int getItem_monthly_electricity_consumption() {
|
||||
return this.getOpcIntegerValue(item_monthly_electricity_consumption);
|
||||
}
|
||||
|
||||
public int getItem_pause() {
|
||||
return this.getOpcIntegerValue(item_pause);
|
||||
}
|
||||
|
||||
Boolean isonline;
|
||||
|
||||
public int getOpcIntegerValue(String protocol) {
|
||||
Integer value = this.driver.getIntegeregerValue(protocol);
|
||||
if (value == null) {
|
||||
setIsonline(false);
|
||||
} else {
|
||||
setIsonline(true);
|
||||
return value;
|
||||
}
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
public static List<ItemDto> getReadableItemDtos() {
|
||||
ArrayList list = new ArrayList();
|
||||
list.add(new ItemDto(item_heartbeat, "心跳", "VW0"));
|
||||
list.add(new ItemDto(item_mode, "模式", "VW2"));
|
||||
list.add(new ItemDto(item_error, "故障", "VW4"));
|
||||
list.add(new ItemDto(item_error_num, "故障次数", "VD6"));
|
||||
list.add(new ItemDto(item_open_time, "开机时间", "VD8"));
|
||||
list.add(new ItemDto(item_close_time, "关机时间", "VD12"));
|
||||
list.add(new ItemDto(item_ready_time, "待机时间", "VD16"));
|
||||
list.add(new ItemDto(item_running_time, "生产时间", "VD20"));
|
||||
list.add(new ItemDto(item_error_time, "故障时间", "VD24"));
|
||||
list.add(new ItemDto(item_temperature, "温度", "VD28"));
|
||||
list.add(new ItemDto(item_voltage, "电压", "VD32"));
|
||||
list.add(new ItemDto(item_current, "电流", "VD36"));
|
||||
list.add(new ItemDto(item_material, "当前生产产品编号", "VD40"));
|
||||
list.add(new ItemDto(item_lack_material, "生产缺料信号", "VD44"));
|
||||
list.add(new ItemDto(item_full_material, "生产满料信号", "VD48"));
|
||||
list.add(new ItemDto(item_storage_qty, "储料斗数量", "VD52"));
|
||||
list.add(new ItemDto(item_feeding_qty, "上料数量", "VD56"));
|
||||
list.add(new ItemDto(item_blanking_qty, "下料数量", "VD60"));
|
||||
list.add(new ItemDto(item_qualified_qty, "当前生产合格品数量", "VD64"));
|
||||
list.add(new ItemDto(item_unqualified_qty, "当前生产不合格数量", "VD68"));
|
||||
list.add(new ItemDto(item_finish, "生产完成", "VD72"));
|
||||
list.add(new ItemDto(item_task, "任务号", "VD76"));
|
||||
list.add(new ItemDto(item_noload_electricity_consumption, "空载电能耗(未生产时)", "VD80"));
|
||||
list.add(new ItemDto(item_prod_electricity_consumption, "生产电能耗", "VD84"));
|
||||
list.add(new ItemDto(item_gas_consumption, "气压能耗", "VD88"));
|
||||
list.add(new ItemDto(item_water_consumption, "水流量能耗", "VD92"));
|
||||
list.add(new ItemDto(item_oil_level, "当前液压油位", "VD96"));
|
||||
list.add(new ItemDto(item_monthly_electricity_consumption, "本月总电能耗", "VD100"));
|
||||
list.add(new ItemDto(item_pause, "设备暂停", "VD104"));
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
public static List<ItemDto> getWriteableItemDtos() {
|
||||
ArrayList list = new ArrayList();
|
||||
list.add(new ItemDto(item_to_heartbeat, "心跳", "VW200"));
|
||||
list.add(new ItemDto(item_to_command, "下发命令", "VW202"));
|
||||
list.add(new ItemDto(item_to_feeding, "下发命令", "VW204"));
|
||||
list.add(new ItemDto(item_to_task, "任务号", "VW208"));
|
||||
list.add(new ItemDto(item_to_pause, "生产暂停", "VW212"));
|
||||
list.add(new ItemDto(item_to_clear, "当前产量清零", "VW216"));
|
||||
list.add(new ItemDto(item_to_finish, "强制完成", "VW220"));
|
||||
list.add(new ItemDto(item_to_open, "设备开机", "VW224"));
|
||||
list.add(new ItemDto(item_to_close, "设备关机", "VW228"));
|
||||
list.add(new ItemDto(item_to_material, "当前任务生产物料", "VW232"));
|
||||
list.add(new ItemDto(item_to_qty, "当前任务生产数量", "VW236"));
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ import hailiang_cleaning_machine_storage_station from '@/views/acs/device/driver
|
||||
import agv_ndc_one from '@/views/acs/device/driver/agv/agv_ndc_one'
|
||||
import agv_ndc_two from '@/views/acs/device/driver/agv/agv_ndc_two'
|
||||
import hailiang_xj_plc_test from '@/views/acs/device/driver/hailiang_one/hailiang_xj_plc_test'
|
||||
|
||||
import hailiang_smart_plc_test from '@/views/acs/device/driver/hailiang_one/hailiang_smart_plc_test'
|
||||
|
||||
export default {
|
||||
name: 'DeviceConfig',
|
||||
@@ -122,7 +122,7 @@ export default {
|
||||
standard_photoelectric_inspect_site, agv_ndc_two, agv_ndc_one, hailiang_packer_station, hailiang_engraving_cache,
|
||||
hailiang_special_pick_station, hailiang_special_empty_station, hailiang_special_full_station, hailiang_special_pour_station, hailiang_special_device,
|
||||
hailiang_engraving_machine, hailiang_auto_cache_line, hailiang_cleaning_feeding_line, hailiang_cleaning_machine, hailiang_cleaning_machine_storage_station,
|
||||
hailiang_xj_plc_test },
|
||||
hailiang_xj_plc_test, hailiang_smart_plc_test },
|
||||
dicts: ['device_type'],
|
||||
mixins: [crud],
|
||||
data() {
|
||||
|
||||
@@ -0,0 +1,504 @@
|
||||
<template>
|
||||
<!--海亮自动缓存线-->
|
||||
<div>
|
||||
<el-card class="box-card" shadow="never">
|
||||
<div slot="header" class="clearfix">
|
||||
<span class="role-span">设备协议:</span>
|
||||
</div>
|
||||
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
OpcServer:
|
||||
<el-select
|
||||
v-model="opc_id"
|
||||
placeholder="无"
|
||||
clearable
|
||||
filterable
|
||||
@change="changeOpc"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in dataOpcservers"
|
||||
:key="item.opc_id"
|
||||
:label="item.opc_name"
|
||||
:value="item.opc_id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
PLC:
|
||||
<el-select
|
||||
v-model="plc_id"
|
||||
placeholder="无"
|
||||
clearable
|
||||
@change="changePlc"
|
||||
filterable
|
||||
>
|
||||
<el-option
|
||||
v-for="item in dataOpcPlcs"
|
||||
:key="item.plc_id"
|
||||
:label="item.plc_name"
|
||||
:value="item.plc_id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
</el-card>
|
||||
|
||||
<el-card class="box-card" shadow="never">
|
||||
<div slot="header" class="clearfix">
|
||||
<span class="role-span">输送系统:</span>
|
||||
</div>
|
||||
<el-form ref="form" :inline="true" :model="form" :rules="rules" size="small" label-width="78px">
|
||||
<el-row>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="电气调度号" label-width="150px">
|
||||
<el-input v-model="form.address" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
</el-card>
|
||||
|
||||
<el-card class="box-card" shadow="never">
|
||||
<div slot="header" class="clearfix">
|
||||
<span class="role-span">指令相关:</span>
|
||||
</div>
|
||||
<el-form ref="form" :inline="true" :model="form" :rules="rules" size="small" label-width="78px">
|
||||
<el-row>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="检验有货">
|
||||
<el-switch v-model="form.inspect_in_stocck" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="忽视取货校验" label-width="150px">
|
||||
<el-switch v-model="form.ignore_pickup_check" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="忽视放货校验" label-width="150px">
|
||||
<el-switch v-model="form.ignore_release_check" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<el-row>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="呼叫">
|
||||
<el-switch v-model="form.apply_task" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="响应" label-width="150px">
|
||||
<el-switch v-model="form.manual_create_task" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<el-row>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="关联设备" prop="device_code">
|
||||
<el-select
|
||||
v-model="form.link_device_code"
|
||||
clearable
|
||||
filterable
|
||||
placeholder="请选择"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in deviceList"
|
||||
:key="item.device_code"
|
||||
:label="item.device_name"
|
||||
:value="item.device_code"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="关联三色灯" prop="device_code" label-width="100px">
|
||||
<el-select
|
||||
v-model="form.link_three_lamp"
|
||||
filterable
|
||||
clearable
|
||||
placeholder="请选择"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in deviceList"
|
||||
:key="item.device_code"
|
||||
:label="item.device_name"
|
||||
:value="item.device_code"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="是否输入物料" label-width="150px">
|
||||
<el-switch v-model="form.input_material" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
</el-card>
|
||||
|
||||
<el-card class="box-card" shadow="never">
|
||||
<div slot="header" class="clearfix">
|
||||
<span class="role-span">AGV相关:</span>
|
||||
</div>
|
||||
<el-form ref="form" :inline="true" :model="form" :rules="rules" size="small" label-width="78px">
|
||||
<el-row>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="取货">
|
||||
<el-switch v-model="form.is_pickup" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="放货">
|
||||
<el-switch v-model="form.is_release" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
</el-card>
|
||||
|
||||
<el-card class="box-card" shadow="never">
|
||||
<div slot="header" class="clearfix">
|
||||
<span class="role-span">PLC读取字段:</span>
|
||||
</div>
|
||||
<el-form ref="form" :inline="true" :model="form" :rules="rules" size="small" label-width="78px">
|
||||
<el-table
|
||||
v-loading="false"
|
||||
:data="data1"
|
||||
:max-height="550"
|
||||
size="small"
|
||||
style="width: 100%;margin-bottom: 15px"
|
||||
>
|
||||
|
||||
<el-table-column prop="name" label="用途" />
|
||||
<el-table-column prop="code" label="别名要求" />
|
||||
<el-table-column prop="db" label="DB块">
|
||||
<template slot-scope="scope">
|
||||
<el-input
|
||||
v-model="data1[scope.$index].db"
|
||||
size="mini"
|
||||
class="edit-input"
|
||||
@input="finishReadEdit(data1[scope.$index])"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="dbr_value">
|
||||
<template slot="header">
|
||||
<el-link type="primary" :underline="false" @click.native="test_read1()">测试读</el-link>
|
||||
</template>
|
||||
<template slot-scope="scope">
|
||||
<el-input v-model="data1[scope.$index].dbr_value" size="mini" class="edit-input" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-form>
|
||||
</el-card>
|
||||
|
||||
<el-card class="box-card" shadow="never">
|
||||
<div slot="header" class="clearfix">
|
||||
<span class="role-span">PLC写入字段:</span>
|
||||
</div>
|
||||
<el-form ref="form" :inline="true" :model="form" :rules="rules" size="small" label-width="78px">
|
||||
<el-table
|
||||
v-loading="false"
|
||||
:data="data2"
|
||||
:max-height="550"
|
||||
size="small"
|
||||
style="width: 100%;margin-bottom: 15px"
|
||||
>
|
||||
|
||||
<el-table-column prop="name" label="用途" />
|
||||
<el-table-column prop="code" label="别名要求" />
|
||||
<el-table-column prop="db" label="DB块">
|
||||
<template slot-scope="scope">
|
||||
<el-input
|
||||
v-model="data2[scope.$index].db"
|
||||
size="mini"
|
||||
class="edit-input"
|
||||
@input="finishWriteEdit(data2[scope.$index])"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="dbw_value">
|
||||
<template slot="header">
|
||||
<el-link type="primary" :underline="false" @click.native="test_write1()">测试写</el-link>
|
||||
</template>
|
||||
<template slot-scope="scope">
|
||||
<el-input v-model="data2[scope.$index].dbw_value" size="mini" class="edit-input" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-form>
|
||||
</el-card>
|
||||
|
||||
<el-card class="box-card" shadow="never">
|
||||
<div slot="header" class="clearfix">
|
||||
<span class="role-span" />
|
||||
<el-button
|
||||
:loading="false"
|
||||
icon="el-icon-check"
|
||||
size="mini"
|
||||
style="float: right; padding: 6px 9px"
|
||||
type="primary"
|
||||
@click="doSubmit"
|
||||
>保存
|
||||
</el-button>
|
||||
</div>
|
||||
</el-card>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {
|
||||
queryDriverConfig,
|
||||
updateConfig,
|
||||
testRead,
|
||||
testwrite
|
||||
} from '@/api/acs/device/driverConfig'
|
||||
import { selectOpcList } from '@/api/acs/device/opc'
|
||||
import { selectPlcList } from '@/api/acs/device/opcPlc'
|
||||
import { selectListByOpcID } from '@/api/acs/device/opcPlc'
|
||||
|
||||
import crud from '@/mixins/crud'
|
||||
import deviceCrud from '@/api/acs/device/device'
|
||||
|
||||
export default {
|
||||
name: 'StandardConveyorControl',
|
||||
mixins: [crud],
|
||||
props: {
|
||||
parentForm: {
|
||||
type: Object,
|
||||
require: true
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
device_code: '',
|
||||
device_id: '',
|
||||
plc_id: '',
|
||||
plc_code: '',
|
||||
address: '',
|
||||
opc_id: '',
|
||||
opc_code: '',
|
||||
configLoading: false,
|
||||
dataOpcservers: [],
|
||||
dataOpcPlcs: [],
|
||||
deviceList: [],
|
||||
data1: [],
|
||||
data2: [],
|
||||
form: {
|
||||
inspect_in_stocck: true,
|
||||
ignore_pickup_check: true,
|
||||
ignore_release_check: true,
|
||||
apply_task: true,
|
||||
link_three_lamp: '',
|
||||
manual_create_task: true,
|
||||
is_pickup: true,
|
||||
is_release: true,
|
||||
link_device_code: ''
|
||||
},
|
||||
rules: {}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.$nextTick(() => {
|
||||
// 从父表单获取设备编码
|
||||
this.device_id = this.$props.parentForm.device_id
|
||||
this.device_code = this.$props.parentForm.device_code
|
||||
queryDriverConfig(this.device_id, this.$props.parentForm.driver_code).then(data => {
|
||||
// 给表单赋值,并且属性不能为空
|
||||
if (data.form) {
|
||||
const arr = Object.keys(data.form)
|
||||
// 不为空
|
||||
if (arr.length > 0) {
|
||||
this.form = data.form
|
||||
}
|
||||
}
|
||||
|
||||
// 给表单赋值,并且属性不能为空
|
||||
if (data.parentForm) {
|
||||
const arr = Object.keys(data.parentForm)
|
||||
// 不为空
|
||||
if (arr.length > 0) {
|
||||
this.opc_code = data.parentForm.opc_code
|
||||
this.plc_code = data.parentForm.plc_code
|
||||
}
|
||||
}
|
||||
this.data1 = data.rs
|
||||
this.data2 = data.ws
|
||||
this.sliceItem()
|
||||
})
|
||||
selectPlcList().then(data => {
|
||||
this.dataOpcPlcs = data
|
||||
this.plc_id = this.$props.parentForm.opc_plc_id
|
||||
})
|
||||
selectOpcList().then(data => {
|
||||
this.dataOpcservers = data
|
||||
this.opc_id = this.$props.parentForm.opc_server_id
|
||||
})
|
||||
deviceCrud.selectDeviceList().then(data => {
|
||||
this.deviceList = data
|
||||
})
|
||||
})
|
||||
},
|
||||
methods: {
|
||||
finishReadEdit(data) {
|
||||
// 编辑的是code列,并且值包含mode
|
||||
if (data.code.indexOf('mode') !== -1) {
|
||||
const dbValue = data.db
|
||||
// .之前的字符串
|
||||
const beforeStr = dbValue.match(/(\S*)\./)[1]
|
||||
// .之后的字符串
|
||||
const afterStr = dbValue.match(/\.(\S*)/)[1]
|
||||
// 取最后数字
|
||||
const endNumber = afterStr.substring(1)
|
||||
// 最后为非数字
|
||||
if (isNaN(parseInt(endNumber))) {
|
||||
return
|
||||
}
|
||||
for (const val in this.data1) {
|
||||
if (this.data1[val].code.indexOf('move') !== -1) {
|
||||
this.data1[val].db = beforeStr + '.' + afterStr.substring(0, 1) + (parseInt(endNumber) + 1)
|
||||
}
|
||||
if (this.data1[val].code.indexOf('action') !== -1) {
|
||||
this.data1[val].db = beforeStr + '.' + afterStr.substring(0, 1) + (parseInt(endNumber) + 2)
|
||||
}
|
||||
if (this.data1[val].code.indexOf('ioaction') !== -1) {
|
||||
this.data1[val].db = beforeStr + '.' + afterStr.substring(0, 1) + (parseInt(endNumber) + 3)
|
||||
}
|
||||
if (this.data1[val].code.indexOf('height') !== -1) {
|
||||
this.data1[val].db = beforeStr + '.' + afterStr.substring(0, 1) + (parseInt(endNumber) + 4)
|
||||
}
|
||||
if (this.data1[val].code.indexOf('error') !== -1) {
|
||||
this.data1[val].db = beforeStr + '.' + afterStr.substring(0, 1) + (parseInt(endNumber) + 5)
|
||||
}
|
||||
if (this.data1[val].code.indexOf('direction') !== -1) {
|
||||
this.data1[val].db = beforeStr + '.' + afterStr.substring(0, 1) + (parseInt(endNumber) + 6)
|
||||
}
|
||||
if (this.data1[val].code.indexOf('operation_type') !== -1) {
|
||||
this.data1[val].db = beforeStr + '.' + afterStr.substring(0, 1) + (parseInt(endNumber) + 7)
|
||||
}
|
||||
if (this.data1[val].code.indexOf('task') !== -1) {
|
||||
this.data1[val].db = beforeStr + '.' + 'D' + (parseInt(endNumber) + 21)
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
finishWriteEdit(data) {
|
||||
// 编辑的是code列,并且值包含mode
|
||||
if (data.code.indexOf('to_command') !== -1) {
|
||||
const dbValue = data.db
|
||||
// .之前的字符串
|
||||
const beforeStr = dbValue.match(/(\S*)\./)[1]
|
||||
// .之后的字符串
|
||||
const afterStr = dbValue.match(/\.(\S*)/)[1]
|
||||
// 取最后数字
|
||||
const endNumber = afterStr.substring(1)
|
||||
// 最后为非数字
|
||||
if (isNaN(parseInt(endNumber))) {
|
||||
return
|
||||
}
|
||||
for (const val in this.data2) {
|
||||
if (this.data2[val].code.indexOf('to_target') !== -1) {
|
||||
this.data2[val].db = beforeStr + '.' + afterStr.substring(0, 1) + (parseInt(endNumber) + 2)
|
||||
}
|
||||
if (this.data2[val].code.indexOf('to_task') !== -1) {
|
||||
this.data2[val].db = beforeStr + '.' + 'D' + (parseInt(endNumber) + 6)
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
changeOpc(val) {
|
||||
this.dataOpcservers.forEach(item => {
|
||||
if (item.opc_id === val) {
|
||||
this.opc_code = item.opc_code
|
||||
}
|
||||
})
|
||||
|
||||
selectListByOpcID(val).then(data => {
|
||||
this.dataOpcPlcs = data
|
||||
this.plc_id = ''
|
||||
this.plc_code = ''
|
||||
if (this.dataOpcPlcs && this.dataOpcPlcs.length > 0) {
|
||||
this.plc_id = this.dataOpcPlcs[0].plc_id
|
||||
this.plc_code = this.dataOpcPlcs[0].plc_code
|
||||
}
|
||||
this.sliceItem()
|
||||
})
|
||||
},
|
||||
changePlc(val) {
|
||||
this.dataOpcPlcs.forEach(item => {
|
||||
if (item.plc_id === val) {
|
||||
this.plc_code = item.plc_code
|
||||
this.sliceItem()
|
||||
return
|
||||
}
|
||||
})
|
||||
},
|
||||
test_read1() {
|
||||
testRead(this.data1, this.opc_id).then(data => {
|
||||
this.data1 = data
|
||||
this.notify('操作成功!', 'success')
|
||||
}).catch(err => {
|
||||
console.log(err.response.data.message)
|
||||
})
|
||||
},
|
||||
test_write1() {
|
||||
testwrite(this.data2, this.opc_id).then(data => {
|
||||
this.notify('操作成功!', 'success')
|
||||
}).catch(err => {
|
||||
console.log(err.response.data.message)
|
||||
})
|
||||
},
|
||||
doSubmit() {
|
||||
this.$refs['form'].validate((valid) => {
|
||||
if (valid) {
|
||||
this.configLoading = true
|
||||
// 根据驱动类型判断是否为路由设备
|
||||
const parentForm = this.parentForm
|
||||
parentForm.is_route = true
|
||||
parentForm.plc_id = this.plc_id
|
||||
parentForm.opc_id = this.opc_id
|
||||
updateConfig(parentForm, this.form, this.data1, this.data2).then(res => {
|
||||
this.notify('保存成功', 'success')
|
||||
this.configLoading = false
|
||||
}).catch(err => {
|
||||
this.configLoading = false
|
||||
console.log(err.response.data.message)
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
sliceItem() { // 拼接DB的Item值
|
||||
this.data1.forEach(item => {
|
||||
const str = item.code
|
||||
// 是否包含.
|
||||
if (str.search('.') !== -1) {
|
||||
// 截取最后一位
|
||||
item.code = this.opc_code + '.' + this.plc_code + '.' + this.device_code + '.' + str.slice(str.lastIndexOf('.') + 1)
|
||||
} else {
|
||||
item.code = this.opc_code + '.' + this.plc_code + '.' + this.device_code + '.' + item.code
|
||||
}
|
||||
})
|
||||
this.data2.forEach(item => {
|
||||
const str = item.code
|
||||
// 是否包含.
|
||||
if (str.search('.') !== -1) {
|
||||
// 截取最后一位
|
||||
item.code = this.opc_code + '.' + this.plc_code + '.' + this.device_code + '.' + str.slice(str.lastIndexOf('.') + 1)
|
||||
} else {
|
||||
item.code = this.opc_code + '.' + this.plc_code + '.' + this.device_code + '.' + item.code
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
Reference in New Issue
Block a user