add 包装线
This commit is contained in:
@@ -85,9 +85,9 @@ public enum DriverTypeEnum {
|
||||
|
||||
CONVEYOR_SSX_BARCODE(54, "conveyor_ssx_barcode", "标准版-下发条码输送线", "station"),
|
||||
|
||||
CONVEYOR_PRESS_STATION(54, "conveyor_press_station", "标准版-压制对接位", "station");
|
||||
|
||||
CONVEYOR_PRESS_STATION(54, "conveyor_press_station", "标准版-压制对接位", "station"),
|
||||
|
||||
PACKAGE_SITE(55, "package_site", "包装线工位", "station");
|
||||
//驱动索引
|
||||
private int index;
|
||||
//驱动编码
|
||||
|
||||
@@ -0,0 +1,162 @@
|
||||
package org.nl.acs.device_driver.lnsh.package_site;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.acs.device.device_driver.standard_inspect.ItemDto;
|
||||
import org.nl.acs.device_driver.lnsh.lnsh_package_site.LnshPackageSiteDeviceDriver;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Getter
|
||||
@Setter
|
||||
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_action = "action";
|
||||
public static String item_ioaction = "ioaction";
|
||||
public static String item_error = "error";
|
||||
public static String item_vehicle_code = "vehicle_code";
|
||||
public static String item_vehicle_type = "vehicle_type";
|
||||
public static String item_task = "task";
|
||||
public static String item_to_command = "to_command";
|
||||
public static String item_to_vehicle_code = "to_vehicle_code";
|
||||
public static String item_to_vehicle_type = "to_vehicle_type";
|
||||
public static String item_to_is_package = "to_is_package";
|
||||
public static String item_is_weight = "is_weight";
|
||||
public static String item_material = "material";
|
||||
public static String item_barcode = "barcode";
|
||||
public static String item_to_target = "to_target";
|
||||
public static String item_to_task= "to_task";
|
||||
public static String item_is_message= "is_message";
|
||||
Boolean isonline;
|
||||
private PackageSiteDeviceDriver driver;
|
||||
|
||||
public ItemProtocol(PackageSiteDeviceDriver driver) {
|
||||
this.driver = driver;
|
||||
}
|
||||
public int getTo_target() {
|
||||
return this.getOpcIntegerValue(item_to_target);
|
||||
}
|
||||
public int getTo_task() {
|
||||
return this.getOpcIntegerValue(item_to_task);
|
||||
}
|
||||
|
||||
public int getHeartbeat() {
|
||||
return this.getOpcIntegerValue(item_heartbeat);
|
||||
}
|
||||
|
||||
public int getMode() {
|
||||
return this.getOpcIntegerValue(item_mode);
|
||||
}
|
||||
|
||||
public int getBarcode() {
|
||||
return this.getOpcIntegerValue(item_barcode);
|
||||
}
|
||||
|
||||
public String getMaterial() {
|
||||
return this.getOpcStringValue(item_material);
|
||||
}
|
||||
|
||||
public String getmessage() {
|
||||
return this.getOpcStringValue(item_is_message);
|
||||
}
|
||||
|
||||
public int getTask() { return this.getOpcIntegerValue(item_task); }
|
||||
|
||||
public int getWeight() { return this.getOpcIntegerValue(item_is_weight);}
|
||||
|
||||
public int getMove() {
|
||||
return this.getOpcIntegerValue(item_move);
|
||||
}
|
||||
|
||||
public int getAction() {
|
||||
return this.getOpcIntegerValue(item_action);
|
||||
}
|
||||
|
||||
public int getIoaction() {
|
||||
return this.getOpcIntegerValue(item_ioaction);
|
||||
}
|
||||
|
||||
public int getError() {
|
||||
return this.getOpcIntegerValue(item_error);
|
||||
}
|
||||
|
||||
public int getVehicle_code() {
|
||||
return this.getOpcIntegerValue(item_vehicle_code);
|
||||
}
|
||||
|
||||
public int getVehicle_type() {
|
||||
return this.getOpcIntegerValue(item_vehicle_type);
|
||||
}
|
||||
|
||||
public int getTo_command() {
|
||||
return this.getOpcIntegerValue(item_to_command);
|
||||
}
|
||||
|
||||
public int getTo_vehicle_code() {
|
||||
return this.getOpcIntegerValue(item_to_vehicle_code);
|
||||
}
|
||||
|
||||
public int getTo_vehicle_type() {
|
||||
return this.getOpcIntegerValue(item_to_vehicle_type);
|
||||
}
|
||||
|
||||
//是否有货
|
||||
public int hasGoods(int move) {
|
||||
return move;
|
||||
}
|
||||
|
||||
|
||||
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 (value == null) {
|
||||
// log.error("读取错误!");
|
||||
} else {
|
||||
return value;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public static List<ItemDto> getReadableItemDtos() {
|
||||
ArrayList<ItemDto> list = new ArrayList<>();
|
||||
list.add(new ItemDto(item_heartbeat, "心跳", "DB51.B0"));
|
||||
list.add(new ItemDto(item_mode, "工作模式", "DB51.B1", Boolean.valueOf(true)));
|
||||
list.add(new ItemDto(item_move, "光电开关信号", "DB51.B2"));
|
||||
list.add(new ItemDto(item_action, "取放信号", "DB51.B3"));
|
||||
list.add(new ItemDto(item_ioaction, "进出信号", "DB51.B4"));
|
||||
list.add(new ItemDto(item_error, "报警信号", "DB51.B5"));
|
||||
list.add(new ItemDto(item_task, "任务号", "DB51.D6"));
|
||||
list.add(new ItemDto(item_is_weight, "重量", "DB51.D10"));
|
||||
list.add(new ItemDto(item_material, "物料", "DB51.STRING14.50"));
|
||||
list.add(new ItemDto(item_barcode, "条码", "DB51.W66"));
|
||||
return list;
|
||||
}
|
||||
|
||||
public static List<ItemDto> getWriteableItemDtos() {
|
||||
ArrayList<ItemDto> list = new ArrayList<>();
|
||||
list.add(new ItemDto(item_to_command, "下发指令", "DB51.B0", Boolean.TRUE));
|
||||
list.add(new ItemDto(item_to_target, "下发目标站", "DB51.B2"));
|
||||
list.add(new ItemDto(item_to_task, "下发任务号", "DB51.B4"));
|
||||
list.add(new ItemDto(item_to_is_package, "下发是否包装", "DB51.B8"));
|
||||
list.add(new ItemDto(item_is_message, "下发信息反馈", "DB62.STRING10.50"));
|
||||
return list;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
package org.nl.acs.device_driver.lnsh.package_site;
|
||||
|
||||
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 PackageSiteDefination implements OpcDeviceDriverDefination {
|
||||
@Override
|
||||
public String getDriverCode() {
|
||||
return "package_site";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDriverName() {
|
||||
return "包装线工位";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDriverDescription() {
|
||||
return "包装线工位";
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeviceDriver getDriverInstance(Device device) {
|
||||
return (new PackageSiteDeviceDriver()).setDevice(device).setDriverDefination(this);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends DeviceDriver> getDeviceDriverType() {
|
||||
return PackageSiteDeviceDriver.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();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,343 @@
|
||||
package org.nl.acs.device_driver.lnsh.package_site;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.acs.device.device_driver.standard_inspect.ReadUtil;
|
||||
import org.nl.acs.device.service.DeviceService;
|
||||
import org.nl.acs.device_driver.DeviceDriver;
|
||||
import org.nl.acs.device_driver.RouteableDeviceDriver;
|
||||
import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver;
|
||||
import org.nl.acs.device_driver.driver.ExecutableDeviceDriver;
|
||||
import org.nl.acs.ext.wms.service.AcsToWmsService;
|
||||
import org.nl.acs.instruction.service.InstructionService;
|
||||
import org.nl.acs.instruction.service.dto.Instruction;
|
||||
import org.nl.acs.log.service.DeviceExecuteLogService;
|
||||
import org.nl.acs.monitor.DeviceStageMonitor;
|
||||
import org.nl.acs.opc.Device;
|
||||
import org.nl.acs.route.service.RouteLineService;
|
||||
import org.nl.acs.task.service.TaskService;
|
||||
import org.nl.modules.wql.util.SpringContextHolder;
|
||||
import org.openscada.opc.lib.da.Server;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 晟华-包装线工位
|
||||
*/
|
||||
@Slf4j
|
||||
@Getter
|
||||
@Setter
|
||||
@RequiredArgsConstructor
|
||||
public class PackageSiteDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor {
|
||||
// protected org.nl.acs.device_driver.lnsh.lnsh_package_site.ItemProtocol itemProtocol = new ItemProtocol(this);
|
||||
protected ItemProtocol itemProtocol=new ItemProtocol(this);
|
||||
InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl");
|
||||
|
||||
DeviceService deviceservice = SpringContextHolder.getBean("deviceServiceImpl");
|
||||
|
||||
RouteLineService routelineserver = SpringContextHolder.getBean("routeLineServiceImpl");
|
||||
|
||||
TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl");
|
||||
|
||||
DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl");
|
||||
|
||||
AcsToWmsService acsToWmsService = SpringContextHolder.getBean("acsToWmsServiceImpl");
|
||||
//放货准备锁
|
||||
String putReadyLock = null;
|
||||
//有货标记
|
||||
protected boolean has_goods_tag = false;
|
||||
String device_code;
|
||||
|
||||
Boolean isonline = true;
|
||||
int hasGoods = 0;
|
||||
Boolean iserror = false;
|
||||
|
||||
boolean hasVehicle = false;
|
||||
boolean isReady = false;
|
||||
protected int instruction_num = 0;
|
||||
protected int instruction_num_truth = 0;
|
||||
private Date instruction_require_time = new Date();
|
||||
private Date instruction_finished_time = new Date();
|
||||
|
||||
private int instruction_require_time_out = 3000;
|
||||
boolean requireSucess = false;
|
||||
|
||||
private int instruction_finished_time_out;
|
||||
private Date checkHeartbeattime = new Date();
|
||||
private Date last_checkHeartbeattime = new Date();
|
||||
|
||||
|
||||
int branchProtocol = 0;
|
||||
//当前指令
|
||||
Instruction inst = null;
|
||||
//上次指令
|
||||
Instruction last_inst = null;
|
||||
|
||||
//触摸屏手动触发任务
|
||||
private Boolean is_has_task = false;
|
||||
|
||||
//暂定 0就绪 1请求取货 2取货完成 3请求放货 4放货完成 5取货完成离开 6放货完成离开 7请求进入区域 8请求离开区域
|
||||
int flag;
|
||||
|
||||
String message;
|
||||
|
||||
int heartbeat = 0;
|
||||
int last_heartbeat = 0;
|
||||
|
||||
int mode = 0;
|
||||
int last_mode = 0;
|
||||
|
||||
int move = 0;
|
||||
int last_move = 0;
|
||||
|
||||
int action = 0;
|
||||
int last_action = 0;
|
||||
|
||||
int ioaction = 0;
|
||||
int last_ioaction = 0;
|
||||
|
||||
int error = 0;
|
||||
int last_error = 0;
|
||||
|
||||
int vehicle_code = 0;
|
||||
int last_vehicle_code = 0;
|
||||
|
||||
int vehicle_type = 0;
|
||||
int last_vehicle_type = 0;
|
||||
|
||||
int to_command = 0;
|
||||
int last_to_command = 0;
|
||||
|
||||
int to_vehicle_code = 0;
|
||||
int last_to_vehicle_code = 0;
|
||||
|
||||
int to_vehicle_type = 0;
|
||||
int last_to_vehicle_type = 0;
|
||||
|
||||
@Override
|
||||
public Device getDevice() {
|
||||
return this.device;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
String message = null;
|
||||
try {
|
||||
device_code = this.getDeviceCode();
|
||||
mode = this.itemProtocol.getMode();
|
||||
move = this.itemProtocol.getMove();
|
||||
action = this.itemProtocol.getAction();
|
||||
ioaction = this.itemProtocol.getIoaction();
|
||||
error = this.itemProtocol.getError();
|
||||
vehicle_code = this.itemProtocol.getVehicle_code();
|
||||
vehicle_type = this.itemProtocol.getVehicle_type();
|
||||
|
||||
if (mode != last_mode) {
|
||||
this.setRequireSucess(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 (ioaction != last_ioaction) {
|
||||
logServer.deviceItemValue(this.device_code, "ioaction", String.valueOf(ioaction));
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号ioaction:" + last_ioaction + " -> " + ioaction);
|
||||
}
|
||||
if (error != last_error) {
|
||||
logServer.deviceItemValue(this.device_code, "error", String.valueOf(error));
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号error:" + last_error + " -> " + error);
|
||||
}
|
||||
if (vehicle_code != last_vehicle_code) {
|
||||
logServer.deviceItemValue(this.device_code, "vehicle_code", String.valueOf(vehicle_code));
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号vehicle_code:" + last_vehicle_code + " -> " + vehicle_code);
|
||||
}
|
||||
if (vehicle_type != last_vehicle_type) {
|
||||
logServer.deviceItemValue(this.device_code, "vehicle_type", String.valueOf(vehicle_type));
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号vehicle_type:" + last_vehicle_type + " -> " + vehicle_type);
|
||||
}
|
||||
} catch (Exception var17) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mode == 0) {
|
||||
this.setIsonline(false);
|
||||
this.setIserror(true);
|
||||
message = "未联机";
|
||||
//有报警
|
||||
} else if (error != 0) {
|
||||
this.setIsonline(false);
|
||||
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:
|
||||
break;
|
||||
case 5:
|
||||
}
|
||||
}
|
||||
|
||||
last_mode = mode;
|
||||
last_move = move;
|
||||
last_action = action;
|
||||
last_ioaction = ioaction;
|
||||
last_error = error;
|
||||
last_vehicle_code = vehicle_code;
|
||||
last_vehicle_type = vehicle_type;
|
||||
last_to_command = to_command;
|
||||
last_to_vehicle_code = to_vehicle_code;
|
||||
last_to_vehicle_type = to_vehicle_type;
|
||||
}
|
||||
|
||||
|
||||
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.lnsh.lnsh_station.ItemProtocol.item_to_command;
|
||||
String opcservcerid = this.getDevice().getOpc_server_id();
|
||||
Server server = ReadUtil.getServer(opcservcerid);
|
||||
Map<String, Object> itemMap = new HashMap<String, Object>();
|
||||
itemMap.put(to_command, command);
|
||||
ReadUtil.write(itemMap, server);
|
||||
ReadUtil.write(itemMap, server);
|
||||
server.disconnect();
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "to_command 写入 " + command);
|
||||
}
|
||||
|
||||
public void writing(String param, String value) {
|
||||
|
||||
String to_param = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
|
||||
+ "." + param;
|
||||
String opcservcerid = this.getDevice().getOpc_server_id();
|
||||
Server server = ReadUtil.getServer(opcservcerid);
|
||||
Map<String, Object> itemMap = new HashMap<>();
|
||||
itemMap.put(to_param, value);
|
||||
|
||||
ReadUtil.write(itemMap, server);
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", param + " 写入 " + value);
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject getDeviceStatusName() throws Exception {
|
||||
String mode;
|
||||
String move;
|
||||
String action;
|
||||
String io_action;
|
||||
boolean hasGoods;
|
||||
|
||||
switch (this.mode) {
|
||||
case 0:
|
||||
mode = "脱机";
|
||||
break;
|
||||
case 2:
|
||||
mode = "待机";
|
||||
break;
|
||||
case 3:
|
||||
mode = "运行中";
|
||||
break;
|
||||
default:
|
||||
mode = String.valueOf(this.mode);
|
||||
}
|
||||
|
||||
if (this.move == 0) {
|
||||
move = "无货";
|
||||
hasGoods = false;
|
||||
} else {
|
||||
move = "有货";
|
||||
hasGoods = true;
|
||||
}
|
||||
|
||||
switch (this.action) {
|
||||
case 1:
|
||||
action = "允许取货";
|
||||
break;
|
||||
case 2:
|
||||
action = "允许放货";
|
||||
break;
|
||||
case 3:
|
||||
action = "允许取放";
|
||||
break;
|
||||
default:
|
||||
action = "禁止取放";
|
||||
}
|
||||
|
||||
switch (this.ioaction) {
|
||||
case 1:
|
||||
io_action = "允许进入";
|
||||
break;
|
||||
case 2:
|
||||
io_action = "允许离开";
|
||||
break;
|
||||
case 3:
|
||||
io_action = "允许进入离开";
|
||||
break;
|
||||
default:
|
||||
io_action = "禁止进入离开";
|
||||
}
|
||||
|
||||
String error;
|
||||
switch (this.error) {
|
||||
case 1:
|
||||
error = "急停中";
|
||||
break;
|
||||
case 2:
|
||||
error = "光幕报警";
|
||||
break;
|
||||
case 3:
|
||||
error = "本体报警";
|
||||
break;
|
||||
case 4:
|
||||
error = "未排产报警";
|
||||
break;
|
||||
case 5:
|
||||
error = "扫码故障";
|
||||
break;
|
||||
default:
|
||||
error = String.valueOf(this.error);
|
||||
}
|
||||
|
||||
JSONObject jo = new JSONObject();
|
||||
jo.put("device_name", this.getDevice().getDevice_name());
|
||||
jo.put("mode", mode);
|
||||
jo.put("move", move);
|
||||
jo.put("action", action);
|
||||
jo.put("io_action", io_action);
|
||||
jo.put("error", error);
|
||||
jo.put("barcode", vehicle_code);
|
||||
jo.put("container_type", vehicle_type);
|
||||
jo.put("isError", iserror);
|
||||
jo.put("isOnline", isonline);
|
||||
jo.put("hasGoods", hasGoods);
|
||||
jo.put("message", message);
|
||||
return jo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDeviceStatus(JSONObject data) {
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user