ÎļþÃû´Ó src/main/kotlin/com/flightfeather/uav/socket/MessageManager.kt ÐÞ¸Ä |
| | |
| | | package com.flightfeather.uav.socket |
| | | package com.flightfeather.uav.socket.processor |
| | | |
| | | import com.flightfeather.uav.common.utils.FileUtil |
| | | import com.flightfeather.uav.repository.* |
| | | import com.flightfeather.uav.socket.bean.* |
| | | import com.flightfeather.uav.repository.AirDataRepository |
| | | import com.flightfeather.uav.socket.bean.AirDataPackage |
| | | import com.flightfeather.uav.socket.decoder.AirDataDecoder |
| | | import com.flightfeather.uav.socket.decoder.impl.DataPackageDecoderImpl |
| | | import com.flightfeather.uav.socket.decoder.DataPackageDecoder |
| | | import com.flightfeather.uav.socket.eunm.AirCommandUnit |
| | | import io.netty.channel.ChannelHandlerContext |
| | | import org.springframework.beans.factory.annotation.Autowired |
| | |
| | | */ |
| | | |
| | | @Component |
| | | class MessageManager{ |
| | | class UnderwayProcessor : BaseProcessor() { |
| | | |
| | | companion object{ |
| | | private lateinit var instance: MessageManager |
| | | private lateinit var instance: UnderwayProcessor |
| | | |
| | | private const val TAG = "UAV" |
| | | } |
| | |
| | | lateinit var airDataRepository: AirDataRepository |
| | | |
| | | val airDataDecoder = AirDataDecoder.instance |
| | | val dataPackageDecoder = DataPackageDecoderImpl() |
| | | val dataPackageDecoder = DataPackageDecoder() |
| | | |
| | | @PostConstruct |
| | | fun init() { |
| | | instance = this |
| | | airDataRepository = this.airDataRepository |
| | | } |
| | | |
| | | fun dealStringMsg(msg: String, ctx: ChannelHandlerContext?) { |
| | | override var tag: String = "èµ°èªçæµ" |
| | | |
| | | override fun dealStringMsg(msg: String, ctx: ChannelHandlerContext?) { |
| | | //è§£å
|
| | | val packageData = airDataDecoder.decode(msg) |
| | | |
| | | |
| | | if (bccCheck(msg)) { |
| | | //ä¿å |
| | | DeviceSession.saveDevice(packageData.deviceCode, ctx) |
| | | deviceSession.saveDevice(packageData.deviceCode, ctx) |
| | | saveToTxt(msg) |
| | | saveToDataBase(packageData) |
| | | } else { |
| | | println("------${TAG}æ°æ®BCCæ ¡éªå¤±è´¥ï¼èå¼ [${SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(Date())}]") |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * ä¿åè³txtææ¬ |
| | | */ |
| | | fun saveToTxt(msg: String) { |
| | | val data = "[${SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(Date())}]data=> $msg" |
| | | FileUtil.instance?.saveObdData(data) |
| | | } |
| | | |
| | | /** |