[Fix]推荐速度逻辑修改

This commit is contained in:
chenfufeng
2021-11-19 21:15:12 +08:00
parent eeb8d81660
commit 879d6ef283

View File

@@ -11,6 +11,8 @@ import com.mogo.eagle.core.utilcode.util.ThreadUtils
import com.mogo.module.common.enums.EventTypeEnum
import com.mogo.utils.logger.Logger
import kotlin.math.abs
import kotlin.math.ceil
import kotlin.math.floor
class RedLightWarningManager : IMoGoTrafficLightListener {
@@ -58,7 +60,12 @@ class RedLightWarningManager : IMoGoTrafficLightListener {
if (arriveTime <= remainTime) {
redLightWarning()
} else if (arriveTime > remainTime + yellowLightTime) {// 到达时红、黄灯都走完
greenLightWarning()
// 单位Km/h当前为红灯推荐速度越慢越容易绿灯通过且要满足[10,50]
val originRemainSpeed = floor(100 / (remainTime + yellowLightTime) * 3.6).toInt()
when {
originRemainSpeed > 50 -> greenLightWarning("10到50")
originRemainSpeed in 10..50 -> greenLightWarning("10到$originRemainSpeed")
}
}
}
trafficLightStatus.isYellow() -> {
@@ -67,7 +74,12 @@ class RedLightWarningManager : IMoGoTrafficLightListener {
if (arriveTime <= remainTime) {
redLightWarning()
} else {
greenLightWarning()
// 单位Km/h当前为黄灯推荐速度越慢越容易绿灯通过且要满足[10,50]
val originRemainSpeed = floor(100 / remainTime * 3.6).toInt()
when {
originRemainSpeed > 50 -> greenLightWarning("10到50")
originRemainSpeed in 10..50 -> greenLightWarning("10到$originRemainSpeed")
}
}
}
trafficLightStatus.isGreen() -> {
@@ -76,6 +88,12 @@ class RedLightWarningManager : IMoGoTrafficLightListener {
if (arriveTime >= remainTime) {
redLightWarning()
} else if (arriveTime < remainTime) {
// 单位Km/h当前为绿灯推荐速度越快越容易绿灯通过且要满足[10,50]
val originRemainSpeed = ceil(100 / remainTime * 3.6).toInt()
when {
originRemainSpeed < 10 -> greenLightWarning("10到50")
originRemainSpeed in 10..50 -> greenLightWarning("${originRemainSpeed}到50")
}
greenLightWarning()
}
}
@@ -104,16 +122,16 @@ class RedLightWarningManager : IMoGoTrafficLightListener {
/**
* 绿灯通行提示
*/
private fun greenLightWarning() {
private fun greenLightWarning(speed: String = "50") {
Logger.d(TAG, "=====绿灯通行预警=====")
ThreadUtils.runOnUiThread {
val content = String.format(
EventTypeEnum.getWarningContent(EventTypeEnum.TYPE_USECASE_ID_IVP_GREEN.poiType),
50
speed
)
val tts = String.format(
EventTypeEnum.getWarningTts(EventTypeEnum.TYPE_USECASE_ID_IVP_GREEN.poiType),
50
speed
)
CallerHmiManager.showWarningV2X(
EventTypeEnum.TYPE_USECASE_ID_IVP_GREEN.poiType.toInt(),