C

HVAC Zoned Example

Demonstrates how to handle zoned features when using the Qt IVI Generator Extensions for Android Automotive.

"QtAA HVAC Zoned Example"

This example uses the zones capability of the Qt IVI Generator Extensions for Android Automotive. For a detailed description see HVAC Example.

This page covers only the usage of zones.

Preparing Configuration Files with Zoning Enabled

First, in the .qface file, the zoned attribute of config for the component must be set to true:

@config: { zoned: true, id: "io.qt.qtivi.android.ClimateControl/1.0", ... }

Second, to be able to access a specific VHAL property in different zones, it must be assigned to those zones. In the following example the targetTemperatureSet attribute of the QIviClimateControl will be present both in the Driver and Passenger zones.

QtIviAndroidVehicleFunctions.QIviClimateControl#targetTemperatureSet:
    config_android_automotive:
        vhalId: HVAC_TEMPERATURE_SET
        zone:
            - DRIVER_ZONE_ID
            - PASSENGER_ZONE_ID
        vhalType: FLOAT
        javaType: Float
        mightNeedConversion: true

The DRIVER_ZONE_ID and PASSENGER_ZONE_ID are zone aliases to (Android Automotive Area Types).

zoneAliases:
    - DRIVER_ZONE_ID = VehicleAreaSeat.SEAT_ROW_1_LEFT | VehicleAreaSeat.SEAT_ROW_2_LEFT
        | VehicleAreaSeat.SEAT_ROW_2_CENTER
    - PASSENGER_ZONE_ID = VehicleAreaSeat.SEAT_ROW_1_RIGHT
        | VehicleAreaSeat.SEAT_ROW_2_RIGHT
    - SEAT_ALL = DRIVER_ZONE_ID | PASSENGER_ZONE_ID
    - REAR_WINDSHIELD = VehicleAreaWindow.WINDOW_REAR_WINDSHIELD
    - FRONT_WINDSHIELD = VehicleAreaWindow.WINDOW_FRONT_WINDSHIELD

The names of the zones, that will be used in QML (Driver and Passenger, etc.), are defined in zoneMappings section:

zoneMappings:
    "": SEAT_ALL
    Driver: DRIVER_ZONE_ID
    Passenger: PASSENGER_ZONE_ID
    RearWindshield: REAR_WINDSHIELD
    FrontWindshield: FRONT_WINDSHIELD

Running the Example

To run the example from Qt Creator, open the Welcome mode and select the example from Examples. For more information, visit Building and Running an Example.

Using Zones in QML

In this example, the connection to the back end is done the same way as in HVAC Example; the connection is defined in a distinct QML file ClimateControlFacade.qml.

Accessing a particular zone's property in Qml is straightforward. The generated ClimateControl component provides the zoneAt property, which subsequently provides an additional property, named after the zone (Driver, Passenger, etc.). This property is an instance of the ClimateControl component. However, the only active properties are the ones that have been assigned to a particular zone. So, you could assign a value for Driver's defroster, but it would not give any effect.

As the zone is a separate object we have to make the connections separately for each zone.

    Connections {
        target: climateControl.zoneAt.Driver
        function onTargetTemperatureSetChanged(targetTemperatureSet) {
            facade.targetTemperatureSetDriver = targetTemperatureSet
        }
    }

    Connections {
        target: climateControl.zoneAt.Passenger
        function onTargetTemperatureSetChanged(targetTemperatureSet) {
            facade.targetTemperatureSetPassenger = targetTemperatureSet
        }
    }

To pass the values of the zoned properties to the back end, we must do it with respect to the zone containing those properties.

    Connections {
        id: ui2vhal
        target: facade

        // Defrosters
        function onDefrostFrontOnChanged() {
            climateControl.zoneAt.FrontWindshield.defroster = facade.defrostFrontOn
        }
        function onDefrostRearOnChanged() {
            climateControl.zoneAt.RearWindshield.defroster = facade.defrostRearOn
        }
        // Temperatures
        function onTargetTemperatureSetDriverChanged() {
            climateControl.zoneAt.Driver.targetTemperatureSet = facade.targetTemperatureSetDriver
        }

        function onTargetTemperatureSetPassengerChanged() {
            climateControl.zoneAt.Passenger.targetTemperatureSet =
                    facade.targetTemperatureSetPassenger
        }

See also Qt for Android and Qt IVI.

Available under certain Qt licenses.
Find out more.