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


Public Methods | |
| SimAnalog () | |
| Default Constructor. More... | |
| virtual | ~SimAnalog () |
| Destructor. More... | |
| virtual bool | config (jccl::ConfigElementPtr element) |
| Just call base class config. More... | |
| bool | startSampling () |
| These functions don't do anything. More... | |
| bool | stopSampling () |
| bool | sample () |
| virtual void | updateData () |
| Updates the data. More... | |
| virtual std::vector< KeyModPair > | getUpKeys () |
| virtual std::vector< KeyModPair > | getDownKeys () |
| void | operator delete (void *p) |
| Invokes the global scope delete operator. More... | |
Static Public Methods | |
| std::string | getElementType () |
Protected Methods | |
| virtual void | destroy () |
| Deletes this object. More... | |
It allows any number of simulated analog devices to be created.
This class should not be used directly by the user.
Definition at line 57 of file SimAnalog.h.
|
|
Default Constructor.
Definition at line 40 of file SimAnalog.cpp.
00041 : mAnaStep(0.0f)
00042 , mInitialValue(0.0f)
00043 {
00044 //vprDEBUG(vprDBG_ALL, vprDBG_VERB_LVL)<<"*** SimAnalog::SimPinchGlove()\n"<< vprDEBUG_FLUSH;
00045 }
|
|
|
Destructor.
Definition at line 48 of file SimAnalog.cpp.
00049 {
00050 //vprDEBUG(vprDBG_ALL, vprDBG_VERB_LVL)<<"*** SimAnalog::~SimPinchGlove()\n"<< vprDEBUG_FLUSH;
00051 }
|
|
|
Just call base class config.
Reimplemented from gadget::Analog. Definition at line 58 of file SimAnalog.cpp.
00059 {
00060 //vprDEBUG(vprDBG_ALL, vprDBG_VERB_LVL)<<"*** SimAnalog::config()\n"<< vprDEBUG_FLUSH;
00061 if (! (Input::config(element) && Analog::config(element) &&
00062 SimInput::config(element)) )
00063 {
00064 return false;
00065 }
00066
00067 std::vector<jccl::ConfigElementPtr> key_inc_list, key_dec_list;
00068
00069 int key_count = element->getNum("increment_keypress");
00070
00071 for ( int i = 0; i < key_count; ++i )
00072 {
00073 key_inc_list.push_back(element->getProperty<jccl::ConfigElementPtr>("increment_keypress", i));
00074 }
00075
00076 key_count = element->getNum("decrement_keypress");
00077
00078 for ( int i = 0; i < key_count; ++i )
00079 {
00080 key_dec_list.push_back(element->getProperty<jccl::ConfigElementPtr>("decrement_keypress", i));
00081 }
00082
00083 mSimKeysUp = readKeyList(key_inc_list);
00084 mSimKeysDown = readKeyList(key_dec_list);
00085
00086 mAnaStep = element->getProperty<float>("delta");
00087 mInitialValue = element->getProperty<float>("initial_value");
00088
00089 // Initialize all the data to the inital_value
00090 size_t num_pairs = mSimKeysUp.size();
00091 mAnaData = std::vector<AnalogData>(num_pairs);
00092 for (size_t i=0; i<num_pairs; ++i)
00093 {
00094 mAnaData[i].setAnalog(mInitialValue);
00095 }
00096
00097 return true;
00098 }
|
|
|
These functions don't do anything.
Definition at line 67 of file SimAnalog.h.
00067 { return 1; }
|
|
|
Definition at line 68 of file SimAnalog.h.
00068 { return 1; }
|
|
|
Definition at line 69 of file SimAnalog.h.
00069 { return 1; }
|
|
|
Updates the data.
Definition at line 100 of file SimAnalog.cpp. References gadget::Analog::addAnalogSample, gadget::Analog::getMax, gadget::Analog::getMin, gadget::Analog::normalizeMinToMax, and gadget::Analog::swapAnalogBuffers.
00101 {
00102 //vprDEBUG(vprDBG_ALL, vprDBG_VERB_LVL)<<"*** SimAnalog::updateData()\n"<< vprDEBUG_FLUSH;
00103
00104 // Make an list of the data that will be normalized
00105 std::vector<AnalogData> norm_data(mAnaData.size());
00106
00107 // -- Update analog data --- //
00108 for (unsigned int i = 0; i < mSimKeysUp.size(); ++i)
00109 {
00110 mAnaData[i].setTime();
00111 mAnaData[i].setAnalog(mAnaData[i].getAnalog()
00112 + (float)checkKeyPair(mSimKeysUp[i]) * mAnaStep);
00113 mAnaData[i].setAnalog(mAnaData[i].getAnalog()
00114 - (float)checkKeyPair(mSimKeysDown[i]) * mAnaStep);
00115
00116 // Clamp to the min/max range
00117 mAnaData[i].setAnalog(gmtl::Math::clamp(mAnaData[i].getAnalog(),
00118 getMin(), getMax()));
00119
00120 float normalized_value;
00121 normalizeMinToMax(mAnaData[i].getAnalog(), normalized_value);
00122
00123 // Set the normalized data
00124 norm_data[i] = normalized_value;
00125 norm_data[i].setTime();
00126 }
00127
00128 // Locks and then swaps the indices.
00129 addAnalogSample(norm_data);
00130 swapAnalogBuffers();
00131 }
|
|
|
Definition at line 53 of file SimAnalog.cpp.
00054 {
00055 return "simulated_analog_device";
00056 }
|
|
|
Definition at line 76 of file SimAnalog.h.
00076 { return mSimKeysUp; }
|
|
|
Definition at line 77 of file SimAnalog.h.
00077 { return mSimKeysDown; }
|
|
|
Invokes the global scope delete operator. This is required for proper releasing of memory in DLLs on Win32. Definition at line 83 of file SimAnalog.h.
00084 {
00085 ::operator delete(p);
00086 }
|
|
|
Deletes this object. This is an implementation of the pure virtual gadget::Input::destroy() method. Definition at line 93 of file SimAnalog.h.
00094 {
00095 delete this;
00096 }
|
1.2.14 written by Dimitri van Heesch,
© 1997-2002