add:产线接驳台、拆封盖对接位驱动
This commit is contained in:
@@ -0,0 +1,110 @@
|
|||||||
|
package org.nl.acs.device_driver.zz_driver.production_line_docking_station;
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 产线接驳台
|
||||||
|
* zhengxuming
|
||||||
|
* 2025年8月11日15:42:58
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Data
|
||||||
|
public class
|
||||||
|
ItemProtocol {
|
||||||
|
|
||||||
|
//心跳
|
||||||
|
public static String item_heartbeat = "heartbeat";
|
||||||
|
//工作模式 0-脱机;1-弃用(留作兼容);2-待机;3-运行中;
|
||||||
|
public static String item_mode = "mode";
|
||||||
|
//光电信号
|
||||||
|
public static String item_move = "move";
|
||||||
|
//取放信号
|
||||||
|
public static String item_action = "action";
|
||||||
|
//报警
|
||||||
|
public static String item_error = "error";
|
||||||
|
/**
|
||||||
|
* 1-到达取货点(取货申请);2-取货完成;3-到达放货点(放货申请);4-放货完成;5-复位;99-失败
|
||||||
|
*/
|
||||||
|
public static String item_to_command = "to_command";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private ProductionLineDockingStationDeviceDriver driver;
|
||||||
|
|
||||||
|
public ItemProtocol(ProductionLineDockingStationDeviceDriver driver){
|
||||||
|
this.driver=driver;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getHeartbeat() {
|
||||||
|
return this.getOpcIntegerValue(item_heartbeat);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMode() {
|
||||||
|
return this.getOpcIntegerValue(item_mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMove() {
|
||||||
|
return this.getOpcIntegerValue(item_move);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getAction() {
|
||||||
|
return this.getOpcIntegerValue(item_action);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getError() {
|
||||||
|
return this.getOpcIntegerValue(item_error);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getTo_command() {
|
||||||
|
return getOpcIntegerValue(item_to_command);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Boolean isonline;
|
||||||
|
|
||||||
|
public int getOpcIntegerValue(String protocol) {
|
||||||
|
Integer value = this.driver.getIntegeregerValue(protocol);
|
||||||
|
if (value == null) {
|
||||||
|
// log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!");
|
||||||
|
setIsonline(false);
|
||||||
|
} else {
|
||||||
|
setIsonline(true);
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getOpcStringValue(String protocol) {
|
||||||
|
String value = this.driver.getStringValue(protocol);
|
||||||
|
if (StrUtil.isBlank(value)) {
|
||||||
|
|
||||||
|
} else {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<ItemDto> getReadableItemDtos() {
|
||||||
|
ArrayList<ItemDto> list = new ArrayList<>();
|
||||||
|
list.add(new ItemDto(item_heartbeat, "心跳", "DB1.B0"));
|
||||||
|
list.add(new ItemDto(item_mode, "工作模式", "DB1.B2"));
|
||||||
|
list.add(new ItemDto(item_move, "光电信号", "DB1.B3"));
|
||||||
|
list.add(new ItemDto(item_action, "取放信号", "DB1.B4"));
|
||||||
|
list.add(new ItemDto(item_error, "报警信号", "DB1.B5"));
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<ItemDto> getWriteableItemDtos() {
|
||||||
|
ArrayList<ItemDto> list = new ArrayList<>();
|
||||||
|
list.add(new ItemDto(item_to_command, "下发命令", "DB2.W0"));
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
package org.nl.acs.device_driver.zz_driver.production_line_docking_station;
|
||||||
|
|
||||||
|
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 ProductionLineDockingStationDefination implements OpcDeviceDriverDefination {
|
||||||
|
@Override
|
||||||
|
public String getDriverCode() {
|
||||||
|
return "production_line_docking_station";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDriverName() {
|
||||||
|
return "产线接驳台";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDriverDescription() {
|
||||||
|
return "产线接驳台";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DeviceDriver getDriverInstance(Device device) {
|
||||||
|
return (new ProductionLineDockingStationDeviceDriver()).setDevice(device).setDriverDefination(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<? extends DeviceDriver> getDeviceDriverType() {
|
||||||
|
return ProductionLineDockingStationDeviceDriver.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<DeviceType> getFitDeviceTypes() {
|
||||||
|
List<DeviceType> types = new LinkedList();
|
||||||
|
types.add(DeviceType.robot);
|
||||||
|
return types;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<ItemDto> getReadableItemDtos() {
|
||||||
|
return ItemProtocol.getReadableItemDtos();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<ItemDto> getWriteableItemDtos() {
|
||||||
|
return ItemProtocol.getWriteableItemDtos();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,250 @@
|
|||||||
|
package org.nl.acs.device_driver.zz_driver.production_line_docking_station;
|
||||||
|
|
||||||
|
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.DeviceExtraService;
|
||||||
|
import org.nl.acs.device.service.impl.DeviceExtraServiceImpl;
|
||||||
|
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.ext.wms.data.ApplyManipulatorActionRequest;
|
||||||
|
import org.nl.acs.ext.wms.data.ApplyManipulatorActionResponse;
|
||||||
|
import org.nl.acs.ext.wms.data.ApplyPlugPullSitResponse;
|
||||||
|
import org.nl.acs.ext.wms.service.AcsToWmsService;
|
||||||
|
import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl;
|
||||||
|
import org.nl.acs.history.ErrorUtil;
|
||||||
|
import org.nl.acs.history.service.DeviceErrorLogService;
|
||||||
|
import org.nl.acs.history.service.impl.DeviceErrorLogServiceImpl;
|
||||||
|
import org.nl.acs.instruction.domain.Instruction;
|
||||||
|
import org.nl.acs.instruction.service.InstructionService;
|
||||||
|
import org.nl.acs.log.service.DeviceExecuteLogService;
|
||||||
|
import org.nl.acs.monitor.DeviceStageMonitor;
|
||||||
|
import org.nl.acs.opc.DeviceAppService;
|
||||||
|
import org.nl.acs.opc.DeviceAppServiceImpl;
|
||||||
|
import org.nl.acs.route.service.RouteLineService;
|
||||||
|
import org.nl.acs.route.service.impl.RouteLineServiceImpl;
|
||||||
|
import org.nl.acs.task.service.TaskService;
|
||||||
|
import org.nl.config.SpringContextHolder;
|
||||||
|
import org.nl.config.language.LangProcess;
|
||||||
|
import org.nl.config.lucene.service.LuceneExecuteLogService;
|
||||||
|
import org.nl.config.lucene.service.dto.LuceneLogDto;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 产线接驳台
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Data
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class ProductionLineDockingStationDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor {
|
||||||
|
|
||||||
|
protected ItemProtocol itemProtocol = new ItemProtocol(this);
|
||||||
|
@Autowired
|
||||||
|
DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl");
|
||||||
|
@Autowired
|
||||||
|
TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl");
|
||||||
|
@Autowired
|
||||||
|
InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl");
|
||||||
|
@Autowired
|
||||||
|
DeviceAppService deviceAppService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
|
||||||
|
@Autowired
|
||||||
|
RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineServiceImpl.class);
|
||||||
|
@Autowired
|
||||||
|
DeviceExtraService deviceExtraService = SpringContextHolder.getBean(DeviceExtraServiceImpl.class);
|
||||||
|
@Autowired
|
||||||
|
DeviceErrorLogService errorLogServer = SpringContextHolder.getBean(DeviceErrorLogServiceImpl.class);
|
||||||
|
@Autowired
|
||||||
|
AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsServiceImpl.class);
|
||||||
|
@Autowired
|
||||||
|
LuceneExecuteLogService luceneExecuteLogService = SpringContextHolder.getBean(LuceneExecuteLogService.class);
|
||||||
|
|
||||||
|
//工作模式
|
||||||
|
//0-脱机;1-弃用(留作兼容);2-待机;3-运行中;
|
||||||
|
int mode = 0;
|
||||||
|
int last_mode = 0;
|
||||||
|
//光电信号
|
||||||
|
int move = 0;
|
||||||
|
int last_move = 0;
|
||||||
|
//取放信号
|
||||||
|
int action = 0;
|
||||||
|
int last_action = 0;
|
||||||
|
//报警信号
|
||||||
|
int error = 0;
|
||||||
|
int last_error = 0;
|
||||||
|
//任务号
|
||||||
|
|
||||||
|
int heartbeat = 0;
|
||||||
|
int last_heartbeat = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 请求成功标记
|
||||||
|
*/
|
||||||
|
Boolean requireSucess = false;
|
||||||
|
|
||||||
|
|
||||||
|
/** 下发命令: 1-到达取货点(取货申请);2-取货完成;3-到达放货点(放货申请);4-放货完成;5-复位;99-失败 */
|
||||||
|
int to_command = 0;
|
||||||
|
int last_to_command = 0;
|
||||||
|
|
||||||
|
Boolean isonline = true;
|
||||||
|
int hasGoods = 0;
|
||||||
|
String message = null;
|
||||||
|
Boolean iserror = false;
|
||||||
|
String device_code;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Device getDevice() {
|
||||||
|
return this.device;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute() throws Exception {
|
||||||
|
// 具体业务
|
||||||
|
try {
|
||||||
|
device_code = this.getDeviceCode();
|
||||||
|
heartbeat = itemProtocol.getHeartbeat();
|
||||||
|
mode = itemProtocol.getMode();
|
||||||
|
action = itemProtocol.getAction();
|
||||||
|
move = itemProtocol.getMove();
|
||||||
|
error = itemProtocol.getError();
|
||||||
|
} catch (Exception e) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//信号日志
|
||||||
|
if (mode != last_mode) {
|
||||||
|
LuceneLogDto logDto = LuceneLogDto.builder()
|
||||||
|
.device_code(device_code)
|
||||||
|
.content("信号" + this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.device_code + "." + ItemProtocol.item_mode + "变更从" + this.last_mode + "->" + this.mode)
|
||||||
|
.build();
|
||||||
|
logDto.setLog_level(2);
|
||||||
|
luceneExecuteLogService.deviceExecuteLog(logDto);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (action != last_action) {
|
||||||
|
LuceneLogDto logDto = LuceneLogDto.builder()
|
||||||
|
.device_code(device_code)
|
||||||
|
.content("信号" + this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.device_code + "." + ItemProtocol.item_action + "变更从" + this.last_action + "->" + this.action)
|
||||||
|
.build();
|
||||||
|
logDto.setLog_level(2);
|
||||||
|
luceneExecuteLogService.deviceExecuteLog(logDto);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (move != last_move) {
|
||||||
|
LuceneLogDto logDto = LuceneLogDto.builder()
|
||||||
|
.device_code(device_code)
|
||||||
|
.content("信号" + this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.device_code + "." + ItemProtocol.item_move + "变更从" + this.last_move + "->" + this.move)
|
||||||
|
.build();
|
||||||
|
logDto.setLog_level(2);
|
||||||
|
luceneExecuteLogService.deviceExecuteLog(logDto);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!this.itemProtocol.getIsonline()) {
|
||||||
|
this.setIsonline(false);
|
||||||
|
this.setIserror(true);
|
||||||
|
//未联机
|
||||||
|
} else if (mode == 0) {
|
||||||
|
this.setIsonline(false);
|
||||||
|
this.setIserror(true);
|
||||||
|
//有报警
|
||||||
|
} else {
|
||||||
|
this.setIsonline(true);
|
||||||
|
this.setIserror(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
last_mode = mode;
|
||||||
|
last_action = action;
|
||||||
|
last_move = move;
|
||||||
|
last_error = error;
|
||||||
|
last_to_command = to_command;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void writing(Map<String, Object> map) throws Exception {
|
||||||
|
Map<String, Object> itemMap = new LinkedHashMap<>();
|
||||||
|
map.forEach((key, value) -> {
|
||||||
|
if (ObjectUtil.isNotEmpty(value)) {
|
||||||
|
itemMap.put(getToParam(key), value);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (ObjectUtil.isNotEmpty(itemMap)) {
|
||||||
|
this.checkcontrol(itemMap);
|
||||||
|
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 void writing(String commandKey, int command) {
|
||||||
|
Map<String, Object> itemMap = new HashMap<>();
|
||||||
|
itemMap.put(getToParam(commandKey), command);
|
||||||
|
this.control(itemMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getToParam(String key) {
|
||||||
|
return this.getDevice().getOpc_server_code()
|
||||||
|
+ "." + this.getDevice().getOpc_plc_code()
|
||||||
|
+ "." + this.getDevice().getDevice_code()
|
||||||
|
+ "." + key;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public JSONObject getDeviceStatusName() throws Exception {
|
||||||
|
JSONObject jo = new JSONObject();
|
||||||
|
String mode = "";
|
||||||
|
String move = "";
|
||||||
|
String action = "";
|
||||||
|
if (this.getMode() == 0) {
|
||||||
|
mode = LangProcess.msg("universal_off-line");
|
||||||
|
} else if (this.getMode() == 1) {
|
||||||
|
mode = LangProcess.msg("universal_stand-alone");
|
||||||
|
} else if (this.getMode() == 2) {
|
||||||
|
mode = LangProcess.msg("universal_standby");
|
||||||
|
} else if (this.getMode() == 3) {
|
||||||
|
mode = LangProcess.msg("universal_operation");
|
||||||
|
}
|
||||||
|
if (this.getMove() == 0) {
|
||||||
|
move = LangProcess.msg("universal_no");
|
||||||
|
jo.put("hasGoods", false);
|
||||||
|
} else if (this.getMove() == 1) {
|
||||||
|
move = LangProcess.msg("universal_yes");
|
||||||
|
jo.put("hasGoods", true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(this.getAction() == 1){
|
||||||
|
action = LangProcess.msg("universal_allow");
|
||||||
|
} else if(this.getAction() == 0){
|
||||||
|
action = LangProcess.msg("universal_not_allow");
|
||||||
|
}
|
||||||
|
jo.put("device_name", this.getDevice().getDevice_name());
|
||||||
|
jo.put("mode", mode);
|
||||||
|
jo.put("move", move);
|
||||||
|
jo.put("action", action);
|
||||||
|
jo.put("isOnline", true);
|
||||||
|
// jo.put("error", ErrorUtil.getDictDetail("gxhj_error_type", String.valueOf(this.getError())));
|
||||||
|
// jo.put("isError", this.getIserror());
|
||||||
|
return jo;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setDeviceStatus(JSONObject data) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
/**
|
||||||
|
* 产线接驳台驱动
|
||||||
|
* @Author: zhengxuming
|
||||||
|
* @Date: 2025年8月13日17:54:39
|
||||||
|
*/
|
||||||
|
package org.nl.acs.device_driver.zz_driver.production_line_docking_station;
|
||||||
@@ -0,0 +1,110 @@
|
|||||||
|
package org.nl.acs.device_driver.zz_driver.remove_seal_cover_position;
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 拆封盖对接位
|
||||||
|
* zhengxuming
|
||||||
|
* 2025年8月26日14:46:21
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Data
|
||||||
|
public class
|
||||||
|
ItemProtocol {
|
||||||
|
|
||||||
|
//心跳
|
||||||
|
public static String item_heartbeat = "heartbeat";
|
||||||
|
//工作模式 0-脱机;1-弃用(留作兼容);2-待机;3-运行中;
|
||||||
|
public static String item_mode = "mode";
|
||||||
|
//取放信号
|
||||||
|
public static String item_action = "action";
|
||||||
|
//报警
|
||||||
|
public static String item_error = "error";
|
||||||
|
//任务号
|
||||||
|
public static String item_task = "task";
|
||||||
|
/**
|
||||||
|
* 1-到达取货点(取货申请);2-取货完成;3-到达放货点(放货申请);4-放货完成;5-复位;99-失败
|
||||||
|
*/
|
||||||
|
public static String item_to_command = "to_command";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private RemoveSealCoverPositionDriver driver;
|
||||||
|
|
||||||
|
public ItemProtocol(RemoveSealCoverPositionDriver driver){
|
||||||
|
this.driver=driver;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getHeartbeat() {
|
||||||
|
return this.getOpcIntegerValue(item_heartbeat);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMode() {
|
||||||
|
return this.getOpcIntegerValue(item_mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getAction() {
|
||||||
|
return this.getOpcIntegerValue(item_action);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getError() {
|
||||||
|
return this.getOpcIntegerValue(item_error);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getTask() {
|
||||||
|
return this.getOpcIntegerValue(item_task);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getTo_command() {
|
||||||
|
return getOpcIntegerValue(item_to_command);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Boolean isonline;
|
||||||
|
|
||||||
|
public int getOpcIntegerValue(String protocol) {
|
||||||
|
Integer value = this.driver.getIntegeregerValue(protocol);
|
||||||
|
if (value == null) {
|
||||||
|
// log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!");
|
||||||
|
setIsonline(false);
|
||||||
|
} else {
|
||||||
|
setIsonline(true);
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getOpcStringValue(String protocol) {
|
||||||
|
String value = this.driver.getStringValue(protocol);
|
||||||
|
if (StrUtil.isBlank(value)) {
|
||||||
|
|
||||||
|
} else {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<ItemDto> getReadableItemDtos() {
|
||||||
|
ArrayList<ItemDto> list = new ArrayList<>();
|
||||||
|
list.add(new ItemDto(item_heartbeat, "心跳", "DB1.B0"));
|
||||||
|
list.add(new ItemDto(item_mode, "工作模式", "DB1.B2"));
|
||||||
|
list.add(new ItemDto(item_action, "取放信号", "DB1.B4"));
|
||||||
|
list.add(new ItemDto(item_error, "报警信号", "DB1.B5"));
|
||||||
|
list.add(new ItemDto(item_task, "任务号", "DB1.B6"));
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<ItemDto> getWriteableItemDtos() {
|
||||||
|
ArrayList<ItemDto> list = new ArrayList<>();
|
||||||
|
list.add(new ItemDto(item_to_command, "下发命令", "DB2.W0"));
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
package org.nl.acs.device_driver.zz_driver.remove_seal_cover_position;
|
||||||
|
|
||||||
|
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 RemoveSealCoverPositionDefination implements OpcDeviceDriverDefination {
|
||||||
|
@Override
|
||||||
|
public String getDriverCode() {
|
||||||
|
return "remove_seal_cover_position";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDriverName() {
|
||||||
|
return "拆封盖对接位";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDriverDescription() {
|
||||||
|
return "拆封盖对接位";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DeviceDriver getDriverInstance(Device device) {
|
||||||
|
return (new RemoveSealCoverPositionDriver()).setDevice(device).setDriverDefination(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<? extends DeviceDriver> getDeviceDriverType() {
|
||||||
|
return RemoveSealCoverPositionDriver.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<DeviceType> getFitDeviceTypes() {
|
||||||
|
List<DeviceType> types = new LinkedList();
|
||||||
|
types.add(DeviceType.robot);
|
||||||
|
return types;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<ItemDto> getReadableItemDtos() {
|
||||||
|
return ItemProtocol.getReadableItemDtos();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<ItemDto> getWriteableItemDtos() {
|
||||||
|
return ItemProtocol.getWriteableItemDtos();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,243 @@
|
|||||||
|
package org.nl.acs.device_driver.zz_driver.remove_seal_cover_position;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
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.DeviceExtraService;
|
||||||
|
import org.nl.acs.device.service.impl.DeviceExtraServiceImpl;
|
||||||
|
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.history.service.DeviceErrorLogService;
|
||||||
|
import org.nl.acs.history.service.impl.DeviceErrorLogServiceImpl;
|
||||||
|
import org.nl.acs.instruction.service.InstructionService;
|
||||||
|
import org.nl.acs.log.service.DeviceExecuteLogService;
|
||||||
|
import org.nl.acs.monitor.DeviceStageMonitor;
|
||||||
|
import org.nl.acs.opc.DeviceAppService;
|
||||||
|
import org.nl.acs.opc.DeviceAppServiceImpl;
|
||||||
|
import org.nl.acs.route.service.RouteLineService;
|
||||||
|
import org.nl.acs.route.service.impl.RouteLineServiceImpl;
|
||||||
|
import org.nl.acs.task.service.TaskService;
|
||||||
|
import org.nl.config.SpringContextHolder;
|
||||||
|
import org.nl.config.language.LangProcess;
|
||||||
|
import org.nl.config.lucene.service.LuceneExecuteLogService;
|
||||||
|
import org.nl.config.lucene.service.dto.LuceneLogDto;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 拆封盖对接位
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Data
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class RemoveSealCoverPositionDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor {
|
||||||
|
|
||||||
|
protected ItemProtocol itemProtocol = new ItemProtocol(this);
|
||||||
|
@Autowired
|
||||||
|
DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl");
|
||||||
|
@Autowired
|
||||||
|
TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl");
|
||||||
|
@Autowired
|
||||||
|
InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl");
|
||||||
|
@Autowired
|
||||||
|
DeviceAppService deviceAppService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
|
||||||
|
@Autowired
|
||||||
|
RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineServiceImpl.class);
|
||||||
|
@Autowired
|
||||||
|
DeviceExtraService deviceExtraService = SpringContextHolder.getBean(DeviceExtraServiceImpl.class);
|
||||||
|
@Autowired
|
||||||
|
DeviceErrorLogService errorLogServer = SpringContextHolder.getBean(DeviceErrorLogServiceImpl.class);
|
||||||
|
@Autowired
|
||||||
|
AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsServiceImpl.class);
|
||||||
|
@Autowired
|
||||||
|
LuceneExecuteLogService luceneExecuteLogService = SpringContextHolder.getBean(LuceneExecuteLogService.class);
|
||||||
|
|
||||||
|
//工作模式
|
||||||
|
//0-脱机;1-弃用(留作兼容);2-待机;3-运行中;
|
||||||
|
int mode = 0;
|
||||||
|
int last_mode = 0;
|
||||||
|
|
||||||
|
//取放信号
|
||||||
|
int action = 0;
|
||||||
|
int last_action = 0;
|
||||||
|
//报警信号
|
||||||
|
int error = 0;
|
||||||
|
int last_error = 0;
|
||||||
|
//任务号
|
||||||
|
int task = 0;
|
||||||
|
int last_task = 0;
|
||||||
|
|
||||||
|
int heartbeat = 0;
|
||||||
|
int last_heartbeat = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 请求成功标记
|
||||||
|
*/
|
||||||
|
Boolean requireSucess = false;
|
||||||
|
|
||||||
|
|
||||||
|
/** 下发命令: 1-到达取货点(取货申请);2-取货完成;3-到达放货点(放货申请);4-放货完成;5-复位;99-失败 */
|
||||||
|
int to_command = 0;
|
||||||
|
int last_to_command = 0;
|
||||||
|
|
||||||
|
Boolean isonline = true;
|
||||||
|
int hasGoods = 0;
|
||||||
|
String message = null;
|
||||||
|
Boolean iserror = false;
|
||||||
|
String device_code;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Device getDevice() {
|
||||||
|
return this.device;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute() throws Exception {
|
||||||
|
// 具体业务
|
||||||
|
try {
|
||||||
|
device_code = this.getDeviceCode();
|
||||||
|
heartbeat = itemProtocol.getHeartbeat();
|
||||||
|
mode = itemProtocol.getMode();
|
||||||
|
action = itemProtocol.getAction();
|
||||||
|
task = itemProtocol.getTask();
|
||||||
|
error = itemProtocol.getError();
|
||||||
|
} catch (Exception e) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//信号日志
|
||||||
|
if (mode != last_mode) {
|
||||||
|
LuceneLogDto logDto = LuceneLogDto.builder()
|
||||||
|
.device_code(device_code)
|
||||||
|
.content("信号" + this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.device_code + "." + ItemProtocol.item_mode + "变更从" + this.last_mode + "->" + this.mode)
|
||||||
|
.build();
|
||||||
|
logDto.setLog_level(2);
|
||||||
|
luceneExecuteLogService.deviceExecuteLog(logDto);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (action != last_action) {
|
||||||
|
LuceneLogDto logDto = LuceneLogDto.builder()
|
||||||
|
.device_code(device_code)
|
||||||
|
.content("信号" + this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.device_code + "." + ItemProtocol.item_action + "变更从" + this.last_action + "->" + this.action)
|
||||||
|
.build();
|
||||||
|
logDto.setLog_level(2);
|
||||||
|
luceneExecuteLogService.deviceExecuteLog(logDto);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (task != last_task) {
|
||||||
|
LuceneLogDto logDto = LuceneLogDto.builder()
|
||||||
|
.device_code(device_code)
|
||||||
|
.content("信号" + this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.device_code + "." + ItemProtocol.item_task + "变更从" + this.last_task + "->" + this.task)
|
||||||
|
.build();
|
||||||
|
logDto.setLog_level(2);
|
||||||
|
luceneExecuteLogService.deviceExecuteLog(logDto);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!this.itemProtocol.getIsonline()) {
|
||||||
|
this.setIsonline(false);
|
||||||
|
this.setIserror(true);
|
||||||
|
//未联机
|
||||||
|
} else if (mode == 0) {
|
||||||
|
this.setIsonline(false);
|
||||||
|
this.setIserror(true);
|
||||||
|
//有报警
|
||||||
|
} else {
|
||||||
|
this.setIsonline(true);
|
||||||
|
this.setIserror(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
last_mode = mode;
|
||||||
|
last_action = action;
|
||||||
|
last_task = task;
|
||||||
|
last_error = error;
|
||||||
|
last_to_command = to_command;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void writing(Map<String, Object> map) throws Exception {
|
||||||
|
Map<String, Object> itemMap = new LinkedHashMap<>();
|
||||||
|
map.forEach((key, value) -> {
|
||||||
|
if (ObjectUtil.isNotEmpty(value)) {
|
||||||
|
itemMap.put(getToParam(key), value);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (ObjectUtil.isNotEmpty(itemMap)) {
|
||||||
|
this.checkcontrol(itemMap);
|
||||||
|
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 void writing(String commandKey, int command) {
|
||||||
|
Map<String, Object> itemMap = new HashMap<>();
|
||||||
|
itemMap.put(getToParam(commandKey), command);
|
||||||
|
this.control(itemMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getToParam(String key) {
|
||||||
|
return this.getDevice().getOpc_server_code()
|
||||||
|
+ "." + this.getDevice().getOpc_plc_code()
|
||||||
|
+ "." + this.getDevice().getDevice_code()
|
||||||
|
+ "." + key;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public JSONObject getDeviceStatusName() throws Exception {
|
||||||
|
JSONObject jo = new JSONObject();
|
||||||
|
String mode = "";
|
||||||
|
String task = "";
|
||||||
|
String action = "";
|
||||||
|
if (this.getMode() == 0) {
|
||||||
|
mode = LangProcess.msg("universal_off-line");
|
||||||
|
} else if (this.getMode() == 1) {
|
||||||
|
//
|
||||||
|
mode = LangProcess.msg("universal_stand-alone");
|
||||||
|
} else if (this.getMode() == 2) {
|
||||||
|
mode = LangProcess.msg("universal_standby");
|
||||||
|
} else if (this.getMode() == 3) {
|
||||||
|
mode = LangProcess.msg("universal_running");
|
||||||
|
} else if (this.getMode() == 4) {
|
||||||
|
mode = LangProcess.msg("universal_open_finish");
|
||||||
|
} else if (this.getMode() == 5) {
|
||||||
|
mode = LangProcess.msg("universal_close_finish");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(this.getAction() == 1){
|
||||||
|
action = LangProcess.msg("universal_allow");
|
||||||
|
} else if(this.getAction() == 0){
|
||||||
|
action = LangProcess.msg("universal_not_allow");
|
||||||
|
}
|
||||||
|
jo.put("device_name", this.getDevice().getDevice_name());
|
||||||
|
jo.put("mode", mode);
|
||||||
|
jo.put("task", task);
|
||||||
|
jo.put("action", action);
|
||||||
|
jo.put("isOnline", true);
|
||||||
|
// jo.put("error", ErrorUtil.getDictDetail("gxhj_error_type", String.valueOf(this.getError())));
|
||||||
|
// jo.put("isError", this.getIserror());
|
||||||
|
return jo;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setDeviceStatus(JSONObject data) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
/**
|
||||||
|
* 产线接驳台驱动
|
||||||
|
* @Author: zhengxuming
|
||||||
|
* @Date: 2025年8月13日17:54:39
|
||||||
|
*/
|
||||||
|
package org.nl.acs.device_driver.zz_driver.remove_seal_cover_position;
|
||||||
Reference in New Issue
Block a user