| | |
| | | package com.flightfeather.uav.socket.bean |
| | | |
| | | import com.flightfeather.uav.common.utils.DateUtil |
| | | import com.flightfeather.uav.lightshare.bean.DataVo |
| | | import com.flightfeather.uav.socket.eunm.AirCommandUnit |
| | | import com.flightfeather.uav.socket.eunm.FactorType |
| | | import java.text.SimpleDateFormat |
| | | import java.util.* |
| | | |
| | | /** |
| | |
| | | //数据中的保留字节数 |
| | | const val RESERVED_DATA_COUNT = 12 |
| | | |
| | | //一个保留监测因子的属性所占字节数 |
| | | const val FACTOR_BIT_LENGTH_2 = 3 |
| | | |
| | | //一个动态监测因子的属性所占字节数 |
| | | //动态监测因子所占字节数,不同位数对应不同的组合策略 |
| | | const val FACTOR_BIT_LENGTH_1 = 6 |
| | | const val FACTOR_BIT_LENGTH_2 = 3 |
| | | const val FACTOR_BIT_LENGTH_3 = 2 |
| | | } |
| | | |
| | | fun toDataVo()= DataVo().apply { |
| | | this.time = DateUtil.instance.dateToString(dataTime, DateUtil.DateStyle.YYYY_MM_DD_HH_MM_SS) |
| | | this.deviceCode = this@AirDataPackage.deviceCode |
| | | val tempList = mutableListOf<AirData>() |
| | | this@AirDataPackage.dataUnit.forEach { |
| | | if (it is AirData) { |
| | | when (it.factorId?.toInt()) { |
| | | FactorType.LAT.value -> { |
| | | this.lat = it.factorData |
| | | } |
| | | FactorType.LNG.value -> { |
| | | this.lng = it.factorData |
| | | } |
| | | FactorType.TIME.value -> { |
| | | it.statusList?.takeIf {l-> l.isNotEmpty() }?.get(0)?.let {d -> |
| | | this.time = d |
| | | } |
| | | } |
| | | } |
| | | tempList.add(it) |
| | | } |
| | | } |
| | | this.values = tempList |
| | | } |
| | | } |