opt: 立库输送机写入信号判断优化,添加输送机称重驱动

This commit is contained in:
yanps
2024-06-19 15:44:50 +08:00
parent dc356bf29e
commit 8037d14a47
10 changed files with 2135 additions and 39 deletions

View File

@@ -35,6 +35,8 @@ public enum DriverTypeEnum {
SIEMENS_CONVEYOR(13, "siemens_conveyor", "西门子-输送机驱动", "conveyor"),
SIEMENS_WEIGHT_CONVEYOR(29, "siemens_weight_conveyor", "西门子-输送机驱动-称重", "conveyor"),
HONGXIANG_CONVEYOR(13, "hongxiang_conveyor", "烘箱对接位", "conveyor"),
INSPECT_CONVEYOR_CONTROL_WITH_SCANNER(14, "standard_conveyor_control_with_scanner", "标准版-输送机-控制点-关联扫码", "conveyor"),

View File

@@ -110,7 +110,7 @@ public class BoxPalletizingManipulatorDeviceDriver extends AbstractOpcDeviceDriv
action = this.itemProtocol.getAction();
walk_y = this.itemProtocol.getWalk_y();
error = this.itemProtocol.getError();
task = this.itemProtocol.getTask();
/*task = this.itemProtocol.getTask();*/
iserror = this.itemProtocol.deviceStatus;
if (mode != last_mode) {
logServer.deviceItemValue(this.device_code, "mode", String.valueOf(mode));
@@ -132,10 +132,10 @@ public class BoxPalletizingManipulatorDeviceDriver extends AbstractOpcDeviceDriv
logServer.deviceItemValue(this.device_code, "walk_y", String.valueOf(walk_y));
logServer.deviceExecuteLog(this.device_code, "", "", "信号walk_y" + last_walk_y + "->" + walk_y);
}
if (task != last_task) {
/*if (task != last_task) {
logServer.deviceItemValue(this.device_code, "task", String.valueOf(task));
logServer.deviceExecuteLog(this.device_code, "", "", "信号task" + last_task + "->" + task);
}
}*/
} catch (Exception var17) {
return;

View File

@@ -25,8 +25,8 @@ public class ItemProtocol {
public static String item_walk_y = "walk_y";
//报警
public static String item_error = "error";
//任务号
public static String item_task = "task";
/*//任务号
public static String item_task = "task";*/
private BoxPalletizingManipulatorDeviceDriver driver;
@@ -59,9 +59,9 @@ public class ItemProtocol {
return this.getOpcIntegerValue(item_error);
}
public int getTask() {
/*public int getTask() {
return this.getOpcIntegerValue(item_task);
}
}*/
Boolean isonline;
@@ -103,7 +103,7 @@ public class ItemProtocol {
list.add(new ItemDto(item_action, "动作信号", "DB1.B3"));
list.add(new ItemDto(item_walk_y, "行走列", "DB1.B4"));
list.add(new ItemDto(item_error, "报警信号", "DB1.B5"));
list.add(new ItemDto(item_task, "任务号", "DB1.D6"));
/*list.add(new ItemDto(item_task, "任务号", "DB1.D6"));*/
return list;
}

View File

@@ -747,9 +747,18 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme
map3.put("code", "to_command");
map3.put("value", "1");
list.add(map3);
this.writing(list);
requireSucess = true;
while (!StrUtil.equals(this.getOpcValueAccessor().getValue(this.getOpcServer() + "." + this.getOpcPlc() + "." + this.getDevice_code() + ".task").toString()
try {
this.writing(list);
} catch (Exception e) {
logServer.deviceExecuteLog(device_code, "", "", "下发指令:" + inst.getInstruction_code()
+ ",指令起点:" + inst.getStart_device_code()
+ ",指令终点:" + inst.getNext_device_code() + ",根据指令下发信号失败" + e.getMessage());
if (ObjectUtil.isEmpty(instructionService.findByTaskcodeAndStatus(taskdto.getTask_code()))) {
requireSucess = false;
return false;
}
}
/*while (!StrUtil.equals(this.getOpcValueAccessor().getValue(this.getOpcServer() + "." + this.getOpcPlc() + "." + this.getDevice_code() + ".task").toString()
, inst.getInstruction_code())) {
this.writing(list);
logServer.deviceExecuteLog(device_code, "", "", inst.getInstruction_code() + "再次下发信号");
@@ -762,18 +771,11 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme
requireSucess = false;
return false;
}
}
// if (task != Integer.parseInt(inst.getInstruction_code())) {
// this.writing(list);
// message = "重新下发电气信号";
// logServer.deviceExecuteLog(device_code, "", "", inst.getInstruction_code() + "再次下发电气信号");
// }
}*/
message = "下发电气任务号成功";
requireSucess = true;
return true;
}
// type 5 输送任务
if (!StrUtil.equals(taskdto.getTask_type(), "5")) {
return false;
@@ -870,9 +872,18 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme
map3.put("code", "to_command");
map3.put("value", "1");
list.add(map3);
this.writing(list);
requireSucess = true;
while (!StrUtil.equals(this.getOpcValueAccessor().getValue(this.getOpcServer() + "." + this.getOpcPlc() + "." + this.getDevice_code() + ".task").toString()
try {
this.writing(list);
} catch (Exception e) {
logServer.deviceExecuteLog(device_code, "", "", "下发指令:" + instdto.getInstruction_code()
+ ",指令起点:" + instdto.getStart_device_code()
+ ",指令终点:" + instdto.getNext_device_code() + ",根据指令下发信号失败" + e.getMessage());
if (ObjectUtil.isEmpty(instructionService.findByTaskcodeAndStatus(taskdto.getTask_code()))) {
requireSucess = false;
return false;
}
}
/*while (!StrUtil.equals(this.getOpcValueAccessor().getValue(this.getOpcServer() + "." + this.getOpcPlc() + "." + this.getDevice_code() + ".task").toString()
, instdto.getInstruction_code())) {
this.writing(list);
logServer.deviceExecuteLog(device_code, "", "", inst.getInstruction_code() + "再次下发电气信号");
@@ -885,14 +896,7 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme
requireSucess = false;
return false;
}
}
// if (task != Integer.parseInt(inst.getInstruction_code())) {
// this.writing(list);
// message = "重新下发电气信号";
// logServer.deviceExecuteLog(device_code, "", "", inst.getInstruction_code() + "再次下发电气信号");
// }
}*/
} else {
//如果不存在则直接找对应指令
Instruction inst = instructionService.findByDeviceCodeFromCache(this.device_code);
@@ -929,9 +933,18 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme
map3.put("code", "to_command");
map3.put("value", "1");
list.add(map3);
this.writing(list);
requireSucess = true;
while (!StrUtil.equals(this.getOpcValueAccessor().getValue(this.getOpcServer() + "." + this.getOpcPlc() + "." + this.getDevice_code() + ".task").toString()
try {
this.writing(list);
} catch (Exception e) {
logServer.deviceExecuteLog(device_code, "", "", "下发指令:" + inst.getInstruction_code()
+ ",指令起点:" + inst.getStart_device_code()
+ ",指令终点:" + inst.getNext_device_code() + ",根据指令下发信号失败" + e.getMessage());
if (ObjectUtil.isEmpty(instructionService.findByTaskcodeAndStatus(taskdto.getTask_code()))) {
requireSucess = false;
return false;
}
}
/*while (!StrUtil.equals(this.getOpcValueAccessor().getValue(this.getOpcServer() + "." + this.getOpcPlc() + "." + this.getDevice_code() + ".task").toString()
, inst.getInstruction_code())) {
this.writing(list);
logServer.deviceExecuteLog(device_code, "", "", inst.getInstruction_code() + "再次下发电气信号");
@@ -944,11 +957,13 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme
requireSucess = false;
return false;
}
}
}*/
// if (task != Integer.parseInt(inst.getInstruction_code())) {
// this.writing(list);
// logServer.deviceExecuteLog(device_code, "", "", inst.getInstruction_code() + "再次下发电气信号");
// }
requireSucess = true;
return true;
}
return true;
}
@@ -1116,7 +1131,18 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme
if (jo.getInteger("status") == 200) {
message = "申请补码AGV搬运任务成功";
List list = new ArrayList();
while (!StrUtil.equals(this.getOpcValueAccessor().getValue(this.getOpcServer() + "." + this.getOpcPlc() + "." + this.getDevice_code() + ".to_command").toString()
Map map = new HashMap();
map.put("code", "to_command");
map.put("value", "8");
list.add(map);
try {
this.writing(list);
} catch (Exception e) {
logServer.deviceExecuteLog(device_code, "", "", "申请补码AGV搬运任务下发信号失败" + e.getMessage());
requireSucess = false;
return;
}
/*while (!StrUtil.equals(this.getOpcValueAccessor().getValue(this.getOpcServer() + "." + this.getOpcPlc() + "." + this.getDevice_code() + ".to_command").toString()
, "8")) {
this.writing(list);
logServer.deviceExecuteLog(device_code, "", "", "再次下发mode信号");
@@ -1125,7 +1151,7 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}*/
logServer.deviceExecuteLog(this.device_code, "", "", "申请补码AGV任务,返回参数:" + jo);
requireSucess = true;
} else {
@@ -1166,8 +1192,14 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme
map.put("code", "to_command");
map.put("value", "8");
list.add(map);
this.writing(list);
while (!StrUtil.equals(this.getOpcValueAccessor().getValue(this.getOpcServer() + "." + this.getOpcPlc() + "." + this.getDevice_code() + ".to_command").toString()
try {
this.writing(list);
} catch (Exception e) {
logServer.deviceExecuteLog(device_code, "", "", "申请AGV搬运任务下发信号失败" + e.getMessage());
requireSucess = false;
return;
}
/*while (!StrUtil.equals(this.getOpcValueAccessor().getValue(this.getOpcServer() + "." + this.getOpcPlc() + "." + this.getDevice_code() + ".to_command").toString()
, "8")) {
this.writing(list);
logServer.deviceExecuteLog(device_code, "", "", inst.getInstruction_code() + "再次下发mode信号");
@@ -1176,7 +1208,7 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}*/
logServer.deviceExecuteLog(this.device_code, "", "", "申请AGV任务,返回参数:" + jo);
requireSucess = true;
} else {

View File

@@ -0,0 +1,174 @@
package org.nl.acs.device_driver.basedriver.siemens_weigh_conveyor;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.nl.acs.device.device_driver.standard_inspect.ItemDto;
import java.util.ArrayList;
import java.util.List;
@Slf4j
@Data
public class ItemProtocol {
//心跳
public static String item_heartbeat = "heartbeat";
//工作模式
public static String item_mode = "mode";
//光电信号
public static String item_move = "move";
//托盘方向
public static String item_carrier_direction = "carrier_direction";
//报警
public static String item_error = "error";
//任务号
public static String item_task = "task";
//重量
public static String item_weight = "weight";
//下发命令
public static String item_to_command = "to_command";
//下发目标站
public static String item_to_target = "to_target";
//下发托盘类型
public static String item_to_container_type = "to_container_type";
//下发任务号
public static String item_to_task = "to_task";
//困扎次数
public static String item_to_strap_times = "to_strap_times";
//木箱长度
public static String item_to_length = "to_length";
//木箱宽度
public static String item_to_weight = "to_weight";
//木箱高度
public static String item_to_height = "to_height";
private SiemensWeightConveyorDeviceDriver driver;
public ItemProtocol(SiemensWeightConveyorDeviceDriver 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 getCarrier_direction() {
return this.getOpcIntegerValue(item_carrier_direction);
}
public int getError() {
return this.getOpcIntegerValue(item_error);
}
public int getTask() {
return this.getOpcIntegerValue(item_task);
}
public int getTo_command() {
return this.getOpcIntegerValue(item_to_command);
}
public int getTo_target() {
return this.getOpcIntegerValue(item_to_target);
}
public int getTo_task() {
return this.getOpcIntegerValue(item_to_task);
}
public int getTo_strap_times() {
return this.getOpcIntegerValue(item_to_strap_times);
}
public int getTo_length() {
return this.getOpcIntegerValue(item_to_length);
}
public int getTo_weight() {
return this.getOpcIntegerValue(item_to_weight);
}
public int getTo_height() {
return this.getOpcIntegerValue(item_to_height);
}
public int getWeight() {
return this.getOpcIntegerValue(item_weight);
}
Boolean isonline;
Boolean deviceStatus = false;
public int getOpcIntegerValue(String protocol) {
Integer value = this.driver.getIntegeregerValue(protocol);
if(ObjectUtil.isEmpty(value)){
deviceStatus = true;
}else if (item_heartbeat.equals(protocol)){
deviceStatus = false;
}
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.isEmpty(value)) {
} else {
return value;
}
return "0";
}
public static List<ItemDto> getReadableItemDtos() {
ArrayList list = new ArrayList();
list.add(new ItemDto(item_heartbeat, "心跳", "DB600.B0"));
list.add(new ItemDto(item_mode, "工作模式", "DB600.B2"));
list.add(new ItemDto(item_move, "光电信号", "DB600.B3"));
list.add(new ItemDto(item_carrier_direction, "托盘方向", "DB600.B4"));
list.add(new ItemDto(item_error, "报警信号", "DB600.B6"));
list.add(new ItemDto(item_task, "任务号", "DB600.D10"));
list.add(new ItemDto(item_weight, "重量", "DB600.D12"));
return list;
}
public static List<ItemDto> getWriteableItemDtos() {
ArrayList list = new ArrayList();
list.add(new ItemDto(item_to_command, "下发命令", "DB601.W2"));
list.add(new ItemDto(item_to_target, "下发目标站", "DB601.W4"));
list.add(new ItemDto(item_to_container_type, "下发托盘类型", "DB601.W6"));
list.add(new ItemDto(item_to_task, "下发任务号", "DB601.D8"));
list.add(new ItemDto(item_to_strap_times, "困扎次数", "DB601.W12"));
list.add(new ItemDto(item_to_length, "木箱长度", "DB601.W14"));
list.add(new ItemDto(item_to_weight, "木箱宽度", "DB601.W16"));
list.add(new ItemDto(item_to_height, "木箱高度", "DB601.W18"));
return list;
}
@Override
public String toString() {
return "";
}
}

View File

@@ -0,0 +1,64 @@
package org.nl.acs.device_driver.basedriver.siemens_weigh_conveyor;
import org.nl.acs.device.device_driver.standard_inspect.ItemDto;
import org.nl.acs.device_driver.DeviceDriver;
import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination;
import org.nl.acs.opc.Device;
import org.nl.acs.opc.DeviceType;
import org.springframework.stereotype.Service;
import java.util.LinkedList;
import java.util.List;
/**
* 西门子-输送机驱动
*
*/
@Service
public class SiemensWeightConveyorDefination implements OpcDeviceDriverDefination {
@Override
public String getDriverCode() {
return "siemens_weight_conveyor";
}
@Override
public String getDriverName() {
return "西门子-输送机驱动-称重";
}
@Override
public String getDriverDescription() {
return "西门子-输送机驱动-称重";
}
@Override
public DeviceDriver getDriverInstance(Device device) {
return (new SiemensWeightConveyorDeviceDriver()).setDevice(device).setDriverDefination(this);
}
@Override
public Class<? extends DeviceDriver> getDeviceDriverType() {
return SiemensWeightConveyorDeviceDriver.class;
}
@Override
public List<DeviceType> getFitDeviceTypes() {
List<DeviceType> types = new LinkedList();
types.add(DeviceType.station);
return types;
}
@Override
public List<ItemDto> getReadableItemDtos() {
return ItemProtocol.getReadableItemDtos();
}
@Override
public List<ItemDto> getWriteableItemDtos() {
return ItemProtocol.getWriteableItemDtos();
}
}

View File

@@ -39,6 +39,7 @@ import org.nl.acs.device_driver.basedriver.siemens_conveyor.SiemensConveyorDevic
import org.nl.acs.device_driver.basedriver.siemens_conveyor_ckk.SiemensConveyorCkkDeviceDriver;
import org.nl.acs.device_driver.basedriver.siemens_conveyor_labeling.SiemensConveyorLabelingDeviceDriver;
import org.nl.acs.device_driver.basedriver.siemens_onefloor_agv_conveyor.SiemensOneFloorAGVConveyorDeviceDriver;
import org.nl.acs.device_driver.basedriver.siemens_weigh_conveyor.SiemensWeightConveyorDeviceDriver;
import org.nl.acs.device_driver.basedriver.slit_two_manipulator.SlitTwoManipulatorDeviceDriver;
import org.nl.acs.device_driver.basedriver.standard_conveyor_control_with_scanner.StandardCoveyorControlWithScannerDeviceDriver;
import org.nl.acs.device_driver.basedriver.standard_ordinary_site.StandardOrdinarySiteDefination;
@@ -265,6 +266,9 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
CasingStationConveyorDeviceDriver casingStationConveyorDeviceDriver;
//RGV
RgvDeviceDriver rgvDeviceDriver;
//西门子-输送机称重驱动
SiemensWeightConveyorDeviceDriver siemensWeightConveyorDeviceDriver;
if (datas.size() == 0) {
throw new BadRequestException("缺少输入参数!");
@@ -498,6 +502,14 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
// jo.put("task2", driver.getTask2());
jo.put("error", driver.getError());
jo.put("error_msg", driver.getError() == 0 ? "" : ErrorUtil.getDictDetail("ssx_error_type", String.valueOf(driver.getError())));
}else if (device.getDeviceDriver() instanceof SiemensWeightConveyorDeviceDriver) {
siemensWeightConveyorDeviceDriver = (SiemensWeightConveyorDeviceDriver) device.getDeviceDriver();
jo.put("device_code", siemensWeightConveyorDeviceDriver.getDevice().getDevice_code());
jo.put("device_name", siemensWeightConveyorDeviceDriver.getDevice().getDevice_name());
jo.put("mode", siemensWeightConveyorDeviceDriver.getMode());
jo.put("move", siemensWeightConveyorDeviceDriver.getMove());
jo.put("error", siemensWeightConveyorDeviceDriver.getError());
jo.put("weight", siemensWeightConveyorDeviceDriver.getWeight());
} else {
jo.put("device_code", parent_device_code);
}