QIfZonedFeatureInterface Class

QIfZonedFeatureInterface defines the base interface for the feature backend classes. More...

Header: #include <QIfZonedFeatureInterface>
qmake: QT += interfaceframework
Inherits: QIfFeatureInterface
Inherited By:

QIfClimateControlBackendInterface and QIfWindowControlBackendInterface

Public Functions

QIfZonedFeatureInterface(QObject *parent = nullptr)
virtual QStringList availableZones() const = 0

Signals

void availableZonesChanged(const QStringList &zones)

Detailed Description

Vehicle feature can be zoned or be just generic depending of the vehicle. For example some vehicles can contain only one climate fan and some other may have one fan for the front seats and one for the back seat. To fill both requirements, a backend developer can specify each feature attribute to be generic or zone specific. If the backend doesn't specify a zone for an attribute, then the attribute is generic. There can be multiple zone attributes, but only a single generic one. The zone value for a generic attribute is an empty string, and it can be omitted from the signals. The code snippets below describes how to implement zone specific fanSpeedlevel and generic steeringWheelHeater support in the backend.

Providing Available Zones

Before making any further calls to the backend, VehicleFunctions will query the list of available zones. Zones are string keys and can be anything defined by the backend developer. In this case we have two zones: "Front" and "Rear".

The backend must return all available zones via availableZones:

 QStringList backend::availableZones() const {
     QStringList zones;
     zones << "Front";
     zones << "Rear";
     return zones;
}

Initializing Attributes

VehicleFunctions calls the backend to initialize all attributes. Backend implementation has to emit all supported attribute signals, passing the zone as a parameter. Zone is not needed if attribute is generic.

Initialization signals are emitted in the initialize:

 void backend::initialize() {
     emit fanSpeedLevelChanged(2, "Front");
     emit fanSpeedLevelChanged(2, "Rear");
     emit steeringWheelHeaterChanged(0); // Generic, no zone specified
     emit initializationDone();
}

Implementing Feature-specific Attributes

Fan speed is zoned, validating requested zones is the responsibility of the backend. If zone is valid, the vehicle's actual fan speed level can be adjusted. The backend has to emit a signal for the changed zone.

 void backend::setFanSpeedLevel(int value, const QString &zone) {
     if (!m_fanSpeedZones.contains(zone)) {
         emit errorChanged(QIfAbstractFeature::InvalidZone);
     } else {
         // Set specified zone fan to value
         ...
         emit fanSpeedLevelChanged(value, zone);
     }
}

 int backend::fanSpeedLevel(const QString &zone) {
     if (!m_fanSpeedZones.contains(zone)) {
         emit errorChanged(QIfAbstractFeature::InvalidZone);
         return -1;
     } else {
         int value = ... // Get vehicle's zone fan Speed
         return value;
     }
}

Steering wheel heater is not zone specific, so zone attribute should be empty. If zone is empty, the vehicle's actual steering wheel heater can be controlled. The backend has to emit a signal for the changed value. Because the attribute is generic, zone is omitted from the signal.

 void backend::setSteeringWheelHeater(int value, const QString &zone) {
     if (!zone.isEmpty()) {  // zone must be empty for a generic attribute
         emit errorChanged(QIfAbstractFeature::InvalidZone);
         return;
     } else {
         // Set vehicle's steering wheel heater value
         ...
         emit steeringWheelHeaterChanged(value);
     }
}

 int backend::steeringWheelHeater(const QString &zone) {
     if (!zone.isEmpty()) {  // zone must be empty for a generic attribute
         emit errorChanged(QIfAbstractFeature::InvalidZone);
         return -1;
     } else {
         int value = ... // Get vehicle's steering wheel heater value
         return value;
     }
}

To implement a backend plugin you need also to implement QIfServiceInterface from the QtInterfaceFramework module.

See the full example backend implementation from src/plugins/ifvehiclefunctions/climate_simulator.

See also QIfAbstractZonedFeature and QIfServiceInterface.

Member Function Documentation

QIfZonedFeatureInterface::QIfZonedFeatureInterface(QObject *parent = nullptr)

Constructs a backend base interface.

The parent is sent to the QObject constructor.

[signal, since 5.13] void QIfZonedFeatureInterface::availableZonesChanged(const QStringList &zones)

Emitted when the available zones changed.

Use this signal when the list of available zones need to be retrieved first, and are not available when the backend instance is created.

This function was introduced in Qt 5.13.

See also availableZones() and Providing Available Zones.

[pure virtual] QStringList QIfZonedFeatureInterface::availableZones() const

Returns a list of supported zone names. This is called from the client after having connected.

The returned names must be valid QML property names, i.e. [a-z_][A-Za-z0-9_]*.

See also availableZonesChanged() and Providing Available Zones.

© 2021 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.