#include <X10Recv.h>
Inheritance diagram for rwil::X10Recv::
Public Methods | |
std::string | GetStatus () const |
Returns a string containing the cached value of how many messages have been recieved. More... | |
X10Recv (const std::string &name, MessageList &output) | |
Constructs an X10 Recv object. More... | |
virtual ExecuteReturns::Returns | ExecuteMessage (const Message &msg) |
Function to execute a message. This is called automatically. do nothing. More... | |
virtual bool | Tick () |
Look for an inbound message coming in from the X10 bus. More... | |
Protected Methods | |
std::string | GetRealHouse (char house) const |
Given a house letter returns what it is in Powerlinc terms Given a house letter in Powerlinc terms return its value in normal terms. More... | |
std::string | GetRealNumber (char unitnumber) const |
Given a unit number in Powerlinc terms return its value in normal terms. More... | |
std::string | GetMessageType (char type) const |
Given a message type in Powerlinc terms return its value in normal terms. More... | |
Protected Attributes | |
int | messages |
The cached value of how many messages have been recieved. More... | |
std::map< std::string, std::string > | activenums |
Which unit number is active. More... |
Definition at line 10 of file X10Recv.h.
|
Constructs an X10 Recv object.
Definition at line 16 of file X10Recv.h. References rwil::Device::Device(), and messages.
|
|
Function to execute a message. This is called automatically. do nothing.
Reimplemented from rwil::Device. Definition at line 18 of file X10Recv.h.
00018 {} |
|
Given a message type in Powerlinc terms return its value in normal terms.
Definition at line 63 of file X10Recv.cpp. Referenced by Tick().
00064 { 00065 switch(type) 00066 { 00067 case 'A' : return "all-units-off"; 00068 case 'C' : return "all-lights-on"; 00069 case 'E' : return "on"; 00070 case 'G' : return "off"; 00071 case 'I' : return "dim"; 00072 case 'K' : return "bright"; 00073 case 'M' : return "all-lights-off"; 00074 case 'O' : return "extended-code"; 00075 case 'Q' : return "hail-request"; 00076 case 'W' : return "pre-set-dim-high"; 00077 case 'U' : return "pre-set-dim-low"; 00078 case 'Y' : return "extended-data"; 00079 case '[' : return "status-on"; 00080 case ']' : return "status-off"; 00081 case '_' : return "status-request"; 00082 } 00083 return ""; 00084 assert(0); 00085 } |
|
Given a house letter returns what it is in Powerlinc terms Given a house letter in Powerlinc terms return its value in normal terms.
Definition at line 13 of file X10Recv.cpp. Referenced by Tick().
00014 { 00015 switch(house) 00016 { 00017 case 'F' : return "A"; 00018 case 'N' : return "B"; 00019 case 'B' : return "C"; 00020 case 'J' : return "D"; 00021 case 'A' : return "E"; 00022 case 'I' : return "F"; 00023 case 'E' : return "G"; 00024 case 'M' : return "H"; 00025 case 'G' : return "I"; 00026 case 'O' : return "J"; 00027 case 'C' : return "K"; 00028 case 'K' : return "L"; 00029 case '@' : return "M"; 00030 case 'H' : return "N"; 00031 case 'D' : return "O"; 00032 case 'L' : return "P"; 00033 } 00034 return ""; 00035 assert(0); //should never get here 00036 } |
|
Given a unit number in Powerlinc terms return its value in normal terms.
Definition at line 38 of file X10Recv.cpp. Referenced by Tick().
00039 { 00040 switch(unitnumber) 00041 { 00042 case 'L' : return "1"; 00043 case '\\' : return "2"; 00044 case 'D' : return "3"; 00045 case 'T' : return "4"; 00046 case 'B' : return "5"; 00047 case 'R' : return "6"; 00048 case 'J' : return "7"; 00049 case 'Z' : return "8"; 00050 case 'N' : return "9"; 00051 case '^' : return "10"; 00052 case 'F' : return "11"; 00053 case 'V' : return "12"; 00054 case '@' : return "13"; 00055 case 'P' : return "14"; 00056 case 'H' : return "15"; 00057 case 'X' : return "16"; 00058 } 00059 return ""; 00060 assert(0); //should never get here 00061 } |
|
Returns a string containing the cached value of how many messages have been recieved.
Reimplemented from rwil::Device. Definition at line 14 of file X10Recv.h. References rwil::IntToString(), and messages.
00014 { return IntToString( messages ); } |
|
Look for an inbound message coming in from the X10 bus.
Reimplemented from rwil::Device. Definition at line 87 of file X10Recv.cpp. References activenums, rwil::SerialOp::configure_port(), rwil::SerialOp::fd, GetMessageType(), rwil::Device::GetName(), GetRealHouse(), GetRealNumber(), rwil::Device::m_output, and rwil::SerialOp::open_port().
00088 { 00089 std::string messagetype; 00090 std::string unitnumber; 00091 std::string house; 00092 char buf[5]; 00093 //check to see if 5 bytes .. or more are sitting there. 00094 int waiting; 00095 if(fd==0) 00096 { 00097 open_port(); 00098 configure_port(); 00099 } 00100 00101 while(true) 00102 { 00103 int n; 00104 ioctl(fd, FIONREAD, &waiting); 00105 if(waiting < 5) return false; 00106 00107 n = read(fd, buf, 1); 00108 if(n < 0) return false; 00109 if(n == 1) 00110 { 00111 if((buf[0] == 0x58) || (buf[0] == 0x78)) 00112 break; 00113 } 00114 } 00115 00116 //read 5 bytes 00117 int n; 00118 int totalread = 0; 00119 while(totalread < 4) 00120 { 00121 n = read(fd, buf + 1 + totalread, 4-totalread); 00122 if(n < 0) return false; 00123 totalread += n; 00124 } 00125 house = GetRealHouse(buf[1]); 00126 unitnumber = GetRealNumber(buf[2]); 00127 messagetype = GetMessageType(buf[2]); 00128 00129 00130 if(!((buf[4] == 0x0d) || (buf[4] == 0x0a))) return false; 00131 if(house.length() == 0) return false; 00132 if((unitnumber.length() == 0) && (messagetype.length() == 0)) return false; 00133 if(unitnumber.length()) 00134 { 00135 activenums[house] = unitnumber; 00136 return true; 00137 } 00138 if(activenums[house].length() == 0) return true; 00139 //If here we've got a complete message. 00140 Message msg(GetName(), messagetype); 00141 msg.SetParam("house", house); 00142 msg.SetParam("number", activenums[house]); 00143 m_output.Add(msg); 00144 //verify that its a message 00145 00146 } |
|
Which unit number is active.
Definition at line 40 of file X10Recv.h. Referenced by Tick(). |
|
The cached value of how many messages have been recieved.
|