MGF Server  2.1
Multigaze framework server
 All Classes Functions
gdtypes.h
1 /*-----------------------------------------------------------------------------
2  * This file defines custom data type, used to store and process gaze data
3  */
4 #pragma once
5 
6 #ifdef _WIN32
7 #include <ctime>
8 #endif
9 
10 #include "gdproto.h"
11 #include <ostream>
12 
13 using namespace std;
14 
15 #define MAX_NICKNAME_LENGTH 8
16 #define MAX_DESCRIPTION_LENGTH 256
17 
18 #define DEFAULT_LOG_FOLDER "C:\\GDLOG"
19 
20 //Gaze Data Items' types
21 typedef enum _gdElementType
22 {
23  GDT_UNDEFINED,
24  GDT_SAMPLE,
25  GDT_SINGLESAMPLE,
26  GDT_FIXATION,
27  GDT_BLINK,
28  GDT_EVENT
29 } gdElementType;
30 
31 //Gaze Data Items' types
32 typedef enum _gdLogRecordType
33 {
34  LRT_UNDEFINED = 0x000,
35  LRT_GAZEDATA = 0x001,
36  LRT_MESSAGE = 0x002,
37  LRT_REGCLIENT = 0x003,
38  LRT_UNREGCLIENT = 0x004,
39  LRT_POKECLIENT = 0x005,
40  LRT_STARTTRACK = 0x006,
41  LRT_SETNICKNAME = 0x007,
42  LRT_SETDESCRIPT = 0x008
43 } gdLogRecordType;
44 
45 typedef enum _gdEye
46 {
47  GDE_UNDEFINED = -1,
48  GDE_LEFT = 0,
49  GDE_RIGHT = 1
50 } gdEye;
51 
52 
53 /****************************************************************************/
54 /* Protocol messages gaze data types */
55 /****************************************************************************/
56 
60 typedef struct _gdSingleSample
61 {
62  CARD32 number; //ordinal number
63  CARD32 time; //time offset from the start of the record
64  CARD16 eye; //event code
65  CARD16 pad; //reserved
66  CARD32 x; //x coordinate of the eye
67  CARD32 y; //y coordinate of the eye
68  CARD32 pupil; //pupil size
70 
71 #define sz_gdSingleSample 24
72 
76 typedef struct _gdFixation
77 {
78  CARD32 number; //ordinal number
79  CARD32 time; //time offset from the start of the record
80  CARD32 duration; //fixation duration
81  CARD16 eye; //eye number
82  CARD16 pad;
83  CARD32 x; //x coordinate of the eye
84  CARD32 y; //y coordinate of the eye
85 } gdFixation;
86 
87 #define sz_gdFixation 24
88 
92 typedef struct _gdBlink
93 {
94  CARD32 number; //ordinal number
95  CARD32 time; //time offset from the start of the record
96  CARD32 duration; //fixation duration
97  CARD16 eye; //eye number
98  CARD16 pad;
99 } gdBlink;
100 
101 #define sz_gdBlink 16
102 
103 
104 struct TimeStamp
105 {
106  unsigned short Year; //current year
107  unsigned int Days; //days past since January 1st
108  unsigned long Milliseconds; //Milliseconds past since 00:00 for the current day
109 
110 public:
111  TimeStamp()
112  {
113 #ifdef _WIN32
114  time_t systime = time(NULL);
115  tm* t = gmtime(&systime);
116 
117  Year = t->tm_year;
118  Days = t->tm_yday;
119  Milliseconds = (t->tm_hour*3600 + t->tm_min*60 + t->tm_sec) * 1000;
120 #endif
121  }
122 
123  TimeStamp(unsigned short Y, unsigned int D, unsigned long M):
124  Year(Y), Days(D), Milliseconds(M)
125  {}
126 
127  friend ostream &operator<<(ostream &stream, TimeStamp ts)
128  {
129  stream << ts.Year << "-";
130  stream << ts.Days << "-";
131  stream << ts.Milliseconds;
132 
133  return stream;
134  }
135 };