diff --git a/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/v2x/TrafficLightDispatcher.kt b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/v2x/TrafficLightDispatcher.kt index 703fcd4f6f..faeca9e548 100644 --- a/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/v2x/TrafficLightDispatcher.kt +++ b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/v2x/TrafficLightDispatcher.kt @@ -153,6 +153,11 @@ class TrafficLightDispatcher : IMoGoAutopilotIdentifyListener, IMoGoTrafficLight convert(light.nextTwoState),light.nextTwoDuration.toInt(), DataSourceType.TELEMATIC_UNION_V2N ) + //当前灯态倒计时小于5S时,展示额外的提示框 + if(light.duration < 5){ + onTrafficLightPrompt(convert(light.state),light.duration.toInt()) + } + //TODO 提示框的消失逻辑 } } } @@ -264,6 +269,20 @@ class TrafficLightDispatcher : IMoGoAutopilotIdentifyListener, IMoGoTrafficLight CallerTrafficLightListenerManager.disableTrafficLight() } + /** + * 融合V2N红绿灯额外提示框提醒 + */ + @ChainLog( + linkChainLog = ChainConstant.CHAIN_TYPE_SOCKET_TRAFFIC_LIGHT, + linkCode = ChainConstant.CHAIN_SOURCE_ADAS, + nodeAliasCode = ChainConstant.CHAIN_CODE_ADAS_TRAFFIC_LIGHT, + paramIndexes = [0, 1]) + override fun onTrafficLightPrompt(currentState: TrafficLightEnum, currentDuration: Int) { + super.onTrafficLightPrompt(currentState, currentDuration) + Log.i("xuxinchao","融合V2N红绿灯额外提示框提醒 Dis") + CallerTrafficLightListenerManager.onShowTrafficLightPrompt(currentState, currentDuration) + } + /** * 融合V2N红绿灯数据,带有下一下二灯态 */ diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/notice/traffic/TrafficLightPromptView.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/notice/traffic/TrafficLightPromptView.kt new file mode 100644 index 0000000000..e91a850337 --- /dev/null +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/notice/traffic/TrafficLightPromptView.kt @@ -0,0 +1,126 @@ +package com.mogo.eagle.core.function.hmi.ui.notice.traffic + +import android.content.Context +import android.util.AttributeSet +import android.util.Log +import android.view.LayoutInflater +import android.view.View +import android.widget.TextView +import androidx.constraintlayout.widget.ConstraintLayout +import androidx.core.content.ContextCompat +import com.mogo.eagle.core.data.enums.TrafficLightEnum +import com.mogo.eagle.core.function.api.datacenter.union.IMoGoTrafficLightListener +import com.mogo.eagle.core.function.call.v2x.CallerTrafficLightListenerManager +import com.mogo.eagle.core.function.hmi.R +import com.mogo.eagle.core.function.hmi.ui.widget.TypefaceTextView +import com.mogo.eagle.core.utilcode.util.ThreadUtils + +/** + * 融合红绿灯变灯提示 + * 鹰眼650需求 + */ +class TrafficLightPromptView @JvmOverloads constructor( + context: Context, + attrs: AttributeSet? = null, + defStyleAttr: Int = 0 +) : ConstraintLayout(context, attrs, defStyleAttr), IMoGoTrafficLightListener { + + companion object { + private const val TAG = "TrafficLightPromptView" + } + + private var user = 0 //使用方,driver:0 passenger:1 + private var tvPromptTitle: TextView ?= null + private var tvPromptContent: TextView ?= null + private var tvTrafficNum: TypefaceTextView ?= null + private var tvTrafficNumDecimal: TypefaceTextView ?= null + private val randomList = ArrayList() + + init { + val typedArray = context.obtainStyledAttributes(attrs, R.styleable.TrafficLightPromptView) + user = typedArray.getInt(R.styleable.TrafficLightPromptView_promptUser,0) + typedArray.recycle() + } + + override fun onAttachedToWindow() { + super.onAttachedToWindow() + if(user == 0){ + LayoutInflater.from(context).inflate(R.layout.view_traffic_light_prompt, this, true) + tvPromptTitle = findViewById(R.id.tvPromptTitle) + }else{ + LayoutInflater.from(context).inflate(R.layout.view_traffic_light_prompt_p, this, true) + } + tvPromptContent = findViewById(R.id.tvPromptContent) + tvTrafficNum = findViewById(R.id.tvTrafficNum) + tvTrafficNumDecimal = findViewById(R.id.tvTrafficNumDecimal) + CallerTrafficLightListenerManager.addListener(TAG, this) + + randomList.add(0.99f) + randomList.add(0.72f) + randomList.add(0.44f) + randomList.add(0.21f) + randomList.add(0.06f) + +// tvPromptContent?.text = "请准备出发" +// tvTrafficNum?.text = "12" +// tvTrafficNumDecimal?.text = ".56" + } + + override fun onDetachedFromWindow() { + super.onDetachedFromWindow() + CallerTrafficLightListenerManager.removeListener(TAG) + } + + + + /** + * 红绿灯额外提示框 + * @param currentState 当前灯态 + * @param currentDuration 当前灯态倒计时 + */ + override fun onShowTrafficLightPrompt(currentState: TrafficLightEnum, currentDuration: Int) { + super.onShowTrafficLightPrompt(currentState, currentDuration) + Log.i("xuxinchao","TrafficLightPromptView onTrafficLightPrompt") + Log.i("xuxinchao","onShowTrafficLightPrompt user="+user) + ThreadUtils.runOnUiThread { + when(currentState){ + TrafficLightEnum.GREEN->{ + this@TrafficLightPromptView.visibility = View.VISIBLE + if(user == 0){ + tvTrafficNum?.setTextColor(ContextCompat.getColor(context,R.color.light_prompt_green)) + tvTrafficNumDecimal?.setTextColor(ContextCompat.getColor(context,R.color.light_prompt_green)) + }else{ + Log.i("xuxinchao","user="+user) + tvTrafficNum?.setTextColor(ContextCompat.getColor(context,R.color.light_prompt_green_p)) + tvTrafficNumDecimal?.setTextColor(ContextCompat.getColor(context,R.color.light_prompt_green_p)) + } + } + TrafficLightEnum.RED->{ + this@TrafficLightPromptView.visibility = View.VISIBLE + if(user == 0){ + tvTrafficNum?.setTextColor(ContextCompat.getColor(context,R.color.light_prompt_red)) + tvTrafficNumDecimal?.setTextColor(ContextCompat.getColor(context,R.color.light_prompt_red)) + }else{ + tvTrafficNum?.setTextColor(ContextCompat.getColor(context,R.color.light_prompt_red_p)) + tvTrafficNumDecimal?.setTextColor(ContextCompat.getColor(context,R.color.light_prompt_red_p)) + } + } + TrafficLightEnum.YELLOW->{ + this@TrafficLightPromptView.visibility = View.VISIBLE + if(user == 0){ + tvTrafficNum?.setTextColor(ContextCompat.getColor(context,R.color.light_prompt_yellow)) + tvTrafficNumDecimal?.setTextColor(ContextCompat.getColor(context,R.color.light_prompt_yellow)) + }else{ + tvTrafficNum?.setTextColor(ContextCompat.getColor(context,R.color.light_prompt_yellow_p)) + tvTrafficNumDecimal?.setTextColor(ContextCompat.getColor(context,R.color.light_prompt_yellow_p)) + } + } + TrafficLightEnum.BLACK->{ + this@TrafficLightPromptView.visibility = View.GONE + } + } + tvTrafficNum?.text = currentDuration.toString() + } + } + +} \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xhdpi/bg_light_prompt.png b/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xhdpi/bg_light_prompt.png new file mode 100644 index 0000000000..00e3226db3 Binary files /dev/null and b/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xhdpi/bg_light_prompt.png differ diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/layout/view_traffic_light_prompt.xml b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/view_traffic_light_prompt.xml new file mode 100644 index 0000000000..3ce541d148 --- /dev/null +++ b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/view_traffic_light_prompt.xml @@ -0,0 +1,48 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/layout/view_traffic_light_prompt_p.xml b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/view_traffic_light_prompt_p.xml new file mode 100644 index 0000000000..27cf95e6a8 --- /dev/null +++ b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/view_traffic_light_prompt_p.xml @@ -0,0 +1,38 @@ + + + + + + + + + + \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/values/attr.xml b/core/function-impl/mogo-core-function-hmi/src/main/res/values/attr.xml index 75121362da..257d023d29 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/res/values/attr.xml +++ b/core/function-impl/mogo-core-function-hmi/src/main/res/values/attr.xml @@ -129,4 +129,11 @@ + + + + + + + \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/values/color.xml b/core/function-impl/mogo-core-function-hmi/src/main/res/values/color.xml index 82b6d4e3c5..63da6ab51e 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/res/values/color.xml +++ b/core/function-impl/mogo-core-function-hmi/src/main/res/values/color.xml @@ -92,4 +92,12 @@ #106FF0 #42464F + #131415 + #FF3B2D + #31FF56 + #FFCD3D + #F63C12 + #36DB1C + #FDB700 + \ No newline at end of file diff --git a/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/datacenter/union/IMoGoTrafficLightListener.kt b/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/datacenter/union/IMoGoTrafficLightListener.kt index 6f1be122fa..2278328f24 100644 --- a/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/datacenter/union/IMoGoTrafficLightListener.kt +++ b/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/datacenter/union/IMoGoTrafficLightListener.kt @@ -30,6 +30,11 @@ interface IMoGoTrafficLightListener { } + /** + * 红绿灯额外提示框 + */ + fun onTrafficLightPrompt(currentState: TrafficLightEnum,currentDuration: Int){} + /** * 融合红绿灯,带有下一灯态和下二灯态 */ @@ -57,6 +62,13 @@ interface IMoGoTrafficLightListener { */ fun showTrafficLight(checkLightId: TrafficLightEnum, lightSource: DataSourceType) {} + /** + * 红绿灯额外提示框 + * @param currentState 当前灯态 + * @param currentDuration 当前灯态倒计时 + */ + fun onShowTrafficLightPrompt(currentState: TrafficLightEnum,currentDuration: Int){} + /** * 展示融合带有下一下二灯态的红绿灯 * @param currentState 当前灯态 diff --git a/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/v2x/CallerTrafficLightListenerManager.kt b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/v2x/CallerTrafficLightListenerManager.kt index 83103ec2e1..40d3cc465f 100644 --- a/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/v2x/CallerTrafficLightListenerManager.kt +++ b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/v2x/CallerTrafficLightListenerManager.kt @@ -1,5 +1,6 @@ package com.mogo.eagle.core.function.call.v2x +import android.util.Log import com.mogo.eagle.core.data.enums.DataSourceType import com.mogo.eagle.core.data.enums.TrafficLightEnum import com.mogo.eagle.core.data.biz.trafficlight.TrafficLightResult @@ -71,6 +72,18 @@ object CallerTrafficLightListenerManager : CallerBase } } + /** + * 红绿灯额外提示框 + * @param currentState 当前灯态 + * @param currentDuration 当前灯态倒计时 + */ + fun onShowTrafficLightPrompt(currentState: TrafficLightEnum,currentDuration: Int){ + M_LISTENERS.forEach{ + val listener = it.value + listener.onShowTrafficLightPrompt(currentState,currentDuration) + } + } + /** * 展示融合带有下一下二灯态的红绿灯 * @param currentState 当前灯态