TarzaNN
TarzaNN neural network simulator
C:/Users/albertlr/projects/TarzaNN/TarzaNN/InputSocketFeaturePlane.h
Go to the documentation of this file.
00001 #ifndef INPUTSOCKETFEATUREPLANE_H_INCLUDED
00002 #define INPUTSOCKETFEATUREPLANE_H_INCLUDED
00003 
00004 
00005 /************************************************************************************/
00006 //Network commands for Trish head
00007 
00008 #define MAXLEN 1000
00009 
00010 //Axis
00011 #define LEYE_V 1
00012 #define LEYE_H 2
00013 #define HEAD   3
00014 #define REYE_H 4
00015 #define REYE_V 5
00016 
00017 
00018 //Motion Controller Constants
00019 #define RIGHT_EYE_V             1       //move right eye up or down
00020 #define RIGHT_EYE_H             2       //move right eye to the left or to the right
00021 #define LEFT_EYE_V              4       //move left eye up or down
00022 #define LEFT_EYE_H              8       //move left eye to the left or to the right
00023 #define ONLY_HEAD               16      //move head (but not the eyes)
00024 #define HEAD_AND_EYES   32      //move head and eyes together
00025 #define LEFT_EYE                33      //move left eye (vertical and horizontal motion)
00026 #define RIGHT_EYE               34      //move right eye (vertical and horizontal motion)
00027 #define AXIS_POS                50      //get position of an axis
00028 #define INVALID                 234     //invalid command
00029 #define MC_ERROR                235     //error occured
00030 #define MC_OK                   236     //command executed
00031 
00032 #define EYE_H_SCALE 45.08
00033 #define EYE_V_SCALE 100.12
00034 #define HEAD_H_SCALE = 125.06
00035 
00036 //Frame grabber settings
00037 #define GRAB                    1
00038 #define SNAP                    2
00039 
00040 #define RGB32                   1
00041 #define RGB24                   2
00042 
00043 #define GREYLG                  0
00044 #define GREYSM                  1
00045 #define COLORLG                 2
00046 #define COLORSM                 3
00047 
00048 //Frame grabber commands
00049 #define GETFRAMES               128     //get N frames
00050 #define INIT                    129     //initialize frame grabber
00051 
00052 #define FG_OK                   235     //command executed
00053 #define FG_ERROR                236     //command failed
00054 
00055 /************************************************************************************/
00056 
00057 #include "InputControllerAbstract.h"
00058 
00059 #include "common.h"
00060 #include <QString>
00061 #include <QByteArray>
00062 #include <QMutex>
00063 #include <q3socketdevice.h>
00064 #include <QHostAddress>
00065 #include <QImage>
00066 #include <QPixmap>
00067 
00068 class InputSocketFeaturePlane : public InputControllerAbstract {
00069         friend class FeaturePlaneFactory;
00070 
00071 protected:
00072     InputSocketFeaturePlane( Network* net, int l, QString* n, int w, int h, NotifyStrategyAbstract* notify,
00073                             const char* controllerHost = "130.63.92.218", 
00074                             int controllerPort = 4000, 
00075                             const char* imageHost = "130.63.92.218", 
00076                             int imagePort = 5000);
00077 
00078 public:
00079     ~InputSocketFeaturePlane();
00080     OutputImage* getHeadImage();
00081     bool moveHead(int deltaX, int deltaY, bool notify=true);
00082 
00083 private:
00084     InputSocketFeaturePlane();
00085     void initializeImageSocket();
00086     void initializeControllerSocket();
00087 
00088     QHostAddress controllerHost;
00089     int controllerPort;
00090     Q3SocketDevice controllerSocket;
00091     QMutex controllerSocketMutex;
00092 
00093     QHostAddress imageHost;
00094     int imagePort;
00095     Q3SocketDevice imageSocket; 
00096     QMutex imageSocketMutex;
00097 
00098     int imageH,imageW,imageD; //width, height, depth
00099     unsigned char* imageData;
00100     unsigned char* imageDataR, *imageDataG, *imageDataB;    
00101 };
00102 #endif // INPUTSOCKETFEATUREPLANE_H_INCLUDED
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines