Exemplo n.º 1
0
        /// <summary>
        /// Sets the temperature for the passenger's climate control
        /// </summary>
        /// <param name="desiredTemperature">The value to which the climate control should be set</param>
        public void HvacSetPassengerLevel(int desiredTemperature)
        {
            decimal            convertedLevel;
            HvacSetLevelResult result;
            string             rounded;

            try
            {
                HvacSetTempUnits();

                if (Settings.TemperatureUnits == "F")
                {
                    rounded = Calculators.GetTempCelsiusFromFarenheit(Convert.ToDecimal(desiredTemperature)).ToString("0.##");
                }
                else
                {
                    rounded = desiredTemperature.ToString();
                }

                convertedLevel = Convert.ToDecimal(rounded);
                result         = new HvacSetLevelResult(convertedLevel, HvacSetLevelResult.TempLocations.Passenger);
                result.GetResult();
                CrestronEnvironment.Sleep(2000);
                result.GetResult();
            }
            catch (Exception ex)
            {
                CrestronConsole.PrintLine("SimplTeslaCar.Main.HvacSetPassengerLevel()::Error Setting Passenger HVAC: " + ex.ToString());
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Gets the climate control's set value, based on the user's preferred units as set in the car's UI
        /// </summary>
        /// <param name="desiredTemperature">The value to be converted</param>
        private decimal HvacGetConvertedLevel(int desiredTemperature)
        {
            decimal result;

            HvacSetTempUnits();

            result = Convert.ToDecimal(Calculators.GetTemperatureValue(desiredTemperature, Settings.TemperatureUnits));

            return(result);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Converts a temperature value from the vehicle to the user preferred unit (celsius or farenheit, as defined in the car's configuration by the user)
        /// </summary>
        /// <param name="temp">The value to be converted</param>
        /// <param name="tempUnits">The user preferred unit type</param>
        public static string GetTemperatureValue(decimal temp, string tempUnits)
        {
            decimal calcTemp;

            if (tempUnits == "F")
            {
                calcTemp = Calculators.GetTempFarenheitFromCelsius(temp);
            }
            else
            {
                calcTemp = temp;
            }

            return(calcTemp.ToString());
        }