| | |
| | | import com.flightfeather.obd.socket.decoder.DataUnitDecoder |
| | | import com.flightfeather.obd.socket.decoder.RealTimeDataDecoder |
| | | import com.flightfeather.obd.socket.eunm.ObdDataType |
| | | import org.springframework.beans.factory.annotation.Autowired |
| | | import org.springframework.stereotype.Component |
| | | import java.lang.StringBuilder |
| | | import java.util.* |
| | | import javax.annotation.PostConstruct |
| | | |
| | | /** |
| | | * @author riku |
| | |
| | | val time = decodeDataTime(b) |
| | | |
| | | //国标法: 起始字节为7 开始的2个字节表示 流水号 |
| | | // val serialNum = "${b[7]}${b[8]}".toInt(16) |
| | | val serialNum = "${b[7]}${b[8]}".toInt(16) |
| | | |
| | | //上海法: 起始字节为6 开始的2个字节表示 流水号 |
| | | val serialNum = "${b[6]}${b[7]}".toInt(16) |
| | | // val serialNum = "${b[6]}${b[7]}".toInt(16) |
| | | |
| | | val dataList = mutableListOf<String>().apply { addAll(b) } |
| | | //删去前6位时间 |
| | |
| | | * 删去流水号,得到信息标志与信息体的组合 |
| | | * (国标法:去除前6位时间后,起始字节为1 开始的2个字节表示 流水号) |
| | | */ |
| | | // if (dataList.size >= 2) dataList.removeAt(1) |
| | | // if (dataList.size >= 2) dataList.removeAt(1) |
| | | if (dataList.size >= 2) dataList.removeAt(1) |
| | | if (dataList.size >= 2) dataList.removeAt(1) |
| | | |
| | | /* |
| | | * 删去流水号,得到信息标志与信息体的组合 |
| | | * (上海法:去除前6位时间后,起始字节为0 开始的2个字节表示 流水号) |
| | | */ |
| | | if (dataList.isNotEmpty()) dataList.removeAt(0) |
| | | if (dataList.isNotEmpty()) dataList.removeAt(0) |
| | | // if (dataList.isNotEmpty()) dataList.removeAt(0) |
| | | // if (dataList.isNotEmpty()) dataList.removeAt(0) |
| | | |
| | | val resultList = mutableListOf<RealTimeData>() |
| | | |
| | |
| | | if (data.isNotEmpty()) { |
| | | val r = when (data[0].toInt(16)) { |
| | | ObdDataType.ObdData.value -> realTimeDataDecoder.getObdData(time, serialNum, data) |
| | | ObdDataType.EngineDataFlow.value -> realTimeDataDecoder.getEngineDataFlow(time, serialNum, data) |
| | | ObdDataType.SupplementDataFlow.value -> realTimeDataDecoder.getSupplementDataFlow(time, serialNum, data) |
| | | ObdDataType.EngineDataFlow.value -> realTimeDataDecoder.getEngineDataStream(time, serialNum, data) |
| | | ObdDataType.SupplementDataFlow.value -> realTimeDataDecoder.getSupplementDataStream(time, serialNum, data) |
| | | else -> null |
| | | } |
| | | |
| | |
| | | for (i in 0 until data.size) { |
| | | if (dataList.isNotEmpty()) dataList.removeAt(0) |
| | | } |
| | | }else if (dataList.isNotEmpty()) { |
| | | //按照规则没有取到信息体,并且原数据不为空,表示原数据格式错误,退出循环 |
| | | // break |
| | | } |
| | | } |
| | | |
| | |
| | | val sec = b[5].toInt(16) |
| | | val cal = Calendar.getInstance().apply { |
| | | set(year, month - 1, day, hour, min, sec) |
| | | set(Calendar.MILLISECOND, 0) |
| | | } |
| | | |
| | | return cal.time |