[8.5.0]
[singapore] [前后屏展示]
This commit is contained in:
@@ -40,5 +40,6 @@ dependencies {
|
||||
implementation rootProject.ext.dependencies.androidxappcompat
|
||||
api rootProject.ext.dependencies.serialport
|
||||
implementation "com.mogo.support.device.manager:led_screen_cpower5a:1.0.13"
|
||||
implementation "com.mogo.support.device.manager:led_screen_cubasic:1.0.0"
|
||||
implementation rootProject.ext.dependencies.view_model_scope
|
||||
}
|
||||
|
||||
@@ -0,0 +1,117 @@
|
||||
package com.mogo.support.device.culed
|
||||
|
||||
import com.mogo.support.device.IWriteChainLogListener
|
||||
import com.mogo.support.device.manager.cubasic.log.LogLevel
|
||||
import com.mogo.support.device.manager.cubasic.log.LogListener
|
||||
import com.mogo.support.device.manager.cubasic.log.LogManager
|
||||
import com.mogo.support.device.manager.cubasic.netty.NettyXimpleClient
|
||||
import kotlin.properties.Delegates
|
||||
|
||||
object CuLedManager {
|
||||
|
||||
/**
|
||||
* 0 没有灯态
|
||||
* 1 左转灯
|
||||
* 2 右转灯
|
||||
* 3 双闪
|
||||
*/
|
||||
private var lightState: Int by Delegates.observable(0) { _, oldValue, newValue ->
|
||||
if (oldValue != newValue) {
|
||||
if(newValue==0){
|
||||
if(oldValue==1) {
|
||||
client?.setLeftTurn(false)
|
||||
}else if(oldValue==2){
|
||||
client?.setRightTurn(false)
|
||||
}else{
|
||||
client?.setLeftTurn(false)
|
||||
client?.setRightTurn(false)
|
||||
}
|
||||
}else{
|
||||
when (newValue) {
|
||||
1 -> {client?.setLeftTurn(true)}
|
||||
2 -> {client?.setRightTurn(true)}
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private var client: NettyXimpleClient? = null
|
||||
|
||||
private var writeChainLogListener: IWriteChainLogListener? = null
|
||||
|
||||
fun init(host:String="",port:Int=0){
|
||||
if (client == null) {
|
||||
client = NettyXimpleClient()
|
||||
if (host.isNotEmpty() && port > 0) {
|
||||
client?.setHostAndPort(host, port)
|
||||
}
|
||||
client?.connect()
|
||||
}
|
||||
LogManager.getInstance().isDebug = true
|
||||
LogManager.getInstance().logListener = object :LogListener{
|
||||
override fun writeLog(logLevel: LogLevel?, tag: String?, message: String?) {
|
||||
writeChainLogListener?.onWriteChainLog(logLevel?.name?:"level",tag?:"",message?:"")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun registerWriteChainLogListener(writeChainLogListener: IWriteChainLogListener) {
|
||||
this.writeChainLogListener = writeChainLogListener
|
||||
}
|
||||
|
||||
fun unregisterWriteChainLogListener() {
|
||||
this.writeChainLogListener = null
|
||||
}
|
||||
|
||||
fun reConnect(host:String="",port:Int=0){
|
||||
if (client == null) {
|
||||
client = NettyXimpleClient()
|
||||
if (host.isNotEmpty() && port > 0) {
|
||||
client?.setHostAndPort(host, port)
|
||||
}
|
||||
client?.connect()
|
||||
} else {
|
||||
if(client?.isConnected==true) {
|
||||
if (host.isNotEmpty() && port > 0) {
|
||||
client?.setHostAndPort(host, port)
|
||||
}
|
||||
client?.reconnect()
|
||||
}else{
|
||||
if(client?.connectionStatus=="CONNECTING"){
|
||||
if (host.isNotEmpty() && port > 0) {
|
||||
client?.setHostAndPort(host, port)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 0 没有灯态
|
||||
* 1 左转灯
|
||||
* 2 右转灯
|
||||
* 3 双闪
|
||||
*/
|
||||
fun updateTurnSignalData(type: Int) {
|
||||
this.lightState = type
|
||||
}
|
||||
|
||||
fun updateTripInfoData(
|
||||
type: Int,
|
||||
lineName: String,
|
||||
lastStopName:String
|
||||
) {
|
||||
when (type) {
|
||||
1 -> { client?.setRoute(lineName,lastStopName) }
|
||||
2 -> { client?.setOffService() }
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
|
||||
fun triggerStopRequest(isActive:Boolean){
|
||||
client?.triggerStopRequest(isActive)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user