add:添加驱动

This commit is contained in:
2024-01-09 13:19:16 +08:00
parent 7ef90eb8e6
commit ce6f38597c
10 changed files with 731 additions and 221 deletions

View File

@@ -11,75 +11,45 @@ import java.util.List;
@Data
public class ItemProtocol {
/**
* 1/0 手动/自动
*/
//心跳
public static String item_heartbeat = "heartbeat";
//工作模式
public static String item_mode = "mode";
/**
* 0/1 半自动/全自动
*/
public static String item_action = "action";
/**
* 0/1 远程/本地控制
*/
public static String item_control = "control";
/**
* 2 运行中
* 1 急停/故障
* 0 待机中
*/
public static String item_status = "status";
/**
* 1 机头上有轴
*/
//光电信号
public static String item_move = "move";
/**
* 1/0 穿轴中/穿轴完成
*/
public static String item_plug_finish = "plug_finish";
/**
* 1/0 把轴中/拔轴完成
*/
public static String item_pull_finish = "pull_finish";
/**
* 3寸轴穿轴次数
*/
public static String item_3plug_times = "3plug_times";
/**
* 6寸轴穿轴次数
*/
public static String item_6plug_times = "6plug_times";
/**
* 3寸轴拔轴次数
*/
public static String item_3pull_times = "3pull_times";
/**
* 6寸轴拔轴次数
*/
public static String item_6pull_times = "6pull_times";
/**
* 穿轴总次数
*/
public static String item_plug_alltimes = "plug_alltimes";
/**
* 拔轴总次数
*/
public static String item_pull_alltimes = "pull_alltimes";
//动作信号
public static String item_action = "action";
//任务号
public static String item_task = "task";
//报警
public static String item_error = "error";
//气涨轴条码
public static String item_barcode = "barcode";
//纸管1重量
public static String item_weight1 = "weight1";
//纸管1规格
public static String item_material1 = "material1";
//纸管2重量
public static String item_weight2 = "weight2";
//纸管2规格
public static String item_material2 = "material2";
/**
* 1 全自动启动
*/
//下发命令
public static String item_to_command = "to_command";
/**
* 0/1 穿轴/拔轴
*/
public static String item_to_type = "to_type";
/**
* 3/6 轴尺寸
*/
//纸管1规格
public static String item_to_material1 = "to_material1";
//纸管2规格
public static String item_to_material2 = "to_material2";
//纸管数量
public static String item_to_qty = "to_qty";
//气涨轴类型
public static String item_to_qzz_type = "to_qzz_type";
//是否换轴
public static String item_to_is_changeShaft = "to_is_changeShaft";
//尺寸
public static String item_to_size = "to_size";
//存储位置
public static String item_to_location = "to_location";
private PlugPullDeviceSiteDeviceDriver driver;
@@ -87,85 +57,71 @@ public class ItemProtocol {
this.driver = driver;
}
public int getItem_mode() {
public int getHeartbeat() {
return this.getOpcIntegerValue(item_heartbeat);
}
public int getMode() {
return this.getOpcIntegerValue(item_mode);
}
;
public int getItem_move() {
public int getMove() {
return this.getOpcIntegerValue(item_move);
}
;
public int getItem_action() {
public int getAction() {
return this.getOpcIntegerValue(item_action);
}
;
public int getItem_control() {
return this.getOpcIntegerValue(item_control);
public int getError() {
return this.getOpcIntegerValue(item_error);
}
;
public int getItem_status() {
return this.getOpcIntegerValue(item_status);
public int getTask() {
return this.getOpcIntegerValue(item_task);
}
;
public int getBarcode(){ return this.getOpcIntegerValue(item_barcode);}
public int getItem_plug_finish() {
return this.getOpcIntegerValue(item_plug_finish);
public int getWeight1(){ return this.getOpcIntegerValue(item_weight1);}
public int getMaterial1(){ return this.getOpcIntegerValue(item_material1);}
public int getWeight2(){ return this.getOpcIntegerValue(item_weight2);}
public int getMaterial2(){ return this.getOpcIntegerValue(item_material2);}
public int getTo_command() {
return this.getOpcIntegerValue(item_to_command);
}
;
public int getItem_pull_finish() {
return this.getOpcIntegerValue(item_pull_finish);
public int getTo_material1() {
return this.getOpcIntegerValue(item_to_material1);
}
;
public int getItem_3plug_times() {
return this.getOpcIntegerValue(item_3plug_times);
public int getTo_material2() {
return this.getOpcIntegerValue(item_to_material2);
}
;
public int getItem_6plug_times() {
return this.getOpcIntegerValue(item_6plug_times);
public int getTo_qty() {
return this.getOpcIntegerValue(item_to_qty);
}
;
public int getItem_3pull_times() {
return this.getOpcIntegerValue(item_3pull_times);
public int getTo_qzz_type() {
return this.getOpcIntegerValue(item_to_qzz_type);
}
;
public int getItem_6pull_times() {
return this.getOpcIntegerValue(item_6pull_times);
public int getTo_is_changeShaft() {
return this.getOpcIntegerValue(item_to_is_changeShaft);
}
;
public int getItem_plug_alltimes() {
return this.getOpcIntegerValue(item_plug_alltimes);
public int getTo_size() {
return this.getOpcIntegerValue(item_to_size);
}
;
public int getItem_pull_alltimes() {
return this.getOpcIntegerValue(item_pull_alltimes);
public int getTo_location() {
return this.getOpcIntegerValue(item_to_location);
}
;
Boolean isonline;
public int getOpcIntegerValue(String protocol) {
@@ -195,27 +151,30 @@ public class ItemProtocol {
public static List<ItemDto> getReadableItemDtos() {
ArrayList list = new ArrayList();
list.add(new ItemDto(item_mode, "工作模式", "30243"));
list.add(new ItemDto(item_action, "半自动/全自动", "30245"));
list.add(new ItemDto(item_control, "远程控制", "30254"));
list.add(new ItemDto(item_status, "状态", "30181"));
list.add(new ItemDto(item_move, "机头上有轴", "30252"));
list.add(new ItemDto(item_plug_finish, "穿轴完成", "30249"));
list.add(new ItemDto(item_pull_finish, "拔轴完成", "30250"));
list.add(new ItemDto(item_3plug_times, "3寸轴穿轴次数", "30231"));
list.add(new ItemDto(item_6plug_times, "6寸轴穿轴次数", "30235"));
list.add(new ItemDto(item_3pull_times, "3寸轴拔轴次数", "30233"));
list.add(new ItemDto(item_6pull_times, "6寸轴拔轴次数", "30237"));
list.add(new ItemDto(item_plug_alltimes, "穿轴总次数", "30239"));
list.add(new ItemDto(item_pull_alltimes, "拔轴总次数", "30241"));
list.add(new ItemDto(item_heartbeat, "心跳", "DB1.B0"));
list.add(new ItemDto(item_mode, "工作模式", "DB1.B1"));
list.add(new ItemDto(item_move, "光电信号", "DB1.B2"));
list.add(new ItemDto(item_action, "动作信号", "DB1.B3"));
list.add(new ItemDto(item_barcode, "气胀轴条码", "DB1.B4"));
list.add(new ItemDto(item_weight1, "纸管1重量", "DB1.B4"));
list.add(new ItemDto(item_material1, "纸管1规格", "DB1.B4"));
list.add(new ItemDto(item_weight2, "纸管2重量", "DB1.B4"));
list.add(new ItemDto(item_material2, "纸管2规格", "DB1.B4"));
list.add(new ItemDto(item_error, "报警信号", "DB1.B5"));
list.add(new ItemDto(item_task, "任务号", "DB1.D6"));
return list;
}
public static List<ItemDto> getWriteableItemDtos() {
ArrayList list = new ArrayList();
list.add(new ItemDto(item_to_command, "下发命令", "40246"));
list.add(new ItemDto(item_to_type, "类型", "40244"));
list.add(new ItemDto(item_to_size, "尺寸", "40247"));
list.add(new ItemDto(item_to_command, "下发命令", "DB2.W0"));
list.add(new ItemDto(item_to_material1, "纸管1规格", "DB2.W2"));
list.add(new ItemDto(item_to_material2, "纸管2规格", "DB2.W4"));
list.add(new ItemDto(item_to_qty, "纸管数量", "DB2.W6"));
list.add(new ItemDto(item_to_qzz_type, "气胀轴类型", "DB2.W8"));
list.add(new ItemDto(item_to_is_changeShaft, "是否换轴", "DB2.W"));
list.add(new ItemDto(item_to_location, "存储位置", "DB2.W10"));
list.add(new ItemDto(item_to_size, "尺寸", "DB2.W12"));
return list;
}

View File

@@ -1,5 +1,6 @@
package org.nl.acs.device_driver.conveyor.plug_pull_device_site;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject;
import lombok.Data;
@@ -14,6 +15,7 @@ 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.domain.Instruction;
import org.nl.acs.instruction.service.InstructionService;
import org.nl.acs.log.service.DeviceExecuteLogService;
import org.nl.acs.monitor.DeviceStageMonitor;
@@ -58,32 +60,71 @@ public class PlugPullDeviceSiteDeviceDriver extends AbstractOpcDeviceDriver impl
private Date instruction_apply_time = new Date();
private int instruction_require_time_out = 3000;
public int mode = 0;
public int move = 0;
public int action = 0;
public int status = 0;
public int control = 0;
public int plug_finish = 0;
public int pull_finish = 0;
public int plug3_times = 0;
public int plug6_times = 0;
public int pull3_times = 0;
public int pull6_times = 0;
public int plug_alltimes = 0;
public int pull_alltimes = 0;
//工作模式
int mode = 0;
int last_mode = 0;
//光电信号
int move = 0;
int last_move = 0;
//动作信号
int action = 0;
int last_action = 0;
public int last_mode = 0;
public int last_move = 0;
public int last_action = 0;
public int last_status = 0;
public int last_control = 0;
public int last_plug_finish = 0;
public int last_pull_finish = 0;
//报警信号
int error = 0;
int last_error = 0;
//任务号
int task = 0;
int last_task = 0;
int heartbeat = 0;
int last_heartbeat = 0;
int to_command = 0;
int last_to_command = 0;
//气胀轴条码
int barcode =0;
int last_barcode =0;
//纸管1重量
int weight1 =0;
int last_weight1 =0;
//纸管1规格
int material1 =0;
int last_material1 =0;
//纸管2重量
int weight2 =0;
int last_weight2 =0;
//纸管2规格
int material2 =0;
int last_material2 =0;
int to_size = 0;
int last_to_size = 0;
int to_material1 = 0;
int last_to_material1 = 0;
int to_material2 = 0;
int last_to_material2 = 0;
int to_qty = 0;
int last_to_qty = 0;
int to_qzz_type = 0;
int last_to_qzz_type = 0;
int to_is_changeShaft = 0;
int last_to_is_changeShaft = 0;
int to_location = 0;
int last_to_location = 0;
Boolean isonline = true;
Boolean iserror = false;
//当前指令
Instruction inst = null;
/**
* 1-执行任务2-取货完成3-放货完成;
@@ -92,6 +133,8 @@ public class PlugPullDeviceSiteDeviceDriver extends AbstractOpcDeviceDriver impl
String device_code;
String message = null;
@Override
public Device getDevice() {
return this.device;
@@ -101,40 +144,213 @@ public class PlugPullDeviceSiteDeviceDriver extends AbstractOpcDeviceDriver impl
* 请求成功标记
*/
Boolean requireSucess = false;
String feedMessage = "";
@Override
public void execute() {
String message = null;
device_code = this.getDeviceCode();
mode = this.itemProtocol.getItem_mode();
move = this.itemProtocol.getItem_move();
action = this.itemProtocol.getItem_action();
status = this.itemProtocol.getItem_status();
control = this.itemProtocol.getItem_control();
plug_finish = this.itemProtocol.getItem_plug_finish();
pull_finish = this.itemProtocol.getItem_pull_finish();
plug3_times = this.itemProtocol.getItem_3plug_times();
plug6_times = this.itemProtocol.getItem_6plug_times();
pull3_times = this.itemProtocol.getItem_3pull_times();
pull6_times = this.itemProtocol.getItem_6pull_times();
plug_alltimes = this.itemProtocol.getItem_plug_alltimes();
pull_alltimes = this.itemProtocol.getItem_pull_alltimes();
mode = this.itemProtocol.getMode();
move = this.itemProtocol.getMove();
action = this.itemProtocol.getAction();
error = this.itemProtocol.getError();
task = this.itemProtocol.getTask();
heartbeat = this.itemProtocol.getHeartbeat();
barcode = this.itemProtocol.getBarcode();
weight1 = this.itemProtocol.getWeight1();
material1 = this.itemProtocol.getMaterial1();
weight2 = this.itemProtocol.getWeight2();
material2 = this.itemProtocol.getMaterial2();
to_command = this.itemProtocol.getTo_command();
to_material1 = this.itemProtocol.getTo_material1();
to_material2 = this.itemProtocol.getTo_material2();
to_qty = this.itemProtocol.getTo_qty();
to_qzz_type=this.itemProtocol.getTo_qzz_type();
to_is_changeShaft=this.itemProtocol.getTo_is_changeShaft();
to_location=this.itemProtocol.getTo_location();
to_size = this.itemProtocol.getTo_size();
if (mode != last_mode) {
requireSucess = false;
logServer.deviceItemValue(this.device_code, "mode", String.valueOf(mode));
logServer.deviceExecuteLog(this.device_code, "", "", "信号mode" + last_mode + "->" + mode);
}
if (move != last_move) {
logServer.deviceItemValue(this.device_code, "move", String.valueOf(move));
logServer.deviceExecuteLog(this.device_code, "", "", "信号move" + last_move + "->" + move);
}
if (action != last_action) {
logServer.deviceItemValue(this.device_code, "action", String.valueOf(action));
logServer.deviceExecuteLog(this.device_code, "", "", "信号action" + last_action + "->" + action);
}
if (error != last_error) {
logServer.deviceItemValue(this.device_code, "error", String.valueOf(error));
logServer.deviceExecuteLog(this.device_code, "", "", "信号error" + last_error + "->" + error);
}
if (barcode != last_barcode) {
logServer.deviceItemValue(this.device_code, "walk_y", String.valueOf(barcode));
logServer.deviceExecuteLog(this.device_code, "", "", "信号barcode" + last_barcode + "->" + barcode);
}
if (weight1 != last_weight1) {
logServer.deviceItemValue(this.device_code, "walk_y", String.valueOf(weight1));
logServer.deviceExecuteLog(this.device_code, "", "", "信号weight1" + last_weight1 + "->" + weight1);
}
if (material1 != last_material1) {
logServer.deviceItemValue(this.device_code, "walk_y", String.valueOf(material1));
logServer.deviceExecuteLog(this.device_code, "", "", "信号material1" + last_material1 + "->" + material1);
}
if (weight2 != last_weight2) {
logServer.deviceItemValue(this.device_code, "walk_y", String.valueOf(weight2));
logServer.deviceExecuteLog(this.device_code, "", "", "信号weight2" + last_weight2 + "->" + weight2);
}
if (material2 != last_material2) {
logServer.deviceItemValue(this.device_code, "walk_y", String.valueOf(material2));
logServer.deviceExecuteLog(this.device_code, "", "", "信号material2" + last_material2 + "->" + material2);
}
if (task != last_task) {
logServer.deviceItemValue(this.device_code, "task", String.valueOf(task));
logServer.deviceExecuteLog(this.device_code, "", "", "信号task" + last_task + "->" + task);
}
if (to_command != last_to_command) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号to_command" + last_to_command + "->" + to_command);
}
if (to_material1 != last_to_material1) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号to_material1" + last_to_material1 + "->" + to_material1);
}
if (to_material2 != last_to_material2) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号to_material2" + last_to_material2 + "->" + to_material2);
}
if (to_qty != last_to_qty) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号to_qty" + last_to_qty + "->" + to_qty);
}
if (to_qzz_type != last_to_qzz_type) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号to_qzz_type" + last_to_qzz_type + "->" + to_qzz_type);
}
if (to_is_changeShaft != last_to_is_changeShaft) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号to_is_changeShaft" + last_to_is_changeShaft + "->" + to_is_changeShaft);
}
if (to_location != last_to_location) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号to_location" + last_to_location + "->" + to_location);
}
if (to_size != last_to_size) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号to_size" + last_to_size + "->" + to_size);
}
if (status != 1) {
if (mode == 0) {
this.setIsonline(false);
message = "未联机";
//有报警
} else if (error != 0) {
this.setIserror(true);
message = "有报警";
//无报警
} else {
this.setIsonline(true);
this.setIserror(false);
message = "";
Instruction instruction = null;
List toInstructions;
//插拔轴机工位申请任务
switch (mode) {
case 1:
log.debug("弃用(留作兼容)");
break;
case 2:
log.info("待机");
break;
case 3:
log.info("运行中");
break;
case 4:
if (move == 1 && !requireSucess && task > 0) {
//申请套管
apply_casing(mode);
}
break;
case 5:
if (!requireSucess && task > 0) {
//套管完成
bushingSucess(mode);
}
break;
case 6:
if (!requireSucess && task > 0) {
//拔轴完成
pullShaftSucess(mode);
}
break;
case 7:
if (!requireSucess && task > 0) {
//套管失败无库存
//todo
}
break;
case 8:
if (!requireSucess && task > 0) {
//缓存线已满,生成行架任务
// applyTask();
}
break;
default:
log.info("未知模式");
break;
}
}
last_mode = mode;
last_move = move;
last_action = action;
last_error = error;
last_task = task;
last_heartbeat = heartbeat;
last_barcode =barcode;
last_weight1=weight1;
last_weight2=weight2;
last_material1=material1;
last_material2=material2;
last_to_command = to_command;
last_to_material1 =to_material1;
last_to_material2 = to_material2;
last_to_qty=to_qty;
last_to_qzz_type=to_qzz_type;
last_to_is_changeShaft = to_is_changeShaft;
last_to_location=to_location;
last_to_size = to_size;
}
/**
* 申请套管
*/
private synchronized void apply_casing(int mode) {
this.writeSignal(mode);
logServer.deviceExecuteLog(this.device_code, "", "", "申请套管,返回参数:" + "applyResponse");
message = "申请套管成功";
}
/**
* 套管完成
*/
private synchronized void bushingSucess(int mode) {
this.writeSignal(mode);
logServer.deviceExecuteLog(this.device_code, "", "", "反馈套管完成,返回参数:" + "applyResponse");
message = "套管完成成功";
}
/**
* 拔轴完成
*/
private synchronized void pullShaftSucess(int mode) {
this.writeSignal(mode);
logServer.deviceExecuteLog(this.device_code, "", "", "申请拔轴,返回参数:" + "applyResponse");
message = "拔轴完成成功";
}
public void writeSignal(int mode){
Map<String, Object> map = new LinkedHashMap<>();
map.put("to_command", mode);
this.writing(map);
requireSucess = true;
}
@@ -160,6 +376,24 @@ public class PlugPullDeviceSiteDeviceDriver extends AbstractOpcDeviceDriver impl
this.control(itemMap);
}
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() + ".";
}
/**
* 将扩展表中的字符串数据转换成集合
*/

View File

@@ -7,7 +7,9 @@ import com.alibaba.fastjson.JSONObject;
import lombok.Data;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nl.acs.AcsConfig;
import org.nl.acs.agv.server.AgvService;
import org.nl.acs.common.base.CommonFinalParam;
import org.nl.acs.device.domain.Device;
import org.nl.acs.device.service.DeviceService;
import org.nl.acs.device_driver.DeviceDriver;
@@ -23,6 +25,7 @@ import org.nl.acs.history.ErrorUtil;
import org.nl.acs.history.service.DeviceErrorLogService;
import org.nl.acs.history.service.dto.DeviceErrorLogDto;
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;
@@ -31,6 +34,7 @@ import org.nl.acs.opc.DeviceAppService;
import org.nl.acs.route.service.RouteLineService;
import org.nl.acs.task.service.TaskService;
import org.nl.config.SpringContextHolder;
import org.nl.system.service.param.ISysParamService;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.*;
@@ -44,6 +48,26 @@ import java.util.*;
public class GreenFoilMachineButtonDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor, FeedLmsRealFailed {
protected ItemProtocol itemProtocol = new ItemProtocol(this);
@Autowired
InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class);
@Autowired
DeviceService deviceservice = SpringContextHolder.getBean(DeviceService.class);
@Autowired
RouteLineService routelineserver = SpringContextHolder.getBean(RouteLineService.class);
@Autowired
TaskService taskserver = SpringContextHolder.getBean(TaskService.class);
@Autowired
DeviceAppService deviceAppservice = SpringContextHolder.getBean(DeviceAppService.class);
@Autowired
RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class);
@Autowired
ISysParamService paramService = SpringContextHolder.getBean(ISysParamService.class);
@Autowired
AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsService.class);
DeviceErrorLogService deviceErrorLogService = SpringContextHolder.getBean(DeviceErrorLogServiceImpl.class);
@@ -113,6 +137,78 @@ public class GreenFoilMachineButtonDriver extends AbstractOpcDeviceDriver implem
logServer.deviceExecuteLog(this.device_code, "", "", "信号error" + last_error + "->" + error);
}
if (mode == 0) {
this.setIsonline(false);
message = "未联机";
// 有报警
// } else if (error != 0) {
// this.setIsonline(false);
// this.setIserror(true);
// message = "有报警";
// //无报警
} else {
this.setIsonline(true);
this.setIserror(false);
if (error != 0) {
this.setIserror(true);
message = "有报警";
}
message = "";
Instruction instruction = null;
List toInstructions;
switch (mode) {
case 2:
log.debug("设备运转模式:等待工作");
break;
case 3:
log.debug("设备运转模式:等待工作");
break;
case 4:
// 申请AGV取空取满放空放满任务
if (move > 0 && !requireSucess) {
// applyFourPointAgvTask();
}
break;
case 5:
/**
* 申请AGV取空放空的任务
*/
if (move > 0 && !requireSucess) {
applyTakeEmptyAgvTask();
}
break;
case 6:
// 申请取满放满任务
if (move > 0 && !requireSucess) {
// applyTakeFullAgvTask();
}
break;
case 7:
// 允许AGV进入
if (move == 0 && !requireSucess) {
// allowAgvEntry();
}
break;
case 8:
// 允许AGV离开
if (move == 0 && !requireSucess) {
// allowAgvLeave();
}
break;
case 9:
// 取消任务
if (move == 0 && !requireSucess) {
// cancelTask();
}
break;
default:
break;
}
}
last_mode = mode;
last_move = move;
last_action = action;
@@ -120,6 +216,39 @@ public class GreenFoilMachineButtonDriver extends AbstractOpcDeviceDriver implem
}
/**
* 申请AGV取空放空的任务
*/
public synchronized void applyTakeEmptyAgvTask() {
Date date = new Date();
if (date.getTime() - this.instruction_require_time.getTime()
< (long) this.instruction_require_time_out) {
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out);
return;
} else {
this.instruction_require_time = date;
if (StrUtil.equals(paramService.findByCode(AcsConfig.HASWMS).getValue(), CommonFinalParam.ONE)) {
message = "申请AGV搬运任务中...";
JSONObject apply = new JSONObject();
apply.put("device_code", device_code);
apply.put("type", CommonFinalParam.ONE);
String str = acsToWmsService.applyTaskToWms(apply);
JSONObject jo = JSON.parseObject(str);
if (ObjectUtil.isEmpty(jo)) {
message = "申请AGV搬运任务接口不通";
} else {
if (jo.getInteger("status") == 200) {
message = "申请AGV搬运任务成功";
requireSucess = true;
} else {
requireSucess = false;
message = "申请AGV搬运任务失败," + jo.get("message").toString();
}
}
}
}
}

View File

@@ -38,6 +38,21 @@ public class ItemProtocol {
public static String item_to_target = "to_target";
//下发任务号
public static String item_to_task = "to_task";
//是否拔轴
public static String item_to_pull = "to_pull";
//是否套轴
public static String item_to_sleeve = "to_sleeve";
//尺寸
public static String item_to_size = "to_size";
//代数
public static String item_to_version = "to_version";
//子卷数量
public static String item_to_qty = "to_qty";
//子卷1长度
public static String item_to_length1 = "to_length1";
//子卷2长度
public static String item_to_length2 = "to_length2";
private PullHeadManipulatorDeviceDriver driver;
@@ -77,6 +92,26 @@ public class ItemProtocol {
return this.getOpcIntegerValue(item_to_task);
}
public int getTo_pull() {
return this.getOpcIntegerValue(item_to_pull);
}
public int getTo_sleeve() {
return this.getOpcIntegerValue(item_to_sleeve);
}
public int getTo_size() {
return this.getOpcIntegerValue(item_to_size);
}
public int getTo_version() {
return this.getOpcIntegerValue(item_to_version);
}
public int getTo_qty() {
return this.getOpcIntegerValue(item_to_qty);
}
public int getTo_onset() {
return this.getOpcIntegerValue(item_to_onset);
}
@@ -97,6 +132,14 @@ public class ItemProtocol {
return this.getOpcFloatValue(item_y_position);
}
public float getTo_length1() {
return this.getOpcFloatValue(item_to_length1);
}
public float getTo_length2() {
return this.getOpcFloatValue(item_to_length2);
}
Boolean isonline;
public int getOpcIntegerValue(String protocol) {
@@ -155,6 +198,13 @@ public class ItemProtocol {
list.add(new ItemDto(item_to_onset, "下发起始站", "DB2.W2"));
list.add(new ItemDto(item_to_target, "下发目标站", "DB2.W4"));
list.add(new ItemDto(item_to_task, "下发任务号", "DB2.D6"));
list.add(new ItemDto(item_to_pull, "是否拔轴", "DB2.W8"));
list.add(new ItemDto(item_to_sleeve, "是否套轴", "DB2.W10"));
list.add(new ItemDto(item_to_size, "尺寸", "DB2.W12"));
list.add(new ItemDto(item_to_version, "代数", "DB2.W14"));
list.add(new ItemDto(item_to_qty, "子卷数量", "DB2.W16"));
list.add(new ItemDto(item_to_length1, "子卷1长度", "DB2.W18"));
list.add(new ItemDto(item_to_length2, "子卷2长度", "DB2.W20"));
return list;
}

View File

@@ -103,6 +103,29 @@ public class PullHeadManipulatorDeviceDriver extends AbstractOpcDeviceDriver imp
int to_onset = 0;
int last_to_onset = 0;
int to_pull = 0;
int last_to_pull = 0;
int to_sleeve = 0;
int last_to_sleeve = 0;
int to_size = 0;
int last_to_size = 0;
int to_version = 0;
int last_to_version = 0;
int to_qty = 0;
int last_to_qty = 0;
// 子卷1长度
float to_length1 = 0;
float last_to_length1 = 0;
// y坐标
float to_length2 = 0;
float last_to_length2 = 0;
Boolean isonline = true;
int hasGoods = 0;
@@ -162,6 +185,13 @@ public class PullHeadManipulatorDeviceDriver extends AbstractOpcDeviceDriver imp
to_command = this.itemProtocol.getTo_command();
to_target = this.itemProtocol.getTo_target();
to_task = this.itemProtocol.getTo_task();
to_pull = this.itemProtocol.getTo_pull();
to_sleeve = this.itemProtocol.getTo_sleeve();
to_size = this.itemProtocol.getTo_size();
to_qty = this.itemProtocol.getTo_qty();
to_version = this.itemProtocol.getTo_version();
to_length1 = this.itemProtocol.getTo_length1();
to_length2 = this.itemProtocol.getTo_length2();
to_onset = this.itemProtocol.getTo_onset();
x_position = this.itemProtocol.getX_position();
y_position = this.itemProtocol.getY_position();
@@ -178,6 +208,27 @@ public class PullHeadManipulatorDeviceDriver extends AbstractOpcDeviceDriver imp
if (to_task != last_to_task) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号to_task" + last_to_task + "->" + to_task);
}
if (to_pull != last_to_pull) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号to_pull" + last_to_pull + "->" + to_pull);
}
if (to_sleeve != last_to_sleeve) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号to_sleeve" + last_to_sleeve + "->" + to_sleeve);
}
if (to_size != last_to_size) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号to_size" + last_to_size + "->" + to_size);
}
if (to_version != last_to_version) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号to_version" + last_to_version + "->" + to_version);
}
if (to_qty != last_to_qty) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号to_qty" + last_to_qty + "->" + to_qty);
}
if (to_length1 != last_to_length1) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号to_length1" + last_to_length1 + "->" + to_length1);
}
if (to_length2 != last_to_length2) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号to_length2" + last_to_length2 + "->" + to_length2);
}
if (mode != last_mode) {
requireSucess = false;
logServer.deviceItemValue(this.device_code, "mode", String.valueOf(mode));
@@ -234,42 +285,16 @@ public class PullHeadManipulatorDeviceDriver extends AbstractOpcDeviceDriver imp
}
}
//反馈重量
if (mode == 3 && action == 5 && move == 1 && task > 0) {
Instruction inst2 = instructionService.findByCodeFromCache(String.valueOf(task));
if (ObjectUtil.isNotEmpty(inst2)) {
Map<String, Object> map = new LinkedHashMap<>();
//todo:反馈重量
map.put("to_command", "5");
this.writing(map);
} else {
logServer.deviceExecuteLog(this.device_code, "", "", "未反馈电气信号原因:当前步骤不为允许取货now_steps_type=3");
}
} else {
feedMessage = "行架机械手:";
if (mode != 3) {
feedMessage = feedMessage + "mode不为运行中状态,";
}
if (action != 5) {
feedMessage = feedMessage + "action不为反馈重量状态,";
}
if (move != 1) {
feedMessage = feedMessage + "move不为有货状态,";
}
if (task == 0) {
feedMessage = feedMessage + "task为0。";
}
}
//任务完成
if (mode == 3 && action == 6 && move == 0 && task > 0) {
if (mode == 3 && action == 4 && move == 0 && task > 0) {
Instruction inst2 = instructionService.findByCodeFromCache(String.valueOf(task));
if (inst2 != null) {
if (StrUtil.equals(inst2.getInstruction_status(), InstructionStatusEnum.BUSY.getIndex())) {
try {
finish_instruction(inst2);
Map<String, Object> map = new LinkedHashMap<>();
map.put("to_command", "6");
map.put("to_command", "5");
this.writing(map);
} catch (Exception e) {
e.printStackTrace();
@@ -278,6 +303,8 @@ public class PullHeadManipulatorDeviceDriver extends AbstractOpcDeviceDriver imp
}
}
} catch (Exception var17) {
var17.printStackTrace();
feedMessage = var17.getMessage();
@@ -346,6 +373,13 @@ public class PullHeadManipulatorDeviceDriver extends AbstractOpcDeviceDriver imp
last_to_onset = to_onset;
last_x_position = x_position;
last_y_position = y_position;
last_to_pull = to_pull;
last_to_sleeve = to_sleeve;
last_to_size = to_size;
last_to_version = to_version;
last_to_qty = to_qty;
last_to_length1 = to_length1;
last_to_length2 = to_length2;
}
/**

View File

@@ -29,6 +29,8 @@ public class ItemProtocol {
public static String item_x_position = "x_position";
//y轴坐标
public static String item_y_position = "y_position";
//重量
public static String item_weight = "weight";
//下发命令
public static String item_to_command = "to_command";
@@ -97,6 +99,10 @@ public class ItemProtocol {
return this.getOpcFloatValue(item_y_position);
}
public float getWeight() {
return this.getOpcFloatValue(item_weight);
}
Boolean isonline;
public int getOpcIntegerValue(String protocol) {
@@ -146,6 +152,7 @@ public class ItemProtocol {
list.add(new ItemDto(item_task, "任务号", "DB1.D6"));
list.add(new ItemDto(item_x_position, "x坐标", "DB1.REAL10"));
list.add(new ItemDto(item_y_position, "y坐标", "DB1.REAL14"));
list.add(new ItemDto(item_weight, "重量", "DB1.REAL16"));
return list;
}

View File

@@ -88,6 +88,10 @@ public class PullTailManipulatorDeviceDriver extends AbstractOpcDeviceDriver imp
float y_position = 0;
float last_y_position = 0;
//重量
float weight = 0;
float last_weight = 0;
int heartbeat = 0;
int last_heartbeat = 0;
int to_command = 0;
@@ -158,6 +162,7 @@ public class PullTailManipulatorDeviceDriver extends AbstractOpcDeviceDriver imp
error = this.itemProtocol.getError();
task = this.itemProtocol.getTask();
heartbeat = this.itemProtocol.getHeartbeat();
weight = this.itemProtocol.getWeight();
to_command = this.itemProtocol.getTo_command();
to_target = this.itemProtocol.getTo_target();
to_task = this.itemProtocol.getTo_task();
@@ -210,6 +215,10 @@ public class PullTailManipulatorDeviceDriver extends AbstractOpcDeviceDriver imp
logServer.deviceItemValue(this.device_code, "y_position", String.valueOf(y_position));
logServer.deviceExecuteLog(this.device_code, "", "", "信号y_position" + last_y_position + "->" + y_position);
}
if (weight != last_weight) {
logServer.deviceItemValue(this.device_code, "weight", String.valueOf(weight));
logServer.deviceExecuteLog(this.device_code, "", "", "信号weight" + last_weight + "->" + weight);
}
// 更新指令状态
if (mode == 3 && task > 0) {
@@ -234,7 +243,7 @@ public class PullTailManipulatorDeviceDriver extends AbstractOpcDeviceDriver imp
}
//反馈重量
if (mode == 3 && action == 5 && move == 1 && task > 0) {
if (mode == 3 && action == 5 && move == 0 && task > 0) {
Instruction inst2 = instructionService.findByCodeFromCache(String.valueOf(task));
if (ObjectUtil.isNotEmpty(inst2)) {
Map<String, Object> map = new LinkedHashMap<>();
@@ -338,6 +347,7 @@ public class PullTailManipulatorDeviceDriver extends AbstractOpcDeviceDriver imp
last_walk_y = walk_y;
last_error = error;
last_task = task;
last_weight = weight;
last_heartbeat = heartbeat;
last_to_task = to_task;
last_to_command = to_command;

View File

@@ -1,5 +1,6 @@
package org.nl.acs.device_driver.waste_foil_weighing_station;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONObject;
import lombok.Data;
import lombok.RequiredArgsConstructor;
@@ -12,13 +13,12 @@ import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver;
import org.nl.acs.device_driver.driver.ExecutableDeviceDriver;
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.log.service.DeviceExecuteLogService;
import org.nl.acs.monitor.DeviceStageMonitor;
import org.nl.config.SpringContextHolder;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.*;
/**
* 废箔称重
@@ -112,6 +112,44 @@ public class WasteFoilWeighingStationDriver extends AbstractOpcDeviceDriver impl
logServer.deviceExecuteLog(this.device_code, "", "", "信号old_weight" + last_old_weight + "->" + old_weight);
}
if (mode == 0) {
this.setIsonline(false);
message = "未联机";
// 有报警
// } else if (error != 0) {
// this.setIsonline(false);
// this.setIserror(true);
// message = "有报警";
// //无报警
} else {
this.setIsonline(true);
this.setIserror(false);
if (error != 0) {
this.setIserror(true);
message = "有报警";
}
message = "";
Instruction instruction = null;
List toInstructions;
switch (mode) {
case 2:
log.debug("设备运转模式:等待工作");
break;
case 3:
log.debug("设备运转模式:等待工作");
break;
case 7:
// 称重确认完成
if (move > 0 && !requireSucess) {
weightConfirmSuccess();
}
break;
default:
break;
}
}
last_mode = mode;
last_move = move;
last_action = action;
@@ -119,6 +157,15 @@ public class WasteFoilWeighingStationDriver extends AbstractOpcDeviceDriver impl
}
/**
* 称重确认完成
*/
public synchronized void weightConfirmSuccess() {
Map<String, Object> map = new LinkedHashMap<>();
map.put("to_command", "7");
this.writing(map);
}
@@ -134,6 +181,29 @@ public class WasteFoilWeighingStationDriver extends AbstractOpcDeviceDriver impl
logServer.deviceExecuteLog(device_code, "", "", "下发电气信号设备号:" + device_code + ",下发电气:" + to_param + ",下发电气值:" + value);
}
public String getToParam() {
return this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + ".";
}
/**
* 多个信号一起下发电气
*
* @param map
*/
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);
}
}
@Override
public JSONObject feedLmsRealFailedInfo() {

View File

@@ -133,7 +133,6 @@ public class TaskServiceImpl extends CommonServiceImpl<TaskMapper, Task> impleme
}
@Override
public TaskDto findById(String id) {
return ConvertUtil.convert(getById(id), TaskDto.class);
}