C

Vehicle Properties Browser

Presents an editable list of available properties grouped by component using QML models.

"QtAA Vehicle Properties Browser Example Screenshot"

The example presents a list of available properties from the Vehicle Properties module. The properties are grouped by module, for example: HVAC, WindowControl and so on.

The first thing to do when using vehicle properties in QML is to import the Qt Vehicle Properties Module:

import QtIf.Android.VehicleProperties 1.0

The example provides two-way communication between the application and Android VHAL. Property modifications made to the app are visible in the Android VHAL. The reverse is true as well: changes made in the Android VHAL are immediately reflected in the app. The available properties and the required metadata are collected under a single property defined in PropertiesModelDefinition.qml:

    readonly property var modulesModelData: [
        {
            name: 'QIfHvac',
            object: climateControl,
            properties: [
                {
                    name: 'powerOn',
                    property_id: 'HVAC_POWER_ON'
                },
                {
                    name: 'acOn',
                    property_id: 'HVAC_AC_ON'
                },
                {
                    name: 'maxAcOn',
                    property_id: 'HVAC_MAX_AC_ON'
                },
                {
                    name: 'dualOn',
                    property_id: 'HVAC_DUAL_ON'
                },
                {
                    name: 'autoOn',
                    property_id: 'HVAC_AUTO_ON'
                },
                {
                    name: 'temperatureSet',
                    property_id: 'HVAC_TEMPERATURE_SET',
                    zones: ['DriverSide', 'PassengerSide']
                },
                {
                    name: 'fanDirection',
                    property_id: 'HVAC_FAN_DIRECTION',
                    values: ['FACE', 'FLOOR', 'DEFROST']
                },
                {
                    name: 'fanSpeed',
                    property_id: 'HVAC_FAN_SPEED'
                },
                {
                    name: 'defroster',
                    property_id: 'HVAC_DEFROSTER',
                    zones: ['FrontWindshield', 'RearWindshield']
                },
                {
                    name: 'recircOn',
                    property_id: 'HVAC_RECIRC_ON'
                },
                {
                    name: 'autoRecircOn',
                    property_id: 'HVAC_AUTO_RECIRC_ON'
                },
                {
                    name: 'seatVentilation',
                    property_id: 'HVAC_SEAT_VENTILATION',
                    zones: [
                        'Passenger', 'Driver'
                    ]
                },
                {
                    name: 'maxDefrostOn',
                    property_id: 'HVAC_MAX_DEFROST_ON'
                },
                {
                    name: 'seatTemperature',
                    property_id: 'HVAC_SEAT_TEMPERATURE',
                    zones: [
                        'Passenger', 'Driver'
                    ]
                },
                {
                    name: 'steeringWheelHeat',
                    property_id: 'HVAC_STEERING_WHEEL_HEAT',
                    zones: [ 'Global' ]
                },
                {
                    name: 'temperatureDisplayUnits',
                    property_id: 'HVAC_TEMPERATURE_DISPLAY_UNITS',
                    values: ['CELSIUS', 'FAHRENHEIT'],
                    zones: [ 'Global' ],
                    exclusive: true
                }
            ]
        },
        {
            name: 'QIfWindowControl',
            object: windowControl,
            properties: [
                {
                    name: 'windowPos',
                    property_id: 'WINDOW_POS',
                    zones: [
                        'Driver', 'Passenger',
                        'PassengerRow2Left', 'PassengerRow2Right', 'Roof1'
                    ]
                },
                {
                    name: 'windowLock',
                    property_id: 'WINDOW_LOCK',
                    readonly: true
                }
            ]
        },
        {
            name: 'QIfCarInfo',
            object: carInfo,
            properties: [
                {
                    name: 'infoFuelCapacity',
                    property_id: 'INFO_FUEL_CAPACITY',
                    readonly: true
                },
                {
                    name: 'infoEvBatteryCapacity',
                    property_id: 'INFO_EV_BATTERY_CAPACITY',
                    readonly: true
                },
                {
                    name: 'infoFuelDoorLocation',
                    property_id: 'INFO_FUEL_DOOR_LOCATION',
                    readonly: true
                },
                {
                    name: 'infoEvPortLocation',
                    property_id: 'INFO_EV_PORT_LOCATION',
                    readonly: true
                },
                {
                    name: 'infoDriverSeat',
                    property_id: 'INFO_DRIVER_SEAT',
                    readonly: true
                }
            ]
        },
        {
            name: 'QIfTireControl',
            object: tireControl,
            properties: [
                {
                    name: 'tirePressure',
                    property_id: 'TIRE_PRESSURE',
                    zones: [
                        'RightFront', 'LeftFront',
                        'RightRear', 'LeftRear'
                    ],
                    readonly: true
                }
            ]
        },
        {
            name: 'QIfLightsControl',
            object: lightsControl,
            properties: [
                {
                    name: 'headlightsState',
                    property_id: 'HEADLIGHTS_STATE',
                    readonly: true
                },
                {
                    name: 'highbeamLightsState',
                    property_id: 'HIGH_BEAM_LIGHTS_STATE',
                    readonly: true
                },
                {
                    name: 'fogLightsState',
                    property_id: 'FOG_LIGHTS_STATE',
                    readonly: true
                },
                {
                    name: 'hazardLightsState',
                    property_id: 'HAZARD_LIGHTS_STATE',
                    readonly: true
                },
                {
                    name: 'headlightsSwitch',
                    property_id: 'HEADLIGHTS_SWITCH',
                    readonly: false
                },
                {
                    name: 'highbeamLightsSwitch',
                    property_id: 'HIGH_BEAM_LIGHTS_SWITCH',
                    readonly: false
                },
                {
                    name: 'fogLightsSwitch',
                    property_id: 'FOG_LIGHTS_SWITCH',
                    readonly: false
                },
                {
                    name: 'hazardLightsSwitch',
                    property_id: 'HAZARD_LIGHTS_SWITCH',
                    readonly: false
                },
                {
                    name: 'nightMode',
                    property_id: 'NIGHT_MODE',
                    readonly: true
                }
            ]
        },
        {
            name: 'QIfFuelControl',
            object: fuelControl,
            properties: [
                {
                    name: 'fuelLevel',
                    property_id: 'FUEL_LEVEL',
                    readonly: true
                },
                {
                    name: 'fuelLevelLow',
                    property_id: 'FUEL_LEVEL_LOW',
                    readonly: true
                },
                {
                    name: 'fuelDoorOpen',
                    property_id: 'FUEL_DOOR_OPEN',
                    readonly: false
                },
                {
                    name: 'evBatteryInstantaneousChargeRate',
                    property_id: 'EV_BATTERY_INSTANTANEOUS_CHARGE_RATE',
                    readonly: true
                },
                {
                    name: 'evBatteryLevel',
                    property_id: 'EV_BATTERY_LEVEL',
                    readonly: true
                },
                {
                    name: 'evChargePortConnected',
                    property_id: 'EV_CHARGE_PORT_CONNECTED',
                    readonly: true
                },
                {
                    name: 'evChargePortOpen',
                    property_id: 'EV_CHARGE_PORT_OPEN',
                    readonly: true
                },
                {
                    name: 'rangeRemaining',
                    property_id: 'RANGE_REMAINING',
                    readonly: true
                }
            ]
        },
        {
            name: 'QIfDoorControl',
            object: doorControl,
            properties: [
                {
                    name: 'doorPos',
                    property_id: 'DOOR_POS',
                    zones:['Rear', 'Row1Left', 'Row1Right', 'Row2Left', 'Row2Right'],
                    readonly: false
                },
                {
                    name: 'doorLock',
                    zones:['Row1Left', 'Row1Right', 'Row2Left', 'Row2Right'],
                    property_id: 'DOOR_LOCK',
                    readonly: false
                }
            ]
        },
        {
            name: 'QIfDriveInfo',
            object: driveInfo,
            properties: [
                {
                    name: 'perfOdometer',
                    property_id: 'PERF_ODOMETER',
                    readonly: true
                },
                {
                    name: 'perfVehicleSpeed',
                    property_id: 'PERF_VEHICLE_SPEED',
                    readonly: true
                },
                {
                    name: 'gearSelection',
                    property_id: 'GEAR_SELECTION',
                    readonly: true
                },
                {
                    name: 'currentGear',
                    property_id: 'CURRENT_GEAR',
                    readonly: true
                },
                {
                    name: 'parkingBrakeOn',
                    property_id: 'PARKING_BRAKE_ON',
                    readonly: true
                },
                {
                    name: 'ignitionState',
                    property_id: 'IGNITION_STATE',
                    readonly: true
                },
                {
                    name: 'absActive',
                    property_id: 'ABS_ACTIVE',
                    readonly: true
                },
                {
                    name: 'tractionControlActive',
                    property_id: 'TRACTION_CONTROL_ACTIVE',
                    readonly: true
                },
                {
                    name: 'distanceDisplayUnits',
                    property_id: 'DISTANCE_DISPLAY_UNITS',
                    readonly: false
                },
                {
                    name: 'envOutsideTemperature',
                    property_id: 'ENV_OUTSIDE_TEMPERATURE',
                    readonly: true
                }
            ]
        },
        {
            name: 'QIfEngineInfo',
            object: engineInfo,
            properties: [
                {
                    name: 'engineOilLevel',
                    property_id: 'ENGINE_OIL_LEVEL',
                    readonly: true
                },
                {
                    name: 'engineOilTemp',
                    property_id: 'ENGINE_OIL_TEMP',
                    readonly: true
                },
                {
                    name: 'engineRpm',
                    property_id: 'ENGINE_RPM',
                    readonly: true
                }
            ]
        }
    ]

Each top-level entry provides metadata for a single Vehicle Properties component and its properties. The instances of the components declared in the same file are also referenced through the object field.

    HVAC {
        id: climateControl
    }

    WindowControl {
        id: windowControl
    }

The QML model is defined in PropertiesModel.qml. It uses a property's metadata and component instances, these are defined in PropertiesModelDefinition.qml. Any bindings necessary to update the QML model, whenever the data model of Android VHAL has changed, are created using an Instantiator:

    Instantiator {
        id: syncingInstantiator

        model: listModel

        delegate: Instantiator {
            id: propertiesInstantiator

            readonly property int moduleIndex: index

            model: properties

            delegate: Instantiator {
                id: zonesInstantiator

                model: zones
                readonly property string propertyName: name

                delegate: QtObject {
                    readonly property var propertyValue: {
                        const module = definitions.modulesModelData[moduleIndex]
                        const object = module.object
                        const zonedObject = internal.resolveZone(object, zone)

                        return zonedObject[zonesInstantiator.propertyName]
                    }

                    onPropertyValueChanged: {
                        zones.get(index).valueWrapper = { value: propertyValue }
                    }
                }
            }
        }
    }

Altering properties from the application level is done as follows:

    function updateProperty(moduleIndex, propertyIndex, zoneIndex, value) {
        const module = definitions.modulesModelData[moduleIndex]
        const property = module.properties[propertyIndex]
        const zones = property.zones || []
        const moduleObject = module.object
        const zonedObject = internal.resolveZone(moduleObject,
                                                 zones[zoneIndex] || '')
        zonedObject[property.name] = value
    }

The user interface consists of two components based on ListView: ModulesList and PropertiesList. These use the provided QML model. Finally, the visual representation of the property is rendered by a ValueDelegate component which provides the appropriate controls depending on the property type and other metadata.

See also Qt IF Android Vehicle Properties Module, Qt for Android, and Qt IF.

Available under certain Qt licenses.
Find out more.