diff --git a/hd/nladmin-system/src/main/java/org/nl/acs/agv/server/AgvService.java b/hd/nladmin-system/src/main/java/org/nl/acs/agv/server/AgvService.java index 908bf8f..781cbf2 100644 --- a/hd/nladmin-system/src/main/java/org/nl/acs/agv/server/AgvService.java +++ b/hd/nladmin-system/src/main/java/org/nl/acs/agv/server/AgvService.java @@ -147,6 +147,11 @@ public interface AgvService { */ public HttpResponse sendOrderSequencesToXZ(Instruction inst) throws Exception; + + public HttpResponse pauseVehicleToXZ(JSONObject jsonObject) throws Exception; + + public HttpResponse resumeVehicleToXZ(JSONObject jsonObject) throws Exception; + public HttpResponse addOrderSequences(Instruction inst) throws Exception; /** @@ -161,6 +166,7 @@ public interface AgvService { public JSONObject createOrederData(Instruction inst, String type); public JSONArray createBlocksData(Instruction inst); + /** * magic 全部暂停车辆 */ diff --git a/hd/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/AgvServiceImpl.java b/hd/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/AgvServiceImpl.java index 8648cf5..a91f531 100644 --- a/hd/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/AgvServiceImpl.java +++ b/hd/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/AgvServiceImpl.java @@ -5,6 +5,7 @@ import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import cn.hutool.http.HttpRequest; import cn.hutool.http.HttpResponse; +import com.alibaba.fastjson.JSON; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import net.sf.json.JSONArray; @@ -1521,6 +1522,48 @@ public class AgvServiceImpl implements AgvService { } } + @Override + public HttpResponse pauseVehicleToXZ(JSONObject jsonObject) throws Exception { + if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.FORKAGV).toString(), "1")) { + String agvurl = acsConfigService.findConfigFromCache().get(AcsConfig.AGVURL); + String agvport = acsConfigService.findConfigFromCache().get(AcsConfig.AGVPORT); + + agvurl = agvurl + ":" + agvport + "/gotoSitePause"; + System.out.println("请求地址为:" + agvurl); + HttpResponse result = HttpRequest.post(agvurl) + .body(JSON.toJSONString(jsonObject))//表单内容 + .timeout(20000)//超时,毫秒 + .execute(); + System.out.println("返回结果为:" + result); + log.info(agvurl); + logServer.log("pauseVehicle", "pauseVehicleToXZ", "info", String.valueOf(jsonObject), result.body(), String.valueOf(result.getStatus()), agvurl, String.valueOf(jsonObject)); + return result; + } else { + return null; + } + } + + @Override + public HttpResponse resumeVehicleToXZ(JSONObject jsonObject) throws Exception { + if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.FORKAGV).toString(), "1")) { + String agvurl = acsConfigService.findConfigFromCache().get(AcsConfig.AGVURL); + String agvport = acsConfigService.findConfigFromCache().get(AcsConfig.AGVPORT); + + agvurl = agvurl + ":" + agvport + "/gotoSiteResume"; + System.out.println("请求地址为:" + agvurl); + HttpResponse result = HttpRequest.post(agvurl) + .body(JSON.toJSONString(jsonObject))//表单内容 + .timeout(20000)//超时,毫秒 + .execute(); + System.out.println("返回结果为:" + result); + log.info(agvurl); + logServer.log("resumeVehicle", "resumeVehicleToXZ", "info", String.valueOf(jsonObject), result.body(), String.valueOf(result.getStatus()), agvurl, String.valueOf(jsonObject)); + return result; + } else { + return null; + } + } + @Override public HttpResponse addOrderSequences(Instruction inst) throws Exception { JSONObject orderjo = createOrederData(inst, "1"); diff --git a/hd/nladmin-system/src/main/java/org/nl/acs/common/deviceInfo/PauseOrResumeDevice.java b/hd/nladmin-system/src/main/java/org/nl/acs/common/deviceInfo/PauseOrResumeDevice.java new file mode 100644 index 0000000..31c4de4 --- /dev/null +++ b/hd/nladmin-system/src/main/java/org/nl/acs/common/deviceInfo/PauseOrResumeDevice.java @@ -0,0 +1,44 @@ +package org.nl.acs.common.deviceInfo; + +import net.sf.json.JSONObject; +import org.nl.acs.common.AbstractDriverService; +import org.nl.acs.device_driver.tianneng.PauseOrResumeDeviceDriver; +import org.nl.acs.opc.Device; +import org.nl.acs.task.service.dto.TaskDto; +import org.springframework.stereotype.Component; + +/** + * @author geng by + * 输送线 + */ +@Component("pauseOrResume") +public class PauseOrResumeDevice extends AbstractDriverService { + PauseOrResumeDeviceDriver pauseOrResumeDeviceDriver; + + @Override + public JSONObject getDeviceInfo(Device device) { + pauseOrResumeDeviceDriver = (PauseOrResumeDeviceDriver) device.getDeviceDriver(); + JSONObject jo = this.getCommonDeviceInfo(pauseOrResumeDeviceDriver); + return jo; + } + + @Override + public Boolean createInstCheckStartPoint(Device device, TaskDto taskDto) throws Exception { + //standardConveyorLineDeviceDriver = (StandardConveyorLineDeviceDriver) device.getDeviceDriver(); + //return this.checkStartPoint(standardConveyorLineDeviceDriver, taskDto, InstEnum.standard_conveyor_line_start.getMode(), InstEnum.standard_conveyor_line_start.getMove()); + return true; + } + + @Override + public Boolean createInstCheckNextPoint(Device device, TaskDto taskDto) throws Exception { + //standardConveyorLineDeviceDriver = (StandardConveyorLineDeviceDriver) device.getDeviceDriver(); + // return this.checkNextPoint(standardConveyorLineDeviceDriver, taskDto,InstEnum.standard_conveyor_line_next.getMode(), InstEnum.standard_conveyor_line_next.getMove()); + return true; + } + + @Override + public void changeDeviceStatus(Device device, JSONObject form) { + pauseOrResumeDeviceDriver = (PauseOrResumeDeviceDriver) device.getDeviceDriver(); + this.changeDeviceStatus(pauseOrResumeDeviceDriver, form, false); + } +} diff --git a/hd/nladmin-system/src/main/java/org/nl/acs/device/device_driver/DriverTypeEnum.java b/hd/nladmin-system/src/main/java/org/nl/acs/device/device_driver/DriverTypeEnum.java index e224c50..4c6f124 100644 --- a/hd/nladmin-system/src/main/java/org/nl/acs/device/device_driver/DriverTypeEnum.java +++ b/hd/nladmin-system/src/main/java/org/nl/acs/device/device_driver/DriverTypeEnum.java @@ -82,7 +82,8 @@ public enum DriverTypeEnum { // // ssj_cache_site(37, "ssj_cache_site", "三时纪-缓存站点", "conveyor"), - STANDARDCONVEYORLINE(38, "standard_conveyor_line", "缓存架", "conveyor"); + STANDARDCONVEYORLINE(38, "standard_conveyor_line", "缓存架", "conveyor"), + PAUSEorresume(39, "pauseOrResume", "agv暂停或继续", "conveyor"); //驱动索引 diff --git a/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/tianneng/ItemProtocol.java b/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/tianneng/ItemProtocol.java new file mode 100644 index 0000000..f3e4ab6 --- /dev/null +++ b/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/tianneng/ItemProtocol.java @@ -0,0 +1,59 @@ +package org.nl.acs.device_driver.tianneng; + +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_agv_action = "agv_action"; + + private PauseOrResumeDeviceDriver driver; + + public ItemProtocol(PauseOrResumeDeviceDriver driver) { + this.driver = driver; + } + + public int getAgv_action() { + return this.getOpcIntegerValue(item_agv_action); + } + + //是否有货 + public int hasGoods(int move) { + return move; + } + + Boolean isonline; + + public int getOpcIntegerValue(String protocol) { + Integer value = this.driver.getIntegerValue(protocol); + if (value == null) { + log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!"); + setIsonline(false); + } else { + setIsonline(true); + return value; + } + return 0; + + } + + public static List getReadableItemDtos() { + ArrayList list = new ArrayList(); + list.add(new ItemDto(item_agv_action, "agv工作状态", "DB600.B502")); + return list; + } + + public static List getWriteableItemDtos() { + ArrayList list = new ArrayList(); + list.add(new ItemDto(item_agv_action, "agv工作状态", "DB600.B502")); + return list; + } + +} + diff --git a/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/tianneng/PauseOrResumeDefination.java b/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/tianneng/PauseOrResumeDefination.java new file mode 100644 index 0000000..df5a37f --- /dev/null +++ b/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/tianneng/PauseOrResumeDefination.java @@ -0,0 +1,63 @@ +package org.nl.acs.device_driver.tianneng; + +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.ArrayList; +import java.util.LinkedList; +import java.util.List; + +/** + * agv-暂停或恢复 + */ +@Service +public class PauseOrResumeDefination implements OpcDeviceDriverDefination { + @Override + public String getDriverCode() { + return "pauseOrResume"; + } + + @Override + public String getDriverName() { + return "agv-暂停或恢复"; + } + + @Override + public String getDriverDescription() { + return "agv-暂停或恢复"; + } + + @Override + public DeviceDriver getDriverInstance(Device device) { + return (new PauseOrResumeDeviceDriver()).setDevice(device).setDriverDefination(this); + + } + + @Override + public Class getDeviceDriverType() { + return PauseOrResumeDeviceDriver.class; + } + + @Override + public List getFitDeviceTypes() { + List types = new LinkedList(); + types.add(DeviceType.conveyor); + return types; + } + + @Override + public List getReadableItemDtos() { + return ItemProtocol.getReadableItemDtos(); + } + + + @Override + public List getWriteableItemDtos() { + return ItemProtocol.getWriteableItemDtos(); + } + +} diff --git a/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/tianneng/PauseOrResumeDeviceDriver.java b/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/tianneng/PauseOrResumeDeviceDriver.java new file mode 100644 index 0000000..8aa94d4 --- /dev/null +++ b/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/tianneng/PauseOrResumeDeviceDriver.java @@ -0,0 +1,279 @@ +package org.nl.acs.device_driver.tianneng; + +import lombok.Data; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; +import org.nl.acs.agv.server.AgvService; +import org.nl.acs.agv.server.impl.AgvServiceImpl; +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.instruction.service.InstructionService; +import org.nl.acs.instruction.service.dto.Instruction; +import org.nl.acs.opc.Device; +import org.nl.acs.opc.DeviceAppService; +import org.nl.acs.opc.DeviceAppServiceImpl; +import org.nl.acs.route.service.RouteLineService; +import org.nl.acs.task.service.TaskService; +import org.nl.utils.SpringContextHolder; +import org.openscada.opc.lib.da.Server; +import org.springframework.beans.factory.annotation.Autowired; + +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * agv暂停或恢复驱动 + */ +@Slf4j +@Data +@RequiredArgsConstructor +public class PauseOrResumeDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver { + protected ItemProtocol itemProtocol = new ItemProtocol(this); + @Autowired + InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl"); + @Autowired + DeviceService deviceservice = SpringContextHolder.getBean("deviceServiceImpl"); + @Autowired + RouteLineService routelineserver = SpringContextHolder.getBean("routeLineServiceImpl"); + @Autowired + TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl"); + @Autowired + RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class); + @Autowired + DeviceAppService deviceAppservice = SpringContextHolder.getBean(DeviceAppService.class); + @Autowired + DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); + @Autowired + AgvService agvService = SpringContextHolder.getBean(AgvServiceImpl.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; + + //请求暂停成功标记 + Boolean requirePauseSuccess = false; + //请求继续成功标记 + Boolean requireResumeSuccess = false; + + int agv_action = 0; + int last_agv_action = 0; + + Boolean isonline = true; + int hasGoods = 0; + String message = null; + Boolean iserror = false; + + String Container = null; + String device_code = null; + int branchProtocol = 0; + //备注 + String remark; + //数量 + String qty; + //物料 + String material; + //当前指令 + Instruction inst = null; + //上次指令 + Instruction last_inst = null; + + //暂定 0就绪 1请求取货 2取货完成 3请求放货 4放货完成 5取货完成离开 6放货完成离开 7请求进入区域 8请求离开区域 + int flag; + + @Override + public Device getDevice() { + return this.device; + } + + + @Override + public void execute() throws Exception { + String message = null; + try { + device_code = this.getDeviceCode(); + agv_action = this.itemProtocol.getAgv_action(); + + if (agv_action != last_agv_action) { + if (agv_action == 1) { + this.setRequirePauseSuccess(false); + } + if (agv_action == 2) { + this.setRequireResumeSuccess(false); + } + this.execute_log.setResource(this.device_code, this.device.getDevice_name()); + this.execute_log.log("设备:" + device_code + ",last_agv_action -> agv_action:" + last_agv_action + "->" + agv_action); + } + + } catch (Exception var17) { + return; + } + + if (!this.itemProtocol.getIsonline()) { + this.setIsonline(false); + this.setIserror(true); + message = "信号量同步异常"; + //未联机 + } else { + this.setIsonline(true); + this.setIserror(false); + message = ""; + Instruction instruction = null; + List toInstructions; + switch (agv_action) { + case 1: + if (!requirePauseSuccess) { + JSONObject map = new JSONObject(); + JSONArray vehicles = new JSONArray(); + map.put("vehicles", vehicles); + agvService.pauseVehicleToXZ(map); + this.setRequirePauseSuccess(true); + } + break; + case 2: + if (!requireResumeSuccess) { + JSONObject map = new JSONObject(); + JSONArray vehicles = new JSONArray(); + map.put("vehicles", vehicles); + agvService.resumeVehicleToXZ(map); + this.setRequireResumeSuccess(true); + } + break; + } + +// switch (flag) { +// //取货完成 +// case 1: +// writing(2); +// return; +// //放货完成 +// case 2: +// writing(3); +// return; +// +// } + last_agv_action = agv_action; + } + + } + + + public boolean exe_error() { +// if (this.error == 0) { +// return true; +// } else { +// log.debug("设备报警"); +// return false; +// } + return true; + } + + protected void thingToNothing() { + log.debug("从有货到无货 清理数据"); + } + + public void set_last_container(String barcode, String type_desc) { + this.set_last_container(barcode); + this.set_last_container_type_desc(type_desc); + } + + public void set_last_container(String barcode) { + } + + public void set_last_container_type_desc(String type) { + } + + public boolean exe_business() { + return true; + } + + protected void executing(Instruction instruction) { + this.executing(1, instruction, ""); + } + + public void executing(int command, Instruction instruction, String appendMessage) { +// String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() +// + "." + ItemProtocol.item_to_command; +// String to_target = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() +// + "." + ItemProtocol.item_to_target; +// String to_task = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() +// + "." + ItemProtocol.item_to_task; +// if (appendMessage == null) { +// appendMessage = ""; +// } + + } + + public void executing(Server server, Map itemMap) { + ReadUtil.write(itemMap, server); + } + + 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 itemMap = new HashMap(); +// itemMap.put(to_command, command); +// ReadUtil.write(itemMap, server); + + } + + public void writing(int type, int command) { +// String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() +// + "." + ItemProtocol.item_to_command; +// String to_target = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() +// + "." + ItemProtocol.item_to_target; +// String to_onset = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() +// + "." + ItemProtocol.item_to_onset; +// String to_task = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() +// + "." + ItemProtocol.item_to_task; +// String opcservcerid = this.getDevice().getOpc_server_id(); +// Server server = ReadUtil.getServer(opcservcerid); +// Map itemMap = new HashMap(); +// if (type == 1) { +// itemMap.put(to_command, command); +// } else if (type == 2) { +// itemMap.put(to_target, command); +// +// } else if (type == 3) { +// itemMap.put(to_task, command); +// } +// ReadUtil.write(itemMap, server); + } + + + public void writing(Instruction inst) { +// String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() +// + "." + ItemProtocol.item_to_command; +// String to_target = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() +// + "." + ItemProtocol.item_to_target; +// String to_onset = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() +// + "." + ItemProtocol.item_to_onset; +// String to_task = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() +// + "." + ItemProtocol.item_to_task; +// String opcservcerid = this.getDevice().getOpc_server_id(); +// Server server = ReadUtil.getServer(opcservcerid); +// Map itemMap = new HashMap(); +// itemMap.put(to_command, 1); +// itemMap.put(to_onset, appService.findDeviceByCode(inst.getStart_device_code()).getAddress()); +// itemMap.put(to_target, appService.findDeviceByCode(inst.getNext_device_code()).getAddress()); +// itemMap.put(to_task, inst.getInstruction_code()); +// ReadUtil.write(itemMap, server); +// this.execute_log.setResource(this.device_code, device_code); +// this.execute_log.log("设备:{},下发作业命令:{},起始站{},目标站:{},任务号:{}", device_code, to_command, to_onset, to_target, to_task); +// } + + } + + +} diff --git a/qd/src/views/acs/device/config.vue b/qd/src/views/acs/device/config.vue index fbeb111..de4ce78 100644 --- a/qd/src/views/acs/device/config.vue +++ b/qd/src/views/acs/device/config.vue @@ -109,6 +109,7 @@ import standard_rgv from '@/views/acs/device/driver/standard_rgv' import ykbk_special from '@/views/acs/device/driver/ykbk_special' import ssj_cache_site from '@/views/acs/device/driver/ssj_cache_site' import standard_conveyor_line from '@/views/acs/device/driver/standard_conveyor_line' +import pauseOrResume from '@/views/acs/device/driver/pauseOrResume' export default { name: 'DeviceConfig', @@ -118,7 +119,7 @@ export default { standard_conveyor_control_with_plcscanner, standard_conveyor_control, standard_conveyor_monitor, weighing_site, machines_site, non_line_manipulator_inspect_site, non_line_inspect_site, manipulator_inspect_site_NDC, feedback_agv_status_site, standard_manipulator_stacking_site, standard_photoelectric_inspect_site, ndxy_special, hailiang_labeling, ndxy_special_two, whxr_storage_conveyor, whxr_ball_mill, whxr_spary_tower, whxr_weight, - electric_fence, oumulong_plc, traffic_light, standard_rgv, ykbk_special, ssj_cache_site, standard_conveyor_line }, + electric_fence, oumulong_plc, traffic_light, standard_rgv, ykbk_special, ssj_cache_site, standard_conveyor_line, pauseOrResume }, dicts: ['device_type'], mixins: [crud], data() { diff --git a/qd/src/views/acs/device/driver/pauseOrResume.vue b/qd/src/views/acs/device/driver/pauseOrResume.vue new file mode 100644 index 0000000..10839ab --- /dev/null +++ b/qd/src/views/acs/device/driver/pauseOrResume.vue @@ -0,0 +1,538 @@ + + + + +