// ThermostatSample.cs
//
// Sample project to demonstrate Dwell.Net CodeDoc features.
//

using System;

namespace Home.ClimateControl
{
    
ThermostatSample Class

Controls a thermostat. (Sample code.)

Remarks

This class uses Fahrenheit degrees. To convert to Celcius, use FahrenheitToCelcius For example, FahrenheitToCelcius(32) returns zero.

    public class ThermostatSample
    {
        
ThermostatSample Constructor

Initializes an instance of this class. (Sample code.)

Parameters

address

The address of the thermostat to control.

        public ThermostatSample(string address)
        {
            // insert real code here
        }

        
ThermostatSample.SetThermostat Method

Changes the thermostat settings. (Sample code.)

Parameters

desiredTemperature

The desired temperature in Fahrenheit degrees.

airConditioning

true to turn on air conditioning, false to turn it off.

Return Value

true if the new settings are different than the previous settings.

Remarks

If airConditioning is set to true, the air conditioning system will only run when the room temperature rises above desiredTemperature.

Example

This example sets the thermostat to 72 degrees Fahrenheit. The current temperature is checked using the CurrentTemperature property; if it's is above 72, air conditioning is turned on.

C#
ThermostatSample thermostat = new ThermostatSample("1.2.3.4");
if (thermostat.CurrentTemperature > 72)
    thermostat.SetThermostat(72, true);
else
    thermostat.SetThermostat(72, false);

See Also
        public bool SetThermostat(double desiredTemperature, bool airConditioning)
        {
            // real code goes here
            return true;
        }

        
ThermostatSample.CurrentTemperature Property

Gets the current room temperature measured by the thermostat. (Sample code.)

Property Value

The temperature in Fahrenheit degrees.

        public double CurrentTemperature
        {
            get
            {
                return 68; // insert real code here
            }
        }

        
ThermostatSample.FahrenheitToCelcius Method

Converts Fahrenheit degrees to Celcius. (Sample code.)

Parameters

fahrenheit

Temperature to convert.

        public static double FahrenheitToCelcius(double fahrenheit)
        {
            return (fahrenheit - 32) * 5 / 9;
        }
    }

    
HomeDeviceException Class

Represents a failure of a home control device. (Sample code.)

See Also
    public class HomeDeviceException : Exception
    {
        
HomeDeviceException Constructor

Initializes an instance of this class. (Sample code.)

Parameters

address

The address of the device that failed.

        internal HomeDeviceException(string address)
        {
            // real code goes here
        }

        
HomeDeviceException.Address Property

Gets the address of the device that failed. (Sample code.)

        public string Address
        {
            get
            {
                return String.Empty; // real code goes here
            }
        }
    }
}