From f9f9575e59e19fded55b1c2f80af36b87bd66642 Mon Sep 17 00:00:00 2001 From: weidong Date: Thu, 7 Nov 2024 21:28:39 +0800 Subject: [PATCH 1/8] =?UTF-8?q?=E4=BC=98=E5=8C=96log=E6=9C=BA=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sec-beidou-fwd/pom.xml | 10 +--------- .../service/GnssSingleBufferServiceImpl.java | 17 ++++++++++++----- .../src/main/resources/application.properties | 4 +++- sec-beidou-rtcm/src/main/resources/logback.xml | 2 +- sec-beidou/pom.xml | 2 +- .../controller/GnssSingleDataController.java | 7 +++++++ .../src/main/resources/application.properties | 2 ++ sec-beidou/src/main/resources/db/schema.sql | 15 +++++++++++++++ .../templates/page/gnss_single_data.html | 2 +- .../common/util/WarningLogExecutor.java | 18 ++++++++++-------- sec-test-device/pom.xml | 9 +-------- .../src/main/resources/application.properties | 2 ++ 12 files changed, 56 insertions(+), 34 deletions(-) diff --git a/sec-beidou-fwd/pom.xml b/sec-beidou-fwd/pom.xml index 1c56e2f1..031a6412 100644 --- a/sec-beidou-fwd/pom.xml +++ b/sec-beidou-fwd/pom.xml @@ -114,15 +114,7 @@ - - org.apache.maven.plugins - maven-compiler-plugin - 3.8.1 - - 11 - 11 - - + diff --git a/sec-beidou-rtcm/src/main/java/com/imdroid/sideslope/service/GnssSingleBufferServiceImpl.java b/sec-beidou-rtcm/src/main/java/com/imdroid/sideslope/service/GnssSingleBufferServiceImpl.java index e49b92d8..44b7295d 100644 --- a/sec-beidou-rtcm/src/main/java/com/imdroid/sideslope/service/GnssSingleBufferServiceImpl.java +++ b/sec-beidou-rtcm/src/main/java/com/imdroid/sideslope/service/GnssSingleBufferServiceImpl.java @@ -1,5 +1,6 @@ package com.imdroid.sideslope.service; +import com.imdroid.common.util.ThreadManager; import com.imdroid.secapi.dto.GnssSingleData; import com.imdroid.secapi.dto.GnssSingleDataMapper; import org.slf4j.Logger; @@ -32,7 +33,6 @@ public class GnssSingleBufferServiceImpl implements GnssSingleBufferService { buffer.add(data); if (buffer.size() >= BUFFER_SIZE) { // 溢出时直接保存 - // 此处暂定,但很有必要引入一个线程来保存,避免阻塞主线程 flush(); } } @@ -48,12 +48,19 @@ public class GnssSingleBufferServiceImpl implements GnssSingleBufferService { try { List batchList = new ArrayList<>(buffer); buffer.clear(); - // 由于每秒写数据库操作频繁,这里采用批量保存的方式 - saveBatch(batchList); - logger.debug("批量插入{}条数据成功", batchList.size()); + // 数据库操作异步执行,不阻塞主线程 + ThreadManager.getSingleThreadPool("gnss-single-save").submit(() -> { + try { + saveBatch(batchList); + logger.debug("批量插入{}条数据成功", batchList.size()); + } catch (Exception e) { + logger.error("批量插入数据失败", e); + } + }); + } catch (Exception e) { - logger.error("批量插入数据失败", e); + logger.error("线程创建失败", e); throw e; } } diff --git a/sec-beidou-rtcm/src/main/resources/application.properties b/sec-beidou-rtcm/src/main/resources/application.properties index 05977793..0210c779 100644 --- a/sec-beidou-rtcm/src/main/resources/application.properties +++ b/sec-beidou-rtcm/src/main/resources/application.properties @@ -33,4 +33,6 @@ mybatis-plus.configuration.map-underscore-to-camel-case=false xfz.server.host = 171.106.48.63 xfz.server.port = 52000 -xfz.server.data.send = false \ No newline at end of file +xfz.server.data.send = false + +warning.log.directory=./log \ No newline at end of file diff --git a/sec-beidou-rtcm/src/main/resources/logback.xml b/sec-beidou-rtcm/src/main/resources/logback.xml index 1742b9e7..f8735b8b 100644 --- a/sec-beidou-rtcm/src/main/resources/logback.xml +++ b/sec-beidou-rtcm/src/main/resources/logback.xml @@ -20,7 +20,7 @@ - + diff --git a/sec-beidou/pom.xml b/sec-beidou/pom.xml index d14c4b5e..ba7c6cf7 100644 --- a/sec-beidou/pom.xml +++ b/sec-beidou/pom.xml @@ -155,7 +155,7 @@ - org.apache.maven.pluginsmaven-compiler-plugin1111 + diff --git a/sec-beidou/src/main/java/com/imdroid/beidou/controller/GnssSingleDataController.java b/sec-beidou/src/main/java/com/imdroid/beidou/controller/GnssSingleDataController.java index 4c4f2cd5..2ddaa671 100644 --- a/sec-beidou/src/main/java/com/imdroid/beidou/controller/GnssSingleDataController.java +++ b/sec-beidou/src/main/java/com/imdroid/beidou/controller/GnssSingleDataController.java @@ -12,6 +12,8 @@ import org.springframework.ui.Model; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import java.time.Duration; import java.time.LocalDateTime; @@ -80,6 +82,11 @@ public class GnssSingleDataController extends BasicController implements CommonE return this.pageList(session, page, limit, searchParams); } + @RequestMapping("/gnss/data/single/export") + @ResponseBody + public void exportData(HttpSession session, HttpServletRequest request, HttpServletResponse response) throws Exception { + this.export(session, request, response); + } @Override public Class getEntityClass() { diff --git a/sec-beidou/src/main/resources/application.properties b/sec-beidou/src/main/resources/application.properties index 22c57f7c..b458234c 100644 --- a/sec-beidou/src/main/resources/application.properties +++ b/sec-beidou/src/main/resources/application.properties @@ -46,3 +46,5 @@ aliyun.oss.accessKey = LTAI4G6hmpX7h9hQvUnwKWxj aliyun.oss.accessSecret = GHVzHKLLor8i5ZR1qyeoi4KMf3mjHb aliyun.oss.bucket = imdroid-device-management aliyun.oss.publicReadUrl = https://imdroid-device-management.oss-cn-shanghai.aliyuncs.com + +warning.log.directory=./log \ No newline at end of file diff --git a/sec-beidou/src/main/resources/db/schema.sql b/sec-beidou/src/main/resources/db/schema.sql index d35646a3..3dc7f2dd 100644 --- a/sec-beidou/src/main/resources/db/schema.sql +++ b/sec-beidou/src/main/resources/db/schema.sql @@ -67,6 +67,7 @@ CREATE TABLE IF NOT EXISTS `gnssdevices` ( `appver` varchar(16) DEFAULT NULL COMMENT '固件版本', `imei` varchar(16) DEFAULT NULL, `model` smallint DEFAULT 0, + `loggingmode` smallint DEFAULT 0 COMMENT '日志模式: 0-精简模式(仅D3F0和D3F2), 1-完整模式', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; @@ -320,3 +321,17 @@ CREATE TABLE IF NOT EXISTS `ApiKey` ( `tenantname` varchar(100) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE IF NOT EXISTS `gnssdevicesinglerecords` ( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID', + `deviceid` varchar(64) NOT NULL COMMENT '设备ID', + `createtime` datetime(3) NOT NULL COMMENT '创建时间', + `model` smallint NOT NULL COMMENT '设备型号: 0-F9P(G505), 1-博通(G510)', + `x` double NOT NULL COMMENT 'GGA时是latitude, ECEF时是x', + `y` double NOT NULL COMMENT 'GGA时是longitude, ECEF时是y', + `z` double NOT NULL COMMENT 'GGA时是altitude, ECEF时是z', + `status` int NOT NULL DEFAULT '0' COMMENT 'GGA: 0初始化,1单点定位,2码差分,3无效PPS,4固定解,5浮点解,6估算,7人工固定,8模拟,9WAAS差分; ECEF: 0无B562,1浮点解,2固定解', + PRIMARY KEY (`id`), + KEY `idx_deviceid_createtime` (`deviceid`,`createtime`), + KEY `idx_createtime` (`createtime`) +) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='GNSS单次解算记录表'; \ No newline at end of file diff --git a/sec-beidou/src/main/resources/templates/page/gnss_single_data.html b/sec-beidou/src/main/resources/templates/page/gnss_single_data.html index 3555a637..3def2e9f 100644 --- a/sec-beidou/src/main/resources/templates/page/gnss_single_data.html +++ b/sec-beidou/src/main/resources/templates/page/gnss_single_data.html @@ -149,7 +149,7 @@ // 监听导出操作 form.on('submit(data-export-btn)', function (data) { var result = $('#searchFrm').serialize(); - var u = "/gnss/data/calc/export?" + result; + var u = "/gnss/data/single/export?" + result; window.open(u, "_blank"); return false; }); diff --git a/sec-common/src/main/java/com/imdroid/common/util/WarningLogExecutor.java b/sec-common/src/main/java/com/imdroid/common/util/WarningLogExecutor.java index feaf22bc..f2e6e47b 100644 --- a/sec-common/src/main/java/com/imdroid/common/util/WarningLogExecutor.java +++ b/sec-common/src/main/java/com/imdroid/common/util/WarningLogExecutor.java @@ -8,6 +8,7 @@ import java.util.List; import java.util.concurrent.ExecutorService; import java.util.concurrent.ConcurrentHashMap; import java.util.stream.Collectors; +import java.util.stream.Stream; public class WarningLogExecutor { @@ -32,14 +33,15 @@ public class WarningLogExecutor { initializeWarningFile(warningFile, keyword, warningTypeName); } - // 找到日志文件 - List logFiles = Files.list(Paths.get(logDirectory)) - .filter(Files::isRegularFile) - .filter(path -> path.getFileName().toString().matches("sideslopertcm(\\.\\d{4}-\\d{2}-\\d{2}\\.\\d+)?\\.log")) - .collect(Collectors.toList()); + try (Stream logFilesStream = Files.list(Paths.get(logDirectory))) { + List logFiles = logFilesStream + .filter(Files::isRegularFile) + .filter(path -> path.getFileName().toString().matches("sideslopertcm(\\.\\d{4}-\\d{2}-\\d{2}\\.\\d+)?\\.log")) + .collect(Collectors.toList()); - for (Path logFile : logFiles) { - executor.submit(() -> processFile(logFile, keyword, warningTypeName, warningFile)); + for (Path logFile : logFiles) { + executor.submit(() -> processFile(logFile, keyword, warningFile)); + } } } catch (IOException e) { e.printStackTrace(); @@ -67,7 +69,7 @@ public class WarningLogExecutor { } } - private void processFile(Path logFile, String keyword, String warningTypeName, Path warningFile) { + private void processFile(Path logFile, String keyword, Path warningFile) { try (BufferedReader reader = Files.newBufferedReader(logFile); BufferedWriter writer = Files.newBufferedWriter(warningFile, StandardOpenOption.CREATE, StandardOpenOption.APPEND)) { diff --git a/sec-test-device/pom.xml b/sec-test-device/pom.xml index 271a8f75..a3596c3d 100644 --- a/sec-test-device/pom.xml +++ b/sec-test-device/pom.xml @@ -100,14 +100,7 @@ - - org.apache.maven.plugins - maven-compiler-plugin - - 11 - 11 - - + diff --git a/sec-test-device/src/main/resources/application.properties b/sec-test-device/src/main/resources/application.properties index 9ac62967..fa848559 100644 --- a/sec-test-device/src/main/resources/application.properties +++ b/sec-test-device/src/main/resources/application.properties @@ -20,3 +20,5 @@ app.format.time = HH:mm:ss app.format.datetime = yyyy-MM-dd HH:mm:ss mybatis-plus.configuration.map-underscore-to-camel-case=false + +netty.test.port = 9917 \ No newline at end of file From ec66599b980c28861197268266ef7497d75ec3a1 Mon Sep 17 00:00:00 2001 From: weidong Date: Sat, 9 Nov 2024 09:22:16 +0800 Subject: [PATCH 2/8] =?UTF-8?q?=E6=93=8D=E4=BD=9C=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=86=85=E5=AE=B9=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/templates/page/operation_log.html | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sec-beidou/src/main/resources/templates/page/operation_log.html b/sec-beidou/src/main/resources/templates/page/operation_log.html index e1406c5c..c49eec5f 100644 --- a/sec-beidou/src/main/resources/templates/page/operation_log.html +++ b/sec-beidou/src/main/resources/templates/page/operation_log.html @@ -24,6 +24,12 @@ +
+ +
+ +
+
From 8761164e4f3791e7516127bef5d2101265569e6d Mon Sep 17 00:00:00 2001 From: weidong Date: Sat, 9 Nov 2024 09:28:32 +0800 Subject: [PATCH 3/8] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=88=9B=E5=BB=BA?= =?UTF-8?q?=E8=A1=A8=E7=9A=84sql?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sec-beidou/src/main/resources/db/schema.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sec-beidou/src/main/resources/db/schema.sql b/sec-beidou/src/main/resources/db/schema.sql index 3dc7f2dd..a6348ba2 100644 --- a/sec-beidou/src/main/resources/db/schema.sql +++ b/sec-beidou/src/main/resources/db/schema.sql @@ -334,4 +334,4 @@ CREATE TABLE IF NOT EXISTS `gnssdevicesinglerecords` ( PRIMARY KEY (`id`), KEY `idx_deviceid_createtime` (`deviceid`,`createtime`), KEY `idx_createtime` (`createtime`) -) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='GNSS单次解算记录表'; \ No newline at end of file +) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8 COMMENT='GNSS单次解算记录表'; \ No newline at end of file From 20c2953a97e6c1f37dcfb50ae15eeb80364bbd1d Mon Sep 17 00:00:00 2001 From: weidong Date: Mon, 11 Nov 2024 21:55:57 +0800 Subject: [PATCH 4/8] =?UTF-8?q?=E6=8E=A8=E9=80=81=E7=BB=842=E5=AF=B9?= =?UTF-8?q?=E9=9D=9ESAAS=E7=94=A8=E6=88=B7=E4=B8=8D=E5=8F=AF=E8=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sec-beidou/src/main/resources/templates/page/gnss_dev_cfg.html | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sec-beidou/src/main/resources/templates/page/gnss_dev_cfg.html b/sec-beidou/src/main/resources/templates/page/gnss_dev_cfg.html index 8d9064ff..75a5563e 100644 --- a/sec-beidou/src/main/resources/templates/page/gnss_dev_cfg.html +++ b/sec-beidou/src/main/resources/templates/page/gnss_dev_cfg.html @@ -123,6 +123,9 @@ if([[${role}]] == "USER") { cfg_cols[15].hide = true; } + if([[${tenant_id}]] != 0) { + cfg_cols[10].hide = true; + } /** * 初始化表单,要加上,不然刷新部分组件可能会不加载 */ From 5c4fff393dcd65b0804dfd4d5e5c38a0cdab2528 Mon Sep 17 00:00:00 2001 From: weidong Date: Wed, 13 Nov 2024 15:07:39 +0800 Subject: [PATCH 5/8] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=9C=80=E5=90=8E?= =?UTF-8?q?=E4=B8=80=E6=AC=A1=E6=BF=80=E6=B4=BB=E6=97=B6=E9=97=B4=E7=9A=84?= =?UTF-8?q?=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sideslope/message/D3F0SelfCheckMessage.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/sec-beidou-rtcm/src/main/java/com/imdroid/sideslope/message/D3F0SelfCheckMessage.java b/sec-beidou-rtcm/src/main/java/com/imdroid/sideslope/message/D3F0SelfCheckMessage.java index bfb51351..2cb5fff4 100644 --- a/sec-beidou-rtcm/src/main/java/com/imdroid/sideslope/message/D3F0SelfCheckMessage.java +++ b/sec-beidou-rtcm/src/main/java/com/imdroid/sideslope/message/D3F0SelfCheckMessage.java @@ -57,6 +57,17 @@ public class D3F0SelfCheckMessage extends BaseMessage { " blVer:"+src.readUnsignedByte() + " reboot:"+src.readUnsignedShort(); } + if(src.readableBytes()>=8){ + long lastActiveDate = src.readUnsignedInt(); + long lastActiveTime = src.readUnsignedInt(); + short year = (short) ((lastActiveDate>>16)&0xFF); + short month = (short) ((lastActiveDate>>8)&0xFF); + short day = (short) (lastActiveDate&0xFF); + byte hour = (byte) (lastActiveTime/3600); + byte munite = (byte) (lastActiveTime/60 - hour*60); + auxInfo = auxInfo + " last active time:"+ + year+"-"+month+"-"+day+" "+hour+":"+munite; + } // read 会移动 bytebuf 的指针,所以保存原始码流需要将此指针挑拨回开始处 src.readerIndex(0); From 9a95f3d0aaed0c922831472a908c8822b969a378 Mon Sep 17 00:00:00 2001 From: weidong Date: Wed, 13 Nov 2024 19:39:58 +0800 Subject: [PATCH 6/8] =?UTF-8?q?=E7=AE=97=E6=B3=957=E6=94=B9=E4=B8=BAECEF+?= =?UTF-8?q?=E5=88=A4=E6=96=AD=E5=91=A8=E8=B7=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sideslope/bd/FocusCalculator7.java | 56 ++++++++++++++++++- 1 file changed, 54 insertions(+), 2 deletions(-) diff --git a/sec-beidou-rtcm/src/main/java/com/imdroid/sideslope/bd/FocusCalculator7.java b/sec-beidou-rtcm/src/main/java/com/imdroid/sideslope/bd/FocusCalculator7.java index 5fb77415..821c78b7 100644 --- a/sec-beidou-rtcm/src/main/java/com/imdroid/sideslope/bd/FocusCalculator7.java +++ b/sec-beidou-rtcm/src/main/java/com/imdroid/sideslope/bd/FocusCalculator7.java @@ -2,13 +2,16 @@ package com.imdroid.sideslope.bd; import com.imdroid.sideslope.sal.Device; +import static com.imdroid.sideslope.bd.GeoCoordConverterUtil.ECEF2ENU; +import static com.imdroid.sideslope.bd.GeoCoordConverterUtil.LLA2ECEF; + /** * 博通:用GGA绝对坐标代替相对位置 */ public class FocusCalculator7 extends FocusCalculator3{ - final static long scale = 100000000L;//地球1°:111km,放大到mm乘以100,000,000 + //final static long scale = 100000000L;//地球1°:111km,放大到mm乘以100,000,000 final static int bad_change_mm = 500;//固定解跳变连续10次超过500mm,认为是周跳 final static int bad_duration = 10; @@ -18,7 +21,7 @@ public class FocusCalculator7 extends FocusCalculator3{ super(bsDevice); } - @Override + /*@Override public void addGGA(Gga gga) { if(gga == null) return; @@ -41,6 +44,55 @@ public class FocusCalculator7 extends FocusCalculator3{ } else if(gga.getQuality() == 5) counterNoFixed++; else counterNoB562 ++; + }*/ + + @Override + public void addGGA(Gga gga) { + if(gga == null) return; + double[] end; + + // 测站的GGA - 测站 LLA 数据 + GeoCoordConverterUtil.LLA_Coordinate rover_lla = new GeoCoordConverterUtil.LLA_Coordinate(gga.getLatitude(),gga.getLongitude(),gga.getAltitude()); + // 测站 LLA 坐标转 ECEF 坐标,单位米 + GeoCoordConverterUtil.ECEF_Coordinate rover_ecef = LLA2ECEF(rover_lla); + + if(bsDevice==null || bsDevice.getEcefx()==null){ + end = new double[]{ + rover_ecef.getECEF_X()*1000, + rover_ecef.getECEF_Y()*1000, + rover_ecef.getECEF_Z()*1000, + gga.getQuality()}; + } + else { + // 查询测站的绑定的基站 + GeoCoordConverterUtil.ECEF_Coordinate reference_ecef = new GeoCoordConverterUtil.ECEF_Coordinate(bsDevice.getEcefx(), bsDevice.getEcefy(), bsDevice.getEcefz()); + + // 以基站为站心的 ENU 坐标 + GeoCoordConverterUtil.ENU_Coordinate difference_enu = ECEF2ENU(reference_ecef, rover_ecef); + end = new double[]{ + difference_enu.ENU_E*1000, + difference_enu.ENU_N*1000, + difference_enu.ENU_U*1000, + gga.getQuality()}; + } + + if(gga.isFixed()) { + counterFixedResult++; + if(pointList.size()>0){ + double[] lastXyz = pointList.get(pointList.size()-1); + if(Math.abs(end[0]-lastXyz[0])>bad_change_mm || + Math.abs(end[1]-lastXyz[1])>bad_change_mm || + Math.abs(end[2]-lastXyz[2])>bad_change_mm){ + bad_count++; + return; + } + } + bad_count = 0; + + pointList.add(end); + } + else if(gga.getQuality() == 5) counterNoFixed++; + else counterNoB562 ++; } @Override From 9683dfc8a9ec5a4dd4e872f653196de1a06bd846 Mon Sep 17 00:00:00 2001 From: weidong Date: Wed, 20 Nov 2024 23:35:53 +0800 Subject: [PATCH 7/8] =?UTF-8?q?1=E3=80=81=E5=A2=9E=E5=8A=A0=E5=91=BD?= =?UTF-8?q?=E4=BB=A4=E5=8F=91=E9=80=81=E9=80=9A=E9=81=93=E9=80=89=E6=8B=A9?= =?UTF-8?q?=202=E3=80=81d3f0=E5=9B=9E=E5=BA=94=E7=AD=94d3f1=203=E3=80=81?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0d3f0=E6=96=B0=E5=AD=97=E6=AE=B5=EF=BC=88?= =?UTF-8?q?=E4=B8=B2=E5=8F=A3=E5=BC=82=E5=B8=B8=E7=BB=9F=E8=AE=A1=EF=BC=89?= =?UTF-8?q?=E8=A7=A3=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/imdroid/secapi/client/RtcmClient.java | 3 +++ .../D3F0SelfCheckMessageExecutor.java | 13 +++++++++ .../message/D3F0SelfCheckMessage.java | 23 ++++++++++++++++ .../imdroid/sideslope/web/ApiController.java | 27 +++++++++++++++++++ .../beidou/controller/CmdLineController.java | 8 ++++-- .../resources/templates/page/cmd_line.html | 9 +++++++ 6 files changed, 81 insertions(+), 2 deletions(-) diff --git a/sec-api/src/main/java/com/imdroid/secapi/client/RtcmClient.java b/sec-api/src/main/java/com/imdroid/secapi/client/RtcmClient.java index 7212ee59..2781e2b0 100644 --- a/sec-api/src/main/java/com/imdroid/secapi/client/RtcmClient.java +++ b/sec-api/src/main/java/com/imdroid/secapi/client/RtcmClient.java @@ -9,6 +9,9 @@ public interface RtcmClient { @PostMapping("/config") HttpResp config(@RequestParam(name = "deviceId") String deviceId, @RequestParam(name = "configuration") String configData); + @PostMapping("/config_by_udp") + HttpResp configByUdp(@RequestParam(name = "deviceId") String deviceId, @RequestParam(name = "configuration") String configData); + @PostMapping("/device_param_changed") HttpResp deviceParamChanged(@RequestParam(name = "deviceId") String deviceId,@RequestParam(name = "oldParentId") String oldParentId); diff --git a/sec-beidou-rtcm/src/main/java/com/imdroid/sideslope/executor/D3F0SelfCheckMessageExecutor.java b/sec-beidou-rtcm/src/main/java/com/imdroid/sideslope/executor/D3F0SelfCheckMessageExecutor.java index 22f7c6b8..aad86465 100644 --- a/sec-beidou-rtcm/src/main/java/com/imdroid/sideslope/executor/D3F0SelfCheckMessageExecutor.java +++ b/sec-beidou-rtcm/src/main/java/com/imdroid/sideslope/executor/D3F0SelfCheckMessageExecutor.java @@ -49,6 +49,9 @@ public class D3F0SelfCheckMessageExecutor implements Executor=14){ + int uart1Exception = src.readUnsignedShort(); + int uart2Exception = src.readUnsignedShort(); + int dtuException = src.readUnsignedShort(); + long lastDtuErrDate = src.readUnsignedInt(); + long lastDtuErrTime = src.readUnsignedInt(); + if(uart1Exception>0) { + auxInfo = auxInfo + " uart1 err: "+uart1Exception; + } + if(uart2Exception>0) { + auxInfo = auxInfo + " uart2 err: "+uart2Exception; + } + if(lastDtuErrDate!=0){ + auxInfo = auxInfo + " last dtu err state: "+dtuException; + short year = (short) ((lastDtuErrDate>>16)&0xFF); + short month = (short) ((lastDtuErrDate>>8)&0xFF); + short day = (short) (lastDtuErrDate&0xFF); + byte hour = (byte) (lastDtuErrTime/3600); + byte munite = (byte) (lastDtuErrTime/60 - hour*60); + auxInfo = auxInfo + " time: "+ + year+"-"+month+"-"+day+" "+hour+":"+munite; + } + } // read 会移动 bytebuf 的指针,所以保存原始码流需要将此指针挑拨回开始处 src.readerIndex(0); diff --git a/sec-beidou-rtcm/src/main/java/com/imdroid/sideslope/web/ApiController.java b/sec-beidou-rtcm/src/main/java/com/imdroid/sideslope/web/ApiController.java index 33c5a929..5fbc2585 100644 --- a/sec-beidou-rtcm/src/main/java/com/imdroid/sideslope/web/ApiController.java +++ b/sec-beidou-rtcm/src/main/java/com/imdroid/sideslope/web/ApiController.java @@ -70,6 +70,33 @@ public class ApiController { return resp; } + @PostMapping(value = "/config_by_udp") + public HttpResp configByUdp(String deviceId, String configuration) { + Map status = new HashMap<>(); + HttpResp resp = new HttpResp(); + DeviceChannel deviceChannel = OnlineChannels.INSTANCE.getDataChannel(deviceId); + + if(deviceChannel!=null){ + status.put("status", "Online"); + // send command + ByteBuf buf = Unpooled.buffer(); + byte[] data = getBinaryData(ConfigDataTypeEnum.HEX, configuration); + logger.info("send command:{}", configuration); + buf.writeBytes(data); + deviceChannel.writeAndFlush(buf); + } + + if (status.isEmpty()) { + status.put("status", "Offline"); + resp.setCode(HttpResp.HTTP_RSP_FAILED); + resp.setResponseMessage("Offline."); + } else { + resp.setResponseMessage("Command sent."); + } + resp.setResponseObject(status); + return resp; + } + @PostMapping("/device_param_changed") public HttpResp deviceParamChanged(String deviceId, String oldParentId) { // 更新设备缓存 diff --git a/sec-beidou/src/main/java/com/imdroid/beidou/controller/CmdLineController.java b/sec-beidou/src/main/java/com/imdroid/beidou/controller/CmdLineController.java index 2ab43766..35c97520 100644 --- a/sec-beidou/src/main/java/com/imdroid/beidou/controller/CmdLineController.java +++ b/sec-beidou/src/main/java/com/imdroid/beidou/controller/CmdLineController.java @@ -60,7 +60,8 @@ public class CmdLineController extends BasicController{ public HttpResult configCmd(HttpSession session, @RequestParam("tx_win") String cmd, @RequestParam("device_id") String deviceId, - @RequestParam("cmd_type") int cmdType) { + @RequestParam("cmd_type") int cmdType, + @RequestParam("send_channel") int sendChannel) { String sendCmd = cmd.replaceAll(" +",""); short len = 0; int msgType = 0xD310 + cmdType; @@ -75,7 +76,10 @@ public class CmdLineController extends BasicController{ sendCmd = Integer.toHexString(msgType) + HexUtil.Short2HexString(len)+ HexUtil.Int2HexString(Integer.parseInt(deviceId))+sendCmd; } - HttpResp> rsp = rtcmClient.config(deviceId,sendCmd); + HttpResp> rsp; + if(sendChannel == 0) + rsp = rtcmClient.config(deviceId,sendCmd); + else rsp = rtcmClient.configByUdp(deviceId,sendCmd); String txInfo = "TX "+ dateFormat.format(System.currentTimeMillis())+ " "+deviceId+" "+sendCmd; diff --git a/sec-beidou/src/main/resources/templates/page/cmd_line.html b/sec-beidou/src/main/resources/templates/page/cmd_line.html index 2e1eef13..95c25382 100644 --- a/sec-beidou/src/main/resources/templates/page/cmd_line.html +++ b/sec-beidou/src/main/resources/templates/page/cmd_line.html @@ -53,6 +53,15 @@
+
+ +
+ +
+
From 2076b8bca00bf09ed9a059036eef32d13ed11104 Mon Sep 17 00:00:00 2001 From: weidong Date: Thu, 21 Nov 2024 14:44:46 +0800 Subject: [PATCH 8/8] =?UTF-8?q?1=E3=80=81=E4=B8=8D=E6=89=93=E5=8D=B0?= =?UTF-8?q?=E7=A0=81=E6=B5=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/imdroid/sideslope/server/udp/RtcmUdpHandler.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sec-beidou-rtcm/src/main/java/com/imdroid/sideslope/server/udp/RtcmUdpHandler.java b/sec-beidou-rtcm/src/main/java/com/imdroid/sideslope/server/udp/RtcmUdpHandler.java index d5596fe1..cfcefb89 100644 --- a/sec-beidou-rtcm/src/main/java/com/imdroid/sideslope/server/udp/RtcmUdpHandler.java +++ b/sec-beidou-rtcm/src/main/java/com/imdroid/sideslope/server/udp/RtcmUdpHandler.java @@ -32,11 +32,11 @@ public class RtcmUdpHandler extends ChannelInboundHandlerAdapter { if (packet.content() == null) { return; } - if (logger.isDebugEnabled()) { + /*if (logger.isDebugEnabled()) { byte[] data = new byte[packet.content().readableBytes()]; packet.content().getBytes(0, data); logger.debug("receive message:" + DataTypeUtil.getHexString(data)); - } + }*/ // 消息解析 BaseMessage message = MessageParser.instance.parse(packet.content()); OnlineChannels.INSTANCE.updateDataChannel(message.getId(), ctx.channel(), packet.sender());