From dc7548ee87670ff12f25e81863802106211380ff Mon Sep 17 00:00:00 2001 From: gengby <858962040@qq.com> Date: Thu, 5 Jan 2023 15:01:32 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../agv/server/impl/XianGongAgvServiceImpl.java | 2 +- .../device_driver/agv/MaGangAgvDeviceDriver.java | 6 +++--- .../quartz/task/QueryXZAgvDeviceStatus.java | 16 +++++++++++++--- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/XianGongAgvServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/XianGongAgvServiceImpl.java index a833e57..05cdfdf 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/XianGongAgvServiceImpl.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/XianGongAgvServiceImpl.java @@ -124,7 +124,7 @@ public class XianGongAgvServiceImpl implements XianGongAgvService { HttpResponse result = HttpRequest.get(agvurl) .timeout(20000)//超时,毫秒 .execute(); - + log.info("queryXZAgvDeviceStatus----查询agv状态数据数据:{}" + result.body()); return result; } else { return null; diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/agv/MaGangAgvDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/agv/MaGangAgvDeviceDriver.java index 9984b8b..3ebacc0 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/agv/MaGangAgvDeviceDriver.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/agv/MaGangAgvDeviceDriver.java @@ -109,18 +109,18 @@ public class MaGangAgvDeviceDriver extends AbstractOpcDeviceDriver implements De } - public void writing(String param, String value) { + public void writing1(String param, String value) { String to_command = 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 itemMap = new HashMap(); - itemMap.put(to_command, value); + itemMap.put(to_command, Integer.parseInt(value)); ReadUtil.write(itemMap, server); log.info("设备号{},kep点位名称{},下发信号{}", this.getDevice().getDevice_code(), to_command, value); } - public void writing(String param, float value) { + public void writing(String param, String value) { String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + "." + param; String opcservcerid = this.getDevice().getOpc_server_id(); diff --git a/acs/nladmin-system/src/main/java/org/nl/modules/quartz/task/QueryXZAgvDeviceStatus.java b/acs/nladmin-system/src/main/java/org/nl/modules/quartz/task/QueryXZAgvDeviceStatus.java index 8f79835..627cbae 100644 --- a/acs/nladmin-system/src/main/java/org/nl/modules/quartz/task/QueryXZAgvDeviceStatus.java +++ b/acs/nladmin-system/src/main/java/org/nl/modules/quartz/task/QueryXZAgvDeviceStatus.java @@ -44,6 +44,11 @@ public class QueryXZAgvDeviceStatus { JSONObject body = JSONObject.parseObject(response.body()); JSONArray ja = body.getJSONArray("report"); for (int i = 0; i < ja.size(); i++) { + System.out.println(ja.getJSONObject(1)); + if (i == 1){ + System.out.println(i); + } + System.out.println("此刻i=" + i); JSONObject jo = ja.getJSONObject(i); //机器人编码 String agv_code = jo.getString("uuid"); @@ -76,6 +81,7 @@ public class QueryXZAgvDeviceStatus { String status = "0"; if (connectionStatus == 0) { status = "5"; + task_type = "0"; } else { if (procBusiness) { //工作中 @@ -84,13 +90,16 @@ public class QueryXZAgvDeviceStatus { if (charging) { //充电中 status = "2"; + task_type = "0"; } else { if (is_error) { //故障 status = "3"; + task_type = "0"; } else { //休息中 status = "4"; + task_type = "0"; } } } @@ -102,10 +111,10 @@ public class QueryXZAgvDeviceStatus { String kepStatus = String.valueOf(maGangAgvDeviceDriver.getStatus()); String kepType = String.valueOf(maGangAgvDeviceDriver.getType()); if (!StrUtil.equals(kepStatus, status)) { - maGangAgvDeviceDriver.writing("status", Integer.parseInt(status)); + maGangAgvDeviceDriver.writing1("status", status); } if (!StrUtil.equals(kepType, task_type)) { - maGangAgvDeviceDriver.writing("type", Integer.parseInt(task_type)); + maGangAgvDeviceDriver.writing1("type", task_type); } maGangAgvDeviceDriver.writing("x_coordinate", hisFormat.format(x)); maGangAgvDeviceDriver.writing("y_coordinate", hisFormat.format(y)); @@ -114,7 +123,8 @@ public class QueryXZAgvDeviceStatus { } } } catch (Exception e) { - + System.out.println("出现异常"); + e.printStackTrace(); } try {