From 09f411e381f885619b32e05fc89cad26bb20824d Mon Sep 17 00:00:00 2001 From: riku <risaku@163.com> Date: 星期一, 01 三月 2021 14:27:56 +0800 Subject: [PATCH] Merge remote-tracking branch 'obdserver2/master' --- src/test/kotlin/com/flightfeather/uav/Test.kt | 31 +++++++++++++++++++++---------- 1 files changed, 21 insertions(+), 10 deletions(-) diff --git a/src/test/kotlin/com/flightfeather/uav/Test.kt b/src/test/kotlin/com/flightfeather/uav/Test.kt index 7927e80..9ab8a21 100644 --- a/src/test/kotlin/com/flightfeather/uav/Test.kt +++ b/src/test/kotlin/com/flightfeather/uav/Test.kt @@ -1,6 +1,13 @@ package com.flightfeather.uav +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.* @@ -18,16 +25,20 @@ @Test fun foo2() { - val b = arrayOf("41", "79", "24", "04", "0B", "45") - val i = 0 - val valid = b[i].toInt(16).toChar()//缁忕含搴︽槸鍚︽湁鏁堬紙鏈夋晥: A; 鏃犳晥: V锛� - val a1 = b[i + 1].toInt(16) - val b1 = b[i + 2].toInt(16) - var b2 = "${b[i + 3]}${b[i + 4]}".toInt(16).toDouble() - while (b2 >= 1) { - b2 /= 10 + 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 lng = a1 + (b1 + b2) / 60 - val s = b[i + 5].toInt(16).toChar() + val str = Gson().toJson(list) + out.append(str) + out.flush() + out.close() } } \ No newline at end of file -- Gitblit v1.9.3