| | |
| | | package com.flightfeather.uav |
| | | |
| | | import com.flightfeather.uav.common.utils.FileExchange |
| | | import com.flightfeather.uav.domain.entity.Company |
| | | 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() |
| | | } |
| | | |
| | | @Test |
| | | fun listCopy() { |
| | | val l1 = listOf(Company().apply { ciGuid = "a" }, Company().apply { ciGuid = "b" }, Company().apply { ciGuid = "c" }) |
| | | val l2 = mutableListOf<Company>().apply { addAll(l1) } |
| | | l2[1].ciGuid = "d" |
| | | println(l1) |
| | | println(l2) |
| | | } |
| | | |
| | | @Test |
| | | fun average() { |
| | | for (i in 0..2) { |
| | | println(i) |
| | | } |
| | | val list = listOf(1, 2, 3, 4, 5, 0) |
| | | println(list.average()) |
| | | } |
| | | } |