红绿灯

红绿灯Bus司机端增加信号来源显示
This commit is contained in:
xuxinchao
2022-06-23 16:07:40 +08:00
parent 9aace7a2a5
commit ebb88145aa
17 changed files with 143 additions and 49 deletions

View File

@@ -57,7 +57,7 @@ class V2XTrafficLightBroadcastReceiver : BroadcastReceiver() {
* @param trafficLightCountDown 对应交通灯倒计时如果倒计时为0则disable
*/
private fun dispatchShowWaring(trafficLightCheckType: Int, trafficLightCountDown: Int) {
CallerHmiManager.showWarningTrafficLight(trafficLightCheckType)
CallerHmiManager.showWarningTrafficLight(trafficLightCheckType,1)
when(trafficLightCheckType){
1 -> CallerHmiManager.changeCountdownRed(trafficLightCountDown)
2 -> CallerHmiManager.changeCountdownYellow(trafficLightCountDown)

View File

@@ -78,7 +78,7 @@ import kotlin.collections.ArrayList
* 预警图层
*/
@Route(path = MoGoFragmentPaths.PATH_FRAGMENT_HMI)
class MoGoHmiFragment : MvpFragment<MoGoHmiContract.View?, HmiPresenter?>(),
class MoGoHmiFragment : MvpFragment<MoGoHmiContract.View?, HmiPresenter?>(),
IMoGoWaringProvider,
IMoGoHmiViewProxy,
MoGoHmiContract.View,
@@ -618,9 +618,10 @@ class MoGoHmiFragment : MvpFragment<MoGoHmiContract.View?, HmiPresenter?>(),
* 展示红绿灯预警
*
* @param checkLightId 0-都是默认不亮起1-红2-黄3-绿
* @param lightSource 1:云端下发2:自车感知
*/
override fun showWarningTrafficLight(checkLightId: Int) {
mViewTrafficLight?.showWarningTrafficLight(checkLightId)
override fun showWarningTrafficLight(checkLightId: Int,lightSource: Int) {
mViewTrafficLight?.showWarningTrafficLight(checkLightId,lightSource)
}
override fun isWarningTrafficLightShow(): Boolean {

View File

@@ -5,9 +5,11 @@ import android.util.AttributeSet
import android.view.LayoutInflater
import android.view.View
import android.widget.ImageView
import androidx.core.view.marginLeft
import android.widget.TextView
import com.mogo.eagle.core.data.config.FunctionBuildConfig
import com.mogo.eagle.core.function.api.hmi.view.IViewTrafficLight
import com.mogo.eagle.core.function.hmi.R
import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils
import com.mogo.eagle.core.utilcode.util.UiThreadHandler
/**
@@ -21,6 +23,8 @@ class SingleTrafficLightView @JvmOverloads constructor(
private var mLightIconIV: ImageView? = null
private var mLightIconBG: ImageView? = null
private var mLightTimeTV: GradientTextView? = null
private var mLightSourceTV: TextView? = null
private var mLightSourceDivider: View? = null
private var mCurrentLightId = 0
init {
@@ -32,17 +36,20 @@ class SingleTrafficLightView @JvmOverloads constructor(
mLightIconIV = findViewById(R.id.hmi_traffic_light_iv)
mLightIconBG = findViewById(R.id.hmi_traffic_light_bg)
mLightTimeTV = findViewById(R.id.hmi_traffic_light_time_tv)
mLightSourceTV = findViewById(R.id.hmi_traffic_light_source)
mLightSourceDivider = findViewById(R.id.hmi_traffic_light_divider)
}
/**
* 展示红绿灯预警
*
* @param checkLightId 0-都是默认1-红2-黄3-绿
* @param lightSource 1:云端下发2:自车感知
*/
override fun showWarningTrafficLight(checkLightId: Int) {
super.showWarningTrafficLight(checkLightId)
override fun showWarningTrafficLight(checkLightId: Int,lightSource: Int) {
super.showWarningTrafficLight(checkLightId,lightSource)
mCurrentLightId = checkLightId
updateTrafficLightIcon(checkLightId)
updateTrafficLightIcon(checkLightId,lightSource)
}
/**
@@ -59,11 +66,26 @@ class SingleTrafficLightView @JvmOverloads constructor(
override fun disableCountdown() {
super.disableCountdown()
UiThreadHandler.post {
val lp = this.layoutParams as MarginLayoutParams
lp.width = context.resources.getDimension(R.dimen.hmi_traffic_light_icon_size).toInt()
this.layoutParams = lp
mLightTimeTV!!.visibility = GONE
mLightIconBG!!.layoutParams.width = context.resources.getDimension(R.dimen.dp_124).toInt()
// 小巴车的司机端需要展示红绿灯信号来源
if(AppIdentityModeUtils.isDriver(FunctionBuildConfig.appIdentityMode)
&& AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode)){
val lp = this.layoutParams as MarginLayoutParams
lp.width = context.resources.getDimension(R.dimen.dp_325).toInt()
this.layoutParams = lp
mLightSourceTV!!.visibility = VISIBLE
mLightSourceDivider!!.visibility = VISIBLE
mLightTimeTV!!.visibility = GONE
mLightSourceTV!!.setPadding(0,0,75,0)
mLightIconBG!!.layoutParams.width = context.resources.getDimension(R.dimen.dp_310).toInt()
}else{
val lp = this.layoutParams as MarginLayoutParams
lp.width = context.resources.getDimension(R.dimen.hmi_traffic_light_icon_size).toInt()
this.layoutParams = lp
mLightTimeTV!!.visibility = GONE
mLightSourceDivider!!.visibility = View.GONE
mLightSourceTV!!.visibility = View.GONE
mLightIconBG!!.layoutParams.width = context.resources.getDimension(R.dimen.dp_124).toInt()
}
}
}
@@ -149,8 +171,9 @@ class SingleTrafficLightView @JvmOverloads constructor(
* 更新红绿灯icon
*
* @param lightId 0-都是默认1-红2-黄3-绿
* @param lightSource 1:云端下发2:自车感知
*/
private fun updateTrafficLightIcon(lightId: Int) {
private fun updateTrafficLightIcon(lightId: Int,lightSource: Int) {
UiThreadHandler.post {
when (lightId) {
1 -> {
@@ -167,15 +190,41 @@ class SingleTrafficLightView @JvmOverloads constructor(
}
else -> this@SingleTrafficLightView.visibility = GONE
}
when(lightSource){
1 -> {
mLightSourceTV!!.text = "云端下发"
}
2 -> {
mLightSourceTV!!.text = "自车感知"
}
else -> {
mLightSourceTV!!.visibility = GONE
}
}
}
}
private fun resetView(){
val lp = this.layoutParams as MarginLayoutParams
lp.width = context.resources.getDimension(R.dimen.hmi_traffic_light_layout_width).toInt()
this.layoutParams = lp
mLightTimeTV!!.visibility = View.VISIBLE
mLightIconBG!!.layoutParams.width = context.resources.getDimension(R.dimen.hmi_traffic_light_bg_width).toInt()
// 小巴车的司机端需要展示红绿灯信号来源
if(AppIdentityModeUtils.isDriver(FunctionBuildConfig.appIdentityMode)
&& AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode)){
val lp = this.layoutParams as MarginLayoutParams
lp.width = context.resources.getDimension(R.dimen.hmi_traffic_light_bus_layout_width).toInt()
this.layoutParams = lp
mLightTimeTV!!.visibility = View.VISIBLE
mLightSourceDivider!!.visibility = View.VISIBLE
mLightSourceTV!!.visibility = View.VISIBLE
mLightSourceTV!!.setPadding(0,0,0,0)
mLightIconBG!!.layoutParams.width = context.resources.getDimension(R.dimen.hmi_traffic_light_bus_bg_width).toInt()
}else{
val lp = this.layoutParams as MarginLayoutParams
lp.width = context.resources.getDimension(R.dimen.hmi_traffic_light_layout_width).toInt()
this.layoutParams = lp
mLightTimeTV!!.visibility = View.VISIBLE
mLightSourceDivider!!.visibility = View.GONE
mLightSourceTV!!.visibility = View.GONE
mLightIconBG!!.layoutParams.width = context.resources.getDimension(R.dimen.hmi_traffic_light_bg_width).toInt()
}
}
}

View File

@@ -30,8 +30,9 @@ class TrafficLightView @JvmOverloads constructor(
* 展示红绿灯预警
*
* @param checkLightId 0-都是默认1-红2-黄3-绿
* @param lightSource 1:云端下发2:自车感知
*/
override fun showWarningTrafficLight(checkLightId: Int) {
override fun showWarningTrafficLight(checkLightId: Int,lightSource: Int) {
UiThreadHandler.post {
visibility = View.VISIBLE
when (checkLightId) {

View File

@@ -1,19 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="@dimen/hmi_traffic_light_layout_width"
android:layout_width="@dimen/hmi_traffic_light_bus_layout_width"
android:layout_height="@dimen/hmi_traffic_light_layout_height"
xmlns:tools="http://schemas.android.com/tools"
android:visibility="visible">
<ImageView
android:id="@+id/hmi_traffic_light_bg"
android:layout_width="@dimen/hmi_traffic_light_bg_width"
android:layout_width="@dimen/hmi_traffic_light_bus_bg_width"
android:layout_height="@dimen/hmi_traffic_light_bg_height"
android:layout_marginStart="@dimen/hmi_traffic_light_bg_margin_left"
android:layout_marginTop="@dimen/hmi_traffic_light_bg_margin_top"
android:background="@drawable/traffic_light_bg"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" />
app:layout_constraintTop_toTopOf="parent"
/>
<ImageView
android:id="@+id/hmi_traffic_light_iv"
@@ -29,7 +31,33 @@
android:gravity="center"
android:textSize="@dimen/hmi_traffic_light_time_size"
android:textStyle="bold"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintLeft_toRightOf="@id/hmi_traffic_light_iv"
android:layout_marginStart="-30px"
/>
<TextView
android:id="@+id/hmi_traffic_light_source"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:text="自车感知"
android:textColor="@color/color_FFFFFF"
android:textSize="@dimen/hmi_traffic_light_source_size"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
android:layout_marginEnd="@dimen/dp_30"
/>
<View
android:id="@+id/hmi_traffic_light_divider"
android:layout_width="@dimen/dp_1"
android:layout_height="@dimen/dp_47"
android:background="@color/color_FFFFFF"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toLeftOf="@id/hmi_traffic_light_source"
android:layout_marginEnd="@dimen/dp_25"
/>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -39,15 +39,19 @@
<dimen name="dp_1066">1066px</dimen>
<dimen name="hmi_traffic_light_layout_width">225px</dimen>
<dimen name="hmi_traffic_light_bus_layout_width">400px</dimen>
<dimen name="hmi_traffic_light_layout_height">154px</dimen>
<dimen name="hmi_traffic_light_layout_corner">60px</dimen>
<dimen name="hmi_traffic_light_layout_margin_right">40px</dimen>
<dimen name="hmi_traffic_light_layout_margin_top">28px</dimen>
<dimen name="hmi_traffic_light_bg_width">210px</dimen>
<dimen name="hmi_traffic_light_bus_bg_width">385px</dimen>
<dimen name="hmi_traffic_light_bg_height">120px</dimen>
<dimen name="hmi_traffic_light_bg_margin_left">15px</dimen>
<dimen name="hmi_traffic_light_bg_margin_top">17px</dimen>
<dimen name="hmi_traffic_light_icon_size">154px</dimen>
<dimen name="hmi_traffic_light_time_view_width">130px</dimen>
<dimen name="hmi_traffic_light_time_view_width">71px</dimen>
<dimen name="hmi_traffic_light_time_size">60px</dimen>
<dimen name="hmi_traffic_light_source_size">32px</dimen>
</resources>

View File

@@ -45,15 +45,19 @@
<dimen name="brakelight_height_daytime">120px</dimen>
<dimen name="hmi_traffic_light_layout_width">225px</dimen>
<dimen name="hmi_traffic_light_bus_layout_width">400px</dimen>
<dimen name="hmi_traffic_light_layout_height">154px</dimen>
<dimen name="hmi_traffic_light_layout_corner">60px</dimen>
<dimen name="hmi_traffic_light_layout_margin_right">40px</dimen>
<dimen name="hmi_traffic_light_layout_margin_top">28px</dimen>
<dimen name="hmi_traffic_light_bg_width">210px</dimen>
<dimen name="hmi_traffic_light_bus_bg_width">385px</dimen>
<dimen name="hmi_traffic_light_bg_height">120px</dimen>
<dimen name="hmi_traffic_light_bg_margin_left">15px</dimen>
<dimen name="hmi_traffic_light_bg_margin_top">17px</dimen>
<dimen name="hmi_traffic_light_icon_size">154px</dimen>
<dimen name="hmi_traffic_light_time_view_width">130px</dimen>
<dimen name="hmi_traffic_light_time_view_width">71px</dimen>
<dimen name="hmi_traffic_light_time_size">60px</dimen>
<dimen name="hmi_traffic_light_source_size">32px</dimen>
</resources>

View File

@@ -664,7 +664,7 @@ class MogoPrivateObuManager private constructor() {
when (currentLight.phase) {
// 灯光不可用
0x0 -> {
CallerHmiManager.showWarningTrafficLight(0)
CallerHmiManager.showWarningTrafficLight(0,2)
}
// 红灯
0x1 -> {
@@ -673,7 +673,7 @@ class MogoPrivateObuManager private constructor() {
isRedLight = true
}
isGreenLight = false
CallerHmiManager.showWarningTrafficLight(1)
CallerHmiManager.showWarningTrafficLight(1,2)
val red = currentLight.count_down.toInt()
CallerHmiManager.changeCountdownRed(red)
@@ -688,7 +688,7 @@ class MogoPrivateObuManager private constructor() {
isGreenLight = true
}
isRedLight = false
CallerHmiManager.showWarningTrafficLight(3)
CallerHmiManager.showWarningTrafficLight(3,2)
val green = currentLight.count_down.toInt()
CallerHmiManager.changeCountdownGreen(green)
//防止数据出现问题的容错
@@ -733,7 +733,7 @@ class MogoPrivateObuManager private constructor() {
// 黄灯
0x3 -> {
CallerHmiManager.disableWarningV2X(appId.toString())
CallerHmiManager.showWarningTrafficLight(2)
CallerHmiManager.showWarningTrafficLight(2,2)
val yellow = currentLight.count_down.toInt()
CallerHmiManager.changeCountdownYellow(yellow)
CallerHmiManager.changeCountdownGreen(0)

View File

@@ -24,7 +24,7 @@ class TrafficLightHMIManager {
currentTrafficLight?.let {
if (!initView) {
initView = true
CallerHmiManager.showWarningTrafficLight(0)
CallerHmiManager.showWarningTrafficLight(0,1)
}
callerHMIToChangeLight(it)
}
@@ -38,19 +38,19 @@ class TrafficLightHMIManager {
}
when {
trafficLightStatus.isGreen() || trafficLightStatus.isFlashGreen() -> {
CallerHmiManager.showWarningTrafficLight(3)
CallerHmiManager.showWarningTrafficLight(3,1)
CallerHmiManager.changeCountdownGreen(remain)
// CallerHmiManager.changeCountdownRed(-1)
// CallerHmiManager.changeCountdownYellow(-1)
}
trafficLightStatus.isYellow() -> {
CallerHmiManager.showWarningTrafficLight(2)
CallerHmiManager.showWarningTrafficLight(2,1)
CallerHmiManager.changeCountdownYellow(remain)
// CallerHmiManager.changeCountdownGreen(-1)
// CallerHmiManager.changeCountdownRed(-1)
}
trafficLightStatus.isRed() -> {
CallerHmiManager.showWarningTrafficLight(1)
CallerHmiManager.showWarningTrafficLight(1,1)
CallerHmiManager.changeCountdownRed(remain)
// CallerHmiManager.changeCountdownGreen(-1)
// CallerHmiManager.changeCountdownYellow(-1)

View File

@@ -67,17 +67,17 @@ class TrafficLightDispatcher : IMoGoAutopilotIdentifyListener , IMoGoTrafficLigh
when (light.state) {
TrafficLightOuterClass.LightState.STATE_RED -> {
//红灯
CallerHmiManager.showWarningTrafficLight(1)
CallerHmiManager.showWarningTrafficLight(1,2)
CallerHmiManager.changeCountdownGreen(0)
}
TrafficLightOuterClass.LightState.STATE_YELLOW -> {
//黄灯
CallerHmiManager.showWarningTrafficLight(2)
CallerHmiManager.showWarningTrafficLight(2,2)
CallerHmiManager.changeCountdownGreen(0)
}
TrafficLightOuterClass.LightState.STATE_GREEN -> {
//绿灯
CallerHmiManager.showWarningTrafficLight(3)
CallerHmiManager.showWarningTrafficLight(3,2)
CallerHmiManager.changeCountdownGreen(0)
}
else -> {}