Skip to content

Commit

Permalink
Reads some small data from RHMIApplicationEtch
Browse files Browse the repository at this point in the history
AAIdrive relies on the previous behavior where
ImageIdModels can remember their imageId
after being loaded from a resource file.
This can be provided by RHMIApplicationIdempotent
but the unit tests skip this wrapping layer
  • Loading branch information
hufman committed Mar 16, 2024
1 parent d1eba4a commit 6a8e046
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -131,27 +131,42 @@ class RHMIApplicationConcrete : RHMIApplication() {

}

class RHMIApplicationEtch constructor(val remoteServer: BMWRemotingServer, val rhmiHandle: Int) : RHMIApplication() {
/** Represents an application layout that is backed by a Car connection */
class RHMIApplicationEtch(val remoteServer: BMWRemotingServer, val rhmiHandle: Int) : RHMIApplication() {
/** Represents an application layout that is backed by a Car connection
* Most data is not retained, so if you want to read data back out,
* use RHMIApplicationConcrete or RHMIApplicationIdempotent
* */
override val models = HashMap<Int, RHMIModel>()
override val actions = HashMap<Int, RHMIAction>()
override val events = HashMap<Int, RHMIEvent>()
override val states = HashMap<Int, RHMIState>()
override val components = HashMap<Int, RHMIComponent>()

// remember a little bit of properties and small ints
val modelData = HashMap<Int, Any?>()
val propertyData = HashMap<Int, MutableMap<Int, Any?>>()

@Throws(BMWRemoting.SecurityException::class, BMWRemoting.IllegalArgumentException::class, BMWRemoting.ServiceException::class)
override fun setModel(modelId: Int, value: Any?) {
if (value is Int || value is BMWRemoting.RHMIResourceIdentifier) {
modelData[modelId] = value
} else {
modelData.remove(modelId)
}
if (ignoreUpdates) return
this.remoteServer.rhmi_setData(this.rhmiHandle, modelId, value)
}
override fun getModel(modelId: Int): Any? = modelData[modelId]

@Throws(BMWRemoting.SecurityException::class, BMWRemoting.IllegalArgumentException::class, BMWRemoting.ServiceException::class)
override fun setProperty(componentId: Int, propertyId: Int, value: Any?) {
propertyData.getOrPut(componentId){HashMap()}[propertyId] = value
if (ignoreUpdates) return
val propertyValue = HashMap<Int, Any?>()
propertyValue[0] = value
this.remoteServer.rhmi_setProperty(rhmiHandle, componentId, propertyId, propertyValue)
}
override fun getProperty(componentId: Int, propertyId: Int): Any? = propertyData[componentId]?.get(propertyId)

@Throws(BMWRemoting.SecurityException::class, BMWRemoting.IllegalArgumentException::class, BMWRemoting.ServiceException::class)
override fun triggerHMIEvent(eventId: Int, args: Map<Any, Any?>) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -742,6 +742,9 @@ class TestXMLParsing {

assertEquals(1, component?.properties?.size)
assertEquals("false", component?.properties?.get(1)?.value)
val property = component?.properties?.get(1) as RHMIProperty
assertEquals("true", property.getForLayout(0))
assertEquals(1, property.getForLayout(1))
val propertyBag = component?.properties?.get(1) as RHMIProperty.LayoutBag
assertEquals("true", propertyBag.getForLayout(0))
assertEquals(1, propertyBag.getForLayout(1))
Expand Down

0 comments on commit 6a8e046

Please sign in to comment.