riku
2019-09-15 4d44ed185203088052b10a8d1e3526fcbbc88331
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package com.flightfeather.obd.socket.decoder
 
import com.flightfeather.obd.socket.bean.ObdPackageData
import com.flightfeather.obd.socket.decoder.impl.DataPackageDecoderImpl
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.stereotype.Component
import javax.annotation.PostConstruct
 
/**
 * 车辆 obd 数据解码器
 * @author riku
 * Date: 2019/9/12
 */
class VehicleDataDecoder {
 
    private val dataPackageDecoder: DataPackageDecoder = DataPackageDecoderImpl()
 
    fun decode(msg: String): ObdPackageData {
        val list = dataPackageDecoder.toStringList(msg)
        dataPackageDecoder.run {
            return ObdPackageData(
                    getHead(list),
                    getCommandUnit(list),
                    getVinCode(list),
                    getSoftwareVersion(list),
                    getEncryptionWay(list),
                    getDataLength(list),
                    getDataUnit(list),
                    getCheckCode(list)
            )
        }
    }
 
 
}