Browse Source

add: 开发

master
lishuai 3 months ago
parent
commit
50a3d20a14
  1. 33
      acs/nladmin-system/src/main/java/org/nl/acs/agv/server/AgvWaitUtil.java
  2. 2
      acs/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/XianGongAgvServiceImpl.java
  3. 216
      acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/agv/agv_conveyor/AgvConveyorConveyorDeviceDriver.java
  4. 60
      acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/agv/agv_conveyor/AgvConveyorDefinition.java
  5. 96
      acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/agv/agv_conveyor/ItemProtocol.java
  6. 3
      acs/nladmin-system/src/main/java/org/nl/acs/route/service/RouteLineService.java
  7. 21
      acs/nladmin-system/src/main/java/org/nl/acs/route/service/impl/RouteLineServiceImpl.java
  8. 4
      acs/nladmin-system/src/main/resources/config/application-dev.yml
  9. 2
      acs/nladmin-system/src/main/resources/config/application.yml
  10. 3
      acs/nladmin-ui/src/views/acs/device/config.vue
  11. 102
      acs/nladmin-ui/src/views/acs/device/driver/agv/agv_conveyor.vue

33
acs/nladmin-system/src/main/java/org/nl/acs/agv/server/AgvWaitUtil.java

@ -1,11 +1,13 @@
package org.nl.acs.agv.server;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nl.acs.common.StandardOrdinarySiteDevice;
import org.nl.acs.device_driver.RequestMethodEnum;
import org.nl.acs.device_driver.basedriver.agv.agv_conveyor.AgvConveyorConveyorDeviceDriver;
import org.nl.acs.device_driver.nl4.station.NL4StationDeviceDriver;
import org.nl.acs.log.service.DeviceExecuteLogService;
import org.nl.acs.opc.Device;
@ -90,7 +92,7 @@ public class AgvWaitUtil {
}
//取货完成等待
public JSONObject waitOutGet(String deviceCode) {
public JSONObject waitOutGet(String deviceCode, TaskDto task) {
log.info("仙工AGV取货完成后请求离开,设备号 - {}", deviceCode);
boolean flag = false;
@ -117,6 +119,17 @@ public class AgvWaitUtil {
} else if (device.getDeviceDriver() instanceof StandardOrdinarySiteDevice) {
// 普通站点驱动
String message = "允许AGV取货后离开。";
// agv下料完成后写信号
String executeCode = task.getExecute_code();
if (StrUtil.isNotEmpty(executeCode)) {
Device executeDevice = this.deviceAppService.findDeviceByCode(executeCode);
if (executeDevice.getDeviceDriver() instanceof AgvConveyorConveyorDeviceDriver) {
AgvConveyorConveyorDeviceDriver driver = (AgvConveyorConveyorDeviceDriver) executeDevice.getDeviceDriver();
if ("down".equals(task.getExecute_message())) {
driver.writing("to_down_finished", 1);
}
}
}
this.deviceExecuteLogService.deviceExecuteLog(deviceCode, "", "", message);
flag = true;
} else {
@ -244,8 +257,7 @@ public class AgvWaitUtil {
this.deviceExecuteLogService.deviceExecuteLog(deviceCode, "", "", message);
}
}
}
else if (RequestMethodEnum.CHANNEL_STEEL_MATERIAL_FINISHED.getCode().equals(task.getDirection())) {
} else if (RequestMethodEnum.CHANNEL_STEEL_MATERIAL_FINISHED.getCode().equals(task.getDirection())) {
// 槽钢上料完成任务
if (deviceCode.equals(task.getNext_device_code2())) {
// 如果是放满点,需要把取满点的信息写入再请求离开。
@ -278,8 +290,7 @@ public class AgvWaitUtil {
this.deviceExecuteLogService.deviceExecuteLog(deviceCode, "", "", message);
}
}
}
else {
} else {
driver.writing("to_command", 4);
if (driver.getMode() != 0) {
String message = "允许AGV放货后离开。";
@ -297,6 +308,18 @@ public class AgvWaitUtil {
// 普通站点驱动
String message = "允许AGV放货后离开。";
this.deviceExecuteLogService.deviceExecuteLog(deviceCode, "", "", message);
// agv上料完成后写信号
String executeCode = task.getExecute_code();
if (StrUtil.isNotEmpty(executeCode)) {
Device executeDevice = this.deviceAppService.findDeviceByCode(executeCode);
if (executeDevice.getDeviceDriver() instanceof AgvConveyorConveyorDeviceDriver) {
AgvConveyorConveyorDeviceDriver driver = (AgvConveyorConveyorDeviceDriver) executeDevice.getDeviceDriver();
if ("up".equals(task.getExecute_message())) {
driver.writing("to_up_finished", 1);
}
}
}
flag = true;
} else {
flag = true;

2
acs/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/XianGongAgvServiceImpl.java

@ -722,7 +722,7 @@ public class XianGongAgvServiceImpl implements XianGongAgvService {
}
if (address.contains("GET")) {
return agvWaitUtil.waitOutGet(deviceCodeNow);
return agvWaitUtil.waitOutGet(deviceCodeNow,task);
} else if (address.contains("PUT")) {
return agvWaitUtil.waitOutPut(deviceCodeNow, task);
}

216
acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/agv/agv_conveyor/AgvConveyorConveyorDeviceDriver.java

@ -0,0 +1,216 @@
package org.nl.acs.device_driver.basedriver.agv.agv_conveyor;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.nl.acs.agv.server.AgvService;
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.ext.wms.service.impl.AcsToWmsServiceImpl;
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.opc.DeviceAppService;
import org.nl.acs.route.service.RouteLineService;
import org.nl.acs.route.service.dto.RouteLineDto;
import org.nl.acs.task.service.TaskService;
import org.nl.acs.task.service.dto.TaskDto;
import org.nl.modules.system.service.ParamService;
import org.nl.modules.wql.util.SpringContextHolder;
import org.openscada.opc.lib.da.Server;
import java.util.*;
/**
* 货梯对接线
*/
@Slf4j
@Getter
@Setter
@RequiredArgsConstructor
public class AgvConveyorConveyorDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor {
protected ItemProtocol itemProtocol = new ItemProtocol(this);
DeviceAppService deviceAppservice = SpringContextHolder.getBean(DeviceAppService.class);
InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class);
DeviceService deviceservice = SpringContextHolder.getBean(DeviceService.class);
TaskService taskserver = SpringContextHolder.getBean(TaskService.class);
RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class);
AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsServiceImpl.class);
ParamService paramService = SpringContextHolder.getBean(ParamService.class);
DeviceExecuteLogService logServer = SpringContextHolder.getBean(DeviceExecuteLogService.class);
AgvService agvService = SpringContextHolder.getBean(AgvService.class);
private final DeviceExecuteLogService deviceExecuteLogService = SpringContextHolder.getBean(DeviceExecuteLogService.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 error = 0;
int task = 0;
String on_off_site;
String tray_Information;
int down_request;
int up_request;
Boolean isonline = true;
Boolean iserror = false;
int last_error = 0;
String device_code;
@Override
public Device getDevice() {
return this.device;
}
//请求成功标记
Boolean requireSucess = false;
@Override
public void execute() throws Exception {
String message = null;
device_code = this.getDeviceCode();
heartbeat = this.itemProtocol.getItem_heartbeat();
on_off_site = this.itemProtocol.getItem_on_off_site();
tray_Information = this.itemProtocol.getItem_tray_Information();
down_request = this.itemProtocol.getItem_down_request();
up_request = this.itemProtocol.getItem_up_request();
if (error != last_error) {
}
if (!this.itemProtocol.getIsonline()) {
this.setIsonline(false);
this.setIserror(true);
//未联机
} else {
this.setIsonline(true);
this.setIserror(false);
if ((down_request == 1 || up_request == 1) && StringUtils.isNoneEmpty(on_off_site)){
task_apply();
}
}
}
public synchronized boolean task_apply() throws Exception {
Date date = new Date();
if (date.getTime() - this.instruction_require_time.getTime() < (long) this.instruction_require_time_out) {
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out);
return false;
} else {
this.instruction_require_time = date;
//请求下料
if (down_request == 1){
List<RouteLineDto> routeLineDtos = routeLineService.getPathLinesByCode(on_off_site,"normal");
if (CollUtil.isEmpty(routeLineDtos) || routeLineDtos.size() < 1) {
logServer.deviceExecuteLog(this.device_code, "", "", "没有"+ on_off_site + "的路由");
}
RouteLineDto routeLineDto = routeLineDtos.get(0);
TaskDto taskDto = new TaskDto();
taskDto.setStart_device_code(on_off_site);
taskDto.setNext_device_code(routeLineDto.getNext_device_code());
taskDto.setStart_point_code(on_off_site);
taskDto.setNext_point_code(routeLineDto.getNext_device_code());
taskDto.setExecute_code(this.device_code);
taskDto.setExecute_message("down");
taskserver.create(taskDto);
}
//请求上料
if (up_request == 1){
List<RouteLineDto> routeLineDtos = routeLineService.getsByCode(on_off_site,"normal");
if (CollUtil.isEmpty(routeLineDtos) || routeLineDtos.size() < 1) {
logServer.deviceExecuteLog(this.device_code, "", "", "没有"+ on_off_site + "的路由");
}
RouteLineDto routeLineDto = routeLineDtos.get(0);
TaskDto taskDto = new TaskDto();
taskDto.setStart_device_code(routeLineDto.getDevice_code());
taskDto.setNext_device_code(on_off_site);
taskDto.setStart_point_code(routeLineDto.getDevice_code());
taskDto.setNext_point_code(on_off_site);
taskDto.setExecute_code(this.device_code);
taskDto.setExecute_message("up");
taskserver.create(taskDto);
}
return true;
}
}
public void writing(String param, Object value) {
String to_param = this.getDevice().getOpc_server_code() + "." +
this.getDevice().getOpc_plc_code() + "." +
this.getDevice().getDevice_code() + "." +
param;
Map<String, Object> itemMap = new HashMap<>();
itemMap.put(to_param, value);
this.control(itemMap);
this.deviceExecuteLogService.deviceExecuteLog(device_code, "", "", param + " 写入 " + value);
}
@Override
public JSONObject getDeviceStatusName() {
JSONObject jo = new JSONObject();
String mode = "";
String action = "";
String move = "";
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("error", this.getError());
jo.put("isError", this.getIserror());
jo.put("task", this.getTask());
return jo;
}
@Override
public void setDeviceStatus(JSONObject data) {
}
}

60
acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/agv/agv_conveyor/AgvConveyorDefinition.java

@ -0,0 +1,60 @@
package org.nl.acs.device_driver.basedriver.agv.agv_conveyor;
import org.nl.acs.device.device_driver.standard_inspect.ItemDTO;
import org.nl.acs.device_driver.DeviceDriver;
import org.nl.acs.device_driver.definition.OpcDeviceDriverDefinition;
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;
/**
* AGV上料下料
*/
@Service
public class AgvConveyorDefinition implements OpcDeviceDriverDefinition {
@Override
public String getDriverCode() {
return "agv_conveyor";
}
@Override
public String getDriverName() {
return "AGV上料下料";
}
@Override
public String getDriverDescription() {
return "AGV上料下料";
}
@Override
public DeviceDriver getDriverInstance(Device device) {
return (new AgvConveyorConveyorDeviceDriver()).setDevice(device).setDriverDefinition(this);
}
@Override
public Class<? extends DeviceDriver> getDeviceDriverType() {
return AgvConveyorConveyorDeviceDriver.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();
}
}

96
acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/agv/agv_conveyor/ItemProtocol.java

@ -0,0 +1,96 @@
package org.nl.acs.device_driver.basedriver.agv.agv_conveyor;
import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.nl.acs.device.device_driver.standard_inspect.ItemDTO;
import java.util.ArrayList;
import java.util.List;
@Slf4j
@Getter
@Setter
public class ItemProtocol {
public static String item_heartbeat = "heartbeat";
public static String item_on_off_site = "on_off_site";
public static String item_tray_Information = "tray_Information";
public static String item_down_request = "down_request";
public static String item_up_request = "up_request";
public static String item_to_up_finished = "to_up_finished ";
public static String item_to_down_finished = "to_down_finished";
private AgvConveyorConveyorDeviceDriver driver;
public ItemProtocol(AgvConveyorConveyorDeviceDriver driver) {
this.driver = driver;
}
public int getItem_heartbeat() {
return this.getOpcIntegerValue(item_heartbeat);
}
public String getItem_on_off_site() {
return this.getOpcStringValue(item_on_off_site);
}
public String getItem_tray_Information() {
return this.getOpcStringValue(item_tray_Information);
}
public int getItem_down_request() {
return this.getOpcIntegerValue(item_down_request);
}
public int getItem_up_request() {
return this.getOpcIntegerValue(item_up_request);
}
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 (value == null) {
// log.error("读取错误!");
} else {
return value;
}
return "";
}
public static List<ItemDTO> getReadableItemDtos() {
ArrayList list = new ArrayList();
list.add(new ItemDTO(item_heartbeat, "心跳", "VW0"));
list.add(new ItemDTO(item_on_off_site, "上下站点", "VW2"));
list.add(new ItemDTO(item_tray_Information, "料盘信息", "VW4"));
list.add(new ItemDTO(item_down_request, "下料请求", "VW6"));
list.add(new ItemDTO(item_up_request, "上料请求", "VW8"));
return list;
}
public static List<ItemDTO> getWriteableItemDtos() {
ArrayList list = new ArrayList();
list.add(new ItemDTO(item_to_up_finished, "上料完成", "VW102"));
list.add(new ItemDTO(item_to_down_finished, "下料完成", "VW104"));
return list;
}
}

3
acs/nladmin-system/src/main/java/org/nl/acs/route/service/RouteLineService.java

@ -183,8 +183,11 @@ public interface RouteLineService {
*/
public List<RouteLineDto> getPathLinesByCode(String device_code, String plan_code);
public List<RouteLineDto> getsByCode(String device_code, String plan_code);
public List<RouteLineDto> getSuperiorShortPathLinesByCode(String device_code, String plan_code);
public JSONArray getActivePathLine(String device_code, String next_device_code, String plan_code);
}

21
acs/nladmin-system/src/main/java/org/nl/acs/route/service/impl/RouteLineServiceImpl.java

@ -554,6 +554,22 @@ public class RouteLineServiceImpl implements RouteLineService, ApplicationAutoIn
return newresult;
}
@Override
public List<RouteLineDto> getsByCode(String device_code, String plan_code) {
List list = this.routeLines.get(plan_code);
List result = new ArrayList();
Iterator iterator = list.iterator();
while (iterator.hasNext()) {
RouteLineDto routeLineDto = (RouteLineDto) iterator.next();
if (StrUtil.equals(routeLineDto.getDevice_code(), device_code)) {
result.add(routeLineDto);
}
}
List<RouteLineDto> newresult = (List<RouteLineDto>) result.stream().sorted(Comparator.comparing(RouteLineDto::getWeights)).collect(Collectors.toList());
return newresult;
}
@Override
public List<RouteLineDto> getSuperiorShortPathLinesByCode(String device_code, String plan_code) {
List list = this.routeLines.get(plan_code);
@ -570,6 +586,7 @@ public class RouteLineServiceImpl implements RouteLineService, ApplicationAutoIn
}
@Override
public void autoInitial() throws Exception {
this.reload();
@ -610,4 +627,8 @@ public class RouteLineServiceImpl implements RouteLineService, ApplicationAutoIn
JSONArray newresult = WQL.getWO("QROUTE").addParamMap(map).process().getResultJSONArray(0);
return newresult;
}
}

4
acs/nladmin-system/src/main/resources/config/application-dev.yml

@ -6,9 +6,9 @@ spring:
druid:
db-type: com.alibaba.druid.pool.DruidDataSource
driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy
url: jdbc:log4jdbc:mysql://${DB_HOST:127.0.0.1}:${DB_PORT:3306}/${DB_NAME:nl4_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true&allowPublicKeyRetrieval=true
url: jdbc:log4jdbc:mysql://${DB_HOST:127.0.0.1}:${DB_PORT:3306}/${DB_NAME:siqi}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true&allowPublicKeyRetrieval=true
username: ${DB_USER:root}
password: ${DB_PWD:password}
password: ${DB_PWD:123456}
# 初始连接数
initial-size: 5
# 最小连接数

2
acs/nladmin-system/src/main/resources/config/application.yml

@ -2,7 +2,7 @@ spring:
freemarker:
check-template-location: false
profiles:
active: prod
active: dev
jackson:
time-zone: GMT+8
data:

3
acs/nladmin-ui/src/views/acs/device/config.vue

@ -103,6 +103,7 @@ import conveyor_ssx_barcode from '@/views/acs/device/driver/lnsh/conveyor_ssx_ba
import conveyor_press_station from '@/views/acs/device/driver/lnsh/conveyor_press_station'
import agv_ndc_one from '@/views/acs/device/driver/agv/agv_ndc_one'
import agv_ndc_two from '@/views/acs/device/driver/agv/agv_ndc_two'
import agv_conveyor from '@/views/acs/device/driver/agv/agv_conveyor'
import package_site from './driver/lnsh/package_site.vue'
import nl4_station from '@/views/acs/device/driver/nl4/nl4_station.vue'
@ -113,7 +114,7 @@ export default {
standard_conveyor_control, standard_conveyor_monitor, lnsh_mixing_mill, lnsh_press, lnsh_palletizing_manipulator, lnsh_fold_disc_site, lnsh_kiln_lane, lnsh_kiln_truss,
lnsh_package_line, lnsh_out_kiln_truss, lnsh_package_pallet_manipulator, lnsh_pallet_storage, lnsh_labeling_machine, lnsh_split_manipulator, lnsh_rgv,
lnsh_station, lnsh_Laminating_machine, lnsh_package_site, lnsh_crusher, lnsh_palletizing_manipulator_site, conveyor_ssx_barcode, conveyor_press_station,
agv_ndc_one, agv_ndc_two, package_site, nl4_station },
agv_ndc_one, agv_ndc_two, package_site, nl4_station,agv_conveyor },
dicts: ['device_type'],
mixins: [crud],
data() {

102
acs/nladmin-ui/src/views/acs/device/driver/agv/agv_conveyor.vue

@ -0,0 +1,102 @@
<template>
<!--AGV上料下料-->
<div>
<el-card class="box-card" shadow="never">
<div slot="header" class="clearfix">
<span class="role-span">指令相关</span>
</div>
<el-form ref="form" :inline="true" :model="form" size="small" label-width="95px">
<el-row>
<el-col :span="8">
<el-form-item label="ip地址" prop="ip_address">
<el-input
v-model="form.ip_address"/>
</el-form-item>
</el-col>
</el-row>
</el-form>
</el-card>
<el-card class="box-card" shadow="never">
<div slot="header" class="clearfix">
<span class="role-span" />
<el-button
:loading="false"
icon="el-icon-check"
size="mini"
style="float: right; padding: 6px 9px"
type="primary"
@click="doSubmit"
>保存
</el-button>
</div>
</el-card>
</div>
</template>
<script>
import {
queryDriverConfig,
updateConfig
} from '@/api/acs/device/driverConfig'
import crud from '@/mixins/crud'
export default {
name: 'StandardConveyorControl',
mixins: [crud],
props: {
parentForm: {
type: Object,
require: true
}
},
data() {
return {
form: {
ip_address: ''
}
}
},
created() {
this.$nextTick(() => {
//
this.device_id = this.$props.parentForm.device_id
this.device_code = this.$props.parentForm.device_code
queryDriverConfig(this.device_id, this.$props.parentForm.driver_code).then(data => {
//
if (data.form) {
const arr = Object.keys(data.form)
//
if (arr.length > 0) {
this.form = data.form
}
}
this.sliceItem()
})
})
},
methods: {
doSubmit() {
this.$refs['form'].validate((valid) => {
if (valid) {
this.configLoading = true
//
const parentForm = this.parentForm
parentForm.is_route = true
updateConfig(parentForm, this.form, this.modeform, this.data1, this.data2).then(res => {
this.notify('保存成功', 'success')
this.configLoading = false
}).catch(err => {
this.configLoading = false
console.log(err.response.data.message)
})
}
})
}
}
}
</script>
<style scoped>
</style>
Loading…
Cancel
Save