Qt IVI Generator Climate Example

import QtQuick 2.0
import example.ivi.climate.simulation 1.0

QtObject {
    property var settings : IviSimulator.findData(IviSimulator.simulationData, "ClimateControl")
    property bool defaultInitialized: false
    property var backend : ClimateControlBackend {

        function initialize() {
            print("ClimateControlSimulation INITIALIZE")
            if (!defaultInitialized) {
                IviSimulator.initializeDefault(settings, backend)
                defaultInitialized = true
            }
            Base.initialize()
        }

        function availableZones() {
            return settings.zones;
        }

        function setAirConditioning(airConditioning, zone) {
            if (IviSimulator.checkSettings(settings["airConditioning"], airConditioning, zone)) {
                if (zone) {
                    console.log("SIMULATION airConditioning for zone: " + zone + " changed to: " + airConditioning);
                    backend.zones[zone].airConditioning = airConditioning
                } else {
                    console.log("SIMULATION airConditioning changed to: " + airConditioning);
                    backend.airConditioning = airConditioning
                }
            } else {
                console.error("SIMULATION changing airConditioning is not possible: provided: " + airConditioning + " constraint: " + IviSimulator.constraint(settings["airConditioning"]));
            }
        }

        function setHeater(heater, zone) {
            if (IviSimulator.checkSettings(settings["heater"], heater, zone)) {
                if (zone) {
                    console.log("SIMULATION heater for zone: " + zone + " changed to: " + heater);
                    backend.zones[zone].heater = heater
                } else {
                    console.log("SIMULATION heater changed to: " + heater);
                    backend.heater = heater
                }
            } else {
                console.error("SIMULATION changing heater is not possible: provided: " + heater + " constraint: " + IviSimulator.constraint(settings["heater"]));
            }
        }

        function setFanSpeedLevel(fanSpeedLevel, zone) {
            if (IviSimulator.checkSettings(settings["fanSpeedLevel"], fanSpeedLevel, zone)) {
                if (zone) {
                    console.log("SIMULATION fanSpeedLevel for zone: " + zone + " changed to: " + fanSpeedLevel);
                    backend.zones[zone].fanSpeedLevel = fanSpeedLevel
                } else {
                    console.log("SIMULATION fanSpeedLevel changed to: " + fanSpeedLevel);
                    backend.fanSpeedLevel = fanSpeedLevel
                }
            } else {
                console.error("SIMULATION changing fanSpeedLevel is not possible: provided: " + fanSpeedLevel + " constraint: " + IviSimulator.constraint(settings["fanSpeedLevel"]));
            }
        }

        function setSteeringWheelHeater(steeringWheelHeater, zone) {
            if (IviSimulator.checkSettings(settings["steeringWheelHeater"], steeringWheelHeater, zone)) {
                if (zone) {
                    console.log("SIMULATION steeringWheelHeater for zone: " + zone + " changed to: " + steeringWheelHeater);
                    backend.zones[zone].steeringWheelHeater = steeringWheelHeater
                } else {
                    console.log("SIMULATION steeringWheelHeater changed to: " + steeringWheelHeater);
                    backend.steeringWheelHeater = steeringWheelHeater
                }
            } else {
                console.error("SIMULATION changing steeringWheelHeater is not possible: provided: " + steeringWheelHeater + " constraint: " + IviSimulator.constraint(settings["steeringWheelHeater"]));
            }
        }

        function setTargetTemperature(targetTemperature, zone) {
            if (IviSimulator.checkSettings(settings["targetTemperature"], targetTemperature, zone)) {
                if (zone) {
                    console.log("SIMULATION targetTemperature for zone: " + zone + " changed to: " + targetTemperature);
                    backend.zones[zone].targetTemperature = targetTemperature
                } else {
                    console.log("SIMULATION targetTemperature changed to: " + targetTemperature);
                    backend.targetTemperature = targetTemperature
                }
            } else {
                console.error("SIMULATION changing targetTemperature is not possible: provided: " + targetTemperature + " constraint: " + IviSimulator.constraint(settings["targetTemperature"]));
            }
        }

        function setSeatCooler(seatCooler, zone) {
            if (IviSimulator.checkSettings(settings["seatCooler"], seatCooler, zone)) {
                if (zone) {
                    console.log("SIMULATION seatCooler for zone: " + zone + " changed to: " + seatCooler);
                    backend.zones[zone].seatCooler = seatCooler
                } else {
                    console.log("SIMULATION seatCooler changed to: " + seatCooler);
                    backend.seatCooler = seatCooler
                }
            } else {
                console.error("SIMULATION changing seatCooler is not possible: provided: " + seatCooler + " constraint: " + IviSimulator.constraint(settings["seatCooler"]));
            }
        }

        function setSeatHeater(seatHeater, zone) {
            if (IviSimulator.checkSettings(settings["seatHeater"], seatHeater, zone)) {
                if (zone) {
                    console.log("SIMULATION seatHeater for zone: " + zone + " changed to: " + seatHeater);
                    backend.zones[zone].seatHeater = seatHeater
                } else {
                    console.log("SIMULATION seatHeater changed to: " + seatHeater);
                    backend.seatHeater = seatHeater
                }
            } else {
                console.error("SIMULATION changing seatHeater is not possible: provided: " + seatHeater + " constraint: " + IviSimulator.constraint(settings["seatHeater"]));
            }
        }

        function setOutsideTemperature(outsideTemperature, zone) {
            if (IviSimulator.checkSettings(settings["outsideTemperature"], outsideTemperature, zone)) {
                if (zone) {
                    console.log("SIMULATION outsideTemperature for zone: " + zone + " changed to: " + outsideTemperature);
                    backend.zones[zone].outsideTemperature = outsideTemperature
                } else {
                    console.log("SIMULATION outsideTemperature changed to: " + outsideTemperature);
                    backend.outsideTemperature = outsideTemperature
                }
            } else {
                console.error("SIMULATION changing outsideTemperature is not possible: provided: " + outsideTemperature + " constraint: " + IviSimulator.constraint(settings["outsideTemperature"]));
            }
        }

        function setOutsideTemperatureLabel(outsideTemperatureLabel, zone) {
            if (IviSimulator.checkSettings(settings["outsideTemperatureLabel"], outsideTemperatureLabel, zone)) {
                if (zone) {
                    console.log("SIMULATION outsideTemperatureLabel for zone: " + zone + " changed to: " + outsideTemperatureLabel);
                    backend.zones[zone].outsideTemperatureLabel = outsideTemperatureLabel
                } else {
                    console.log("SIMULATION outsideTemperatureLabel changed to: " + outsideTemperatureLabel);
                    backend.outsideTemperatureLabel = outsideTemperatureLabel
                }
            } else {
                console.error("SIMULATION changing outsideTemperatureLabel is not possible: provided: " + outsideTemperatureLabel + " constraint: " + IviSimulator.constraint(settings["outsideTemperatureLabel"]));
            }
        }

        function setZoneSynchronization(zoneSynchronization, zone) {
            if (IviSimulator.checkSettings(settings["zoneSynchronization"], zoneSynchronization, zone)) {
                if (zone) {
                    console.log("SIMULATION zoneSynchronization for zone: " + zone + " changed to: " + zoneSynchronization);
                    backend.zones[zone].zoneSynchronization = zoneSynchronization
                } else {
                    console.log("SIMULATION zoneSynchronization changed to: " + zoneSynchronization);
                    backend.zoneSynchronization = zoneSynchronization
                }
            } else {
                console.error("SIMULATION changing zoneSynchronization is not possible: provided: " + zoneSynchronization + " constraint: " + IviSimulator.constraint(settings["zoneSynchronization"]));
            }
        }

        function setDefrost(defrost, zone) {
            if (IviSimulator.checkSettings(settings["defrost"], defrost, zone)) {
                if (zone) {
                    console.log("SIMULATION defrost for zone: " + zone + " changed to: " + defrost);
                    backend.zones[zone].defrost = defrost
                } else {
                    console.log("SIMULATION defrost changed to: " + defrost);
                    backend.defrost = defrost
                }
            } else {
                console.error("SIMULATION changing defrost is not possible: provided: " + defrost + " constraint: " + IviSimulator.constraint(settings["defrost"]));
            }
        }

        function setRecirculationMode(recirculationMode, zone) {
            if (IviSimulator.checkSettings(settings["recirculationMode"], recirculationMode, zone)) {
                if (zone) {
                    console.log("SIMULATION recirculationMode for zone: " + zone + " changed to: " + recirculationMode);
                    backend.zones[zone].recirculationMode = recirculationMode
                } else {
                    console.log("SIMULATION recirculationMode changed to: " + recirculationMode);
                    backend.recirculationMode = recirculationMode
                }
            } else {
                console.error("SIMULATION changing recirculationMode is not possible: provided: " + recirculationMode + " constraint: " + IviSimulator.constraint(settings["recirculationMode"]));
            }
        }

        function setRecirculation(recirculation, zone) {
            if (IviSimulator.checkSettings(settings["recirculation"], recirculation, zone)) {
                if (zone) {
                    console.log("SIMULATION recirculation for zone: " + zone + " changed to: " + recirculation);
                    backend.zones[zone].recirculation = recirculation
                } else {
                    console.log("SIMULATION recirculation changed to: " + recirculation);
                    backend.recirculation = recirculation
                }
            } else {
                console.error("SIMULATION changing recirculation is not possible: provided: " + recirculation + " constraint: " + IviSimulator.constraint(settings["recirculation"]));
            }
        }

        function setRecirculationSensitivityLevel(recirculationSensitivityLevel, zone) {
            if (IviSimulator.checkSettings(settings["recirculationSensitivityLevel"], recirculationSensitivityLevel, zone)) {
                if (zone) {
                    console.log("SIMULATION recirculationSensitivityLevel for zone: " + zone + " changed to: " + recirculationSensitivityLevel);
                    backend.zones[zone].recirculationSensitivityLevel = recirculationSensitivityLevel
                } else {
                    console.log("SIMULATION recirculationSensitivityLevel changed to: " + recirculationSensitivityLevel);
                    backend.recirculationSensitivityLevel = recirculationSensitivityLevel
                }
            } else {
                console.error("SIMULATION changing recirculationSensitivityLevel is not possible: provided: " + recirculationSensitivityLevel + " constraint: " + IviSimulator.constraint(settings["recirculationSensitivityLevel"]));
            }
        }

        function setClimateMode(climateMode, zone) {
            if (IviSimulator.checkSettings(settings["climateMode"], climateMode, zone)) {
                if (zone) {
                    console.log("SIMULATION climateMode for zone: " + zone + " changed to: " + climateMode);
                    backend.zones[zone].climateMode = climateMode
                } else {
                    console.log("SIMULATION climateMode changed to: " + climateMode);
                    backend.climateMode = climateMode
                }
            } else {
                console.error("SIMULATION changing climateMode is not possible: provided: " + climateMode + " constraint: " + IviSimulator.constraint(settings["climateMode"]));
            }
        }

        function setAutomaticClimateFanIntensityLevel(automaticClimateFanIntensityLevel, zone) {
            if (IviSimulator.checkSettings(settings["automaticClimateFanIntensityLevel"], automaticClimateFanIntensityLevel, zone)) {
                if (zone) {
                    console.log("SIMULATION automaticClimateFanIntensityLevel for zone: " + zone + " changed to: " + automaticClimateFanIntensityLevel);
                    backend.zones[zone].automaticClimateFanIntensityLevel = automaticClimateFanIntensityLevel
                } else {
                    console.log("SIMULATION automaticClimateFanIntensityLevel changed to: " + automaticClimateFanIntensityLevel);
                    backend.automaticClimateFanIntensityLevel = automaticClimateFanIntensityLevel
                }
            } else {
                console.error("SIMULATION changing automaticClimateFanIntensityLevel is not possible: provided: " + automaticClimateFanIntensityLevel + " constraint: " + IviSimulator.constraint(settings["automaticClimateFanIntensityLevel"]));
            }
        }

        function setAirflowDirections(airflowDirections, zone) {
            if (IviSimulator.checkSettings(settings["airflowDirections"], airflowDirections, zone)) {
                if (zone) {
                    console.log("SIMULATION airflowDirections for zone: " + zone + " changed to: " + airflowDirections);
                    backend.zones[zone].airflowDirections = airflowDirections
                } else {
                    console.log("SIMULATION airflowDirections changed to: " + airflowDirections);
                    backend.airflowDirections = airflowDirections
                }
            } else {
                console.error("SIMULATION changing airflowDirections is not possible: provided: " + airflowDirections + " constraint: " + IviSimulator.constraint(settings["airflowDirections"]));
            }
        }
    }
}