Skip to content

Commit

Permalink
feat: Initial Trip-Info screen integration
Browse files Browse the repository at this point in the history
  • Loading branch information
tzebrowski committed Jul 15, 2024
1 parent 746b363 commit 9eb09ac
Show file tree
Hide file tree
Showing 12 changed files with 590 additions and 14 deletions.
25 changes: 15 additions & 10 deletions automotive/src/main/java/org/obd/graphs/aa/screen/CarScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,7 @@ import org.obd.graphs.AA_EDIT_PREF_SCREEN
import org.obd.graphs.RenderingThread
import org.obd.graphs.aa.*
import org.obd.graphs.aa.mapColor
import org.obd.graphs.aa.screen.nav.CHANGE_SCREEN_EVENT
import org.obd.graphs.aa.screen.nav.DRAG_RACING_SCREEN_ID
import org.obd.graphs.aa.screen.nav.GIULIA_SCREEN_ID
import org.obd.graphs.aa.screen.nav.ROUTINES_SCREEN_ID
import org.obd.graphs.aa.screen.nav.*
import org.obd.graphs.aa.toast
import org.obd.graphs.bl.collector.MetricsCollector
import org.obd.graphs.bl.datalogger.WorkflowStatus
Expand Down Expand Up @@ -102,13 +99,21 @@ internal abstract class CarScreen(
}
dataLogger.start(query)
}
DRAG_RACING_SCREEN_ID -> {
query.setStrategy(QueryStrategyType.DRAG_RACING_QUERY)
dataLogger.start(query)
}

DRAG_RACING_SCREEN_ID ->
dataLogger.start(query.apply{
setStrategy(QueryStrategyType.DRAG_RACING_QUERY)
})

TRIP_INFO_SCREEN_ID ->
dataLogger.start(query.apply{
setStrategy(QueryStrategyType.TRIP_INFO_QUERY)
})

ROUTINES_SCREEN_ID -> {
query.setStrategy(QueryStrategyType.ROUTINES_QUERY)
dataLogger.start(query)
dataLogger.start(query.apply{
setStrategy(QueryStrategyType.ROUTINES_QUERY)
})
}
}
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import org.obd.graphs.bl.datalogger.*
const val GIULIA_SCREEN_ID = 0
const val DRAG_RACING_SCREEN_ID = 1
const val ROUTINES_SCREEN_ID = 2
const val TRIP_INFO_SCREEN_ID = 3

internal class AvailableFeaturesScreen(
carContext: CarContext,
Expand Down Expand Up @@ -59,6 +60,13 @@ internal class AvailableFeaturesScreen(
val items = ItemList.Builder().apply {


addItem(
row(
TRIP_INFO_SCREEN_ID, R.drawable.action_giulia,
carContext.getString(R.string.available_features_trip_info_screen_title)
)
)

addItem(
row(
DRAG_RACING_SCREEN_ID, R.drawable.action_drag_race_screen,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ internal class NavTemplateCarScreen(
Log.d(LOG_KEY, "Selected new screen id=$it")
it?.let {
val newScreen = it.toString().toInt()
if (newScreen == GIULIA_SCREEN_ID || newScreen == DRAG_RACING_SCREEN_ID) {
if (newScreen == GIULIA_SCREEN_ID || newScreen == DRAG_RACING_SCREEN_ID || newScreen == TRIP_INFO_SCREEN_ID) {
surfaceScreen.toggleSurfaceRenderer(newScreen)
invalidate()
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,20 @@ class SurfaceController(
}

DRAG_RACING_SCREEN_ID -> {
query.setStrategy(QueryStrategyType.DRAG_RACING_QUERY)
dataLogger.updateQuery(query = query.apply {
setStrategy(QueryStrategyType.DRAG_RACING_QUERY)
})

dataLogger.updateQuery(query = query)
surfaceRenderer = SurfaceRenderer.allocate(carContext, settings, metricsCollector, fps, surfaceRendererType = SurfaceRendererType.DRAG_RACING)
}

TRIP_INFO_SCREEN_ID -> {
dataLogger.updateQuery(query = query.apply {
setStrategy(QueryStrategyType.TRIP_INFO_QUERY)
})
surfaceRenderer = SurfaceRenderer.allocate(carContext, settings, metricsCollector, fps, surfaceRendererType = SurfaceRendererType.TRIP_INFO)
}
}

surfaceRenderer.applyMetricsFilter(query)
Expand Down
2 changes: 2 additions & 0 deletions automotive/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@
<string name="available_features.routine_screen.title">Routines</string>
<string name="available_features.drag_race_screen.title">Drag Racing</string>
<string name="available_features.giulia_screen.title">Metrics</string>
<string name="available_features.trip_info_screen.title">Trip info</string>

</resources>
26 changes: 25 additions & 1 deletion datalogger/src/main/java/org/obd/graphs/bl/query/ObdMetricExt.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,33 @@ private const val VEHICLE_SPEED_PID_ID = 14L
private const val EXT_ENGINE_RPM_PID_ID = 7008L
private const val ENGINE_RPM_PID_ID = 13L

private const val FUEL_CONSUMPTION_PID_ID = 7035L
private const val FUEL_LEVEL_PID_ID = 7037L
private const val GEARBOX_OIL_TEMP_PID_ID = 7025L
private const val GEARBOX_ENGAGED_PID_ID = 7029L
private const val OIL_TEMP_PID_ID = 7003L
private const val COOLANT_TEMP_PID_ID = 7009L
private const val EXHAUST_TEMP_PID_ID = 7016L
private const val AIR_TEMP_PID_ID = 7002L


class PIDsNamesRegistry {

fun getFuelConsumptionPID(): Long = FUEL_CONSUMPTION_PID_ID
fun getFuelLevelPID(): Long = FUEL_LEVEL_PID_ID
fun getGearboxOilTempPID(): Long = GEARBOX_OIL_TEMP_PID_ID

fun getGearboxEngagedPID(): Long = GEARBOX_ENGAGED_PID_ID

fun getOilTempPID(): Long = OIL_TEMP_PID_ID

fun getCoolantTempPID(): Long = COOLANT_TEMP_PID_ID

fun getExhaustTempPID(): Long = EXHAUST_TEMP_PID_ID

fun getAirTempPID(): Long = AIR_TEMP_PID_ID


fun getAtmPressurePID(): Long = EXT_ATM_PRESSURE_PID_ID
fun getAmbientTempPID(): Long = EXT_AMBIENT_TEMP_PID_ID
fun getMeasuredIntakePressurePID (): Long = EXT_MEASURED_INTAKE_PRESSURE_PID_ID
Expand All @@ -38,5 +63,4 @@ class PIDsNamesRegistry {
fun getDynamicSelectorPID(): Long = EXT_DYNAMIC_SELECTOR_PID_ID

private fun isProfileExtensionsEnabled() = Prefs.getBoolean(PREF_PROFILE_2_0_GME_EXTENSION_ENABLED, false)

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ internal class QueryStrategyOrchestrator : java.io.Serializable, Query {
this[QueryStrategyType.DRAG_RACING_QUERY] = DragRacingQueryStrategy()
this[QueryStrategyType.INDIVIDUAL_QUERY_FOR_EACH_VIEW] = IndividualQueryStrategy()
this[QueryStrategyType.ROUTINES_QUERY] = RoutinesQueryStrategy()
this[QueryStrategyType.TRIP_INFO_QUERY] = TripInfoQueryStrategy()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ package org.obd.graphs.bl.query
enum class QueryStrategyType {
ROUTINES_QUERY,
DRAG_RACING_QUERY,
TRIP_INFO_QUERY,
SHARED_QUERY,
INDIVIDUAL_QUERY_FOR_EACH_VIEW
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/**
* Copyright 2019-2024, Tomasz Żebrowski
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
package org.obd.graphs.bl.query


internal class TripInfoQueryStrategy : QueryStrategy() {
override fun getPIDs(): MutableSet<Long> =
mutableSetOf(

namesRegistry.getVehicleSpeedPID(),
namesRegistry.getFuelConsumptionPID(),
namesRegistry.getFuelLevelPID(),
namesRegistry.getAtmPressurePID(),
namesRegistry.getAmbientTempPID(),
namesRegistry.getGearboxEngagedPID(),
namesRegistry.getGearboxOilTempPID(),

namesRegistry.getOilTempPID(),
namesRegistry.getCoolantTempPID(),
namesRegistry.getExhaustTempPID(),
namesRegistry.getAirTempPID(),
)
}

Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ import org.obd.graphs.bl.query.Query
import org.obd.graphs.renderer.drag.DragRacingSurfaceRenderer
import org.obd.graphs.renderer.gauge.GaugeSurfaceRenderer
import org.obd.graphs.renderer.giulia.GiuliaSurfaceRenderer
import org.obd.graphs.renderer.trip.TripSurfaceRenderer

enum class SurfaceRendererType {
GIULIA, GAUGE, DRAG_RACING
GIULIA, GAUGE, DRAG_RACING, TRIP_INFO
}

data class ViewSettings(var marginTop: Int = 0)
Expand All @@ -37,6 +38,7 @@ interface SurfaceRenderer {
fun applyMetricsFilter(query: Query)
fun onDraw(canvas: Canvas, drawArea: Rect?)
fun recycle()

companion object {
fun allocate(
context: Context,
Expand All @@ -50,6 +52,7 @@ interface SurfaceRenderer {
SurfaceRendererType.GAUGE -> GaugeSurfaceRenderer(context, settings, metricsCollector, fps, viewSettings)
SurfaceRendererType.GIULIA -> GiuliaSurfaceRenderer(context, settings, metricsCollector, fps, viewSettings)
SurfaceRendererType.DRAG_RACING -> DragRacingSurfaceRenderer(context, settings, metricsCollector, fps, viewSettings)
SurfaceRendererType.TRIP_INFO -> TripSurfaceRenderer(context, settings, metricsCollector, fps, viewSettings)
}
}
}
Loading

0 comments on commit 9eb09ac

Please sign in to comment.