add:驱动开发

This commit is contained in:
2025-12-25 09:40:47 +08:00
parent d8e1ef0b3e
commit 853de6c582
13 changed files with 1537 additions and 3 deletions

View File

@@ -30,6 +30,8 @@ public enum DriverTypeEnum {
AUTODOOR(10, "standard_autodoor", "标准版-自动门", "autodoor"),
STRETCH(22, "stretch_wrapper", "缠绕机", "stretch"),
STANDARD_STACKER(11, "standard_stacker", "标准版-单工位堆垛机", "stacker"),
SIEMENS_CONVEYOR_LABELING(12, "siemens_conveyor_labeling", "西门子-输送机驱动-贴标", "conveyor"),

View File

@@ -18,7 +18,9 @@ public enum DeviceType {
group("设备组", 12),
plcDb("plcDb块", 13),
shadow("影子设备", 15),
other("其他设备", 16);
other("其他设备", 16),
stretch("缠绕机", 17),
pallet("拆盘机", 18);
private String code;

View File

@@ -17,7 +17,10 @@ import org.nl.acs.device.service.DeviceService;
import org.nl.acs.device_driver.DeviceDriver;
import org.nl.acs.device_driver.RequestMethodEnum;
import org.nl.acs.device_driver.basedriver.agv.utils.AgvActionEnum;
import org.nl.acs.device_driver.basedriver.pallet_dispenser.PalletDispenseDeviceDriver;
import org.nl.acs.device_driver.basedriver.standard_ordinary_site.StandardOrdinarySiteDeviceDriver;
import org.nl.acs.device_driver.basedriver.stretch_wrapper.ItemProtocol;
import org.nl.acs.device_driver.basedriver.stretch_wrapper.StretchWrapperDeviceDriver;
import org.nl.acs.device_driver.driver.AbstractDeviceDriver;
import org.nl.acs.device_driver.storage.standard_storage.StandardStorageDeviceDriver;
import org.nl.acs.ext.wms.data.one.feedBackTaskStatus.FeedBackTaskStatusRequest;
@@ -155,6 +158,7 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
//到达取货点
//(需要WCS反馈)
} else if (phase == 0x03) {
// 请求取货
if (agvaddr == 0) {
agvaddr = agvaddr_copy;
}
@@ -213,11 +217,42 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
data = ndcAgvService.sendAgvOneModeInst(phase, index, 0);
flag = true;
}
// 到达缠绕机
if (device.getDeviceDriver() instanceof StretchWrapperDeviceDriver) {
StretchWrapperDeviceDriver deviceDriver = (StretchWrapperDeviceDriver) device.getDeviceDriver();
// 下发请求取货
deviceDriver.writing(ItemProtocol.to_out, "1");
// 判断是否允许取货
if (deviceDriver.getAction() == 1) {
log.info("到达{}取货点开始取货", device_code);
inst.setExecute_status("1");
instructionService.update(inst);
data = ndcAgvService.sendAgvOneModeInst(phase, index, 0);
flag = true;
}
}
// 到达拆盘机
if (device.getDeviceDriver() instanceof PalletDispenseDeviceDriver) {
PalletDispenseDeviceDriver deviceDriver = (PalletDispenseDeviceDriver) device.getDeviceDriver();
// 下发请求取货
deviceDriver.writing(org.nl.acs.device_driver.basedriver.pallet_dispenser.ItemProtocol.to_out,"1");
// 判断是否允许取货
if (deviceDriver.getAction() == 1) {
log.info("到达{}取货点开始取货", device_code);
inst.setExecute_status("1");
instructionService.update(inst);
data = ndcAgvService.sendAgvOneModeInst(phase, index, 0);
flag = true;
}
}
} else if (phase == 0x04) {
data = getData(data, index, inst, task);
//取货完毕
//(需要WCS反馈)
} else if (phase == 0x05) {
// 取货完成
if (agvaddr == 0) {
agvaddr = agvaddr_copy;
}
@@ -266,11 +301,32 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
flag = true;
}
// 到达缠绕机取货完成
if (device.getDeviceDriver() instanceof StretchWrapperDeviceDriver) {
StretchWrapperDeviceDriver deviceDriver = (StretchWrapperDeviceDriver) device.getDeviceDriver();
deviceDriver.writing(ItemProtocol.to_out_finish, "1");
data = ndcAgvService.sendAgvOneModeInst(phase, index, 0);
log.info("agv进入" + device_code + "取货完成");
flag = true;
}
// 到达拆盘机取货完成
if (device.getDeviceDriver() instanceof PalletDispenseDeviceDriver) {
PalletDispenseDeviceDriver deviceDriver = (PalletDispenseDeviceDriver) device.getDeviceDriver();
deviceDriver.writing(org.nl.acs.device_driver.basedriver.pallet_dispenser.ItemProtocol.to_out_finish, "1");
data = ndcAgvService.sendAgvOneModeInst(phase, index, 0);
log.info("agv进入" + device_code + "取货完成");
flag = true;
}
} else if (phase == 0x06) {
data = getData(data, index, inst, task);
//到达放货点
//(需要WCS反馈)
} else if (phase == 0x07) {
// 请求放货
if (agvaddr == 0) {
agvaddr = agvaddr_copy;
}
@@ -321,9 +377,25 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
// log.info("{},{}", device_code, "允许AGV放货。");
// lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, "允许AGV放货。"));
}
// 缠绕机
if (device.getDeviceDriver() instanceof StretchWrapperDeviceDriver) {
StretchWrapperDeviceDriver deviceDriver = (StretchWrapperDeviceDriver) device.getDeviceDriver();
// 下发请求放货
deviceDriver.writing(ItemProtocol.to_in, "1");
// 判断是否允许放货
if (deviceDriver.getAction() == 1) {
log.info("到达{}放货点开始放货", device_code);
inst.setExecute_status("1");
instructionService.update(inst);
data = ndcAgvService.sendAgvOneModeInst(phase, index, 0);
flag = true;
}
}
//放货完毕
//(需要WCS反馈)
} else if (phase == 0x09) {
// 放货完成
if (agvaddr == 0) {
agvaddr = agvaddr_copy;
}
@@ -376,6 +448,16 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
// log.info("{},{}", device_code, "允许AGV放货后离开。");
//lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, "允许AGV放货后离开。"));
}
// 到达缠绕机放货完成
if (device.getDeviceDriver() instanceof StretchWrapperDeviceDriver) {
StretchWrapperDeviceDriver deviceDriver = (StretchWrapperDeviceDriver) device.getDeviceDriver();
deviceDriver.writing(ItemProtocol.to_in_finish, "1");
data = ndcAgvService.sendAgvOneModeInst(phase, index, 0);
log.info("{}放货完成", device_code);
flag = true;
}
}
//到达位置点
//(需要WCS反馈)

View File

@@ -0,0 +1,69 @@
package org.nl.acs.device_driver.basedriver.pallet_dispenser;
import lombok.extern.slf4j.Slf4j;
import org.nl.acs.device.device_driver.standard_inspect.ItemDto;
import java.util.ArrayList;
import java.util.List;
@Slf4j
public class ItemProtocol {
// 入口允许取放货
public static String action = "action";
// 故障信号
public static String error = "error";
// 下发请求取货
public static String to_out = "to_out";
// 下发取货完成
public static String to_out_finish = "to_out_finish";
private PalletDispenseDeviceDriver driver;
public ItemProtocol(PalletDispenseDeviceDriver driver) {
this.driver = driver;
}
public int getAction() {
return this.getOpcIntegerValue(action);
}
public int getError() {
return this.getOpcIntegerValue(error);
}
public int getToOut() {
return this.getOpcIntegerValue(to_out);
}
public int getToOutFinish() {
return this.getOpcIntegerValue(to_out_finish);
}
public int getOpcIntegerValue(String protocol) {
Integer value = this.driver.getIntegeregerValue(protocol);
if (value == null) {
// log.error("读取错误!");
} else {
return value;
}
return 0;
}
public static List<ItemDto> getReadableItemDtos() {
ArrayList list = new ArrayList();
list.add(new ItemDto(action, "是否允许取货", "V6200.0"));
list.add(new ItemDto(error, "报警信号", "V6200.1"));
return list;
}
public static List<ItemDto> getWriteableItemDtos() {
ArrayList list = new ArrayList();
list.add(new ItemDto(to_out, "下发请求取货", "V6300.0"));
list.add(new ItemDto(to_out_finish, "下发取货完成", "V6300.1"));
return list;
}
}

View File

@@ -0,0 +1,197 @@
package org.nl.acs.device_driver.basedriver.pallet_dispenser;
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.DeviceService;
import org.nl.acs.device_driver.DeviceDriver;
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.log.service.DeviceExecuteLogService;
import org.nl.acs.route.service.RouteLineService;
import org.nl.acs.task.service.TaskService;
import org.nl.acs.utils.ReadUtil;
import org.nl.config.SpringContextHolder;
import org.nl.system.service.lucene.LuceneExecuteLogService;
import org.nl.system.service.lucene.dto.LuceneLogDto;
import org.openscada.opc.lib.da.Server;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
/**
* 拆盘机驱动
*/
@Slf4j
@Data
@RequiredArgsConstructor
public class PalletDispenseDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver {
protected ItemProtocol itemProtocol = new ItemProtocol(this);
InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl");
LuceneExecuteLogService lucene = SpringContextHolder.getBean("luceneExecuteLogServiceImpl");
DeviceService deviceservice = SpringContextHolder.getBean("deviceServiceImpl");
RouteLineService routelineserver = SpringContextHolder.getBean("routeLineServiceImpl");
TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl");
AcsToWmsService acsToWmsService = SpringContextHolder.getBean("acsToWmsServiceImpl");
String container;
String container_type_desc;
String last_container_type_desc;
String last_container;
//放货准备锁
String putReadyLock = null;
//有货标记
protected boolean has_goods_tag = false;
String devicecode;
int action = 0;
int error = 0;
Boolean iserror = false;
int move = 0;
int task = 0;
int last_action = 0;
int last_error = 0;
int last_task_out = 0;
int last_move = 0;
int last_task = 0;
boolean hasVehicle = false;
boolean isReady = false;
protected int instruction_num = 0;
protected int instruction_num_truth = 0;
protected boolean hasGoods = false;
boolean isFold = false;
private String assemble_check_tag;
private Boolean sampleMode0;
private Boolean sampleMode3;
private Integer sampleError;
private Boolean sampleOnline;
protected String displayMessage = null;
public int display_message_time_out = 30000;
public Date display_message_time;
protected String current_stage_instruction_message;
protected String last_stage_instruction_message;
Integer heartbeat_tag;
private Date instruction_require_time = new Date();
private Date instruction_finished_time = new Date();
private int instruction_require_time_out;
boolean requireSucess = false;
private int instruction_finished_time_out;
int branchProtocol = 0;
String message = "";
@Override
public Device getDevice() {
return this.device;
}
@Override
public void execute() {
devicecode = this.getDevice().getDevice_code();
action = this.itemProtocol.getAction();
error = this.itemProtocol.getError();
last_action = action;
last_error = error;
}
/**
* 执行业务逻辑
*/
public void executeTask() {
}
public synchronized String getStatus() {
JSONObject jo = new JSONObject();
if (action == 1) {
jo.put("name", this.getDevice().getDevice_code());
jo.put("status", "OPEN");
} else if (action == 2) {
jo.put("name", this.getDevice().getDevice_code());
jo.put("status", "CLOSE");
} else {
jo.put("name", this.getDevice().getDevice_code());
jo.put("status", "ERROR");
}
return jo.toString();
}
/**
* 多个信号一起下发电气
*
* @param map
*/
public void writing(Map<String, Object> map) {
LuceneExecuteLogService lucene = SpringContextHolder.getBean(LuceneExecuteLogService.class);
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)) {
try {
this.checkcontrol(itemMap);
} catch (Exception e) {
e.printStackTrace();
try {
this.checkcontrol(itemMap);
} catch (Exception e1) {
e1.printStackTrace();
}
}
logServer.deviceExecuteLog(this.getDevice().getDevice_code(), "", "", "下发多个电气信号:" + itemMap);
lucene.deviceExecuteLog(new LuceneLogDto(this.getDeviceCode(), "下发多个电气信号:" + itemMap));
}
}
/**
* 抽取统一下发电气信号前缀
*
* @return
*/
public String getToParam() {
return this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + ".";
}
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<String, Object>();
if (value instanceof String) {
itemMap.put(to_param, value);
} else {
itemMap.put(to_param, value);
}
ReadUtil.write(itemMap, server);
server.disconnect();
log.info("下发PLC信号{},{}", this.devicecode, "to_command:" + value);
lucene.deviceExecuteLog(new LuceneLogDto(this.devicecode, message + param + " 写入 " + value));
}
}

View File

@@ -0,0 +1,69 @@
package org.nl.acs.device_driver.basedriver.pallet_dispenser;
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.ArrayList;
import java.util.LinkedList;
import java.util.List;
/**
* 拆盘机驱动定义
*/
@Service
public class PalletDispenserDefination implements OpcDeviceDriverDefination {
@Override
public String getDriverCode() {
return "pallet_dispenser";
}
@Override
public String getDriverName() {
return "拆盘机";
}
@Override
public String getDriverDescription() {
return "拆盘机";
}
@Override
public DeviceDriver getDriverInstance(Device device) {
return (new PalletDispenseDeviceDriver()).setDevice(device).setDriverDefination(this);
}
@Override
public Class<? extends DeviceDriver> getDeviceDriverType() {
return PalletDispenseDeviceDriver.class;
}
@Override
public List<DeviceType> getFitDeviceTypes() {
List<DeviceType> types = new LinkedList();
types.add(DeviceType.pallet);
return types;
}
@Override
public List<ItemDto> getReadableItemDtos() {
return getReadableItemDtos2();
}
public static List<ItemDto> getReadableItemDtos2() {
List<ItemDto> list = new ArrayList();
list.add(new ItemDto(ItemProtocol.action, "是否允许取货", "V6200.0"));
list.add(new ItemDto(ItemProtocol.error, "报警信号", "V6200.1"));
return list;
}
@Override
public List<ItemDto> getWriteableItemDtos() {
return ItemProtocol.getWriteableItemDtos();
}
}

View File

@@ -0,0 +1,97 @@
package org.nl.acs.device_driver.basedriver.stretch_wrapper;
import lombok.extern.slf4j.Slf4j;
import org.nl.acs.device.device_driver.standard_inspect.ItemDto;
import java.util.ArrayList;
import java.util.List;
@Slf4j
public class ItemProtocol {
// 入口允许取放货
public static String action = "action";
// 缠绕完成(申请取货任务)
public static String task_out = "task_out";
// 故障信号
public static String error = "error";
// 空闲(申请放货任务)
public static String task_in = "task_in";
// 下发请求取货
public static String to_out = "to_out";
// 下发请求放货
public static String to_in = "to_in";
// 下发取货完成
public static String to_out_finish = "to_out_finish";
// 下发放货完成
public static String to_in_finish = "to_in_finish";
private StretchWrapperDeviceDriver driver;
public ItemProtocol(StretchWrapperDeviceDriver driver) {
this.driver = driver;
}
public int getAction() {
return this.getOpcIntegerValue(action);
}
public int getTaskOut() {
return this.getOpcIntegerValue(task_out);
}
public int getError() {
return this.getOpcIntegerValue(error);
}
public int getTaskIn() {
return this.getOpcIntegerValue(task_in);
}
public int getToOut() {
return this.getOpcIntegerValue(to_out);
}
public int getToIn() {
return this.getOpcIntegerValue(to_in);
}
public int getToOutFinish() {
return this.getOpcIntegerValue(to_out_finish);
}
public int getToInFinish() {
return this.getOpcIntegerValue(to_in_finish);
}
public int getOpcIntegerValue(String protocol) {
Integer value = this.driver.getIntegeregerValue(protocol);
if (value == null) {
// log.error("读取错误!");
} else {
return value;
}
return 0;
}
public static List<ItemDto> getReadableItemDtos() {
ArrayList list = new ArrayList();
list.add(new ItemDto(action, "是否允许取放货", "V6000.0"));
list.add(new ItemDto(task_out, "申请取货任务", "V6000.1"));
list.add(new ItemDto(task_in, "申请放货任务", "V6000.3"));
list.add(new ItemDto(error, "报警信号", "V6000.2"));
return list;
}
public static List<ItemDto> getWriteableItemDtos() {
ArrayList list = new ArrayList();
list.add(new ItemDto(to_out, "下发请求取货", "V6100.0"));
list.add(new ItemDto(to_in, "下发请求放货", "V6100.1"));
list.add(new ItemDto(to_out_finish, "下发取货完成", "V6100.2"));
list.add(new ItemDto(to_in_finish, "下发放货完成", "V6100.3"));
return list;
}
}

View File

@@ -0,0 +1,71 @@
package org.nl.acs.device_driver.basedriver.stretch_wrapper;
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.ArrayList;
import java.util.LinkedList;
import java.util.List;
/**
* 缠绕机驱动定义
*/
@Service
public class StretchWrapperDefination implements OpcDeviceDriverDefination {
@Override
public String getDriverCode() {
return "stretch_wrapper";
}
@Override
public String getDriverName() {
return "缠绕机";
}
@Override
public String getDriverDescription() {
return "缠绕机";
}
@Override
public DeviceDriver getDriverInstance(Device device) {
return (new StretchWrapperDeviceDriver()).setDevice(device).setDriverDefination(this);
}
@Override
public Class<? extends DeviceDriver> getDeviceDriverType() {
return StretchWrapperDeviceDriver.class;
}
@Override
public List<DeviceType> getFitDeviceTypes() {
List<DeviceType> types = new LinkedList();
types.add(DeviceType.stretch);
return types;
}
@Override
public List<ItemDto> getReadableItemDtos() {
return getReadableItemDtos2();
}
public static List<ItemDto> getReadableItemDtos2() {
List<ItemDto> list = new ArrayList();
list.add(new ItemDto(ItemProtocol.action, "是否允许取货", "V6000.0"));
list.add(new ItemDto(ItemProtocol.task_out, "申请取货任务", "V6000.1"));
list.add(new ItemDto(ItemProtocol.task_in, "申请放货任务", "V6000.3"));
list.add(new ItemDto(ItemProtocol.error, "报警信号", "V6000.2"));
return list;
}
@Override
public List<ItemDto> getWriteableItemDtos() {
return ItemProtocol.getWriteableItemDtos();
}
}

View File

@@ -0,0 +1,212 @@
package org.nl.acs.device_driver.basedriver.stretch_wrapper;
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.DeviceService;
import org.nl.acs.device_driver.DeviceDriver;
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.log.service.DeviceExecuteLogService;
import org.nl.acs.route.service.RouteLineService;
import org.nl.acs.task.service.TaskService;
import org.nl.acs.utils.ReadUtil;
import org.nl.config.SpringContextHolder;
import org.nl.system.service.lucene.LuceneExecuteLogService;
import org.nl.system.service.lucene.dto.LuceneLogDto;
import org.openscada.opc.lib.da.Server;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
/**
* 缠绕机驱动
*/
@Slf4j
@Data
@RequiredArgsConstructor
public class StretchWrapperDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver {
protected ItemProtocol itemProtocol = new ItemProtocol(this);
InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl");
LuceneExecuteLogService lucene = SpringContextHolder.getBean("luceneExecuteLogServiceImpl");
DeviceService deviceservice = SpringContextHolder.getBean("deviceServiceImpl");
RouteLineService routelineserver = SpringContextHolder.getBean("routeLineServiceImpl");
TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl");
AcsToWmsService acsToWmsService = SpringContextHolder.getBean("acsToWmsServiceImpl");
String container;
String container_type_desc;
String last_container_type_desc;
String last_container;
//放货准备锁
String putReadyLock = null;
//有货标记
protected boolean has_goods_tag = false;
String devicecode;
int action = 0;
int task_in = 0;
int task_out = 0;
int error = 0;
Boolean iserror = false;
int move = 0;
int task = 0;
int last_action = 0;
int last_error = 0;
int last_task_in = 0;
int last_task_out = 0;
int last_move = 0;
int last_task = 0;
boolean hasVehicle = false;
boolean isReady = false;
protected int instruction_num = 0;
protected int instruction_num_truth = 0;
protected boolean hasGoods = false;
boolean isFold = false;
private String assemble_check_tag;
private Boolean sampleMode0;
private Boolean sampleMode3;
private Integer sampleError;
private Boolean sampleOnline;
protected String displayMessage = null;
public int display_message_time_out = 30000;
public Date display_message_time;
protected String current_stage_instruction_message;
protected String last_stage_instruction_message;
Integer heartbeat_tag;
private Date instruction_require_time = new Date();
private Date instruction_finished_time = new Date();
private int instruction_require_time_out;
boolean requireSucess = false;
private int instruction_finished_time_out;
int branchProtocol = 0;
String message = "";
@Override
public Device getDevice() {
return this.device;
}
@Override
public void execute() {
devicecode = this.getDevice().getDevice_code();
task_in = this.itemProtocol.getTaskIn();
task_out = this.itemProtocol.getTaskOut();
action = this.itemProtocol.getAction();
error = this.itemProtocol.getError();
last_action = action;
last_error = error;
last_task_in = task_in;
last_task_out = task_out;
}
/**
* 执行业务逻辑
*/
public void executeTask() {
// 申请叫料任务
if (last_task_in == 1) {
// 调用上位接口
}
// 申请下料任务
if (last_task_out == 1) {
// 调用上位接口
}
}
public synchronized String getStatus() {
JSONObject jo = new JSONObject();
if (action == 1) {
jo.put("name", this.getDevice().getDevice_code());
jo.put("status", "OPEN");
} else if (action == 2) {
jo.put("name", this.getDevice().getDevice_code());
jo.put("status", "CLOSE");
} else {
jo.put("name", this.getDevice().getDevice_code());
jo.put("status", "ERROR");
}
return jo.toString();
}
/**
* 多个信号一起下发电气
*
* @param map
*/
public void writing(Map<String, Object> map) {
LuceneExecuteLogService lucene = SpringContextHolder.getBean(LuceneExecuteLogService.class);
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)) {
try {
this.checkcontrol(itemMap);
} catch (Exception e) {
e.printStackTrace();
try {
this.checkcontrol(itemMap);
} catch (Exception e1) {
e1.printStackTrace();
}
}
logServer.deviceExecuteLog(this.getDevice().getDevice_code(), "", "", "下发多个电气信号:" + itemMap);
lucene.deviceExecuteLog(new LuceneLogDto(this.getDeviceCode(), "下发多个电气信号:" + itemMap));
}
}
/**
* 抽取统一下发电气信号前缀
*
* @return
*/
public String getToParam() {
return this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + ".";
}
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<String, Object>();
if (value instanceof String) {
itemMap.put(to_param, value);
} else {
itemMap.put(to_param, value);
}
ReadUtil.write(itemMap, server);
server.disconnect();
log.info("下发PLC信号{},{}", this.devicecode, "to_command:" + value);
lucene.deviceExecuteLog(new LuceneLogDto(this.devicecode, message + param + " 写入 " + value));
}
}

View File

@@ -10,10 +10,10 @@ spring:
driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy
# url: jdbc:log4jdbc:mysql://${DB_HOST:192.168.81.252}:${DB_PORT:3306}/${DB_NAME:stand_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true
# url: jdbc:log4jdbc:mysql://${DB_HOST:47.111.78.178}:${DB_PORT:3306}/${DB_NAME:lzhl_two_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true
url: jdbc:log4jdbc:mysql://${DB_HOST:127.0.0.1}:${DB_PORT:3306}/${DB_NAME:beian_xinshengacs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true&allowPublicKeyRetrieval=true
url: jdbc:log4jdbc:mysql://${DB_HOST:192.168.81.251}:${DB_PORT:3306}/${DB_NAME:huadongyiyao_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true&allowPublicKeyRetrieval=true
username: ${DB_USER:root}
# password: ${DB_PWD:Root.123456}
password: ${DB_PWD:root}
password: ${DB_PWD:P@ssw0rd.}
# 初始连接数
initial-size: 5
# 最小连接数