| | |
| | | package com.flightfeather.obd.socket.decoder.impl |
| | | |
| | | import com.flightfeather.obd.socket.bean.EngineDataFlow |
| | | import com.flightfeather.obd.socket.bean.EngineDataStream |
| | | import com.flightfeather.obd.socket.bean.ObdData |
| | | import com.flightfeather.obd.socket.bean.SupplementDataFlow |
| | | 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.* |
| | | |
| | | /** |
| | |
| | | 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() |
| | | obdFaultCodeNum = faultCodeNum |
| | |
| | | } |
| | | } |
| | | |
| | | 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()) { |
| | | //去除 信息类型标志 |
| | |
| | | } |
| | | |
| | | 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) |
| | |
| | | } |
| | | } |
| | | |
| | | 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()) { |
| | | //去除 信息类型标志 |
| | |
| | | } |
| | | |
| | | 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) |
| | |
| | | override fun getDataListByDataType(list: List<String>): MutableList<String> { |
| | | if (list.isEmpty()) return mutableListOf() |
| | | |
| | | //fixme 2019.9.16 不管第一位的信息类型标志是否正确,至少返回一个值,此方法在信息体结构没有严格按照标准, |
| | | //fixme 即在后一个信息类型标志和前一个信息体之间有无效字符时,能够将其忽略,但不确定这种处理方式是否正确和必要 |
| | | val resultList = mutableListOf<String>().apply { |
| | | //添加 信息类型标志 |
| | | add(list[0]) |
| | | } |
| | | |
| | | when (list[0].toIntOrNull(16)) { |
| | | ObdDataType.ObdData.value -> { |
| | | |
| | | //从起始字节 1 开始,固定有97个字节的数据 |
| | | for (i in 1..96) { |
| | | resultList.add(list[i]) |
| | |
| | | } |
| | | } |
| | | ObdDataType.EngineDataFlow.value -> { |
| | | |
| | | //从起始字节 1 开始,固定有37个字节的数据 |
| | | for (i in 1..37) { |
| | | resultList.add(list[i]) |
| | | } |
| | | } |
| | | ObdDataType.SupplementDataFlow.value -> { |
| | | |
| | | //从起始字节 1 开始,固定有17个字节的数据 |
| | | for (i in 1..17) { |
| | | resultList.add(list[i]) |