#include <X10Device.h>
Inheritance diagram for rwil::X10Device::

Public Methods | |
| bool | SupportsDim () |
| Support function that returns true if the device supports dimming. CURRENTLY always returns true. Needs to be fixed. More... | |
| std::string | GetStatus () const |
| Returns a string containing the cached value of how much power is being applied to the device 0-100. More... | |
| X10Device (const std::string &name, MessageList &output, char house, int number) | |
| Constructs an X10 device with the specified name attached to the specified x10 address. More... | |
| virtual ExecuteReturns::Returns | ExecuteMessage (const Message &msg) |
| Function to execute a message. This is called automatically. More... | |
| void | SetHouse (std::string house) |
| Sets the house letter a-p or A-P. More... | |
| void | SetNumber (int number) |
| Sets the unit number 1-16. More... | |
Protected Methods | |
| char | GetRealHouse (std::string house) const |
| Given a house letter returns what it is in Powerlinc terms. More... | |
| char | GetRealNumber (int unitnumber) const |
| Given a unit number returns what it is in Powerlinc terms. More... | |
Protected Attributes | |
| char | m_house |
| The house letter. More... | |
| int | m_number |
| The unit number. More... | |
| int | brightness |
| The cached value of the percent bright the device is. 0-100. More... | |
Definition at line 9 of file X10Device.h.
|
||||||||||||||||||||
|
Constructs an X10 device with the specified name attached to the specified x10 address.
Definition at line 118 of file X10Device.cpp.
|
|
|
Function to execute a message. This is called automatically.
Reimplemented from rwil::Device. Definition at line 3 of file X10Device.cpp. References brightness, GetRealHouse(), GetRealNumber(), m_house, m_number, rwil::Device::m_output, rwil::StringToInt(), and SupportsDim().
00004 {
00005 char house, number;
00006 char temp[2];
00007 temp[1] = '\0';
00008 temp[0]= m_house;
00009 house = GetRealHouse(temp);
00010 number = GetRealNumber(m_number);
00011 if(msg.GetCommand()=="dim")
00012 {
00013 int percent = StringToInt(msg.GetParam("percent"));
00014 assert((percent >= 0) && (percent <= 100));
00015 if(!SupportsDim()) assert(0);
00016 X10::send_Dim_X10(house, number, percent);
00017 int real_percent = X10::get_status_X10(house, number);
00018 if((real_percent < 0) || (abs(percent-real_percent) > 3))
00019 {
00020 return ExecuteReturns::PleaseRetry;
00021 }
00022 brightness = real_percent;
00023 }
00024 if(msg.GetCommand()=="off")
00025 {
00026
00027 if(!SupportsDim())
00028 {
00029 X10::send_X10(house, number, 'G');
00030 }
00031 else
00032 {
00033 X10::send_Dim_X10(house, number, 0);
00034 }
00035 int real_percent = X10::get_status_X10(house, number);
00036 if((real_percent < 0) || (abs(real_percent) > 3))
00037 {
00038 return ExecuteReturns::PleaseRetry;
00039 }
00040 brightness = 0;
00041 }
00042 if(msg.GetCommand()=="on")
00043 {
00044 if(!SupportsDim())
00045 {
00046 X10::send_X10(house, number, 'E');
00047 }
00048 else
00049 {
00050 X10::send_Dim_X10(house, number, 100);
00051 }
00052 int real_percent = X10::get_status_X10(house, number);
00053 if((real_percent < 0) || (abs(100-real_percent) > 3))
00054 {
00055 return ExecuteReturns::PleaseRetry;
00056 }
00057 brightness = 100;
00058 }
00059
00060 m_output.Add(EncapsulatingMessage("success", msg));
00061 return ExecuteReturns::DontRetry;
00062 }
|
|
|
Given a house letter returns what it is in Powerlinc terms.
Definition at line 64 of file X10Device.cpp. Referenced by ExecuteMessage().
00065 {
00066 char chouse = house[0];
00067 switch(chouse)
00068 {
00069 case 'a' : case 'A' : return 'F';
00070 case 'b' : case 'B' : return 'N';
00071 case 'c' : case 'C' : return 'B';
00072 case 'd' : case 'D' : return 'J';
00073 case 'e' : case 'E' : return 'A';
00074 case 'f' : case 'F' : return 'I';
00075 case 'g' : case 'G' : return 'E';
00076 case 'h' : case 'H' : return 'M';
00077 case 'i' : case 'I' : return 'G';
00078 case 'j' : case 'J' : return 'O';
00079 case 'k' : case 'K' : return 'C';
00080 case 'l' : case 'L' : return 'K';
00081 case 'm' : case 'M' : return '@';
00082 case 'n' : case 'N' : return 'H';
00083 case 'o' : case 'O' : return 'D';
00084 case 'p' : case 'P' : return 'L';
00085 }
00086 assert(0); //should never get here
00087 }
|
|
|
Given a unit number returns what it is in Powerlinc terms.
Definition at line 89 of file X10Device.cpp. Referenced by ExecuteMessage().
00090 {
00091 switch(unitnumber)
00092 {
00093 case 1 : return 'L';
00094 case 2 : return '\\';
00095 case 3 : return 'D';
00096 case 4 : return 'T';
00097 case 5 : return 'B';
00098 case 6 : return 'R';
00099 case 7 : return 'J';
00100 case 8 : return 'Z';
00101 case 9 : return 'N';
00102 case 10 : return '^';
00103 case 11 : return 'F';
00104 case 12 : return 'V';
00105 case 13 : return '@';
00106 case 14 : return 'P';
00107 case 15 : return 'H';
00108 case 16 : return 'X';
00109 }
00110 assert(0); //should never get here
00111 }
|
|
|
Returns a string containing the cached value of how much power is being applied to the device 0-100.
Reimplemented from rwil::Device. Definition at line 117 of file X10Device.cpp. References brightness, and rwil::IntToString().
00117 { return IntToString(brightness); }
|
|
|
Sets the house letter a-p or A-P.
Definition at line 113 of file X10Device.cpp. References m_house.
00113 { m_house = house[0]; }
|
|
|
Sets the unit number 1-16.
Definition at line 114 of file X10Device.cpp. References m_number.
00114 { m_number = number; }
|
|
|
Support function that returns true if the device supports dimming. CURRENTLY always returns true. Needs to be fixed.
Definition at line 116 of file X10Device.cpp. Referenced by ExecuteMessage().
00116 {return true; }
|
|
|
The cached value of the percent bright the device is. 0-100.
Definition at line 38 of file X10Device.h. Referenced by ExecuteMessage(), and GetStatus(). |
|
|
The house letter.
Definition at line 34 of file X10Device.h. Referenced by ExecuteMessage(), and SetHouse(). |
|
|
The unit number.
Definition at line 36 of file X10Device.h. Referenced by ExecuteMessage(), and SetNumber(). |
1.2.12 written by Dimitri van Heesch,
© 1997-2001