[unmanned]
[轮训修改]
This commit is contained in:
yangyakun
2024-08-29 17:29:23 +08:00
parent 9f12d87022
commit a66c8b9cf5
5 changed files with 113 additions and 68 deletions

View File

@@ -3,6 +3,7 @@ package com.mogo.eagle.core.function.call.unmanned
import android.util.Log
import com.mogo.eagle.core.function.api.unmanned.IUnmannedListener
import com.mogo.eagle.core.function.call.base.CallerBase
import kotlin.properties.Delegates
/**
* 无人化功能状态监听、回调管理者
@@ -10,7 +11,28 @@ import com.mogo.eagle.core.function.call.base.CallerBase
object CallerUnmannedListenerManager : CallerBase<IUnmannedListener>() {
private const val TAG = "CallerUnmannedListenerManager"
private var virtualTaskPullTaskInterval: Int = 45 //单位:秒
//单位:秒
private var virtualTaskPullTaskInterval: Int by Delegates.observable(45) { _, oldValue, newValue ->
if(oldValue<0&&newValue>0){
M_LISTENERS.forEach {
val listener = it.value
try {
listener.onSwitch(true)// 由非轮训改为轮训
} catch (e: Exception) {
Log.e(TAG, "转发消息出现异常:${e.message}")
}
}
}else if(oldValue>0&&newValue<0){
M_LISTENERS.forEach {
val listener = it.value
try {
listener.onSwitch(false)// 由轮训改为非轮训
} catch (e: Exception) {
Log.e(TAG, "转发消息出现异常:${e.message}")
}
}
}
}
override fun doSomeAfterAddListener(tag: String, listener: IUnmannedListener) {
super.doSomeAfterAddListener(tag, listener)
@@ -32,7 +54,7 @@ object CallerUnmannedListenerManager : CallerBase<IUnmannedListener>() {
/**
* 获取无人化演练拉取的时间间隔(单位: 秒)
*/
fun getVirtualTaskPullTaskInterval(): Int {
fun getVirtualTaskPullTaskIntervalF(): Int {
return virtualTaskPullTaskInterval
}
}