fix bug of func config
This commit is contained in:
@@ -35,9 +35,9 @@ class DevaToolsProvider : IDevaToolsProvider {
|
||||
}
|
||||
|
||||
override fun initBiz() {
|
||||
bizConfigCenter.init(mContext!!)
|
||||
// FuncConfigImpl.init()
|
||||
traceManager.init(mContext!!)
|
||||
bizConfigCenter.init(mContext!!)
|
||||
FuncConfigImpl.init()
|
||||
MogoLogCatchManager.init(mContext!!)
|
||||
}
|
||||
|
||||
|
||||
@@ -42,6 +42,11 @@ class FuncConfigCenter : IMogoOnMessageListener<FuncConfig>, IMoGoAutopilotCarCo
|
||||
MogoAiCloudSocketManager.getInstance(AbsMogoApplication.getApp().applicationContext)
|
||||
.registerOnMessageListener(FUNC_CONFIG_TYPE, this)
|
||||
CallerAutopilotCarConfigListenerManager.addListener(TAG, this)
|
||||
|
||||
//未连接到工控,默认配置
|
||||
val bizJson = SPUtils.getInstance("biz_config")
|
||||
.getString("config", GsonUtils.toJson(defaultFuncConfig()))
|
||||
refreshConfig(GsonUtils.fromJson(bizJson, FuncConfig::class.java))
|
||||
}
|
||||
|
||||
override fun onAutopilotCarConfig(carConfigResp: MessagePad.CarConfigResp) {
|
||||
@@ -49,12 +54,7 @@ class FuncConfigCenter : IMogoOnMessageListener<FuncConfig>, IMoGoAutopilotCarCo
|
||||
UiThreadHandler.post {
|
||||
funcConfigNetWorkModel.requestFuncConfig(carConfigResp.macAddress, {
|
||||
SPUtils.getInstance("biz_config").put("config", GsonUtils.toJson(it))
|
||||
refreshConfig(it)
|
||||
}, {
|
||||
val bizJson = SPUtils.getInstance("biz_config")
|
||||
.getString("config", GsonUtils.toJson(defaultFuncConfig()))
|
||||
refreshConfig(GsonUtils.fromJson(bizJson, FuncConfig::class.java))
|
||||
})
|
||||
refreshConfig(it) }, {})
|
||||
}
|
||||
} else {
|
||||
ToastUtils.showLong("未获取到域控mac信息")
|
||||
|
||||
@@ -15,7 +15,7 @@ object FuncConfigImpl {
|
||||
|
||||
fun init() {
|
||||
CallerDevaToolsFuncConfigListenerManager.registerDevaToolsFuncConfigListener(FOUNDATION,
|
||||
TAG,
|
||||
TAG,false,
|
||||
object : IMoGoDevaToolsFuncConfigListener {
|
||||
override fun updateBizData(
|
||||
type: String,
|
||||
|
||||
@@ -34,9 +34,13 @@ class FuncConfigNetWorkModel {
|
||||
if (error == null) {
|
||||
error = onError
|
||||
}
|
||||
map["sn"] = MoGoAiCloudClientConfig.getInstance().sn
|
||||
map["mac"] = DeviceUtils.getMacAddress()
|
||||
map["channelVersion"] = FuncConfigConst.getChannelCode()
|
||||
//todo test
|
||||
// map["sn"] = MoGoAiCloudClientConfig.getInstance().sn
|
||||
map["sn"] = "X20202203105S688HZ"
|
||||
// map["mac"] = DeviceUtils.getMacAddress()
|
||||
map["mac"] = "48:b0:2d:3a:bc:78"
|
||||
// map["channelVersion"] = FuncConfigConst.getChannelCode()
|
||||
map["channelVersion"] = 1
|
||||
}
|
||||
loader {
|
||||
apiCall {
|
||||
|
||||
@@ -196,9 +196,7 @@ class DebugSettingView @JvmOverloads constructor(
|
||||
|
||||
//添加 业务配置监听
|
||||
CallerDevaToolsFuncConfigListenerManager.registerDevaToolsFuncConfigListener(
|
||||
FuncBizConfig.FOUNDATION,
|
||||
TAG,
|
||||
this
|
||||
FuncBizConfig.FOUNDATION, TAG, true, this
|
||||
)
|
||||
|
||||
if (logInfoView != null) {
|
||||
@@ -230,7 +228,7 @@ class DebugSettingView @JvmOverloads constructor(
|
||||
CallerAutopilotVehicleStateListenerManager.removeListener(TAG)
|
||||
|
||||
// 移除 业务配置监听
|
||||
CallerDevaToolsFuncConfigListenerManager.unRegisterDevaToolsFuncConfigListener(this)
|
||||
CallerDevaToolsFuncConfigListenerManager.unRegisterDevaToolsFuncConfigListener( FuncBizConfig.FOUNDATION, TAG)
|
||||
|
||||
if (logInfoView != null) {
|
||||
logInfoView!!.onEnterBackground()
|
||||
@@ -568,6 +566,10 @@ class DebugSettingView @JvmOverloads constructor(
|
||||
}
|
||||
}
|
||||
|
||||
Log.i(
|
||||
"1026-emArrow",
|
||||
"debug setting FunctionBuildConfig.isDemoMode : ${FunctionBuildConfig.isDemoMode}"
|
||||
)
|
||||
// 演示模式,上一次勾选的数据
|
||||
tbIsDemoMode.isChecked = FunctionBuildConfig.isDemoMode
|
||||
|
||||
@@ -1855,7 +1857,7 @@ class DebugSettingView @JvmOverloads constructor(
|
||||
}
|
||||
}
|
||||
|
||||
override fun updateBizData(type: String, state: Boolean, lock: Boolean, data: String?) {
|
||||
override fun updateBizView(type: String, lock: Boolean) {
|
||||
when (type) {
|
||||
BIZ_BEAUTY_MODE -> {
|
||||
tbIsDemoMode.isClickable = !lock
|
||||
|
||||
@@ -28,7 +28,7 @@ class SOPSettingView @JvmOverloads constructor(
|
||||
defStyleAttr: Int = 0
|
||||
) : ConstraintLayout(context, attrs, defStyleAttr), IMoGoDevaToolsFuncConfigListener {
|
||||
|
||||
companion object{
|
||||
companion object {
|
||||
const val TAG = "SOPSettingView"
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ class SOPSettingView @JvmOverloads constructor(
|
||||
FunctionBuildConfig.isPNCWarning = isChecked
|
||||
}
|
||||
|
||||
if(AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode)){
|
||||
if (AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode)) {
|
||||
tbMarkingObstacles.visibility = View.GONE
|
||||
}
|
||||
|
||||
@@ -71,9 +71,9 @@ class SOPSettingView @JvmOverloads constructor(
|
||||
//红绿灯标识
|
||||
tbTrafficLight.isChecked = HmiBuildConfig.isShowTrafficLightView
|
||||
tbTrafficLight.setOnCheckedChangeListener { _, isChecked ->
|
||||
if(!isChecked){
|
||||
if (!isChecked) {
|
||||
HmiBuildConfig.isShowTrafficLightView = false
|
||||
}else{
|
||||
} else {
|
||||
HmiBuildConfig.isShowTrafficLightView = true
|
||||
CallerHmiManager.disableWarningTrafficLight()
|
||||
}
|
||||
@@ -82,9 +82,9 @@ class SOPSettingView @JvmOverloads constructor(
|
||||
//限速标识
|
||||
tbSpeedLimit.isChecked = HmiBuildConfig.isShowLimitingVelocityView
|
||||
tbSpeedLimit.setOnCheckedChangeListener { _, isChecked ->
|
||||
if(isChecked){
|
||||
if (isChecked) {
|
||||
HmiBuildConfig.isShowLimitingVelocityView = true
|
||||
}else{
|
||||
} else {
|
||||
HmiBuildConfig.isShowLimitingVelocityView = false
|
||||
CallerHmiManager.disableLimitingVelocity()
|
||||
}
|
||||
@@ -122,13 +122,13 @@ class SOPSettingView @JvmOverloads constructor(
|
||||
//OBU控制总开关
|
||||
tbObu.isChecked = CallerOBUManager.isConnected()
|
||||
tbObu.setOnCheckedChangeListener { _, isChecked ->
|
||||
if(!isChecked){
|
||||
if(AppIdentityModeUtils.isTaxi(FunctionBuildConfig.appIdentityMode)){
|
||||
if (!isChecked) {
|
||||
if (AppIdentityModeUtils.isTaxi(FunctionBuildConfig.appIdentityMode)) {
|
||||
CallerOBUManager.resetObuIpAddress("192.168.1.199")
|
||||
}else if(AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode)){
|
||||
} else if (AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode)) {
|
||||
CallerOBUManager.resetObuIpAddress("192.168.8.199")
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
//断开链接
|
||||
CallerOBUManager.disConnectObu()
|
||||
}
|
||||
@@ -137,31 +137,32 @@ class SOPSettingView @JvmOverloads constructor(
|
||||
//变道绕障的目标障碍物速度阈值
|
||||
tvSpeed.text = "${FunctionBuildConfig.detouringSpeed} m/s"
|
||||
ivSpeedReduce.setOnClickListener {
|
||||
if(FunctionBuildConfig.detouringSpeed<=3){
|
||||
if (FunctionBuildConfig.detouringSpeed <= 3) {
|
||||
ToastUtils.showShort("阈值小可为3 m/s")
|
||||
}else{
|
||||
} else {
|
||||
FunctionBuildConfig.detouringSpeed--
|
||||
tvSpeed.text = "${FunctionBuildConfig.detouringSpeed} m/s"
|
||||
}
|
||||
}
|
||||
ivSpeedAdd.setOnClickListener {
|
||||
if(FunctionBuildConfig.detouringSpeed>=7){
|
||||
if (FunctionBuildConfig.detouringSpeed >= 7) {
|
||||
ToastUtils.showShort("阈值最大可为7 m/s")
|
||||
}else{
|
||||
} else {
|
||||
FunctionBuildConfig.detouringSpeed++
|
||||
tvSpeed.text = "${FunctionBuildConfig.detouringSpeed} m/s"
|
||||
}
|
||||
}
|
||||
btnSpeedSet.setOnClickListener {
|
||||
val isSuccess = CallerAutoPilotManager.sendDetouringSpeed(FunctionBuildConfig.detouringSpeed.toDouble())
|
||||
if(isSuccess == true){
|
||||
val isSuccess =
|
||||
CallerAutoPilotManager.sendDetouringSpeed(FunctionBuildConfig.detouringSpeed.toDouble())
|
||||
if (isSuccess == true) {
|
||||
ToastUtils.showShort("变道绕障的目标障碍物速度阈值设置成功")
|
||||
}else{
|
||||
} else {
|
||||
ToastUtils.showShort("变道绕障的目标障碍物速度阈值设置失败")
|
||||
}
|
||||
}
|
||||
|
||||
if(AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode)){
|
||||
if (AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode)) {
|
||||
tvSpeedThresholdTitle.visibility = View.GONE
|
||||
ivSpeedReduce.visibility = View.GONE
|
||||
tvSpeed.visibility = View.GONE
|
||||
@@ -175,19 +176,17 @@ class SOPSettingView @JvmOverloads constructor(
|
||||
super.onAttachedToWindow()
|
||||
//添加 业务配置监听
|
||||
CallerDevaToolsFuncConfigListenerManager.registerDevaToolsFuncConfigListener(
|
||||
FuncBizConfig.FOUNDATION,
|
||||
TAG,
|
||||
this
|
||||
FuncBizConfig.FOUNDATION, TAG, true, this
|
||||
)
|
||||
}
|
||||
|
||||
override fun onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow()
|
||||
// 移除 业务配置监听
|
||||
CallerDevaToolsFuncConfigListenerManager.unRegisterDevaToolsFuncConfigListener(this)
|
||||
CallerDevaToolsFuncConfigListenerManager.unRegisterDevaToolsFuncConfigListener(FuncBizConfig.FOUNDATION, TAG)
|
||||
}
|
||||
|
||||
override fun updateBizData(type: String, state: Boolean, lock: Boolean, data: String?) {
|
||||
override fun updateBizView(type: String, lock: Boolean) {
|
||||
when (type) {
|
||||
FuncBizConfig.BIZ_BEAUTY_MODE -> {
|
||||
tbDemoMode.isClickable = !lock
|
||||
|
||||
@@ -12,5 +12,10 @@ interface IMoGoDevaToolsFuncConfigListener {
|
||||
* lock : 锁定状态
|
||||
* data : json
|
||||
*/
|
||||
fun updateBizData(type: String, state: Boolean, lock: Boolean, data: String?)
|
||||
fun updateBizData(type: String, state: Boolean, lock: Boolean, data: String?) {}
|
||||
|
||||
/**
|
||||
* 更新业务锁定状态,仅限View使用
|
||||
*/
|
||||
fun updateBizView(type: String,lock: Boolean){}
|
||||
}
|
||||
@@ -11,6 +11,7 @@ object CallerDevaToolsFuncConfigListenerManager {
|
||||
ConcurrentHashMap()
|
||||
|
||||
private val cacheMap = mutableMapOf<String, MutableList<SubBiz>>()
|
||||
private val viewCacheMap = mutableMapOf<String, Boolean>()
|
||||
|
||||
/**
|
||||
* 添加监听
|
||||
@@ -20,16 +21,18 @@ object CallerDevaToolsFuncConfigListenerManager {
|
||||
fun registerDevaToolsFuncConfigListener(
|
||||
@Nullable biz: String,
|
||||
@Nullable tag: String,
|
||||
onlyViewRegister:Boolean = false,
|
||||
@Nullable listener: IMoGoDevaToolsFuncConfigListener
|
||||
) {
|
||||
if (M_DEVA_TOOLS_FUNC_CONFIG_LISTENER.containsKey("$biz'_'$tag")) {
|
||||
return
|
||||
}
|
||||
M_DEVA_TOOLS_FUNC_CONFIG_LISTENER["$biz'_'$tag"] = listener
|
||||
viewCacheMap["$biz'_'$tag"] = onlyViewRegister
|
||||
|
||||
cacheMap[biz]?.let {
|
||||
if (it.size > 0) {
|
||||
invokeDevaToolsFuncConfigBizUpdate(biz, it)
|
||||
invokeDevaToolsFuncConfigBizUpdate(biz, it, tag)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -43,6 +46,7 @@ object CallerDevaToolsFuncConfigListenerManager {
|
||||
return
|
||||
}
|
||||
M_DEVA_TOOLS_FUNC_CONFIG_LISTENER.remove("$biz'_'$tag")
|
||||
viewCacheMap.remove("$biz'_'$tag")
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -63,15 +67,32 @@ object CallerDevaToolsFuncConfigListenerManager {
|
||||
/**
|
||||
* 由订阅方判断Type类型,聚合一些
|
||||
*/
|
||||
fun invokeDevaToolsFuncConfigBizUpdate(biz: String, list: MutableList<SubBiz>) {
|
||||
fun invokeDevaToolsFuncConfigBizUpdate(
|
||||
biz: String,
|
||||
list: MutableList<SubBiz>,
|
||||
tag: String = ""
|
||||
) {
|
||||
cacheMap[biz] = list
|
||||
M_DEVA_TOOLS_FUNC_CONFIG_LISTENER.forEach {
|
||||
val key = it.key
|
||||
if (key.contains(biz)) {
|
||||
//全量更新
|
||||
if (tag.isEmpty()) {
|
||||
list.forEach { subBiz ->
|
||||
val listener = it.value
|
||||
listener.updateBizData(subBiz.type, subBiz.state, subBiz.lock, subBiz.data)
|
||||
}
|
||||
return@forEach
|
||||
}
|
||||
// 根据biz_tag选择行下发
|
||||
val key = it.key
|
||||
if (key.contains("$biz'_'$tag")) {
|
||||
list.forEach { subBiz ->
|
||||
val listener = it.value
|
||||
if(viewCacheMap["$biz'_'$tag"] == true){
|
||||
listener.updateBizView(subBiz.type,subBiz.lock)
|
||||
}else{
|
||||
listener.updateBizData(subBiz.type, subBiz.state, subBiz.lock, subBiz.data)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user