| | |
| | | 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.* |
| | | |
| | |
| | | |
| | | @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() |
| | | } |
| | | } |