[686][hardware]LED屏幕添加埋点以及日志,欢迎语更改添加结果吐司提示
This commit is contained in:
@@ -12,7 +12,6 @@ import com.mogo.eagle.core.function.datacenter.location.MoGoLocationDispatcher
|
||||
import com.mogo.eagle.core.function.datacenter.v2x.SpeedLimitDispatcher
|
||||
import com.mogo.eagle.core.function.datacenter.v2x.TrafficLightDispatcher
|
||||
import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils
|
||||
import com.mogo.support.device.led.LedSourceManager
|
||||
|
||||
@Route(path = MogoServicePaths.PATH_DATA_CENTER_MODULE)
|
||||
class DataCenterProvider : IDataCenterProvider {
|
||||
@@ -26,23 +25,17 @@ class DataCenterProvider : IDataCenterProvider {
|
||||
MoGoLocationDispatcher.initListener()
|
||||
mContext = context
|
||||
mContext?.let {
|
||||
val isPassenger = AppIdentityModeUtils.isPassenger(FunctionBuildConfig.appIdentityMode)
|
||||
LedSourceManager.init(!isPassenger)
|
||||
CallerDataCenterBizManager.init()
|
||||
CallerMsgBoxManager.queryAllMessages(it)
|
||||
TrafficLightDispatcher.INSTANCE.initServer(it)
|
||||
SpeedLimitDispatcher.INSTANCE.initLimit(it)
|
||||
if (isPassenger) {
|
||||
IotManager.init()
|
||||
}
|
||||
IotManager.init(AppIdentityModeUtils.isPassenger(FunctionBuildConfig.appIdentityMode))
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
TrafficLightDispatcher.INSTANCE.destroy()
|
||||
SpeedLimitDispatcher.INSTANCE.destroy()
|
||||
if (AppIdentityModeUtils.isPassenger(FunctionBuildConfig.appIdentityMode)) {
|
||||
IotManager.destroy()
|
||||
}
|
||||
IotManager.destroy()
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,7 @@ import com.mogo.eagle.core.function.call.cloud.CallerCloudListenerManager
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.i
|
||||
import com.mogo.support.device.DevicesManager
|
||||
import com.mogo.support.device.IWriteChainLogListener
|
||||
import com.mogo.support.device.led.LedSourceManager
|
||||
import com.zhjt.service.chain.ChainLog
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Date
|
||||
@@ -19,11 +20,18 @@ object IotManager : IMoGoCloudListener, IWriteChainLogListener {
|
||||
private val sdf: SimpleDateFormat = SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS ", Locale.CHINA)
|
||||
private val TAG = IotManager::class.java.simpleName
|
||||
private const val EVENT_KEY_HARDWARE_DEVICES = "event_key_hardware_devices"
|
||||
private var isPassenger: Boolean = false
|
||||
|
||||
fun init() {
|
||||
CallerCloudListenerManager.addListener(TAG, this)
|
||||
hardwareDeviceBind(SharedPrefsMgr.getInstance().sn)
|
||||
DevicesManager.registerWriteChainLogListener(this)
|
||||
fun init(isPassenger: Boolean) {
|
||||
this.isPassenger = isPassenger
|
||||
if (isPassenger) {
|
||||
CallerCloudListenerManager.addListener(TAG, this)
|
||||
DevicesManager.registerWriteChainLogListener(this)
|
||||
hardwareDeviceBind(SharedPrefsMgr.getInstance().sn)
|
||||
} else {
|
||||
LedSourceManager.registerWriteChainLogListener(this)
|
||||
LedSourceManager.init(true)
|
||||
}
|
||||
}
|
||||
|
||||
override fun tokenGot(token: String, sn: String) {
|
||||
@@ -42,21 +50,27 @@ object IotManager : IMoGoCloudListener, IWriteChainLogListener {
|
||||
}
|
||||
|
||||
fun destroy() {
|
||||
DevicesManager.destroy()
|
||||
DevicesManager.unregisterWriteChainLogListener()
|
||||
if (isPassenger) {
|
||||
DevicesManager.unregisterWriteChainLogListener()
|
||||
DevicesManager.destroy()
|
||||
} else {
|
||||
LedSourceManager.unregisterWriteChainLogListener()
|
||||
LedSourceManager.destroy()
|
||||
}
|
||||
}
|
||||
|
||||
@ChainLog(
|
||||
linkChainLog = ChainConstant.CHAIN_TYPE_STATUS,
|
||||
linkCode = ChainConstant.CHAIN_SOURCE_INIT,
|
||||
nodeAliasCode = ChainConstant.CHAIN_CODE_HARDWARE_DEVICES,
|
||||
paramIndexes = [0, 1]
|
||||
paramIndexes = [0, 1, 2]
|
||||
)
|
||||
override fun onWriteChainLog(title: String, info: String) {
|
||||
override fun onWriteChainLog(tag: String, title: String, info: String) {
|
||||
try {
|
||||
i("${TAG}_${EVENT_KEY_HARDWARE_DEVICES}", "${title}_${info}")
|
||||
i("${tag}_${EVENT_KEY_HARDWARE_DEVICES}", "${title}_${info}")
|
||||
val params = HashMap<String, Any>()
|
||||
params["time"] = sdf.format(Date())
|
||||
params["tag"] = tag
|
||||
params["title"] = title
|
||||
params["info"] = info
|
||||
MogoAnalyticUtils.track(EVENT_KEY_HARDWARE_DEVICES, params)
|
||||
|
||||
@@ -64,7 +64,9 @@ import com.mogo.eagle.core.utilcode.mogo.vehicle.SweeperVehicleConfigUtils
|
||||
import com.mogo.eagle.core.utilcode.rv.divider.CommonDividerItemDecoration
|
||||
import com.mogo.eagle.core.utilcode.util.AppStateManager
|
||||
import com.mogo.eagle.core.utilcode.util.GsonUtils.*
|
||||
import com.mogo.eagle.core.utilcode.util.ThreadUtils
|
||||
import com.mogo.eagle.core.utilcode.util.ToastUtils
|
||||
import com.mogo.support.device.led.ILedForeverChangeWelcomeContentListener
|
||||
import com.mogo.support.device.led.LedSourceManager
|
||||
import com.zhjt.mogo.adas.data.AdasConstants
|
||||
import com.zhjt.mogo.adas.data.bean.AdasParam
|
||||
@@ -1522,7 +1524,19 @@ class OperatePanelLayout : LinearLayout {
|
||||
clickEventAnalytics("外屏欢迎语", true)
|
||||
LedSourceManager.foreverChangeWelcomeHint(
|
||||
context?.applicationContext,
|
||||
FunctionBuildConfig.welcomeWords
|
||||
FunctionBuildConfig.welcomeWords,
|
||||
object : ILedForeverChangeWelcomeContentListener {
|
||||
override fun onChangeState(isSucceed: Boolean, errMsg: String) {
|
||||
val customPreference: PreferenceWithWelcomeWords? =
|
||||
findPreference(KEY_WELCOME_WORDS)
|
||||
customPreference?.let {
|
||||
ThreadUtils.runOnUiThread {
|
||||
it.setOkBtnEnable()
|
||||
}
|
||||
}
|
||||
ToastUtils.showLong(errMsg)
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
return super.onPreferenceClick(preference)
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.mogo.eagle.core.function.hmi.ui.operate.preferences
|
||||
import android.content.Context
|
||||
import android.text.TextUtils
|
||||
import android.util.AttributeSet
|
||||
import android.view.View
|
||||
import android.widget.EditText
|
||||
import androidx.core.widget.doOnTextChanged
|
||||
import androidx.preference.Preference
|
||||
@@ -23,6 +24,7 @@ class PreferenceWithWelcomeWords: Preference {
|
||||
|
||||
|
||||
private var mCurrentWelcomeWords: String? = null
|
||||
private var btnOk: View? = null
|
||||
|
||||
override fun setDefaultValue(defaultValue: Any?) {
|
||||
super.setDefaultValue(defaultValue)
|
||||
@@ -36,21 +38,25 @@ class PreferenceWithWelcomeWords: Preference {
|
||||
super.onBindViewHolder(holder)
|
||||
val currentWelcomeWords = mCurrentWelcomeWords
|
||||
val et = holder.findViewById(R.id.et_welcome_words) as? EditText
|
||||
val btn_ok = holder.findViewById(R.id.bt_ok)
|
||||
btn_ok.isEnabled = false
|
||||
btnOk = holder.findViewById(R.id.bt_ok)
|
||||
btnOk?.isEnabled = false
|
||||
et?.doOnTextChanged { text, _, _, _ ->
|
||||
if (!TextUtils.isEmpty(text)) {
|
||||
btn_ok?.isEnabled = true
|
||||
btnOk?.isEnabled = true
|
||||
} else {
|
||||
btn_ok?.isEnabled = false
|
||||
btnOk?.isEnabled = false
|
||||
}
|
||||
}
|
||||
if (!TextUtils.isEmpty(currentWelcomeWords)) {
|
||||
et?.setText(currentWelcomeWords)
|
||||
}
|
||||
btn_ok.onClick {
|
||||
btnOk?.onClick {
|
||||
btnOk?.isEnabled = false
|
||||
extras.putString(KEY_BUNDLE_CURRENT_EDIT_TEXT_VALUE, et?.text.toString())
|
||||
onPreferenceClickListener?.onPreferenceClick(this)
|
||||
}
|
||||
}
|
||||
fun setOkBtnEnable(){
|
||||
btnOk?.isEnabled = true
|
||||
}
|
||||
}
|
||||
@@ -39,6 +39,6 @@ android {
|
||||
dependencies {
|
||||
implementation rootProject.ext.dependencies.androidxappcompat
|
||||
api rootProject.ext.dependencies.serialport
|
||||
implementation "com.mogo.support.device.manager:led_screen_cpower5a:1.0.7"
|
||||
implementation "com.mogo.support.device.manager:led_screen_cpower5a:1.0.8"
|
||||
implementation rootProject.ext.dependencies.view_model_scope
|
||||
}
|
||||
|
||||
@@ -23,8 +23,7 @@ data class OpenState(
|
||||
)
|
||||
|
||||
object DevicesManager {
|
||||
private const val TAG = "DevicesManager"
|
||||
|
||||
private val TAG = DevicesManager::class.java.simpleName
|
||||
private val serialPortManager: SerialPortManager by lazy {
|
||||
SerialPortManager() // 初始化 SerialPortManager
|
||||
}
|
||||
@@ -218,7 +217,7 @@ object DevicesManager {
|
||||
it.value.onServiceState(serviceState)
|
||||
}
|
||||
}
|
||||
writeChainLogListener?.onWriteChainLog("硬件服务", "绑定状态=${msg}")
|
||||
writeChainLogListener?.onWriteChainLog(TAG, "硬件服务", "绑定状态=${msg}")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -240,6 +239,7 @@ object DevicesManager {
|
||||
}
|
||||
}
|
||||
writeChainLogListener?.onWriteChainLog(
|
||||
TAG,
|
||||
"核销设备",
|
||||
"状态=地址:${path} 设备类型:${deviceType} 是否打开:${isOpen} 消息:${message}"
|
||||
)
|
||||
@@ -251,7 +251,7 @@ object DevicesManager {
|
||||
it.value.onReceive(data)
|
||||
}
|
||||
}
|
||||
writeChainLogListener?.onWriteChainLog("核销设备", "核销数据接收=$data")
|
||||
writeChainLogListener?.onWriteChainLog(TAG, "核销设备", "核销数据接收=$data")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -272,6 +272,7 @@ object DevicesManager {
|
||||
}
|
||||
}
|
||||
writeChainLogListener?.onWriteChainLog(
|
||||
TAG,
|
||||
"车外语音设备",
|
||||
"状态=地址:${path} 是否打开:${isOpen} 消息:${throwableMessage}"
|
||||
)
|
||||
@@ -303,7 +304,7 @@ object DevicesManager {
|
||||
|
||||
else -> ""
|
||||
}
|
||||
writeChainLogListener?.onWriteChainLog("车外语音设备", "播报状态=${msg}")
|
||||
writeChainLogListener?.onWriteChainLog(TAG, "车外语音设备", "播报状态=${msg}")
|
||||
}
|
||||
|
||||
override fun onSwitchingValue(path: String, state: Int, data: SwitchingValueData?) {
|
||||
@@ -331,6 +332,7 @@ object DevicesManager {
|
||||
}
|
||||
if (!msg.isNullOrEmpty() && data != null) {
|
||||
writeChainLogListener?.onWriteChainLog(
|
||||
TAG,
|
||||
"车外语音设备",
|
||||
"物理按钮状态=$msg $data"
|
||||
)
|
||||
@@ -358,6 +360,7 @@ object DevicesManager {
|
||||
}
|
||||
if (!msg.isNullOrEmpty()) {
|
||||
writeChainLogListener?.onWriteChainLog(
|
||||
TAG,
|
||||
"车外语音设备",
|
||||
"设备地址读取状态=$msg 设备地址$address"
|
||||
)
|
||||
@@ -404,6 +407,7 @@ object DevicesManager {
|
||||
content
|
||||
)
|
||||
writeChainLogListener?.onWriteChainLog(
|
||||
TAG,
|
||||
"车外语音设备",
|
||||
"播报内容=${content ?: " 调用结果=${code}"}"
|
||||
)
|
||||
|
||||
@@ -5,5 +5,5 @@ package com.mogo.support.device
|
||||
*/
|
||||
interface IWriteChainLogListener {
|
||||
|
||||
fun onWriteChainLog(title: String, info: String)
|
||||
fun onWriteChainLog(tag: String, title: String, info: String)
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.mogo.support.device.led
|
||||
|
||||
import android.util.Log
|
||||
import com.mogo.support.device.IWriteChainLogListener
|
||||
import com.mogo.support.device.manager.cpower5a.LedScreenCpower5aManager
|
||||
import com.mogo.support.device.manager.cpower5a.common.LedScreen
|
||||
import com.mogo.support.device.manager.cpower5a.common.Program
|
||||
@@ -8,7 +9,9 @@ import com.mogo.support.device.manager.cpower5a.common.Program
|
||||
/**
|
||||
* 后屏
|
||||
*/
|
||||
open class BackLedUIViewModel : BaseLedUIViewModel() {
|
||||
open class BackLedUIViewModel(writeChainLogListener: IWriteChainLogListener) : BaseLedUIViewModel(
|
||||
writeChainLogListener
|
||||
) {
|
||||
companion object {
|
||||
const val TAG = "BackLedUIViewModel"
|
||||
|
||||
@@ -51,7 +54,11 @@ open class BackLedUIViewModel : BaseLedUIViewModel() {
|
||||
ledUI.hintMsg,
|
||||
ledUI.isForever
|
||||
)
|
||||
Log.e(TAG, "后屏 播放欢迎语:${ledUI.hintMsg} 是否永久展示:${ledUI.isForever}")
|
||||
writeChainLogListener.onWriteChainLog(
|
||||
TAG,
|
||||
"LED外屏调用",
|
||||
"后屏 播放 ${Program.WELCOME.des}:${ledUI.hintMsg} 是否永久展示:${ledUI.isForever}"
|
||||
)
|
||||
}
|
||||
|
||||
is FinishUI -> {
|
||||
@@ -59,13 +66,21 @@ open class BackLedUIViewModel : BaseLedUIViewModel() {
|
||||
LedScreen.OUTWARD_BACK,
|
||||
ledUI.hintMsg,
|
||||
)
|
||||
Log.e(TAG, "后屏 播放结束语:${ledUI.hintMsg}")
|
||||
writeChainLogListener.onWriteChainLog(
|
||||
TAG,
|
||||
"LED外屏调用",
|
||||
"后屏 播放 ${Program.FINISH.des}:${ledUI.hintMsg}"
|
||||
)
|
||||
}
|
||||
|
||||
is RouteInfoUI -> {
|
||||
LedScreenCpower5aManager.getInstance()
|
||||
.playProgramLineInformation(LedScreen.OUTWARD_BACK, ledUI.lineName)
|
||||
Log.e(TAG, "后屏 播放线路信息:${ledUI.lineName}")
|
||||
writeChainLogListener.onWriteChainLog(
|
||||
TAG,
|
||||
"LED外屏调用",
|
||||
"后屏 播放 ${Program.LINE_INFORMATION.des}:${ledUI.lineName}"
|
||||
)
|
||||
}
|
||||
|
||||
is StationReportUI -> {
|
||||
@@ -75,7 +90,11 @@ open class BackLedUIViewModel : BaseLedUIViewModel() {
|
||||
ledUI.stationName,
|
||||
ledUI.state
|
||||
)
|
||||
Log.e(TAG, "后屏 播放报站 站点:${ledUI.stationName} 状态:${ledUI.state}")
|
||||
writeChainLogListener.onWriteChainLog(
|
||||
TAG,
|
||||
"LED外屏调用",
|
||||
"后屏 播放 ${Program.LINE_STATION_REPORT.des} 站点:${ledUI.stationName} 状态:${ledUI.state}"
|
||||
)
|
||||
}
|
||||
|
||||
is ArriveStationUI -> {
|
||||
@@ -84,7 +103,11 @@ open class BackLedUIViewModel : BaseLedUIViewModel() {
|
||||
LedScreen.OUTWARD_BACK,
|
||||
"车辆进站"
|
||||
)
|
||||
Log.e(TAG, "后屏 播放车辆进站")
|
||||
writeChainLogListener.onWriteChainLog(
|
||||
TAG,
|
||||
"LED外屏调用",
|
||||
"后屏 播放 ${Program.LINE_STATION_REPORT_HINT.des} 提示语:车辆进站"
|
||||
)
|
||||
}
|
||||
|
||||
is LeaveStationUI -> {
|
||||
@@ -93,19 +116,31 @@ open class BackLedUIViewModel : BaseLedUIViewModel() {
|
||||
LedScreen.OUTWARD_BACK,
|
||||
"车辆起步"
|
||||
)
|
||||
Log.e(TAG, "后屏 播放车辆起步")
|
||||
writeChainLogListener.onWriteChainLog(
|
||||
TAG,
|
||||
"LED外屏调用",
|
||||
"后屏 播放 ${Program.LINE_STATION_REPORT_HINT.des} 提示语:车辆起步"
|
||||
)
|
||||
}
|
||||
|
||||
is EmergencyBrakeUI -> {
|
||||
LedScreenCpower5aManager.getInstance()
|
||||
.playProgram(LedScreen.OUTWARD_BACK, Program.REMIND_FRONT_CAR_EMERGENCY_BRAKE)
|
||||
Log.e(TAG, "后屏 车辆急刹")
|
||||
writeChainLogListener.onWriteChainLog(
|
||||
TAG,
|
||||
"LED外屏调用",
|
||||
"后屏 播放 ${Program.REMIND_FRONT_CAR_EMERGENCY_BRAKE.des}"
|
||||
)
|
||||
}
|
||||
|
||||
is RoadWorkAheadWarningUI -> {
|
||||
LedScreenCpower5aManager.getInstance()
|
||||
.playProgram(LedScreen.OUTWARD_BACK, Program.REMIND_ROAD_WORK_AHEAD)
|
||||
Log.e(TAG, "后屏 道路施工")
|
||||
writeChainLogListener.onWriteChainLog(
|
||||
TAG,
|
||||
"LED外屏调用",
|
||||
"后屏 播放 ${Program.REMIND_ROAD_WORK_AHEAD.des}"
|
||||
)
|
||||
}
|
||||
|
||||
is TurnSignalUI -> {
|
||||
@@ -133,8 +168,12 @@ open class BackLedUIViewModel : BaseLedUIViewModel() {
|
||||
LedScreen.OUTWARD_BACK,
|
||||
it
|
||||
)
|
||||
writeChainLogListener.onWriteChainLog(
|
||||
TAG,
|
||||
"LED外屏调用",
|
||||
"后屏 播放 ${program.des}"
|
||||
)
|
||||
}
|
||||
Log.e(TAG, "后屏 播放节目${program}")
|
||||
}
|
||||
|
||||
is TrafficLightUI -> {
|
||||
@@ -146,12 +185,13 @@ open class BackLedUIViewModel : BaseLedUIViewModel() {
|
||||
ledUI.stateStraight, ledUI.durationStraight,
|
||||
ledUI.stateTurnRight, ledUI.durationTurnRight
|
||||
)
|
||||
Log.e(
|
||||
writeChainLogListener.onWriteChainLog(
|
||||
TAG,
|
||||
"后屏 播放信号灯节目 掉头:${ledUI.stateTurnRound} 掉头倒计时:${ledUI.durationTurnRound}\n" +
|
||||
"LED外屏调用",
|
||||
"后屏 播放 信号灯 掉头:${ledUI.stateTurnRound} 掉头倒计时:${ledUI.durationTurnRound}\n" +
|
||||
"左转:${ledUI.stateTurnLeft} 左转倒计时:${ledUI.durationTurnLeft}\n" +
|
||||
"直行:${ledUI.stateStraight} 直行倒计时:${ledUI.stateStraight}\n" +
|
||||
"右转:${ledUI.stateTurnRight} 右转倒计时:${ledUI.durationTurnRight}\n"
|
||||
"右转:${ledUI.stateTurnRight} 右转倒计时:${ledUI.durationTurnRight}"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,13 +4,15 @@ import android.util.Log
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.mogo.support.device.IWriteChainLogListener
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
import java.util.PriorityQueue
|
||||
import kotlin.math.ceil
|
||||
|
||||
open class BaseLedUIViewModel : ViewModel() {
|
||||
open class BaseLedUIViewModel(protected val writeChainLogListener: IWriteChainLogListener) :
|
||||
ViewModel() {
|
||||
companion object {
|
||||
const val TAG = "LedUIViewModel"
|
||||
val DEFAULT_UI = WelcomeUI()
|
||||
|
||||
@@ -1,13 +1,17 @@
|
||||
package com.mogo.support.device.led
|
||||
|
||||
import android.util.Log
|
||||
import com.mogo.support.device.IWriteChainLogListener
|
||||
import com.mogo.support.device.manager.cpower5a.LedScreenCpower5aManager
|
||||
import com.mogo.support.device.manager.cpower5a.common.LedScreen
|
||||
import com.mogo.support.device.manager.cpower5a.common.Program
|
||||
|
||||
/**
|
||||
* 前屏幕
|
||||
*/
|
||||
class FrontLedUIViewModel : BaseLedUIViewModel() {
|
||||
class FrontLedUIViewModel(writeChainLogListener: IWriteChainLogListener) : BaseLedUIViewModel(
|
||||
writeChainLogListener
|
||||
) {
|
||||
companion object {
|
||||
const val TAG = "FrontLedUIViewModel"
|
||||
|
||||
@@ -43,7 +47,11 @@ class FrontLedUIViewModel : BaseLedUIViewModel() {
|
||||
ledUI.hintMsg,
|
||||
ledUI.isForever
|
||||
)
|
||||
Log.e(TAG, "前屏 播放欢迎语:${ledUI.hintMsg} 是否永久展示:${ledUI.isForever}")
|
||||
writeChainLogListener.onWriteChainLog(
|
||||
TAG,
|
||||
"LED外屏调用",
|
||||
"前屏 播放 ${Program.WELCOME.des}:${ledUI.hintMsg} 是否永久展示:${ledUI.isForever}"
|
||||
)
|
||||
}
|
||||
|
||||
is FinishUI -> {
|
||||
@@ -51,13 +59,21 @@ class FrontLedUIViewModel : BaseLedUIViewModel() {
|
||||
LedScreen.OUTWARD_FRONT,
|
||||
ledUI.hintMsg,
|
||||
)
|
||||
Log.e(TAG, "前屏 播放结束语:${ledUI.hintMsg}")
|
||||
writeChainLogListener.onWriteChainLog(
|
||||
TAG,
|
||||
"LED外屏调用",
|
||||
"前屏 播放 ${Program.FINISH.des}:${ledUI.hintMsg}"
|
||||
)
|
||||
}
|
||||
|
||||
is RouteInfoUI -> {
|
||||
LedScreenCpower5aManager.getInstance()
|
||||
.playProgramLineInformation(LedScreen.OUTWARD_FRONT, ledUI.lineName)
|
||||
Log.e(TAG, "前屏 播放线路信息:${ledUI.lineName}")
|
||||
writeChainLogListener.onWriteChainLog(
|
||||
TAG,
|
||||
"LED外屏调用",
|
||||
"前屏 播放 ${Program.LINE_INFORMATION.des}:${ledUI.lineName}"
|
||||
)
|
||||
}
|
||||
|
||||
is StationReportUI -> {
|
||||
@@ -67,7 +83,11 @@ class FrontLedUIViewModel : BaseLedUIViewModel() {
|
||||
ledUI.stationName,
|
||||
ledUI.state
|
||||
)
|
||||
Log.e(TAG, "前屏 播放报站 站点:${ledUI.stationName} 状态:${ledUI.state}")
|
||||
writeChainLogListener.onWriteChainLog(
|
||||
TAG,
|
||||
"LED外屏调用",
|
||||
"前屏 播放 ${Program.LINE_STATION_REPORT.des} 站点:${ledUI.stationName} 状态:${ledUI.state}"
|
||||
)
|
||||
}
|
||||
|
||||
is ArriveStationUI -> {
|
||||
@@ -76,7 +96,11 @@ class FrontLedUIViewModel : BaseLedUIViewModel() {
|
||||
LedScreen.OUTWARD_FRONT,
|
||||
"车辆进站"
|
||||
)
|
||||
Log.e(TAG, "前屏 播放车辆进站")
|
||||
writeChainLogListener.onWriteChainLog(
|
||||
TAG,
|
||||
"LED外屏调用",
|
||||
"前屏 播放 ${Program.LINE_STATION_REPORT_HINT.des} 提示语:车辆进站"
|
||||
)
|
||||
}
|
||||
|
||||
is LeaveStationUI -> {
|
||||
@@ -85,7 +109,11 @@ class FrontLedUIViewModel : BaseLedUIViewModel() {
|
||||
LedScreen.OUTWARD_FRONT,
|
||||
"车辆起步"
|
||||
)
|
||||
Log.e(TAG, "前屏 播放车辆起步")
|
||||
writeChainLogListener.onWriteChainLog(
|
||||
TAG,
|
||||
"LED外屏调用",
|
||||
"前屏 播放 ${Program.LINE_STATION_REPORT_HINT.des} 提示语:车辆起步"
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.mogo.support.device.led
|
||||
|
||||
/**
|
||||
* 永久更换欢迎语结果
|
||||
* 仅更换,指的是仅回调文件上传状态
|
||||
* 更换时播放状态不作处理不管失败还是成功
|
||||
*/
|
||||
interface ILedForeverChangeWelcomeContentListener {
|
||||
|
||||
fun onChangeState(isSucceed: Boolean, errMsg: String)
|
||||
}
|
||||
@@ -3,33 +3,78 @@ package com.mogo.support.device.led
|
||||
|
||||
import android.content.Context
|
||||
import android.os.CountDownTimer
|
||||
import android.text.TextUtils
|
||||
import com.mogo.support.device.IWriteChainLogListener
|
||||
import com.mogo.support.device.manager.cpower5a.LedScreenCpower5aManager
|
||||
import com.mogo.support.device.manager.cpower5a.OnLedScreenCpower5aListener
|
||||
import com.mogo.support.device.manager.cpower5a.common.Cpower5aState.Execute
|
||||
import com.mogo.support.device.manager.cpower5a.common.LedScreen
|
||||
import com.mogo.support.device.manager.cpower5a.common.Program
|
||||
import com.mogo.support.device.manager.cpower5a.common.TrafficLightState
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlin.properties.Delegates
|
||||
import java.util.concurrent.atomic.AtomicInteger
|
||||
|
||||
object LedSourceManager {
|
||||
|
||||
data class ForeverChangeWelcomeState(
|
||||
val ip: String,
|
||||
val state: Execute,
|
||||
val errMsg: String?
|
||||
)
|
||||
|
||||
/**
|
||||
* LED外屏控制 司机屏调用
|
||||
*/
|
||||
object LedSourceManager : IWriteChainLogListener {
|
||||
private val TAG = LedSourceManager::class.java.simpleName
|
||||
private val frontViewModel: FrontLedUIViewModel by lazy {
|
||||
FrontLedUIViewModel() // 初始化
|
||||
FrontLedUIViewModel(this) // 初始化
|
||||
}
|
||||
private val backViewModel: BackLedUIViewModel by lazy {
|
||||
BackLedUIViewModel() // 初始化
|
||||
BackLedUIViewModel(this) // 初始化
|
||||
}
|
||||
private var typeTurnSignal = 0;//转向灯状态 0:无灯;1:左转;2:右转;3:双闪
|
||||
private var lastUpdateEmergencyBrakeTime = 0L//上次触发急刹展示的时间
|
||||
private var isDriver by Delegates.notNull<Boolean>()
|
||||
private var isDriver = false
|
||||
private var writeChainLogListener: IWriteChainLogListener? = null
|
||||
|
||||
//红绿灯定时器,超时未更新隐藏红绿灯
|
||||
@Volatile
|
||||
private var lightCountDownTimer: CountDownTimer? = null
|
||||
private var lastLightTime: Long = System.currentTimeMillis()
|
||||
fun init(isDriver: Boolean) {
|
||||
this.isDriver = isDriver
|
||||
private var foreverChangeWelcomeContentListener: ILedForeverChangeWelcomeContentListener? =
|
||||
null//修改欢迎语状态回调
|
||||
private val foreverChangeWelcomeNum = AtomicInteger(0)//修改欢迎语设备回调个数
|
||||
|
||||
@Volatile
|
||||
private var foreverChangeWelcomeState: ForeverChangeWelcomeState? =
|
||||
null//修改欢迎语结果 一共两块屏幕 不管那那先回调就先赋值
|
||||
|
||||
fun registerWriteChainLogListener(writeChainLogListener: IWriteChainLogListener) {
|
||||
this.writeChainLogListener = writeChainLogListener
|
||||
}
|
||||
|
||||
fun unregisterWriteChainLogListener() {
|
||||
this.writeChainLogListener = null
|
||||
}
|
||||
|
||||
|
||||
fun init(isDriver: Boolean) {
|
||||
this.isDriver = isDriver
|
||||
LedScreenCpower5aManager.getInstance().addListener(cpower5aListener)
|
||||
}
|
||||
|
||||
fun destroy() {
|
||||
frontViewModel.reset()
|
||||
backViewModel.reset()
|
||||
LedScreenCpower5aManager.getInstance().removeListener(cpower5aListener)
|
||||
typeTurnSignal = 0
|
||||
lastUpdateEmergencyBrakeTime = 0L
|
||||
lightCountDownTimer?.cancel()
|
||||
lightCountDownTimer = null
|
||||
lastLightTime = System.currentTimeMillis()
|
||||
}
|
||||
|
||||
private fun receiveUI(ledUI: LedUI) {
|
||||
GlobalScope.launch(Dispatchers.IO) {
|
||||
@@ -62,6 +107,7 @@ object LedSourceManager {
|
||||
*/
|
||||
fun updateTurnSignalData(type: Int) {
|
||||
if (isDriver) {
|
||||
writeChainLogListener?.onWriteChainLog(TAG, "LED外屏数据源", "车灯状态=${type}")
|
||||
if (typeTurnSignal != type) {
|
||||
typeTurnSignal = type
|
||||
receiveUI(TurnSignalUI(type != 0, type))
|
||||
@@ -75,6 +121,11 @@ object LedSourceManager {
|
||||
*/
|
||||
fun updateAccelerationData(acceleration: Double) {
|
||||
if (isDriver) {
|
||||
writeChainLogListener?.onWriteChainLog(
|
||||
TAG,
|
||||
"LED外屏数据源",
|
||||
"车辆加速度值=${acceleration}"
|
||||
)
|
||||
if (acceleration <= -2) {
|
||||
val now = System.currentTimeMillis()
|
||||
if (now - lastUpdateEmergencyBrakeTime > 60 * 1000L) {//1m内不进行多次提示
|
||||
@@ -85,7 +136,7 @@ object LedSourceManager {
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateLightCountDownTimer(){
|
||||
private fun updateLightCountDownTimer() {
|
||||
lastLightTime = System.currentTimeMillis()
|
||||
if (lightCountDownTimer == null) {
|
||||
lightCountDownTimer = object : CountDownTimer(300000, 500) {
|
||||
@@ -137,6 +188,15 @@ object LedSourceManager {
|
||||
stateTurnRight: Int, durationTurnRight: Int
|
||||
) {
|
||||
if (isDriver) {
|
||||
writeChainLogListener?.onWriteChainLog(
|
||||
TAG,
|
||||
"LED外屏数据源",
|
||||
"信号灯 " +
|
||||
"stateTurnRound=${stateTurnRound} durationTurnRound=${durationTurnRound} " +
|
||||
"stateTurnLeft=${stateTurnLeft} durationTurnLeft=${durationTurnLeft} " +
|
||||
"stateStraight=${stateStraight} durationStraight=${durationStraight} " +
|
||||
"stateTurnRight=${stateTurnRight} durationTurnRight=${durationTurnRight}"
|
||||
)
|
||||
var stateTurnRoundTemp: TrafficLightState? = null
|
||||
var stateTurnLeftTemp: TrafficLightState? = null
|
||||
var stateStraightTemp: TrafficLightState? = null
|
||||
@@ -214,6 +274,11 @@ object LedSourceManager {
|
||||
isLastStop: Boolean
|
||||
) {
|
||||
if (isDriver) {
|
||||
writeChainLogListener?.onWriteChainLog(
|
||||
TAG,
|
||||
"LED外屏数据源",
|
||||
"行程 type=${type} lineName=${lineName} departureStopName=${departureStopName} arrivalStopName=${arrivalStopName} isLastStop=${isLastStop}"
|
||||
)
|
||||
if (lineName.isNotEmpty()) {
|
||||
updateLineNameUI(lineName)
|
||||
}
|
||||
@@ -252,10 +317,176 @@ object LedSourceManager {
|
||||
* 永久更改欢迎节目显示内容
|
||||
* context如果是null会设置失败
|
||||
*/
|
||||
fun foreverChangeWelcomeHint(context: Context?, hintMsg: String?) {
|
||||
fun foreverChangeWelcomeHint(
|
||||
context: Context?,
|
||||
hintMsg: String?,
|
||||
listener: ILedForeverChangeWelcomeContentListener
|
||||
) {
|
||||
this.foreverChangeWelcomeContentListener = listener
|
||||
foreverChangeWelcomeNum.set(0)
|
||||
foreverChangeWelcomeState = null
|
||||
LedScreenCpower5aManager.getInstance()
|
||||
.playProgramWelcome(context, LedScreen.OUTWARD_FRONT, hintMsg, true)
|
||||
LedScreenCpower5aManager.getInstance()
|
||||
.playProgramWelcome(context, LedScreen.OUTWARD_BACK, hintMsg, true)
|
||||
}
|
||||
|
||||
//调用LED屏接口数据埋点
|
||||
override fun onWriteChainLog(tag: String, title: String, info: String) {
|
||||
writeChainLogListener?.onWriteChainLog(tag, title, info)
|
||||
}
|
||||
|
||||
|
||||
private val cpower5aListener: OnLedScreenCpower5aListener =
|
||||
object : OnLedScreenCpower5aListener() {
|
||||
override fun onPlayProgramState(
|
||||
ip: String,
|
||||
state: Execute,
|
||||
program: Program,
|
||||
errMsg: String?
|
||||
) {
|
||||
super.onPlayProgramState(ip, state, program, errMsg)
|
||||
writeChainLogListener?.let {
|
||||
var msg = state.msg
|
||||
if (!TextUtils.isEmpty(errMsg)) {
|
||||
msg += " $errMsg"
|
||||
}
|
||||
val ledScreen = LedScreen.getLedScreen(ip)
|
||||
var tag = BaseLedUIViewModel.TAG
|
||||
if (ledScreen == LedScreen.OUTWARD_BACK) {
|
||||
tag = "BackLedUIViewModel"
|
||||
} else if (ledScreen == LedScreen.OUTWARD_FRONT) {
|
||||
tag = "FrontLedUIViewModel"
|
||||
}
|
||||
it.onWriteChainLog(
|
||||
tag,
|
||||
"LED外屏调用结果",
|
||||
"设备“$ip”播放【$program】节目结果:$msg"
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
override fun onFileUploadState(
|
||||
ip: String,
|
||||
state: Execute,
|
||||
program: Program?,
|
||||
fileName: String,
|
||||
progress: Int,
|
||||
errMsg: String?
|
||||
) {
|
||||
super.onFileUploadState(ip, state, program, fileName, progress, errMsg)
|
||||
//上传进度不做展示和日志埋点粗吹牛
|
||||
if (state == Execute.EXECUTE_SUCCEED ||
|
||||
state == Execute.UNKNOWN ||
|
||||
state == Execute.DATA_EXCEPTION ||
|
||||
state == Execute.EXECUTE_EXCEPTION ||
|
||||
state == Execute.CONNECT_FAILED
|
||||
) {
|
||||
if (program == Program.WELCOME) {
|
||||
var msg: String
|
||||
if (Execute.EXECUTE_SUCCEED == state) {
|
||||
msg = "节目上传成功"
|
||||
} else {
|
||||
msg = state.msg
|
||||
if (!TextUtils.isEmpty(errMsg)) {
|
||||
msg += " $errMsg"
|
||||
}
|
||||
}
|
||||
val ledScreen = LedScreen.getLedScreen(ip)
|
||||
var tag = BaseLedUIViewModel.TAG
|
||||
if (ledScreen == LedScreen.OUTWARD_BACK) {
|
||||
tag = "BackLedUIViewModel"
|
||||
} else if (ledScreen == LedScreen.OUTWARD_FRONT) {
|
||||
tag = "FrontLedUIViewModel"
|
||||
}
|
||||
//回调永久更改欢迎语状态
|
||||
foreverChangeWelcomeContentListener?.let {
|
||||
|
||||
val num = foreverChangeWelcomeNum.incrementAndGet()
|
||||
if (num == 1) {
|
||||
foreverChangeWelcomeState = ForeverChangeWelcomeState(
|
||||
ip,
|
||||
state,
|
||||
errMsg
|
||||
)
|
||||
} else if (num == 2) {
|
||||
var temp = ""
|
||||
if (foreverChangeWelcomeState != null) {
|
||||
temp = getForeverChangeWelcomeMsg(
|
||||
foreverChangeWelcomeState!!.ip,
|
||||
foreverChangeWelcomeState!!.state,
|
||||
foreverChangeWelcomeState!!.errMsg
|
||||
)
|
||||
}
|
||||
var temp1 = getForeverChangeWelcomeMsg(
|
||||
ip,
|
||||
state,
|
||||
errMsg
|
||||
)
|
||||
if (temp.isNotEmpty()) {
|
||||
temp1 = temp + "\n" + temp1
|
||||
}
|
||||
it.onChangeState(state == Execute.EXECUTE_SUCCEED, temp1)
|
||||
foreverChangeWelcomeContentListener = null
|
||||
foreverChangeWelcomeNum.set(0)
|
||||
foreverChangeWelcomeState = null
|
||||
}
|
||||
|
||||
}
|
||||
writeChainLogListener?.onWriteChainLog(
|
||||
tag,
|
||||
"LED外屏调用结果",
|
||||
"设备“$ip”永久更换欢迎节目状态:$msg"
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun getForeverChangeWelcomeMsg(
|
||||
ip: String,
|
||||
state: Execute,
|
||||
errMsg: String?
|
||||
): String {
|
||||
var temp = when (state) {
|
||||
Execute.EXECUTE_SUCCEED -> {
|
||||
"欢迎语更改成功"
|
||||
}
|
||||
|
||||
Execute.CONNECT_FAILED -> {
|
||||
"欢迎语更改失败,无法连接到设备"
|
||||
}
|
||||
|
||||
Execute.DATA_EXCEPTION -> {
|
||||
"欢迎语更改失败,数据异常"
|
||||
}
|
||||
|
||||
Execute.EXECUTE_EXCEPTION -> {
|
||||
"欢迎语更改失败,解析或发送异常"
|
||||
}
|
||||
|
||||
else -> {
|
||||
"欢迎语更改失败"
|
||||
}
|
||||
}
|
||||
if (!TextUtils.isEmpty(errMsg)) {
|
||||
temp += ":$errMsg"
|
||||
}
|
||||
val device = when (LedScreen.getLedScreen(ip)) {
|
||||
LedScreen.OUTWARD_FRONT -> {
|
||||
"前屏"
|
||||
}
|
||||
|
||||
LedScreen.OUTWARD_BACK -> {
|
||||
"后屏"
|
||||
}
|
||||
|
||||
else -> {
|
||||
"未知屏幕"
|
||||
}
|
||||
}
|
||||
return device + temp
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user