opt: 组盘,点位页面优化,lms冲床下料入库功能添加;acs添加心跳设备
This commit is contained in:
@@ -27,6 +27,8 @@ public enum DriverTypeEnum {
|
||||
|
||||
PLC_TO_AGV(15, "plc_to_agv", "PLCTOAGV站点", "conveyor"),
|
||||
|
||||
SORTING(16, "sorting", "Sorting站点", "conveyor"),
|
||||
|
||||
AGV_NDC_TWO(8, "agv_ndc_two", "NDC2楼AGV", "agv"),
|
||||
|
||||
XGAGV(9, "xg_agv", "xg_agv", "agv"),
|
||||
|
||||
@@ -111,14 +111,6 @@ public class PlcToAgvDeviceDriver extends AbstractOpcDeviceDriver implements Dev
|
||||
AGVSetOutReqUpper = this.itemProtocol.getAGVSetOutReqUpper();
|
||||
AGVSetOutReqLower = this.itemProtocol.getAGVSetOutReqLower();
|
||||
heartbeat = this.itemProtocol.getHeartbeat();
|
||||
if (heartbeat == 1) {
|
||||
List list = new ArrayList<>();
|
||||
Map map = new HashMap();
|
||||
map.put("code", "heartbeat");
|
||||
map.put("value", writing_heartbeat);
|
||||
list.add(map);
|
||||
writing(list);
|
||||
}
|
||||
} catch (Exception var17) {
|
||||
log.info("读取信号失败,失败原因:{}", var17.getMessage());
|
||||
throw new BadRequestException("读取信号失败,失败原因:" + var17.getMessage());
|
||||
@@ -160,7 +152,6 @@ public class PlcToAgvDeviceDriver extends AbstractOpcDeviceDriver implements Dev
|
||||
itemMap.put(to_param, json.getString("value"));
|
||||
}
|
||||
}
|
||||
|
||||
LuceneLogDto logDto = LuceneLogDto.builder()
|
||||
.device_code(device_code)
|
||||
.content("下发电气信号:" + itemMap)
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
package org.nl.acs.device_driver.basedriver.sorting;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
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";
|
||||
|
||||
private SortingDeviceDriver driver;
|
||||
|
||||
static Object msg;
|
||||
|
||||
public ItemProtocol(SortingDeviceDriver driver) {
|
||||
this.driver = driver;
|
||||
}
|
||||
|
||||
public int getHeartbeat() {
|
||||
return this.getOpcIntegerValue(item_Heartbeat);
|
||||
}
|
||||
|
||||
|
||||
//是否有货
|
||||
public int hasGoods(int move) {
|
||||
return move;
|
||||
}
|
||||
|
||||
Boolean isonline;
|
||||
|
||||
int last_value = 0;
|
||||
long date = 0;
|
||||
private static final long STABILITY_DURATION_MS = 3000; // 稳定时间 3 秒
|
||||
|
||||
public int getOpcIntegerValue(String protocol) {
|
||||
getExends();
|
||||
Integer value = this.driver.getIntegeregerValue(protocol);
|
||||
if (value == null) {
|
||||
setIsonline(false);
|
||||
} else {
|
||||
setIsonline(true);
|
||||
return value;
|
||||
}
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public Short getOpcShortValue(String protocol) {
|
||||
getExends();
|
||||
Short value = this.driver.getShortValue(protocol);
|
||||
if (value == null) {
|
||||
setIsonline(false);
|
||||
} else {
|
||||
setIsonline(true);
|
||||
return value;
|
||||
}
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
public void getExends() {
|
||||
Object upper_lower_levels = this.driver.getExtraValue().get("upper_lower_levels");
|
||||
if (ObjectUtil.isNotEmpty(upper_lower_levels)) {
|
||||
msg = upper_lower_levels;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static List<ItemDto> getReadableItemDtos() {
|
||||
ArrayList list = new ArrayList();
|
||||
list.add(new ItemDto(item_Heartbeat, "心跳", "DB600.D6"));
|
||||
return list;
|
||||
}
|
||||
|
||||
public static List<ItemDto> getWriteableItemDtos() {
|
||||
ArrayList list = new ArrayList();
|
||||
list.add(new ItemDto(item_Heartbeat, "心跳", "DB600.D6"));
|
||||
return list;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
package org.nl.acs.device_driver.basedriver.sorting;
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
* PlcToAgv站点
|
||||
*/
|
||||
@Service
|
||||
public class SortingDefination implements OpcDeviceDriverDefination {
|
||||
@Override
|
||||
public String getDriverCode() {
|
||||
return "sorting";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDriverName() {
|
||||
return "Sorting站点";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDriverDescription() {
|
||||
return "Sorting站点";
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeviceDriver getDriverInstance(Device device) {
|
||||
return (new SortingDeviceDriver()).setDevice(device).setDriverDefination(this);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends DeviceDriver> getDeviceDriverType() {
|
||||
return SortingDeviceDriver.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,223 @@
|
||||
package org.nl.acs.device_driver.basedriver.sorting;
|
||||
|
||||
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.domain.Device;
|
||||
import org.nl.acs.device.service.DeviceService;
|
||||
import org.nl.acs.device_driver.DeviceDriver;
|
||||
import org.nl.acs.device_driver.RouteableDeviceDriver;
|
||||
import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver;
|
||||
import org.nl.acs.device_driver.driver.ExecutableDeviceDriver;
|
||||
import org.nl.acs.ext.wms.service.AcsToWmsService;
|
||||
import org.nl.acs.instruction.service.InstructionService;
|
||||
import org.nl.acs.log.service.DeviceExecuteLogService;
|
||||
import org.nl.acs.monitor.DeviceStageMonitor;
|
||||
import org.nl.acs.route.service.RouteLineService;
|
||||
import org.nl.acs.task.service.TaskService;
|
||||
import org.nl.acs.task.service.mapper.TaskMapper;
|
||||
import org.nl.common.exception.BadRequestException;
|
||||
import org.nl.config.SpringContextHolder;
|
||||
import org.nl.system.service.lucene.LuceneExecuteLogService;
|
||||
import org.nl.system.service.lucene.dto.LuceneLogDto;
|
||||
import org.openscada.opc.lib.da.Server;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* PlcToAgv站点
|
||||
*/
|
||||
@Slf4j
|
||||
@Data
|
||||
@RequiredArgsConstructor
|
||||
public class SortingDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor {
|
||||
protected ItemProtocol itemProtocol = new ItemProtocol(this);
|
||||
|
||||
InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl");
|
||||
|
||||
DeviceService deviceservice = SpringContextHolder.getBean("deviceServiceImpl");
|
||||
|
||||
RouteLineService routelineserver = SpringContextHolder.getBean("routeLineServiceImpl");
|
||||
|
||||
TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl");
|
||||
|
||||
TaskMapper taskMapper;
|
||||
|
||||
AcsToWmsService acsToWmsService = SpringContextHolder.getBean("acsToWmsServiceImpl");
|
||||
|
||||
LuceneExecuteLogService luceneExecuteLogService = SpringContextHolder.getBean(LuceneExecuteLogService.class);
|
||||
|
||||
|
||||
Boolean flag = false;
|
||||
|
||||
String device_code;
|
||||
|
||||
String writing_heartbeat = "0";
|
||||
|
||||
private long STABILITY_DURATION_MS = 8000;
|
||||
|
||||
int heartbeat = 0;
|
||||
int last_heartbeat = 0;
|
||||
private Date instruction_require_time = new Date();
|
||||
|
||||
@Override
|
||||
public Device getDevice() {
|
||||
return this.device;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
String message = null;
|
||||
try {
|
||||
device_code = this.getDeviceCode();
|
||||
heartbeat = this.itemProtocol.getHeartbeat();
|
||||
if (heartbeat == 1) {
|
||||
List list = new ArrayList<>();
|
||||
Map map = new HashMap();
|
||||
map.put("code", "heartbeat");
|
||||
map.put("value", writing_heartbeat);
|
||||
list.add(map);
|
||||
writing(list);
|
||||
}
|
||||
} catch (Exception var17) {
|
||||
log.info("读取信号失败,失败原因:{}", var17.getMessage());
|
||||
throw new BadRequestException("读取信号失败,失败原因:" + var17.getMessage());
|
||||
}
|
||||
last_heartbeat = heartbeat;
|
||||
}
|
||||
|
||||
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<>();
|
||||
|
||||
itemMap.put(to_param, Integer.parseInt(value));
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
this.checkcontrol(itemMap);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (!"heartbeat".equals(param)) {
|
||||
LuceneLogDto logDto = LuceneLogDto.builder()
|
||||
.device_code(device_code)
|
||||
.content("下发多个电气信号" + itemMap)
|
||||
.build();
|
||||
logDto.setLog_level(4);
|
||||
luceneExecuteLogService.deviceExecuteLog(logDto);
|
||||
}
|
||||
}
|
||||
|
||||
public void writing(List list) {
|
||||
Map<String, Object> itemMap = new HashMap<String, Object>();
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
Object ob = list.get(i);
|
||||
JSONObject json = (JSONObject) JSONObject.toJSON(ob);
|
||||
if (!StrUtil.isEmpty(json.getString("value"))) {
|
||||
String to_param = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
|
||||
+ "." + json.getString("code");
|
||||
itemMap.put(to_param, json.getString("value"));
|
||||
}
|
||||
}
|
||||
LuceneLogDto logDto = LuceneLogDto.builder()
|
||||
.device_code(device_code)
|
||||
.content("下发电气信号:" + itemMap)
|
||||
.build();
|
||||
logDto.setLog_level(4);
|
||||
luceneExecuteLogService.deviceExecuteLog(logDto);
|
||||
try {
|
||||
this.checkcontrol(itemMap);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
try {
|
||||
this.checkcontrol(itemMap);
|
||||
} catch (Exception e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void writing(Map<String, Object> map) {
|
||||
if (!"heartbeat".equals(map.get("heartbeat"))) {
|
||||
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)) {
|
||||
try {
|
||||
this.checkcontrol(itemMap);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
logServer.deviceExecuteLog(this.getDevice().getDevice_code(), "", "", "下发多个电气信号:" + itemMap);
|
||||
LuceneLogDto logDto = LuceneLogDto.builder()
|
||||
.device_code(device_code)
|
||||
.content("下发多个电气信号" + itemMap)
|
||||
.build();
|
||||
logDto.setLog_level(3);
|
||||
luceneExecuteLogService.deviceExecuteLog(logDto);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String getToParam() {
|
||||
return this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + ".";
|
||||
}
|
||||
|
||||
|
||||
public void set_last_container(String barcode, String type_desc) {
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
public void executing(Server server, Map<String, Object> itemMap) {
|
||||
this.control(itemMap);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public JSONObject getDeviceStatusName() {
|
||||
JSONObject jo = new JSONObject();
|
||||
return jo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDeviceStatus(JSONObject data) {
|
||||
|
||||
}
|
||||
|
||||
public List<String> getExtraDeviceCodes(String extraName) {
|
||||
String extraValue = (String) this.getDevice().getExtraValue().get(extraName);
|
||||
if (StrUtil.isEmpty(extraValue)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
String devicesString = extraValue.substring(1, extraValue.length() - 1);
|
||||
List<String> devicesList = new ArrayList<>();
|
||||
String[] devices = devicesString.split(",");
|
||||
for (int i = 0; i < devices.length; i++) {
|
||||
String s = devices[i].replace("\"", "").replace("\"", "");
|
||||
devicesList.add(s);
|
||||
}
|
||||
return devicesList;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user