My Project
 All Classes Files Functions Variables Enumerations Enumerator Friends Macros Pages
GpsIntHandler.h
Go to the documentation of this file.
1 // $Id: GpsIntHandler.h,v 1.1.1.1 2009/07/06 23:57:04 eml Exp $
2 
3 #ifndef GCP_ANTENNA_CONTROL_GPSINTHANDLER_H
4 #define GCP_ANTENNA_CONTROL_GPSINTHANDLER_H
5 
16 #define GPS_CALLBACK_FN(fn) void (fn)(void* args)
17 
18 #include "gcp/util/common/Runnable.h"
19 #include "gcp/util/common/TimeVal.h"
20 
21 #include <string>
22 #include <vector>
23 
24 namespace gcp {
25  namespace antenna {
26  namespace control {
27 
29  public:
30 
34  GpsIntHandler(bool spawn, bool simulateTimer,
35  bool simulateGpsCard, unsigned short priority);
36 
37  GpsIntHandler(bool spawn, bool simulateTimer,
38  bool simulateGpsCard=false);
39 
43  virtual ~GpsIntHandler();
44 
48  void registerCallback(GPS_CALLBACK_FN(*fn), void* arg);
49 
53  void run();
54  void runReal();
55  void runSim();
56  void runTest();
57 
58  // Stop this object from running
59 
60  void stop();
61 
62  // Read the current date from the gps board
63 
64  void getDate(gcp::util::TimeVal& lastTick);
65 
66  gcp::util::TimeVal& lastTick() {
67  return lastTick_;
68  }
69 
70  int fd() {
71  return fd_;
72  }
73 
74  private:
75 
76  struct HandlerInfo {
77  GPS_CALLBACK_FN(*fn_);
78  void* arg_;
79 
80  HandlerInfo(GPS_CALLBACK_FN(*fn), void* arg) :
81  fn_(fn), arg_(arg) {}
82  };
83 
87  static const std::string devName_;
88 
93  std::vector<HandlerInfo> handlers_;
94 
95  // If true, stop running this object
96 
97  volatile bool stop_;
98 
99  // The file descriptor associated with the gps interrupt
100  // driver
101 
102  int fd_;
103 
104  bool simulateTimer_;
105  bool simulateGpsCard_;
106 
111  static RUN_FN(runFn);
112 
113  public:
114 
115  // Open the device
116 
117  void open();
118 
119  private:
120 
121  // Close the device
122 
123  void close();
124 
125  // Call handlers when the device becomes readable
126 
127  void callHandlers();
128 
129  gcp::util::TimeVal lastTick_;
130 
131  }; // End class GpsIntHandler
132 
133  } // End namespace control
134  } // End namespace antenna
135 } // End namespace gcp
136 
137 
138 
139 #endif // End #ifndef GCP_ANTENNA_CONTROL_GPSINTHANDLER_H
Definition: GpsIntHandler.h:28
void runSim()
Definition: GpsIntHandler.cc:253
void open()
Definition: GpsIntHandler.cc:60
void stop()
Definition: GpsIntHandler.cc:115
Definition: Runnable.h:23
void run()
Definition: GpsIntHandler.cc:120
Definition: TimeVal.h:55
void registerCallback(GPS_CALLBACK_FN(*fn), void *arg)
Definition: GpsIntHandler.cc:88
GpsIntHandler(bool spawn, bool simulateTimer, bool simulateGpsCard, unsigned short priority)
Definition: GpsIntHandler.cc:22
void runReal()
Definition: GpsIntHandler.cc:132
void runTest()
Definition: GpsIntHandler.cc:221
virtual ~GpsIntHandler()
Definition: GpsIntHandler.cc:52