Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

Modules/BehaviorControl/CommonXabsl2Symbols/JoystickSymbols.cpp

Go to the documentation of this file.
00001 /** 
00002 * @file JoystickSymbols.cpp
00003 *
00004 * Implementation of class JoystickSymbols.
00005 *
00006 * @author Matthias Jüngel
00007 */
00008 
00009 #include "JoystickSymbols.h"
00010 
00011 JoystickSymbols::JoystickSymbols(const BehaviorControlInterfaces& interfaces)
00012 : BehaviorControlInterfaces(interfaces)
00013 {
00014 }
00015 
00016 
00017 void JoystickSymbols::registerSymbols(Xabsl2Engine& engine)
00018 {
00019   // "joystick-data.x"
00020   engine.registerDecimalInputSymbol("joystick-data.x",&(joystickData.x));
00021   // "joystick-data.y"
00022   engine.registerDecimalInputSymbol("joystick-data.y",&(joystickData.y));
00023   // "joystick-data.z"
00024   engine.registerDecimalInputSymbol("joystick-data.z",&(joystickData.z));
00025   // "joystick-data.accel"
00026   engine.registerDecimalInputSymbol("joystick-data.accel",&(joystickData.accel));
00027   // "joystick-data.button"
00028   engine.registerEnumeratedInputSymbol("joystick-data.button",this,
00029     (int (Xabsl2FunctionProvider::*)())&JoystickSymbols::getJoystickButton);
00030   engine.registerEnumeratedInputSymbolEnumElement("joystick-data.button","no-button",0);
00031   //numOfJostickButtons-times
00032   engine.registerEnumeratedInputSymbolEnumElement("joystick-data.button","button1",1);
00033   engine.registerEnumeratedInputSymbolEnumElement("joystick-data.button","button2",2);
00034   engine.registerEnumeratedInputSymbolEnumElement("joystick-data.button","button3",3);
00035   engine.registerEnumeratedInputSymbolEnumElement("joystick-data.button","button4",4);
00036   engine.registerEnumeratedInputSymbolEnumElement("joystick-data.button","button5",5);
00037   engine.registerEnumeratedInputSymbolEnumElement("joystick-data.button","button6",6);
00038   engine.registerEnumeratedInputSymbolEnumElement("joystick-data.button","button7",7);
00039   engine.registerEnumeratedInputSymbolEnumElement("joystick-data.button","button8",8);
00040   engine.registerEnumeratedInputSymbolEnumElement("joystick-data.button","button9",9);
00041   engine.registerEnumeratedInputSymbolEnumElement("joystick-data.button","button10",10);
00042   engine.registerEnumeratedInputSymbolEnumElement("joystick-data.button","button11",11);
00043   engine.registerEnumeratedInputSymbolEnumElement("joystick-data.button","button12",12);
00044   // "joystick-data.coolie"
00045   engine.registerEnumeratedInputSymbol("joystick-data.coolie",(const int*)&(joystickData.coolie));
00046   engine.registerEnumeratedInputSymbolEnumElement("joystick-data.coolie","no-coolie",0);
00047   engine.registerEnumeratedInputSymbolEnumElement("joystick-data.coolie","N",1);
00048   engine.registerEnumeratedInputSymbolEnumElement("joystick-data.coolie","NE",2);
00049   engine.registerEnumeratedInputSymbolEnumElement("joystick-data.coolie","E",3);
00050   engine.registerEnumeratedInputSymbolEnumElement("joystick-data.coolie","SE",4);
00051   engine.registerEnumeratedInputSymbolEnumElement("joystick-data.coolie","S",5);
00052   engine.registerEnumeratedInputSymbolEnumElement("joystick-data.coolie","SW",6);
00053   engine.registerEnumeratedInputSymbolEnumElement("joystick-data.coolie","W",7);
00054   engine.registerEnumeratedInputSymbolEnumElement("joystick-data.coolie","NW",8);
00055   // "joystick-data.direct-special-action"
00056   engine.registerBooleanInputSymbol("joystick-data.direct-special-action",&(joystickData.directSpecialAction));
00057   // "joystick-data.special-action-id"
00058   engine.registerDecimalInputSymbol("joystick-data.special-action-id",this,
00059     (double (Xabsl2FunctionProvider::*)())&JoystickSymbols::getSpecialActionId);
00060   // "joystick-data.time-since-last-message"
00061   engine.registerDecimalInputSymbol("joystick-data.time-since-last-message",this,
00062     (double (Xabsl2FunctionProvider::*)())&JoystickSymbols::getJoystickTimeSinceLastMessage);
00063 }
00064 
00065 void JoystickSymbols::update()
00066 {
00067 }
00068 
00069 
00070 double JoystickSymbols::getJoystickTimeSinceLastMessage()
00071 {
00072   return (double)SystemCall::getTimeSince(joystickData.timeStamp);
00073 }
00074 
00075 int JoystickSymbols::getJoystickButton()
00076 {
00077   for (int i=0;i<numOfJoystickButtons;i++)
00078   {
00079     if ((joystickData.button >> i)&1)
00080     {
00081       //the button with the lowest number has the highest priority
00082       return i+1;
00083     }
00084   }
00085   return 0;
00086 }
00087 
00088 double JoystickSymbols::getSpecialActionId()
00089 {
00090   return (double)joystickData.specialActionID;
00091 }
00092 
00093 /*
00094 * Change Log
00095 * 
00096 * $Log: JoystickSymbols.cpp,v $
00097 * Revision 1.1.1.1  2004/05/22 17:16:58  cvsadm
00098 * created new repository GT2004_WM
00099 *
00100 * Revision 1.3  2004/04/26 15:58:59  thomas
00101 * added new project RobotRemote based on ATHAiboControl
00102 *
00103 * Revision 1.2  2004/03/08 00:58:56  roefer
00104 * Interfaces should be const
00105 *
00106 * Revision 1.1  2003/10/22 22:18:44  loetzsch
00107 * prepared the cloning of the GT2003BehaviorControl
00108 *
00109 * Revision 1.1  2003/10/06 13:39:28  cvsadm
00110 * Created GT2004 (M.J.)
00111 *
00112 * Revision 1.1.1.1  2003/07/02 09:40:23  cvsadm
00113 * created new repository for the competitions in Padova from the 
00114 * tamara CVS (Tuesday 2:00 pm)
00115 *
00116 * removed unused solutions
00117 *
00118 * Revision 1.1  2003/05/07 17:54:40  juengel
00119 * Added missing symbols to GT2003BehaviorControl.
00120 *
00121 */
00122 

Generated on Thu Sep 23 19:57:25 2004 for GT2004 by doxygen 1.3.6