From 81bd0388494d45463de42cd91bd8c33f10f0030a Mon Sep 17 00:00:00 2001
From: riku <risaku@163.com>
Date: 星期四, 17 六月 2021 10:27:21 +0800
Subject: [PATCH] 1. 新增用电量数据的接收协议 2. 调整socket接收模块的代码结构

---
 src/test/kotlin/com/flightfeather/uav/Test.kt |   40 ++++++++++++++++++++++++++++++++++++++++
 1 files changed, 40 insertions(+), 0 deletions(-)

diff --git a/src/test/kotlin/com/flightfeather/uav/Test.kt b/src/test/kotlin/com/flightfeather/uav/Test.kt
index 6152cdb..38e6067 100644
--- a/src/test/kotlin/com/flightfeather/uav/Test.kt
+++ b/src/test/kotlin/com/flightfeather/uav/Test.kt
@@ -1,10 +1,50 @@
 package com.flightfeather.uav
 
+import com.flightfeather.uav.common.utils.FileExchange
+import com.flightfeather.uav.socket.bean.DataUnit
+import com.flightfeather.uav.socket.decoder.AirDataDecoder
+import com.flightfeather.uav.socket.eunm.AirCommandUnit
+import com.google.gson.Gson
+import org.junit.Test
+import java.io.File
+import java.io.FileOutputStream
+import java.io.OutputStreamWriter
+import java.text.SimpleDateFormat
+import java.util.*
+
 /**
  * @author riku
  * Date: 2019/9/12
  */
 class Test {
 
+    @Test
+    fun foo1() {
+        val s = SimpleDateFormat.getDateTimeInstance().format(Date())
+        println(s)
+    }
 
+    @Test
+    fun foo2() {
+        val file = File("E:\\VSprojects\\uav-monitor\\asset\\data\\data-2020-12-24-01-34-24.txt")
+        val outFile = File("E:\\VSprojects\\uav-monitor\\asset\\data\\data.json")
+        val out = OutputStreamWriter(FileOutputStream(outFile))
+        val list = mutableListOf<List<DataUnit>>()
+        file.readLines().forEach {
+            val p = AirDataDecoder.instance.decode(it)
+//            val str = Gson().toJson(p.dataUnit)
+            if (p.commandUnit == AirCommandUnit.AirData.value) {
+                list.add(p.dataUnit)
+            }
+        }
+        val str = Gson().toJson(list)
+        out.append(str)
+        out.flush()
+        out.close()
+    }
+
+    @Test
+    fun dataChange() {
+        FileExchange().doTask2()
+    }
 }
\ No newline at end of file

--
Gitblit v1.9.3