#include <DigitalProxy.h>
Inheritance diagram for gadget::DigitalProxy:


Public Methods | |
| virtual void | updateData () |
| virtual vpr::Interval | getTimeStamp () const |
| Returns time of last update. More... | |
| gadget::Digital::State | getData () const |
| Get the digital data. More... | |
| DigitalData * | getDigitalData () |
| Digital * | getDigitalPtr () |
| int | getUnit () const |
| bool | config (jccl::ConfigElementPtr element) |
| Configures the proxy. More... | |
| virtual Input * | getProxiedInputDevice () |
| Returns a pointer to the base class of the devices being proxied. More... | |
Construction/Destruction | |
| DigitalProxy () | |
| virtual | ~DigitalProxy () |
Static Public Methods | |
| std::string | getElementType () |
| Returns the string rep of the element type used to config this device. More... | |
A DigitalProxy always points to a digital device and subUnit number, the inputgroup can therefore keep an array of these around and treat them as digital devices which only return a single subDevice's amount of data. (one int)
Definition at line 52 of file DigitalProxy.h.
|
|
Definition at line 58 of file DigitalProxy.h.
00059 : mUnitNum(-1), mData(0)
00060 {;}
|
|
|
Definition at line 62 of file DigitalProxy.h.
00063 {;}
|
|
|
Reimplemented from gadget::Proxy. Definition at line 68 of file DigitalProxy.cpp. References gadget::Proxy::isStupified, and gadget::TypedProxy< Digital >::mTypedDevice.
00069 {
00070
00071 if (!isStupified())
00072 {
00073 int old_state = mData.getDigital();
00074 mData = mTypedDevice->getDigitalData(mUnitNum);
00075 int new_state = mData.getDigital();
00076
00077 if (Digital::OFF == old_state)
00078 {
00079 if (new_state) // Button now pressed
00080 mData = Digital::TOGGLE_ON;
00081 else // Button now released
00082 mData = Digital::OFF;
00083 }
00084 else if (Digital::ON == old_state)
00085 {
00086 if (new_state) // Button now pressed
00087 mData = Digital::ON;
00088 else // Button now released
00089 mData = Digital::TOGGLE_OFF;
00090 }
00091 else if (Digital::TOGGLE_ON == old_state)
00092 {
00093 if (new_state) // Button now pressed
00094 mData = Digital::ON;
00095 else // Button now released
00096 mData = Digital::TOGGLE_OFF;
00097 }
00098 else if (Digital::TOGGLE_OFF == old_state)
00099 {
00100 if (new_state) // Button now pressed
00101 mData = Digital::TOGGLE_ON;
00102 else // Button now released
00103 mData = Digital::OFF;
00104 }
00105 }
00106 }
|
|
|
Returns time of last update.
Implements gadget::Proxy. Definition at line 69 of file DigitalProxy.h.
00070 {
00071 return mData.getTime();
00072 }
|
|
|
Get the digital data.
Digital::OFF: Button not pressed, and was not pressed last update either. The identifiers are defined so that a simple test for non-zero means the button is pressed in some way.
Definition at line 88 of file DigitalProxy.h. References gadget::Digital::State.
00089 {
00090 // If we're stupified, return gadget::Digital::OFF. Otherwise, return
00091 // the current digital value.
00092 return (isStupified() ? Digital::OFF
00093 : (gadget::Digital::State) mData.getDigital());
00094 }
|
|
|
Definition at line 96 of file DigitalProxy.h.
00097 {
00098 return &mData;
00099 }
|
|
|
Definition at line 101 of file DigitalProxy.h.
00102 {
00103 // If we're stupified, return NULL. Otherwise, return mTypedDevice.
00104 return (isStupified() ? NULL : mTypedDevice);
00105 }
|
|
|
Definition at line 107 of file DigitalProxy.h.
00108 {
00109 return mUnitNum;
00110 }
|
|
|
Returns the string rep of the element type used to config this device. Used by the Input Manager to find elements that construct devices. Reimplemented from gadget::Proxy. Definition at line 41 of file DigitalProxy.cpp. Referenced by config.
00042 {
00043 return "digital_proxy";
00044 }
|
|
|
Configures the proxy.
Reimplemented from gadget::Proxy. Definition at line 46 of file DigitalProxy.cpp. References gadgetDBG_INPUT_MGR, getElementType, gadget::TypedProxy< Digital >::mDeviceName, and gadget::TypedProxy< Digital >::refresh.
00047 {
00048 vpr::DebugOutputGuard dbg_output(gadgetDBG_INPUT_MGR, vprDBG_STATE_LVL,
00049 std::string("----------- configuring DIGITAL PROXY -----------------\n"),
00050 std::string("----------- exit: configuring digital proxy -----------\n"));
00051
00052 vprASSERT(element->getID() == getElementType());
00053
00054 if( ! Proxy::config(element) )
00055 {
00056 return false;
00057 }
00058
00059 mUnitNum = element->getProperty<int>("unit");
00060 mDeviceName = element->getProperty<std::string>("device");
00061
00062 refresh();
00063 return true;
00064 }
|
|
|
Returns a pointer to the base class of the devices being proxied.
Implements gadget::Proxy. Definition at line 116 of file DigitalProxy.h.
00117 {
00118 if((NULL == mTypedDevice) || (mStupified))
00119 {
00120 return NULL;
00121 }
00122
00123 Input* ret_val = dynamic_cast<Input*>(mTypedDevice);
00124 vprASSERT((ret_val != NULL) && "Cross-cast in DigitalProxy failed");
00125 return ret_val;
00126 }
|
1.2.14 written by Dimitri van Heesch,
© 1997-2002