This commit is contained in:
USER-20220102CG\noblelift
2023-04-06 20:35:52 +08:00
parent c7b7fc8b1a
commit 5dff029c15
6 changed files with 854 additions and 3 deletions

View File

@@ -51,8 +51,9 @@ public enum DriverTypeEnum {
STANDARD_AUTODOOR(20, "standard_autodoor", "标准版-自动门", "autodoor"),
LAMP_THREE_COLOR(21, "lamp_three_color", "标准版-三色灯", "三色灯");
LAMP_THREE_COLOR(21, "lamp_three_color", "标准版-三色灯", "三色灯"),
PAPER_TUBE_DEVICE(22, "paper_tube_conveyor", "纸管库设备", "conveyor");
//驱动索引
private int index;

View File

@@ -0,0 +1,117 @@
package org.nl.acs.device_driver.basedriver.paper_tube_device;
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_inventory_qty ="inventory_qty";
public static String item_out_finish = "out_finish";
public static String item_material = "material";
public static String item_to_target = "to_target";
public static String item_to_command = "to_command";
public static String item_to_out_qty = "to_out_qty";
public static String item_to_material = "to_material";
private PaperTubeConveyorDeviceDriver driver;
public ItemProtocol(PaperTubeConveyorDeviceDriver driver) {
this.driver = driver;
}
public int getHeartbeat() {
return this.getOpcIntegerValue(item_heartbeat);
}
public int getMode() {
return this.getOpcIntegerValue(item_mode);
}
public int getInventory_qty() {
return this.getOpcIntegerValue(item_inventory_qty);
}
public int getOut_finish() {
return this.getOpcIntegerValue(item_out_finish);
}
public String getMaterial() {
return this.getOpcStringValue(item_material);
}
public int getTotarget() {
return this.getOpcIntegerValue(item_to_target);
}
public int getTo_command() {
return this.getOpcIntegerValue(item_to_command);
}
public int getTo_out_qty() {
return this.getOpcIntegerValue(item_to_out_qty);
}
public String getTo_material() {
return this.getOpcStringValue(item_to_material);
}
Boolean isonline;
public int getOpcIntegerValue(String protocol) {
Integer value = this.driver.getIntegeregerValue(protocol);
if (value == null) {
setIsonline(false);
} else {
setIsonline(true);
return value;
}
return 0;
}
public String getOpcStringValue(String protocol) {
String value = this.driver.getStringValue(protocol);
if (StrUtil.isBlank(value)) {
} else {
return value;
}
return "0";
}
public static List<ItemDto> getReadableItemDtos() {
ArrayList list = new ArrayList();
list.add(new ItemDto(item_heartbeat, "心跳", "DB101.W0"));
list.add(new ItemDto(item_mode, "模式", "DB101.W2"));
list.add(new ItemDto(item_inventory_qty, "库存数量", "DB101.W4"));
list.add(new ItemDto(item_out_finish, "出库完成 ", "DB101.W6"));
list.add(new ItemDto(item_material, "物料", "DB101.STRING8.50"));
return list;
}
public static List<ItemDto> getWriteableItemDtos() {
ArrayList list = new ArrayList();
list.add(new ItemDto(item_to_target , "下发仓位号", "DB102.W2"));
list.add(new ItemDto(item_to_command, "下发命令", "DB102.W4"));
list.add(new ItemDto(item_to_out_qty , "下发出库数量", "DB102.W6"));
list.add(new ItemDto(item_to_material, "下发物料", "DB102.STRING8.50"));
return list;
}
}

View File

@@ -0,0 +1,61 @@
package org.nl.acs.device_driver.basedriver.paper_tube_device;
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 PaperTubeConveyorDefination implements OpcDeviceDriverDefination {
@Override
public String getDriverCode() {
return "paper_tube_conveyor";
}
@Override
public String getDriverName() {
return "纸管库";
}
@Override
public String getDriverDescription() {
return "纸管库";
}
@Override
public DeviceDriver getDriverInstance(Device device) {
return (new PaperTubeConveyorDeviceDriver()).setDevice(device).setDriverDefination(this);
}
@Override
public Class<? extends DeviceDriver> getDeviceDriverType() {
return PaperTubeConveyorDeviceDriver.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();
}
}

View File

@@ -0,0 +1,165 @@
package org.nl.acs.device_driver.basedriver.paper_tube_device;
import com.alibaba.fastjson.JSONObject;
import lombok.Data;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nl.acs.agv.server.AgvService;
import org.nl.acs.device.service.DeviceService;
import org.nl.acs.device_driver.DeviceDriver;
import org.nl.acs.device_driver.RouteableDeviceDriver;
import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver;
import org.nl.acs.device_driver.driver.ExecutableDeviceDriver;
import org.nl.acs.ext.wms.service.AcsToWmsService;
import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl;
import org.nl.acs.instruction.service.InstructionService;
import org.nl.acs.log.service.DeviceExecuteLogService;
import org.nl.acs.monitor.DeviceStageMonitor;
import org.nl.acs.opc.Device;
import org.nl.acs.opc.DeviceAppService;
import org.nl.acs.route.service.RouteLineService;
import org.nl.acs.task.service.TaskService;
import org.nl.modules.system.service.ParamService;
import org.nl.modules.wql.util.SpringContextHolder;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
/**
* 纸管库
*/
@Slf4j
@Data
@RequiredArgsConstructor
public class PaperTubeConveyorDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor {
protected ItemProtocol itemProtocol = new ItemProtocol(this);
@Autowired
DeviceAppService deviceAppservice = SpringContextHolder.getBean(DeviceAppService.class);
@Autowired
InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class);
@Autowired
DeviceService deviceservice = SpringContextHolder.getBean(DeviceService.class);
@Autowired
TaskService taskserver = SpringContextHolder.getBean(TaskService.class);
@Autowired
RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class);
@Autowired
AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsServiceImpl.class);
@Autowired
ParamService paramService = SpringContextHolder.getBean(ParamService.class);
@Autowired
DeviceExecuteLogService logServer = SpringContextHolder.getBean(DeviceExecuteLogService.class);
@Autowired
AgvService agvService = SpringContextHolder.getBean(AgvService.class);
private Date instruction_require_time = new Date();
private Date instruction_finished_time = new Date();
private Date instruction_apply_time = new Date();
private int instruction_require_time_out = 3000;
int heartbeat = 0;
int mode = 0;
int inventory_qty =0;
int out_finish =0;
String material = null;
Boolean isonline = true;
Boolean iserror = false;
//1-执行任务2-取货完成3-放货完成;
int flag;
int last_mode = 0;
int last_inventory_qty =0;
int last_out_finish =0;
String last_material = null;
String device_code;
@Override
public Device getDevice() {
return this.device;
}
//请求成功标记
Boolean requireSucess = false;
@Override
public void execute() {
String message = null;
device_code = this.getDeviceCode();
heartbeat = this.itemProtocol.getHeartbeat();
mode = this.itemProtocol.getMode();
inventory_qty = this.itemProtocol.getInventory_qty();
out_finish =this.itemProtocol.getOut_finish();
material = this.itemProtocol.getMaterial();
if (mode != last_mode) {
this.setRequireSucess(false);
}
if (mode == 0) {
this.setIsonline(false);
this.setIserror(true);
message = "未联机";
} else {
this.setIsonline(true);
this.setIserror(false);
}
last_mode = mode;
last_inventory_qty = inventory_qty;
last_out_finish = out_finish;
}
public void writing(int command) {
String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
+ "." + org.nl.acs.device_driver.basedriver.standard_conveyor_control_with_scanner.ItemProtocol.item_to_command;
Map<String, Object> itemMap = new HashMap<String, Object>();
itemMap.put(to_command, command);
this.control(itemMap);
}
public void writing(String key, String value) {
String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
+ "." + key;
Map<String, Object> itemMap = new HashMap<String, Object>();
itemMap.put(to_command, value);
this.control(itemMap);
}
@Override
public JSONObject getDeviceStatusName() {
JSONObject jo = new JSONObject();
String mode = "";
if (this.getMode() == 0) {
mode = "未联机";
} else if (this.getMode() == 1) {
mode = "单机";
} else if (this.getMode() == 2) {
mode = "联机";
} else if (this.getMode() == 3) {
mode = "运行中";
}
jo.put("device_name", this.getDevice().getDevice_name());
jo.put("mode", mode);
jo.put("isOnline", this.getIsonline());
jo.put("isError", this.getIserror());
return jo;
}
@Override
public void setDeviceStatus(JSONObject data) {
}
}