1. 根据新的协议,扩展了设备编号的位数从1位至6位;
2. 新增监测因子无人机高度;
已修改7个文件
已重命名1个文件
60 ■■■■ 文件已修改
src/main/kotlin/com/flightfeather/uav/UAVApplication.kt 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/lightshare/web/RealTimeDataController.kt 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/socket/UnderwaySocketServer.kt 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/socket/bean/AirDataPackage.kt 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/socket/decoder/DataUnitDecoder.kt 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/socket/decoder/impl/DataPackageDecoderImpl.kt 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/socket/decoder/impl/DataUnitDecoderImpl.kt 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/socket/eunm/FactorType.kt 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/UAVApplication.kt
@@ -1,6 +1,6 @@
package com.flightfeather.uav
import com.flightfeather.uav.socket.SocketServerClient
import com.flightfeather.uav.socket.UnderwaySocketServer
import org.springframework.boot.ApplicationRunner
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.runApplication
@@ -11,7 +11,7 @@
    @Bean
    fun runner() = ApplicationRunner{
        SocketServerClient().startServer(9030)
        UnderwaySocketServer().startServer(9030)
    }
}
src/main/kotlin/com/flightfeather/uav/lightshare/web/RealTimeDataController.kt
@@ -12,11 +12,11 @@
    @GetMapping("/sec")
    fun getSecondData(
            @RequestParam(value = "deviceCode", required = false) deviceCode: String?,
            @RequestParam(value = "startTime", required = false) startTime: String?,
            @RequestParam(value = "endTime", required = false) endTime: String?,
            @RequestParam(value = "page", required = false) page: Int?,
            @RequestParam(value = "perPage", required = false) perPage: Int?
        @RequestParam(value = "deviceCode", required = false) deviceCode: String?,
        @RequestParam(value = "startTime", required = false) startTime: String?,
        @RequestParam(value = "endTime", required = false) endTime: String?,
        @RequestParam(value = "page", required = false) page: Int?,
        @RequestParam(value = "perPage", required = false) perPage: Int?
    ) = realTimeDataService.getSecondData(deviceCode, startTime, endTime, page, perPage)
    @GetMapping("/sec/next")
src/main/kotlin/com/flightfeather/uav/socket/UnderwaySocketServer.kt
ÎļþÃû´Ó src/main/kotlin/com/flightfeather/uav/socket/SocketServerClient.kt ÐÞ¸Ä
@@ -10,12 +10,11 @@
import io.netty.handler.codec.string.StringEncoder
import java.nio.charset.Charset
/**
 * socket长连接服务端
 * 2019.8.26
 * @author riku
 */
class SocketServerClient {
/*********************************************************************************
 * èµ°èˆªç›‘测数据socket长连接服务端
 * ç”¨äºŽæŽ¥æ”¶è§£æžèµ°èˆªç›‘测数据,前端监测设备目前包括车载走航、无人机走航以及无人船走航三种类型
 * *******************************************************************************/
class UnderwaySocketServer {
    private val bossGroup = NioEventLoopGroup()
    private val workerGroup = NioEventLoopGroup()
src/main/kotlin/com/flightfeather/uav/socket/bean/AirDataPackage.kt
@@ -33,12 +33,9 @@
        //数据中的保留字节数
        const val RESERVED_DATA_COUNT = 12
        //一个动态监测因子的属性所占字节数
        //动态监测因子所占字节数,不同位数对应不同的组合策略
        const val FACTOR_BIT_LENGTH_1 = 6
        //一个保留监测因子的属性所占字节数
        const val FACTOR_BIT_LENGTH_2 = 3
        const val FACTOR_BIT_LENGTH_3 = 2
    }
}
src/main/kotlin/com/flightfeather/uav/socket/decoder/DataUnitDecoder.kt
@@ -11,13 +11,6 @@
 *
 * æ•°æ®å•元按照命令单元的类型共有以下几种类型:
 * å‘½ä»¤å•å…ƒ @see [AirCommandUnit]
 * ç¼–码(byte)        å®šä¹‰
 * 0x01                 è½¦è¾†ç™»å…¥
 * 0x02                 å®žæ—¶ä¿¡æ¯ä¸ŠæŠ¥
 * 0x03                 è¡¥å‘信息上报
 * 0x04                 è½¦è¾†ç™»å‡º
 * 0x05                 ç»ˆç«¯æ ¡æ—¶
 * 0x06~0x7f       ä¸Šè¡Œæ•°æ®ç³»ç»Ÿé¢„ç•™
 */
interface DataUnitDecoder {
src/main/kotlin/com/flightfeather/uav/socket/decoder/impl/DataPackageDecoderImpl.kt
@@ -14,10 +14,15 @@
class DataPackageDecoderImpl : DataPackageDecoder {
    companion object {
//        æ•°æ®å¤´
        const val HEAD_BYTES = 1
//        ç›‘测参数确认指令位
        const val COMMAND_UNIT_BYTES = 1
        const val DEVICE_CODE_BYTES = 1
//        è®¾å¤‡ç±»åž‹
        const val DEVICE_CODE_BYTES = 6
//        æœ¬æ¬¡ç›‘测的空气因子数量
        const val DATA_LENGTH = 1
//        æ ¡éªŒ
        const val BCC_BYTES = 2
    }
@@ -47,7 +52,7 @@
    }
    override fun getDeviceCode(b: List<String>): String? = if (b.size >= (HEAD_BYTES + COMMAND_UNIT_BYTES + DEVICE_CODE_BYTES)) {
        //2021/1/7 '0A'代表车载设备,'0B'代表无人机设备
        //2021/1/7 '0A'代表车载设备,'0B'代表无人机设备,'0C'为网格化监测
        val s = StringBuilder()
        repeat(DEVICE_CODE_BYTES) {
            s.append(b[HEAD_BYTES + COMMAND_UNIT_BYTES + it])
@@ -91,7 +96,7 @@
    }
    override fun getCheckCode(b: List<String>): Int? {
        return if (b.size >= 5) {
        return if (b.size >= HEAD_BYTES + COMMAND_UNIT_BYTES + DEVICE_CODE_BYTES + BCC_BYTES) {
            val hexNum = "${b[b.size - 2]}${b[b.size - 1]}"
            hexNum.toIntOrNull(16)
src/main/kotlin/com/flightfeather/uav/socket/decoder/impl/DataUnitDecoderImpl.kt
@@ -89,10 +89,10 @@
                }
                FactorType.TIME -> {
                    val year = b[i].toInt(16).toString().run { numberFormat(this) }
                    val month = b[i+1].toInt(16).toString().run { numberFormat(this) }
                    val day = b[i+2].toInt(16).toString().run { numberFormat(this) }
                    val hour = b[i+3].toInt(16).toString().run { numberFormat(this) }
                    val minute = b[i+4].toInt(16).toString().run { numberFormat(this) }
                    val month = b[i + 1].toInt(16).toString().run { numberFormat(this) }
                    val day = b[i + 2].toInt(16).toString().run { numberFormat(this) }
                    val hour = b[i + 3].toInt(16).toString().run { numberFormat(this) }
                    val minute = b[i + 4].toInt(16).toString().run { numberFormat(this) }
                    val second = b[i + 5].toInt(16).toString().run { numberFormat(this) }
                    val date = "20$year-$month-$day $hour:$minute:$second"
                    val time = SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(date).time
src/main/kotlin/com/flightfeather/uav/socket/eunm/FactorType.kt
@@ -21,7 +21,8 @@
    VELOCITY(14, "VELOCITY", 3),//速度
    TIME(15, "TIME", 6),//时间
    WIND_SPEED(16, "WIND_SPEED", 3),
    WIND_DIRECTION(17, "WIND_DIRECTION", 2);
    WIND_DIRECTION(17, "WIND_DIRECTION", 2),
    HEIGHT(18, "HEIGHT", 3);
    companion object {
@@ -43,6 +44,7 @@
            TIME.value -> TIME
            WIND_SPEED.value -> WIND_SPEED
            WIND_DIRECTION.value -> WIND_DIRECTION
            HEIGHT.value -> HEIGHT
            else -> null
        }
    }