From 4ff195370c10fd5cdfcbc5f2a879d468bee5aa4e Mon Sep 17 00:00:00 2001 From: renwj Date: Tue, 30 Apr 2024 15:49:23 +0800 Subject: [PATCH] =?UTF-8?q?[6.4.0][=E5=90=AF=E8=87=AA=E9=A9=BE=E6=8C=87?= =?UTF-8?q?=E5=BC=95]=20=E5=8A=A0=E9=80=9F=E5=BA=A6=E5=80=BC=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../test/TestAutoPilotBeforeLaunch.kt | 2 +- .../status/entity/Status.kt | 2 +- .../status/flow/autopilot/SpeedImpl.kt | 18 +++++++++++------- .../status/model/StatusModel.kt | 2 +- .../status/ui/AutoPilotLaunchBeforeView.kt | 7 +++---- .../layout/layout_autopilot_launch_before.xml | 4 ++-- 6 files changed, 19 insertions(+), 16 deletions(-) diff --git a/app/src/androidTest/java/com/mogo/functions/test/TestAutoPilotBeforeLaunch.kt b/app/src/androidTest/java/com/mogo/functions/test/TestAutoPilotBeforeLaunch.kt index 2338a96eeb..c0d05c2bdb 100644 --- a/app/src/androidTest/java/com/mogo/functions/test/TestAutoPilotBeforeLaunch.kt +++ b/app/src/androidTest/java/com/mogo/functions/test/TestAutoPilotBeforeLaunch.kt @@ -134,7 +134,7 @@ class TestAutoPilotBeforeLaunch { CallerChassisGearStateListenerManager.invokeAutopilotGearData(GEAR_R) val current = CallerChassisLocationGCJ02ListenerManager.getChassisLocationGCJ02() CallerChassisLocationGCJ02ListenerManager.invokeChassisLocationGCJ02(current.also { it.gnssSpeed = Random.nextInt(0 ..20).toFloat(); it.setAcceleration(Random.nextInt(-100, 100).toDouble()) }, DEFAULT) - delay(Random.nextInt(10..50).toLong()) + delay(Random.nextInt(100..500).toLong()) } } launch(Dispatchers.IO) { diff --git a/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/status/entity/Status.kt b/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/status/entity/Status.kt index da3bd8b718..c52ab883b3 100644 --- a/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/status/entity/Status.kt +++ b/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/status/entity/Status.kt @@ -297,7 +297,7 @@ interface IAutopilotPreLaunchStatus /** * 速度 */ -data class SpeedStatus(val speed: Float, var acc: Float): Status(), IAutopilotPreLaunchStatus { +data class SpeedStatus(val speed: Int, var acc: Float): Status(), IAutopilotPreLaunchStatus { override fun isException(): Boolean { return false diff --git a/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/status/flow/autopilot/SpeedImpl.kt b/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/status/flow/autopilot/SpeedImpl.kt index aac970108a..aa3df1d063 100644 --- a/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/status/flow/autopilot/SpeedImpl.kt +++ b/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/status/flow/autopilot/SpeedImpl.kt @@ -24,7 +24,7 @@ internal class SpeedImpl(ctx: Context): IFlow(ctx), IMoGoChassisLoc } @Volatile - private var lastSpeed: Float? = null + private var lastSpeed: Int? = null @Volatile private var lastAcc: Float? = null @@ -40,16 +40,20 @@ internal class SpeedImpl(ctx: Context): IFlow(ctx), IMoGoChassisLoc override fun onChassisLocationGCJ02(mogoLocation: MogoLocation?) { var isChanged = false - if (lastSpeed != mogoLocation?.gnssSpeed) { + val speed = mogoLocation?.gnssSpeed?.toInt() ?: 0 + if (lastSpeed != speed) { isChanged = true - lastSpeed = mogoLocation?.gnssSpeed + lastSpeed = speed } - if (!isChanged && lastAcc != mogoLocation?.acceleration) { - isChanged = true - lastAcc = mogoLocation?.acceleration + val acceleration = mogoLocation?.acceleration?.toString()?.format("%.1")?.toFloat() ?: 0f + if (!isChanged) { + if (lastAcc != acceleration) { + isChanged = true + lastAcc = acceleration + } } if (isChanged) { - send(SpeedStatus(mogoLocation?.gnssSpeed ?: 0f, mogoLocation?.acceleration ?: 0f)) + send(SpeedStatus(speed, acceleration)) } } } \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/status/model/StatusModel.kt b/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/status/model/StatusModel.kt index 22e35db332..6a1ddb383c 100644 --- a/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/status/model/StatusModel.kt +++ b/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/status/model/StatusModel.kt @@ -26,7 +26,7 @@ internal class StatusModel : ViewModel() { it += DoubleFlashStatus(0) it += GearStatus(0) it += RouteDownloadStatus() - it += SpeedStatus(0f, 0f) + it += SpeedStatus(0, 0f) }) } diff --git a/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/status/ui/AutoPilotLaunchBeforeView.kt b/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/status/ui/AutoPilotLaunchBeforeView.kt index 61e8c028de..54d15942e4 100644 --- a/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/status/ui/AutoPilotLaunchBeforeView.kt +++ b/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/status/ui/AutoPilotLaunchBeforeView.kt @@ -33,9 +33,10 @@ import kotlinx.android.synthetic.main.layout_autopilot_launch_before.view.iv_bra import kotlinx.android.synthetic.main.layout_autopilot_launch_before.view.iv_double_flash import kotlinx.android.synthetic.main.layout_autopilot_launch_before.view.iv_steer import kotlinx.android.synthetic.main.layout_autopilot_launch_before.view.speed -import kotlinx.android.synthetic.main.layout_autopilot_launch_before.view.tv_brake_or_accelerator +import kotlinx.android.synthetic.main.layout_autopilot_launch_before.view.tv_accelerator import me.jessyan.autosize.utils.AutoSizeUtils import kotlin.math.abs +import kotlin.text.* class AutoPilotLaunchBeforeView: LinearLayout, IStatusListener { @@ -91,9 +92,7 @@ class AutoPilotLaunchBeforeView: LinearLayout, IStatusListener { iv_brake_or_accelerator?.isSelected = isError } is BrakeStatus -> { - val angle = status.angle iv_brake_or_accelerator?.isSelected = isError - tv_brake_or_accelerator?.text = "a:-${angle.toInt()}" } is DoubleFlashStatus -> { iv_double_flash?.isSelected = isError @@ -103,7 +102,7 @@ class AutoPilotLaunchBeforeView: LinearLayout, IStatusListener { } is SpeedStatus -> { speed?.text = "${(abs(status.speed) * 3.6f).toInt()}" - tv_brake_or_accelerator?.text = String.format("%.1f", status.acc) + tv_accelerator?.text = "a:" + String.format("%-3.1f", status.acc) } else -> { Logger.d(TAG, "other state: $status") diff --git a/core/function-impl/mogo-core-function-devatools/src/main/res/layout/layout_autopilot_launch_before.xml b/core/function-impl/mogo-core-function-devatools/src/main/res/layout/layout_autopilot_launch_before.xml index 0cb89c7cfe..511b33ec30 100644 --- a/core/function-impl/mogo-core-function-devatools/src/main/res/layout/layout_autopilot_launch_before.xml +++ b/core/function-impl/mogo-core-function-devatools/src/main/res/layout/layout_autopilot_launch_before.xml @@ -133,7 +133,7 @@ android:layout_marginEnd="@dimen/dp_14"/> + android:text="a: 0.0"/> \ No newline at end of file