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

Public Methods | |
| Device (const std::string &name, MessageList &output) | |
| Create a device with a specified name and linked to a specific output queue. More... | |
| virtual | ~Device () |
| virtual std::string | GetStatus () const=0 |
| Return a device-type dependent value representing the status of the device. More... | |
| const std::string & | GetName () const |
| Get the name of the device. More... | |
| void | AddToQueue (const Message &msg) |
| Add a message to the execute queue for this device. More... | |
| virtual bool | Tick () |
| Execute the top message in the queue. More... | |
Protected Methods | |
| virtual ExecuteReturns::Returns | ExecuteMessage (const Message &msg)=0 |
| The function which performs the messages. More... | |
Protected Attributes | |
| MessageList & | m_output |
| The output MessageList, this is where success and failure messages are sent. More... | |
Private Attributes | |
| const std::string | m_name |
| The string name of the device. More... | |
| std::queue< Message > | m_queue |
| The execution queue of messages. More... | |
| unsigned | m_retries |
| The number of retries to perform. More... | |
| unsigned | m_currentRetry |
| The number of retries that have been performed on the current message. More... | |
A Device is an abstract class representing the concept of a device that can accept messages and act upon them.
Definition at line 19 of file Device.h.
|
||||||||||||
|
Create a device with a specified name and linked to a specific output queue.
Definition at line 5 of file Device.cpp. Referenced by rwil::X10Recv::X10Recv().
00005 : m_output(output), m_name(name), m_retries(2), m_currentRetry(0) {} |
|
|
Definition at line 7 of file Device.cpp.
00008 {
00009 }
|
|
|
Add a message to the execute queue for this device.
Definition at line 15 of file Device.cpp. References GetName(), and m_queue.
|
|
|
The function which performs the messages. This function is written so that it returns PleaseRetry if it wants the message to be sent to it again. Messages are only repeated a certain number of times(default: 3). This can be changed by send a SetRetriesMessage to the device.
Reimplemented in rwil::X10Device, and rwil::X10Recv. Referenced by Tick(). |
|
|
Get the name of the device.
Definition at line 10 of file Device.cpp. References m_name. Referenced by AddToQueue(), and rwil::X10Recv::Tick().
00011 {
00012 return m_name;
00013 }
|
|
|
Return a device-type dependent value representing the status of the device.
Reimplemented in rwil::X10Device, and rwil::X10Recv. |
|
|
Execute the top message in the queue.
Reimplemented in rwil::X10Recv. Definition at line 25 of file Device.cpp. References ExecuteMessage(), m_currentRetry, m_output, m_queue, m_retries, and rwil::StringToInt().
00026 {
00027 if(m_queue.empty()) return false;
00028
00029 if(m_queue.front().GetCommand() == "SetRetries")
00030 {
00031 try
00032 {
00033 m_retries = StringToInt(m_queue.front().GetParam("retries"));
00034 }
00035 catch(const char * e)
00036 {
00037 cout << e << endl;
00038 }
00039 m_queue.pop();
00040 return true;
00041 }
00042 else
00043 {
00044 ExecuteReturns::Returns retval;
00045 try
00046 {
00047 retval = ExecuteMessage(m_queue.front());
00048 }
00049 catch (const char *e)
00050 {
00051 m_output.Add(EncapsulatingMessage(e, m_queue.front()));
00052
00053 m_queue.pop();
00054 m_currentRetry = 0;
00055 return true;
00056 }
00057 catch (...)
00058 {
00059 m_output.Add(EncapsulatingMessage("Failed", m_queue.front()));
00060
00061 m_queue.pop();
00062 m_currentRetry = 0;
00063 return true;
00064 }
00065 if(retval==ExecuteReturns::DontRetry)
00066 {
00067 m_queue.pop();
00068 m_currentRetry = 0;
00069 }
00070 else
00071 {
00072 m_currentRetry++;
00073 if(m_currentRetry>(m_retries+1))
00074 {
00075 m_output.Add(FailedAfterRetryingMessage(m_queue.front()));
00076 m_queue.pop();
00077 m_currentRetry = 0;
00078 }
00079 }
00080 }
00081 return true;
00082 }
|
|
|
The number of retries that have been performed on the current message.
Definition at line 78 of file Device.h. Referenced by Tick(). |
|
|
The string name of the device.
Definition at line 72 of file Device.h. Referenced by GetName(). |
|
|
The output MessageList, this is where success and failure messages are sent.
Definition at line 58 of file Device.h. Referenced by rwil::X10Device::ExecuteMessage(), rwil::X10Recv::Tick(), and Tick(). |
|
|
The execution queue of messages.
Definition at line 74 of file Device.h. Referenced by AddToQueue(), and Tick(). |
|
|
The number of retries to perform.
Definition at line 76 of file Device.h. Referenced by Tick(). |
1.2.12 written by Dimitri van Heesch,
© 1997-2001