-
Notifications
You must be signed in to change notification settings - Fork 1
/
gpsFaker.h
87 lines (70 loc) · 1.75 KB
/
gpsFaker.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/** Kenneth W. Flynn
* GPSFaker.h
*/
#ifndef __GPSFAKER_H
#define __GPSFAKER_H
#include "gpsPub.h"
#include <sys/time.h>
class FakeDataGenerator;
class GPSFaker
{
public:
static void main (int arg, char* argv[]);
static void exitWithoutError ();
static void exitWithError (const char* err);
static void signalHandler (int signum);
static GPSFaker* faker;
public:
GPSFaker(FakeDataGenerator* gen);
~GPSFaker();
bool ready ();
void run ();
private:
FakeDataGenerator* generator;
GPSHandle handle;
};
// Interface for fake data generators
class FakeDataGenerator
{
public:
virtual void updateTime (const struct timeval* new_time) = 0;
virtual double getLatitude () = 0;
virtual double getLongitude () = 0;
virtual bool getValid () = 0;
};
class StaticGenerator : public FakeDataGenerator
{
public:
StaticGenerator (bool flaky, double longi, double lat);
virtual ~StaticGenerator () {}
virtual void updateTime (const struct timeval* new_time);
virtual double getLatitude ();
virtual double getLongitude ();
virtual bool getValid ();
private:
bool flaky;
double latitude;
double longitude;
};
class LineGenerator : public FakeDataGenerator
{
public:
LineGenerator(bool flaky, double start_long, double start_lat,
double end_long, double end_lat, long total_time);
virtual ~LineGenerator () {}
virtual void updateTime (const struct timeval* new_time);
virtual double getLatitude ();
virtual double getLongitude ();
virtual bool getValid ();
private:
bool flaky;
double curLatitude;
double curLongitude;
double startLatitude;
double startLongitude;
double endLatitude;
double endLongitude;
long totalTime;
struct timeval startTime;
};
#endif