src/main/kotlin/com/flightfeather/obd/socket/decoder/impl/RealTimeDataDecoderImpl.kt
@@ -1,11 +1,10 @@
package com.flightfeather.obd.socket.decoder.impl
import com.flightfeather.obd.socket.bean.EngineDataFlow
import com.flightfeather.obd.socket.bean.ObdData
import com.flightfeather.obd.socket.bean.SupplementDataFlow
import com.flightfeather.obd.socket.bean.EngineDataStream
import com.flightfeather.obd.socket.bean.ObdInfo
import com.flightfeather.obd.socket.bean.SupplementDataStream
import com.flightfeather.obd.socket.decoder.RealTimeDataDecoder
import com.flightfeather.obd.socket.eunm.ObdDataType
import org.springframework.stereotype.Component
import java.util.*
/**
@@ -13,7 +12,7 @@
 * Date: 2019/9/15
 */
class RealTimeDataDecoderImpl : RealTimeDataDecoder {
    override fun getObdData(time: Date?, serialNum: Int, b: List<String>): ObdData? {
    override fun getObdData(time: Date?, serialNum: Int, b: List<String>): ObdInfo? {
        val dataList = mutableListOf<String>().apply { addAll(b) }
        if (b.isNotEmpty()) {
            //去除 信息类型标志
@@ -47,15 +46,15 @@
                }
            }
            return ObdData(time, serialNum).apply {
            return ObdInfo(time, serialNum).apply {
                obdProtocol = dataList[0].toIntOrNull(16)
                obdMil = dataList[1].toIntOrNull(16)
                diagnosisSupportStatus = "${dataList[2]}${dataList[3]}".toIntOrNull(16)?.toString(2)
                diagnosisReadyStatus = "${dataList[4]}${dataList[5]}".toIntOrNull(16)?.toString(2)
                obdVin = vin.toString()
                obdSoftwareCode = softwareCode.toString()
                obdCrn = softwareCode.toString()
                obdCvn = cvn.toString()
                this.IUPR = IUPR.toString()
                this.iupr = IUPR.toString()
                obdFaultCodeNum = faultCodeNum
                obdFaultCode = faultCode.toString()
            }
@@ -64,7 +63,7 @@
        }
    }
    override fun getEngineDataFlow(time: Date?, serialNum: Int, b: List<String>): EngineDataFlow? {
    override fun getEngineDataStream(time: Date?, serialNum: Int, b: List<String>): EngineDataStream? {
        val dataList = mutableListOf<String>().apply { addAll(b) }
        if (b.isNotEmpty()) {
            //去除 信息类型标志
@@ -72,15 +71,15 @@
        }
        return if (dataList.size >= 37) {
             EngineDataFlow(time, serialNum).apply {
             EngineDataStream(time, serialNum).apply {
                obdSpeed = "${dataList[0]}${dataList[1]}".toIntOrNull(16)?.toDouble()?.times((1 / 256).toDouble())
                obdAirPressure = dataList[2].toIntOrNull(16)?.toDouble()?.times(0.5)
                obdEngineTorque = dataList[3].toIntOrNull(16)?.minus(125)?.toDouble()?.div(100)
                obdFrictionTorque = dataList[4].toIntOrNull(16)?.minus(125)?.toDouble()?.div(100)
                obdEngineRpm = "${dataList[5]}${dataList[6]}".toIntOrNull(16)?.toDouble()?.times(0.125)
                obdEngineFuelFlow = "${dataList[7]}${dataList[8]}".toIntOrNull(16)?.toDouble()?.times(0.05)
                obdScrUpstreamNo = "${dataList[9]}${dataList[10]}".toIntOrNull(16)?.minus(200)?.toDouble()?.times(0.05)
                obdScrDownstreamNo = "${dataList[11]}${dataList[12]}".toIntOrNull(16)?.minus(200)?.toDouble()?.times(0.05)
                obdScrUpstreamNox = "${dataList[9]}${dataList[10]}".toIntOrNull(16)?.minus(200)?.toDouble()?.times(0.05)
                obdScrDownstreamNox = "${dataList[11]}${dataList[12]}".toIntOrNull(16)?.minus(200)?.toDouble()?.times(0.05)
                obdRemainReactant = dataList[13].toIntOrNull(16)?.toDouble()?.times(0.4)?.div(100)
                obdAirInput = "${dataList[14]}${dataList[15]}".toIntOrNull(16)?.toDouble()?.times(0.05)
                obdScrInputTemp = "${dataList[16]}${dataList[17]}".toIntOrNull(16)?.minus(273)?.toDouble()?.times(0.03125)
@@ -98,7 +97,7 @@
        }
    }
    override fun getSupplementDataFlow(time: Date?, serialNum: Int, b: List<String>): SupplementDataFlow? {
    override fun getSupplementDataStream(time: Date?, serialNum: Int, b: List<String>): SupplementDataStream? {
        val dataList = mutableListOf<String>().apply { addAll(b) }
        if (b.isNotEmpty()) {
            //去除 信息类型标志
@@ -106,7 +105,7 @@
        }
        return if (dataList.size >= 17) {
            SupplementDataFlow(time, serialNum).apply {
            SupplementDataStream(time, serialNum).apply {
                obdEngineTorqueMode = dataList[0].toIntOrNull(16)
                obdAcceleratorPedal = dataList[1].toIntOrNull(16)?.toDouble()?.times(0.4)?.div(100)
                obdTotalOilConsumption = "${dataList[2]}${dataList[3]}${dataList[4]}${dataList[5]}".toIntOrNull(16)?.toDouble()?.times(0.5)