add:驱动前端

This commit is contained in:
2024-01-02 18:01:23 +08:00
parent 4e8a91e58d
commit 624f7284f9
15 changed files with 2226 additions and 1131 deletions

View File

@@ -13,7 +13,7 @@ import org.nl.acs.agv.server.ZheDaAgvService;
import org.nl.acs.common.base.CommonFinalParam;
import org.nl.acs.device.domain.Device;
import org.nl.acs.device_driver.conveyor.hongxiang_device.HongXiangConveyorDeviceDriver;
import org.nl.acs.device_driver.hongxiang_device.HongXiangConveyorDeviceDriver;
import org.nl.acs.ext.wms.service.AcsToWmsService;
import org.nl.acs.instruction.domain.Instruction;
import org.nl.acs.instruction.service.InstructionService;

View File

@@ -11,7 +11,7 @@ import java.util.LinkedList;
import java.util.List;
/**
* 烘箱工位
* 下料按钮
*/
@Service
public class BlankingButtonDefination implements OpcDeviceDriverDefination {
@@ -22,12 +22,12 @@ public class BlankingButtonDefination implements OpcDeviceDriverDefination {
@Override
public String getDriverName() {
return "生箔机按钮协议";
return "下料按钮";
}
@Override
public String getDriverDescription() {
return "生箔机按钮协议";
return "下料按钮";
}
@Override

View File

@@ -23,7 +23,7 @@ import java.util.HashMap;
import java.util.Map;
/**
* 烘箱工位
* 下料按钮
*/
@Slf4j
@Data

View File

@@ -1,60 +0,0 @@
package org.nl.acs.device_driver.conveyor.hongxiang_device;
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.LinkedList;
import java.util.List;
/**
* 烘箱工位
*/
@Service
public class HongXiangConveyorDefination implements OpcDeviceDriverDefination {
@Override
public String getDriverCode() {
return "hongxiang_device";
}
@Override
public String getDriverName() {
return "烘箱工位";
}
@Override
public String getDriverDescription() {
return "烘箱工位";
}
@Override
public DeviceDriver getDriverInstance(Device device) {
return (new HongXiangConveyorDeviceDriver()).setDevice(device).setDriverDefination(this);
}
@Override
public Class<? extends DeviceDriver> getDeviceDriverType() {
return HongXiangConveyorDeviceDriver.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

@@ -1,356 +0,0 @@
package org.nl.acs.device_driver.conveyor.hongxiang_device;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import lombok.Data;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
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;
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.data.one.ApplyLabelingAndBindingRequest;
import org.nl.acs.ext.wms.data.one.ApplyLabelingAndBindingResponse;
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.DeviceAppService;
import org.nl.acs.route.service.RouteLineService;
import org.nl.acs.storage_cell.domain.StorageCell;
import org.nl.acs.storage_cell.service.mapper.StorageCellMapper;
import org.nl.acs.task.service.TaskService;
import org.nl.system.service.param.ISysParamService;
import org.nl.config.SpringContextHolder;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.*;
/**
* 烘箱工位
*/
@Slf4j
@Data
@RequiredArgsConstructor
public class HongXiangConveyorDeviceDriver 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
ISysParamService paramService = SpringContextHolder.getBean(ISysParamService.class);
@Autowired
DeviceExecuteLogService logServer = SpringContextHolder.getBean(DeviceExecuteLogService.class);
@Autowired
AgvService agvService = SpringContextHolder.getBean(AgvService.class);
@Autowired
StorageCellMapper storageCellMapper;
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;
public int heartbeat = 0;
public int mode = 0;
public int move = 0;
public int action = 0;
public int error = 0;
public int door = 0;
public int temperature = 0;
public int countdown_house = 0;
public int countdown_min = 0;
public int countdown_sec = 0;
public int finish = 0;
public int task = 0;
public int error1 = 0;
public int material = 0;
public int consumption = 0;
public float voltageA = 0;
public float voltageB = 0;
public float voltageC = 0;
public float currentA = 0;
public float currentB = 0;
public float currentC = 0;
public int last_heartbeat = 0;
public int last_mode = 0;
public int last_move = 0;
public int last_action = 0;
public int last_error = 0;
public int last_door = 0;
public int last_temperature = 0;
public int last_countdown_house = 0;
public int last_countdown_min = 0;
public int last_countdown_sec = 0;
public int last_finish = 0;
public int last_task = 0;
public int last_error1 = 0;
public int last_material = 0;
public int last_consumption = 0;
public float last_voltageA = 0;
public float last_voltageB = 0;
public float last_voltageC = 0;
public float last_currentA = 0;
public float last_currentB = 0;
public float last_currentC = 0;
Boolean isonline = true;
Boolean iserror = false;
/**
* 1-执行任务2-取货完成3-放货完成;
*/
int flag;
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.getItem_heartbeat();
mode = this.itemProtocol.getItem_mode();
move = this.itemProtocol.getItem_move();
action = this.itemProtocol.getItem_action();
error = this.itemProtocol.getItem_error();
door = this.itemProtocol.getItem_door();
temperature = this.itemProtocol.getItem_temperature();
countdown_house = this.itemProtocol.getItem_countdown_house();
countdown_min = this.itemProtocol.getItem_countdown_min();
countdown_sec = this.itemProtocol.getItem_countdown_sec();
finish = this.itemProtocol.getItem_finish();
task = this.itemProtocol.getItem_task();
error1 = this.itemProtocol.getItem_error1();
material = this.itemProtocol.getItem_material();
consumption = this.itemProtocol.getItem_consumption();
voltageA = this.itemProtocol.getItem_voltageA();
voltageB = this.itemProtocol.getItem_voltageB();
voltageC = this.itemProtocol.getItem_voltageC();
currentA = this.itemProtocol.getItem_currentA();
currentB = this.itemProtocol.getItem_currentB();
currentC = this.itemProtocol.getItem_currentC();
if (mode != last_mode) {
//this.setRequireSucess(false);
}
if (move != last_move) {
if (move == 0) {
thingToNothing();
}
}
if (finish != last_finish) {
if (finish == 1) {
logServer.deviceExecuteLog(device_code, "", "", "开始请求标记复位`此时请求标记值为requireSucess:" + requireSucess);
requireSucess = false;
logServer.deviceExecuteLog(device_code, "", "", "请求标记复位成功`此时请求标记值为requireSucess:" + requireSucess);
}
logServer.deviceExecuteLog(this.device_code, "", "", "信号move" + last_finish + "->" + finish);
}
if (mode == 0) {
this.setIsonline(false);
message = "有报警";
//无报警
} else if (error != 0) {
this.setIserror(true);
message = "有报警";
//无报警
} else {
this.setIsonline(true);
this.setIserror(false);
if (move == 0 && last_move == 1) {
//requireSucess = false;
}
if (finish == 1 && !requireSucess) {
logServer.deviceExecuteLog(this.getDevice_code(), "", "", "开始烘箱完成反馈lms~");
//烘箱完成反馈LMS
apply_finish();
}
}
last_mode = mode;
last_move = move;
last_action = action;
last_error = error;
last_door = door;
last_temperature = temperature;
last_countdown_house = countdown_house;
last_countdown_min = countdown_min;
last_countdown_sec = countdown_sec;
last_finish = finish;
last_task = task;
last_error1 = error1;
last_material = material;
last_consumption = consumption;
last_voltageA = voltageA;
last_voltageB = voltageB;
last_voltageC = voltageC;
last_currentA = currentA;
last_currentB = currentB;
last_currentC = currentC;
}
protected void thingToNothing() {
//this.setRequireSucess(false);
}
public void writing(int command) {
String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
+ "." + 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);
this.control(itemMap);
}
/**
* 将扩展表中的字符串数据转换成集合
*/
@Override
public List<String> getExtraDeviceCodes(String extraName) {
String extraValue = (String) this.getDevice().getExtraValue().get(extraName);
if (StrUtil.isEmpty(extraValue)) {
return new ArrayList<>();
}
String devicesString = extraValue.substring(1, extraValue.length() - 1);
List<String> devicesList = new ArrayList<>();
String[] devices = devicesString.split(",");
for (int i = 0; i < devices.length; i++) {
String s = devices[i].replace("\"", "").replace("\"", "");
devicesList.add(s);
}
return devicesList;
}
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>();
itemMap.put(to_param, Integer.parseInt(value));
// itemMap.put(to_param, Integer.parseInt(value));
this.control(itemMap);
logServer.deviceExecuteLog(device_code, "", "", "下发电气信号设备号:" + device_code + ",下发电气:" + to_param + ",下发电气值:" + value);
}
@Override
public JSONObject getDeviceStatusName() {
JSONObject jo = new JSONObject();
String mode = "";
String action = "";
String move = "";
if (this.getMode() == 0) {
mode = "未联机";
} else if (this.getMode() == 1) {
mode = "联机";
} else if (this.getMode() == 2) {
mode = "联机";
}
String requireSucess = "0";
if (this.requireSucess) {
requireSucess = CommonFinalParam.ONE;
}
jo.put("requireSucess", requireSucess);
if (this.getMove() == 0) {
move = "无货";
jo.put("hasGoods", false);
} else if (this.getMove() == 1) {
move = "有货";
jo.put("hasGoods", true);
} else if (this.getMove() == 2) {
move = "有托盘有货";
jo.put("hasGoods", true);
}
jo.put("device_name", this.getDevice().getDevice_name());
jo.put("temperature", temperature);
jo.put("finish", finish);
jo.put("isOnline", this.getIsonline());
jo.put("error", this.getError());
jo.put("isError", this.getIserror());
jo.put("countdown_house", countdown_house);
jo.put("countdown_min", countdown_min);
jo.put("countdown_sec", countdown_sec);
jo.put("door", door);
jo.put("mode", mode);
jo.put("move", move);
jo.put("action", action);
jo.put("isOnline", this.getIsonline());
jo.put("error", this.getError());
jo.put("isError", this.getIserror());
jo.put("task", this.getTask());
return jo;
}
@Override
public void setDeviceStatus(JSONObject data) {
}
public synchronized boolean apply_finish() {
Date date = new Date();
if (date.getTime() - this.instruction_apply_time.getTime() < (long) this.instruction_require_time_out) {
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out);
return false;
} else {
this.instruction_apply_time = date;
ApplyLabelingAndBindingRequest applyLabelingAndBindingRequest = new ApplyLabelingAndBindingRequest();
// JSONObject device_json = WQLObject.getWQLObject("acs_storage_cell").query("storage_code ='" + this.device_code + "'").uniqueResult(0);
StorageCell storageCell = new LambdaQueryChainWrapper<>(storageCellMapper)
.eq(StorageCell::getStorage_code, this.device_code)
.one();
String start_point_code = null;
if (!ObjectUtil.isEmpty(storageCell)) {
// start_point_code = (String) device_json.get("parent_storage_code") == null ? this.device_code : (String) device_json.get("parent_storage_code");
start_point_code = (String) storageCell.getParent_storage_code() == null ? this.device_code : (String) storageCell.getParent_storage_code();
}
applyLabelingAndBindingRequest.setDevice_code(start_point_code);
applyLabelingAndBindingRequest.setType("3");
ApplyLabelingAndBindingResponse applyLabelingAndBindingResponse = acsToWmsService.applyLabelingAndBindingRequest(applyLabelingAndBindingRequest);
if (applyLabelingAndBindingResponse.getstatus() == 200) {
requireSucess = true;
logServer.deviceExecuteLog(this.getDevice_code(), "", "", "烘箱完成反馈lms响应消息:" + String.valueOf(applyLabelingAndBindingResponse));
} else {
logServer.deviceExecuteLog(this.getDevice_code(), "", "", "烘箱完成反馈lms响应消息:" + String.valueOf(applyLabelingAndBindingResponse));
}
return true;
}
}
}

View File

@@ -1,256 +0,0 @@
package org.nl.acs.device_driver.conveyor.hongxiang_device;
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_action = "action";
public static String item_error = "error";
public static String item_door = "door";
public static String item_temperature = "temperature";
/**
* 恒温倒计时
*/
public static String item_countdown_house = "countdown_house";
public static String item_countdown_min = "countdown_min";
public static String item_countdown_sec = "countdown_sec";
public static String item_finish = "finish";
public static String item_task = "task";
public static String item_error1 = "error1";
public static String item_material = "material";
public static String item_consumption = "consumption";
public static String item_voltageA = "voltageA";
public static String item_voltageB = "voltageB";
public static String item_voltageC = "voltageC";
public static String item_currentA = "currentA";
public static String item_currentB = "currentB";
public static String item_currentC = "currentC";
public static String item_to_command = "to_command";
public static String item_to_open_door = "to_open_door";
public static String item_to_close_door = "to_close_door";
public static String item_to_temperature = "to_temperature";
public static String item_to_material = "to_material";
public static String item_to_time_house = "to_time_house";
public static String item_to_time_min = "to_time_min";
public static String item_to_time_sec = "to_time_sec";
public static String item_to_task = "to_task";
private HongXiangConveyorDeviceDriver driver;
public ItemProtocol(HongXiangConveyorDeviceDriver driver) {
this.driver = driver;
}
public int getItem_heartbeat() {
return this.getOpcIntegerValue(item_heartbeat);
}
;
public int getItem_mode() {
return this.getOpcIntegerValue(item_mode);
}
;
public int getItem_move() {
return this.getOpcIntegerValue(item_move);
}
;
public int getItem_action() {
return this.getOpcIntegerValue(item_action);
}
;
public int getItem_error() {
return this.getOpcIntegerValue(item_error);
}
;
public int getItem_door() {
return this.getOpcIntegerValue(item_door);
}
;
public int getItem_temperature() {
return this.getOpcIntegerValue(item_temperature);
}
;
public int getItem_countdown_house() {
return this.getOpcIntegerValue(item_countdown_house);
}
;
public int getItem_countdown_min() {
return this.getOpcIntegerValue(item_countdown_min);
}
;
public int getItem_countdown_sec() {
return this.getOpcIntegerValue(item_countdown_sec);
}
;
public int getItem_finish() {
return this.getOpcIntegerValue(item_finish);
}
;
public int getItem_task() {
return this.getOpcIntegerValue(item_task);
}
;
public int getItem_error1() {
return this.getOpcIntegerValue(item_error1);
}
;
public int getItem_material() {
return this.getOpcIntegerValue(item_material);
}
;
public int getItem_consumption() {
return this.getOpcIntegerValue(item_consumption);
}
;
public float getItem_voltageA() {
return this.getOpcFloatValue(item_voltageA);
}
;
public float getItem_voltageB() {
return this.getOpcFloatValue(item_voltageB);
}
;
public float getItem_voltageC() {
return this.getOpcFloatValue(item_voltageC);
}
;
public float getItem_currentA() {
return this.getOpcFloatValue(item_currentA);
}
;
public float getItem_currentB() {
return this.getOpcFloatValue(item_currentB);
}
;
public float getItem_currentC() {
return this.getOpcFloatValue(item_currentC);
}
;
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 float getOpcFloatValue(String protocol) {
Float value = this.driver.getDoubleValue(protocol);
if (value == null) {
setIsonline(false);
} else {
setIsonline(true);
return value;
}
return 0L;
}
public static List<ItemDto> getReadableItemDtos() {
ArrayList list = new ArrayList();
list.add(new ItemDto(item_heartbeat, "心跳", "251"));
list.add(new ItemDto(item_mode, "工作模式", "7990"));
list.add(new ItemDto(item_move, "光电信号", "550"));
list.add(new ItemDto(item_door, "门状态", "450"));
list.add(new ItemDto(item_temperature, "工位温度", "7991"));
list.add(new ItemDto(item_countdown_house, "恒温倒计时(时)", "80500"));
list.add(new ItemDto(item_countdown_min, "恒温倒计时(分)", "80502"));
list.add(new ItemDto(item_countdown_sec, "恒温倒计时(秒)", "80504"));
list.add(new ItemDto(item_finish, "烘干完成", "8025"));
list.add(new ItemDto(item_action, "取放信号", "450"));
list.add(new ItemDto(item_task, "任务号", "220"));
list.add(new ItemDto(item_error, "故障", "8055"));
list.add(new ItemDto(item_error1, "故障1", "216"));
list.add(new ItemDto(item_material, "物料", "223"));
list.add(new ItemDto(item_consumption, "电能耗", "8092"));
list.add(new ItemDto(item_voltageA, "A相电压", "8080"));
list.add(new ItemDto(item_voltageB, "B相电压", "8082"));
list.add(new ItemDto(item_voltageC, "C相电压", "8084"));
list.add(new ItemDto(item_currentA, "A相电流", "8086"));
list.add(new ItemDto(item_currentB, "B相电流", "8088"));
list.add(new ItemDto(item_currentC, "C相电流", "8090"));
return list;
}
public static List<ItemDto> getWriteableItemDtos() {
ArrayList list = new ArrayList();
list.add(new ItemDto(item_to_command, "下发命令", "40226"));
list.add(new ItemDto(item_to_open_door, "开门", "00111"));
list.add(new ItemDto(item_to_close_door, "关门", "00112"));
list.add(new ItemDto(item_to_temperature, "生产温度", "48100"));
list.add(new ItemDto(item_to_material, "生产物料", "40229"));
list.add(new ItemDto(item_to_time_house, "生产时间(时)", "48771"));
list.add(new ItemDto(item_to_time_min, "生产时间(分)", "48770"));
list.add(new ItemDto(item_to_task, "任务号", "40232"));
return list;
}
@Override
public String toString() {
return "";
}
}

View File

@@ -13,9 +13,9 @@ 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.RouteableDeviceDriver;
import org.nl.acs.device_driver.conveyor.hongxiang_device.HongXiangConveyorDeviceDriver;
import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver;
import org.nl.acs.device_driver.driver.ExecutableDeviceDriver;
import org.nl.acs.device_driver.hongxiang_device.HongXiangConveyorDeviceDriver;
import org.nl.acs.ext.wms.service.AcsToWmsService;
import org.nl.acs.instruction.domain.Instruction;
import org.nl.acs.instruction.enums.InstructionStatusEnum;

View File

@@ -1,161 +0,0 @@
package org.nl.acs.device_driver.plug_pull_device_site;
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 {
//1/0 手动/自动
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";
//1 全自动启动
public static String item_to_command = "to_command";
//0/1 穿轴/拔轴
public static String item_to_type = "to_type";
//3/6 轴尺寸
public static String item_to_size = "to_size";
private PlugPullDeviceSiteDeviceDriver driver;
public ItemProtocol(PlugPullDeviceSiteDeviceDriver driver) {
this.driver = driver;
}
public int getItem_mode(){
return this.getOpcIntegerValue(item_mode);
} ;
public int getItem_move(){
return this.getOpcIntegerValue(item_move);
} ;
public int getItem_action(){
return this.getOpcIntegerValue(item_action);
};
public int getItem_control(){
return this.getOpcIntegerValue(item_control);
} ;
public int getItem_status(){
return this.getOpcIntegerValue(item_status);
} ;
public int getItem_plug_finish(){
return this.getOpcIntegerValue(item_plug_finish);
} ;
public int getItem_pull_finish(){
return this.getOpcIntegerValue(item_pull_finish);
} ;
public int getItem_3plug_times(){
return this.getOpcIntegerValue(item_3plug_times);
} ;
public int getItem_6plug_times(){
return this.getOpcIntegerValue(item_6plug_times);
} ;
public int getItem_3pull_times(){
return this.getOpcIntegerValue(item_3pull_times);
} ;
public int getItem_6pull_times(){
return this.getOpcIntegerValue(item_6pull_times);
} ;
public int getItem_plug_alltimes(){
return this.getOpcIntegerValue(item_plug_alltimes);
} ;
public int getItem_pull_alltimes(){
return this.getOpcIntegerValue(item_pull_alltimes);
} ;
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 float getOpcFloatValue(String protocol) {
Float value = this.driver.getDoubleValue(protocol);
if (value == null) {
setIsonline(false);
} else {
setIsonline(true);
return value;
}
return 0;
}
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"));
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"));
return list;
}
@Override
public String toString() {
return "";
}
}

View File

@@ -1,59 +0,0 @@
package org.nl.acs.device_driver.plug_pull_device_site;
import org.nl.acs.device.device_driver.standard_inspect.ItemDto;
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 org.nl.acs.device.domain.Device;
import java.util.LinkedList;
import java.util.List;
/**
* 插拔轴工位
*/
@Service
public class PlugPullDeviceSiteDefination implements OpcDeviceDriverDefination {
@Override
public String getDriverCode() {
return "plug_pull_device_site";
}
@Override
public String getDriverName() {
return "插拔轴工位";
}
@Override
public String getDriverDescription() {
return "插拔轴工位";
}
@Override
public DeviceDriver getDriverInstance(Device device) {
return (new PlugPullDeviceSiteDeviceDriver()).setDevice(device).setDriverDefination(this);
}
@Override
public Class<? extends DeviceDriver> getDeviceDriverType() {
return PlugPullDeviceSiteDeviceDriver.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

@@ -1,232 +0,0 @@
package org.nl.acs.device_driver.plug_pull_device_site;
import cn.hutool.core.util.StrUtil;
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.domain.Device;
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.DeviceAppService;
import org.nl.acs.route.service.RouteLineService;
import org.nl.acs.task.service.TaskService;
import org.nl.config.SpringContextHolder;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.*;
/**
* 插拔轴工位
*/
@Slf4j
@Data
@RequiredArgsConstructor
public class PlugPullDeviceSiteDeviceDriver 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
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;
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;
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;
Boolean isonline = true;
Boolean iserror = false;
//1-执行任务2-取货完成3-放货完成;
int flag;
String device_code;
@Override
public Device getDevice() {
return this.device;
}
//请求成功标记
Boolean requireSucess = false;
@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();
if (status != 1) {
this.setIsonline(false);
this.setIserror(true);
message = "有报警";
//无报警
} else {
}
last_mode = mode;
last_move = move;
last_action = action;
}
protected void thingToNothing() {
//this.setRequireSucess(false);
}
public void writing(List list) {
//String opcservcerid = this.getDevice().getOpc_server_id();
//Server server = ReadUtil.getServer(opcservcerid);
Map<String, Object> itemMap = new HashMap<String, Object>();
for (int i = 0; i < list.size(); i++) {
Object ob = list.get(i);
JSONObject json = (JSONObject) JSONObject.toJSON(ob);
if (!StrUtil.isEmpty(json.getString("value"))) {
String to_param = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
+ "." + json.getString("code");
itemMap.put(to_param, json.getString("value"));
}
}
logServer.deviceExecuteLog(device_code, "", "", "下发电气信号:" + itemMap);
this.control(itemMap);
}
//将扩展表中的字符串数据转换成集合
public List<String> getExtraDeviceCodes(String extraName) {
String extraValue = (String) this.getDevice().getExtraValue().get(extraName);
if (StrUtil.isEmpty(extraValue)) {
return new ArrayList<>();
}
String devicesString = extraValue.substring(1, extraValue.length() - 1);
List<String> devicesList = new ArrayList<>();
String[] devices = devicesString.split(",");
for (int i = 0; i < devices.length; i++) {
String s = devices[i].replace("\"", "").replace("\"", "");
devicesList.add(s);
}
return devicesList;
}
@Override
public JSONObject getDeviceStatusName() {
JSONObject jo = new JSONObject();
String mode = "";
String action = "";
String move = "";
if (this.getMode() == 0) {
mode = "未联机";
} else if (this.getMode() == 1) {
mode = "单机";
} else if (this.getMode() == 2) {
mode = "联机";
} else if (this.getMode() == 3) {
mode = "运行中";
}
if (this.getMove() == 0) {
move = "无货";
jo.put("hasGoods", false);
} else if (this.getMove() == 1) {
move = "有货";
jo.put("hasGoods", true);
} else if (this.getMove() == 2) {
move = "有托盘有货";
jo.put("hasGoods", true);
}
jo.put("device_name", this.getDevice().getDevice_name());
jo.put("mode", mode);
jo.put("move", move);
jo.put("action", action);
jo.put("isOnline", this.getIsonline());
jo.put("isError", this.getIserror());
return jo;
}
@Override
public void setDeviceStatus(JSONObject data) {
}
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>();
itemMap.put(to_param, value);
// itemMap.put(to_param, Integer.parseInt(value));
this.control(itemMap);
}
}

View File

@@ -27,10 +27,10 @@ import org.nl.acs.device.service.DeviceService;
import org.nl.acs.device.service.impl.DeviceServiceImpl;
import org.nl.acs.device_driver.DeviceDriver;
import org.nl.acs.device_driver.DeviceDriverDefination;
import org.nl.acs.device_driver.conveyor.hongxiang_device.HongXiangConveyorDeviceDriver;
import org.nl.acs.device_driver.conveyor.siemens_conveyor.SiemensConveyorDeviceDriver;
import org.nl.acs.device_driver.conveyor.standard_conveyor_control_with_scanner.StandardCoveyorControlWithScannerDeviceDriver;
import org.nl.acs.device_driver.conveyor.standard_inspect_site.StandardInspectSiteDeviceDriver;
import org.nl.acs.device_driver.hongxiang_device.HongXiangConveyorDeviceDriver;
import org.nl.acs.ext.wms.liKuData.*;
import org.nl.acs.ext.wms.service.AcsToLiKuService;
import org.nl.acs.instruction.domain.InstructionMybatis;