Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Examples  

gadget::AnalogProxy Class Reference

A proxy class to analog devices, used by the Input Manager. More...

#include <AnalogProxy.h>

Inheritance diagram for gadget::AnalogProxy:

Inheritance graph
[legend]
Collaboration diagram for gadget::AnalogProxy:

Collaboration graph
[legend]
List of all members.

Public Methods

 AnalogProxy ()
 Constructor. More...

virtual ~AnalogProxy ()
virtual void updateData ()
 Updates the cached data copy from the device. More...

virtual vpr::Interval getTimeStamp () const
 Returns time of last update. More...

float getData () const
 Gets the current analog data value. More...

AnaloggetAnalogPtr ()
int getUnit () const
bool config (jccl::ConfigElementPtr element)
 Configures the proxy. More...

virtual InputgetProxiedInputDevice ()
 Returns a pointer to the base class of the devices being proxied. More...


Static Public Methods

std::string getElementType ()
 Returns the string rep of the element type used to config this device. More...


Detailed Description

A proxy class to analog devices, used by the Input Manager.

An AnalogProxy always points to an analog device and subUnit number. The inputgroup can therefore keep an array of these around and treat them as analog devices which only return a single subDevice's amount of data. (one float)

See also:
Analog

Definition at line 60 of file AnalogProxy.h.


Constructor & Destructor Documentation

gadget::AnalogProxy::AnalogProxy   [inline]
 

Constructor.

Definition at line 65 of file AnalogProxy.h.

00066       : mUnitNum(-1)
00067       , mData(-1.0f)
00068    {;}

virtual gadget::AnalogProxy::~AnalogProxy   [inline, virtual]
 

Definition at line 70 of file AnalogProxy.h.

00071    {;}


Member Function Documentation

virtual void gadget::AnalogProxy::updateData   [inline, virtual]
 

Updates the cached data copy from the device.

Reimplemented from gadget::Proxy.

Definition at line 74 of file AnalogProxy.h.

00075    {
00076       if(!isStupified())
00077       {
00078          mData = mTypedDevice->getAnalogData(mUnitNum);
00079       }
00080    }

virtual vpr::Interval gadget::AnalogProxy::getTimeStamp   const [inline, virtual]
 

Returns time of last update.

Implements gadget::Proxy.

Definition at line 83 of file AnalogProxy.h.

00084    {
00085       return mData.getTime();
00086    }

float gadget::AnalogProxy::getData   const [inline]
 

Gets the current analog data value.

Returns:
The analog data from the device.

Definition at line 92 of file AnalogProxy.h.

00093    {
00094       const float analogDefault(0.0f);
00095       if(isStupified())
00096       {
00097          return analogDefault;
00098       }
00099       else
00100       {
00101          return mData.getAnalog();
00102       }
00103    }

Analog* gadget::AnalogProxy::getAnalogPtr   [inline]
 

Definition at line 105 of file AnalogProxy.h.

00106    {
00107       if(isStupified())
00108       {
00109          return NULL;
00110       }
00111       else
00112       {
00113          return mTypedDevice;
00114       }
00115    }

int gadget::AnalogProxy::getUnit   const [inline]
 

Definition at line 117 of file AnalogProxy.h.

00118    {
00119       return mUnitNum;
00120    }

std::string gadget::AnalogProxy::getElementType   [static]
 

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 AnalogProxy.cpp.

Referenced by config.

00042 {
00043    return "analog_proxy";
00044 }

bool gadget::AnalogProxy::config jccl::ConfigElementPtr    element [virtual]
 

Configures the proxy.

Postcondition:
Proxy is configured (it is not registered yet though).
Returns:
success.

Reimplemented from gadget::Proxy.

Definition at line 46 of file AnalogProxy.cpp.

References gadgetDBG_INPUT_MGR, getElementType, gadget::TypedProxy< Analog >::mDeviceName, and gadget::TypedProxy< Analog >::refresh.

00047 {
00048 vpr::DebugOutputGuard dbg_output(gadgetDBG_INPUT_MGR, vprDBG_STATE_LVL,
00049                                  std::string("----------- configuring ANALOG PROXY -----------------\n"),
00050                                  std::string("----------- exit: configuring analog proxy -----------\n"));
00051    vprASSERT(element->getID() == getElementType());
00052 
00053    if ( ! Proxy::config(element) )
00054    {
00055       return false;
00056    }
00057 
00058    mUnitNum = element->getProperty<int>("unit");
00059    mDeviceName = element->getProperty<std::string>("device");
00060 
00061    refresh();     // Refresh the device now that we have something to point at
00062 
00063    return true;
00064 }

virtual Input* gadget::AnalogProxy::getProxiedInputDevice   [inline, virtual]
 

Returns a pointer to the base class of the devices being proxied.

Returns:
NULL if no device is proxied.

Implements gadget::Proxy.

Definition at line 126 of file AnalogProxy.h.

00127    {
00128       if((NULL == mTypedDevice) || (mStupified))
00129       {
00130          return NULL;
00131       }
00132 
00133       Input* ret_val = dynamic_cast<Input*>(mTypedDevice);
00134       vprASSERT((ret_val != NULL) && "Cross-cast in AnalogProxy failed");
00135       return ret_val;
00136    }


The documentation for this class was generated from the following files:
Generated on Sun May 2 14:26:54 2004 for Gadgeteer by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002