Qt IVI Generator Climate Example
#ifndef CLIMATE_CLIMATECONTROLBACKEND_H_
#define CLIMATE_CLIMATECONTROLBACKEND_H_
#include <QObject>
#include <QQmlPropertyMap>
#include "climatecontrolbackendinterface.h"
class QIviSimulationEngine ;
class ClimateControlZone : public QObject
{
Q_OBJECT
Q_PROPERTY(bool airConditioning READ airConditioning WRITE setAirConditioning NOTIFY airConditioningChanged FINAL)
Q_PROPERTY(bool heater READ heater WRITE setHeater NOTIFY heaterChanged FINAL)
Q_PROPERTY(int fanSpeedLevel READ fanSpeedLevel WRITE setFanSpeedLevel NOTIFY fanSpeedLevelChanged FINAL)
Q_PROPERTY(int steeringWheelHeater READ steeringWheelHeater WRITE setSteeringWheelHeater NOTIFY steeringWheelHeaterChanged FINAL)
Q_PROPERTY(qreal targetTemperature READ targetTemperature WRITE setTargetTemperature NOTIFY targetTemperatureChanged FINAL)
Q_PROPERTY(int seatCooler READ seatCooler WRITE setSeatCooler NOTIFY seatCoolerChanged FINAL)
Q_PROPERTY(int seatHeater READ seatHeater WRITE setSeatHeater NOTIFY seatHeaterChanged FINAL)
Q_PROPERTY(int outsideTemperature READ outsideTemperature WRITE setOutsideTemperature NOTIFY outsideTemperatureChanged FINAL)
Q_PROPERTY(QString outsideTemperatureLabel READ outsideTemperatureLabel WRITE setOutsideTemperatureLabel NOTIFY outsideTemperatureLabelChanged FINAL)
Q_PROPERTY(bool zoneSynchronization READ zoneSynchronization WRITE setZoneSynchronization NOTIFY zoneSynchronizationChanged FINAL)
Q_PROPERTY(bool defrost READ defrost WRITE setDefrost NOTIFY defrostChanged FINAL)
Q_PROPERTY(ClimateModule:: RecirculationMode recirculationMode READ recirculationMode WRITE setRecirculationMode NOTIFY recirculationModeChanged FINAL)
Q_PROPERTY(bool recirculation READ recirculation WRITE setRecirculation NOTIFY recirculationChanged FINAL)
Q_PROPERTY(int recirculationSensitivityLevel READ recirculationSensitivityLevel WRITE setRecirculationSensitivityLevel NOTIFY recirculationSensitivityLevelChanged FINAL)
Q_PROPERTY(ClimateModule:: ClimateMode climateMode READ climateMode WRITE setClimateMode NOTIFY climateModeChanged FINAL)
Q_PROPERTY(int automaticClimateFanIntensityLevel READ automaticClimateFanIntensityLevel WRITE setAutomaticClimateFanIntensityLevel NOTIFY automaticClimateFanIntensityLevelChanged FINAL)
Q_PROPERTY(ClimateModule:: AirflowDirections airflowDirections READ airflowDirections WRITE setAirflowDirections NOTIFY airflowDirectionsChanged FINAL)
public :
explicit ClimateControlZone(const QString & zone, ClimateControlBackendInterface * parent = nullptr);
bool airConditioning() const ;
bool heater() const ;
int fanSpeedLevel() const ;
int steeringWheelHeater() const ;
qreal targetTemperature() const ;
int seatCooler() const ;
int seatHeater() const ;
int outsideTemperature() const ;
QString outsideTemperatureLabel() const ;
bool zoneSynchronization() const ;
bool defrost() const ;
ClimateModule:: RecirculationMode recirculationMode() const ;
bool recirculation() const ;
int recirculationSensitivityLevel() const ;
ClimateModule:: ClimateMode climateMode() const ;
int automaticClimateFanIntensityLevel() const ;
ClimateModule:: AirflowDirections airflowDirections() const ;
public Q_SLOTS:
void setAirConditioning(bool airConditioning);
void setHeater(bool heater);
void setFanSpeedLevel(int fanSpeedLevel);
void setSteeringWheelHeater(int steeringWheelHeater);
void setTargetTemperature(qreal targetTemperature);
void setSeatCooler(int seatCooler);
void setSeatHeater(int seatHeater);
void setOutsideTemperature(int outsideTemperature);
void setOutsideTemperatureLabel(const QString & outsideTemperatureLabel);
void setZoneSynchronization(bool zoneSynchronization);
void setDefrost(bool defrost);
void setRecirculationMode(ClimateModule:: RecirculationMode recirculationMode);
void setRecirculation(bool recirculation);
void setRecirculationSensitivityLevel(int recirculationSensitivityLevel);
void setClimateMode(ClimateModule:: ClimateMode climateMode);
void setAutomaticClimateFanIntensityLevel(int automaticClimateFanIntensityLevel);
void setAirflowDirections(ClimateModule:: AirflowDirections airflowDirections);
signals :
void airConditioningChanged(bool airConditioning);
void heaterChanged(bool heater);
void fanSpeedLevelChanged(int fanSpeedLevel);
void steeringWheelHeaterChanged(int steeringWheelHeater);
void targetTemperatureChanged(qreal targetTemperature);
void seatCoolerChanged(int seatCooler);
void seatHeaterChanged(int seatHeater);
void outsideTemperatureChanged(int outsideTemperature);
void outsideTemperatureLabelChanged(const QString & outsideTemperatureLabel);
void zoneSynchronizationChanged(bool zoneSynchronization);
void defrostChanged(bool defrost);
void recirculationModeChanged(ClimateModule:: RecirculationMode recirculationMode);
void recirculationChanged(bool recirculation);
void recirculationSensitivityLevelChanged(int recirculationSensitivityLevel);
void climateModeChanged(ClimateModule:: ClimateMode climateMode);
void automaticClimateFanIntensityLevelChanged(int automaticClimateFanIntensityLevel);
void airflowDirectionsChanged(ClimateModule:: AirflowDirections airflowDirections);
private :
ClimateControlBackendInterface * m_parent;
QString m_zone;
bool m_airConditioning;
bool m_heater;
int m_fanSpeedLevel;
int m_steeringWheelHeater;
qreal m_targetTemperature;
int m_seatCooler;
int m_seatHeater;
int m_outsideTemperature;
QString m_outsideTemperatureLabel;
bool m_zoneSynchronization;
bool m_defrost;
ClimateModule:: RecirculationMode m_recirculationMode;
bool m_recirculation;
int m_recirculationSensitivityLevel;
ClimateModule:: ClimateMode m_climateMode;
int m_automaticClimateFanIntensityLevel;
ClimateModule:: AirflowDirections m_airflowDirections;
};
class ClimateControlBackend : public ClimateControlBackendInterface
{
Q_OBJECT
Q_PROPERTY(bool airConditioning READ airConditioning WRITE setAirConditioning NOTIFY airConditioningChanged FINAL)
Q_PROPERTY(bool heater READ heater WRITE setHeater NOTIFY heaterChanged FINAL)
Q_PROPERTY(int fanSpeedLevel READ fanSpeedLevel WRITE setFanSpeedLevel NOTIFY fanSpeedLevelChanged FINAL)
Q_PROPERTY(int steeringWheelHeater READ steeringWheelHeater WRITE setSteeringWheelHeater NOTIFY steeringWheelHeaterChanged FINAL)
Q_PROPERTY(qreal targetTemperature READ targetTemperature WRITE setTargetTemperature NOTIFY targetTemperatureChanged FINAL)
Q_PROPERTY(int seatCooler READ seatCooler WRITE setSeatCooler NOTIFY seatCoolerChanged FINAL)
Q_PROPERTY(int seatHeater READ seatHeater WRITE setSeatHeater NOTIFY seatHeaterChanged FINAL)
Q_PROPERTY(int outsideTemperature READ outsideTemperature WRITE setOutsideTemperature NOTIFY outsideTemperatureChanged FINAL)
Q_PROPERTY(QString outsideTemperatureLabel READ outsideTemperatureLabel WRITE setOutsideTemperatureLabel NOTIFY outsideTemperatureLabelChanged FINAL)
Q_PROPERTY(bool zoneSynchronization READ zoneSynchronization WRITE setZoneSynchronization NOTIFY zoneSynchronizationChanged FINAL)
Q_PROPERTY(bool defrost READ defrost WRITE setDefrost NOTIFY defrostChanged FINAL)
Q_PROPERTY(ClimateModule:: RecirculationMode recirculationMode READ recirculationMode WRITE setRecirculationMode NOTIFY recirculationModeChanged FINAL)
Q_PROPERTY(bool recirculation READ recirculation WRITE setRecirculation NOTIFY recirculationChanged FINAL)
Q_PROPERTY(int recirculationSensitivityLevel READ recirculationSensitivityLevel WRITE setRecirculationSensitivityLevel NOTIFY recirculationSensitivityLevelChanged FINAL)
Q_PROPERTY(ClimateModule:: ClimateMode climateMode READ climateMode WRITE setClimateMode NOTIFY climateModeChanged FINAL)
Q_PROPERTY(int automaticClimateFanIntensityLevel READ automaticClimateFanIntensityLevel WRITE setAutomaticClimateFanIntensityLevel NOTIFY automaticClimateFanIntensityLevelChanged FINAL)
Q_PROPERTY(ClimateModule:: AirflowDirections airflowDirections READ airflowDirections WRITE setAirflowDirections NOTIFY airflowDirectionsChanged FINAL)
Q_PROPERTY(QQmlPropertyMap * zones READ zones CONSTANT)
public :
explicit ClimateControlBackend(QObject * parent = nullptr);
explicit ClimateControlBackend(QIviSimulationEngine * engine, QObject * parent = nullptr);
~ ClimateControlBackend();
QStringList availableZones() const override;
Q_INVOKABLE void initialize() override;
void addZone(const QString & zone);
ClimateControlZone* zoneAt(const QString & zone);
bool airConditioning() const ;
bool heater() const ;
int fanSpeedLevel() const ;
int steeringWheelHeater() const ;
qreal targetTemperature() const ;
int seatCooler() const ;
int seatHeater() const ;
int outsideTemperature() const ;
QString outsideTemperatureLabel() const ;
bool zoneSynchronization() const ;
bool defrost() const ;
ClimateModule:: RecirculationMode recirculationMode() const ;
bool recirculation() const ;
int recirculationSensitivityLevel() const ;
ClimateModule:: ClimateMode climateMode() const ;
int automaticClimateFanIntensityLevel() const ;
ClimateModule:: AirflowDirections airflowDirections() const ;
QQmlPropertyMap * zones() const { return m_zones; }
public Q_SLOTS:
void setAirConditioning(bool airConditioning) { setAirConditioning(airConditioning, QString ()); }
virtual void setAirConditioning(bool airConditioning, const QString & zone) override;
void setHeater(bool heater) { setHeater(heater, QString ()); }
virtual void setHeater(bool heater, const QString & zone) override;
void setFanSpeedLevel(int fanSpeedLevel) { setFanSpeedLevel(fanSpeedLevel, QString ()); }
virtual void setFanSpeedLevel(int fanSpeedLevel, const QString & zone) override;
void setSteeringWheelHeater(int steeringWheelHeater) { setSteeringWheelHeater(steeringWheelHeater, QString ()); }
virtual void setSteeringWheelHeater(int steeringWheelHeater, const QString & zone) override;
void setTargetTemperature(qreal targetTemperature) { setTargetTemperature(targetTemperature, QString ()); }
virtual void setTargetTemperature(qreal targetTemperature, const QString & zone) override;
void setSeatCooler(int seatCooler) { setSeatCooler(seatCooler, QString ()); }
virtual void setSeatCooler(int seatCooler, const QString & zone) override;
void setSeatHeater(int seatHeater) { setSeatHeater(seatHeater, QString ()); }
virtual void setSeatHeater(int seatHeater, const QString & zone) override;
void setOutsideTemperature(int outsideTemperature) { setOutsideTemperature(outsideTemperature, QString ()); }
virtual void setOutsideTemperature(int outsideTemperature, const QString & zone) override;
void setOutsideTemperatureLabel(const QString & outsideTemperatureLabel) { setOutsideTemperatureLabel(outsideTemperatureLabel, QString ()); }
virtual void setOutsideTemperatureLabel(const QString & outsideTemperatureLabel, const QString & zone) override;
void setZoneSynchronization(bool zoneSynchronization) { setZoneSynchronization(zoneSynchronization, QString ()); }
virtual void setZoneSynchronization(bool zoneSynchronization, const QString & zone) override;
void setDefrost(bool defrost) { setDefrost(defrost, QString ()); }
virtual void setDefrost(bool defrost, const QString & zone) override;
void setRecirculationMode(ClimateModule:: RecirculationMode recirculationMode) { setRecirculationMode(recirculationMode, QString ()); }
virtual void setRecirculationMode(ClimateModule:: RecirculationMode recirculationMode, const QString & zone) override;
void setRecirculation(bool recirculation) { setRecirculation(recirculation, QString ()); }
virtual void setRecirculation(bool recirculation, const QString & zone) override;
void setRecirculationSensitivityLevel(int recirculationSensitivityLevel) { setRecirculationSensitivityLevel(recirculationSensitivityLevel, QString ()); }
virtual void setRecirculationSensitivityLevel(int recirculationSensitivityLevel, const QString & zone) override;
void setClimateMode(ClimateModule:: ClimateMode climateMode) { setClimateMode(climateMode, QString ()); }
virtual void setClimateMode(ClimateModule:: ClimateMode climateMode, const QString & zone) override;
void setAutomaticClimateFanIntensityLevel(int automaticClimateFanIntensityLevel) { setAutomaticClimateFanIntensityLevel(automaticClimateFanIntensityLevel, QString ()); }
virtual void setAutomaticClimateFanIntensityLevel(int automaticClimateFanIntensityLevel, const QString & zone) override;
void setAirflowDirections(ClimateModule:: AirflowDirections airflowDirections) { setAirflowDirections(airflowDirections, QString ()); }
virtual void setAirflowDirections(ClimateModule:: AirflowDirections airflowDirections, const QString & zone) override;
protected :
bool m_airConditioning;
bool m_heater;
int m_fanSpeedLevel;
int m_steeringWheelHeater;
qreal m_targetTemperature;
int m_seatCooler;
int m_seatHeater;
int m_outsideTemperature;
QString m_outsideTemperatureLabel;
bool m_zoneSynchronization;
bool m_defrost;
ClimateModule:: RecirculationMode m_recirculationMode;
bool m_recirculation;
int m_recirculationSensitivityLevel;
ClimateModule:: ClimateMode m_climateMode;
int m_automaticClimateFanIntensityLevel;
ClimateModule:: AirflowDirections m_airflowDirections;
QQmlPropertyMap * m_zones;
};
#endif // CLIMATE_CLIMATECONTROLBACKEND_H_