gnssApi.h
Go to the documentation of this file.
1 
5 #pragma once
6 
7 #include <boost/function.hpp>
8 #include <boost/system/error_code.hpp>
9 #include <boost/shared_ptr.hpp>
10 #include "gnssPosition.h"
11 #include <vector>
12 
13 class GnssClient;
14 
15 //To avoid redefinition in client and app
16 #ifndef GNSS_TYPES
17 #define GNSS_TYPES
18 
24 namespace dpyGnss {
25 
32 };
33 
36 {
40 };
41 
44 {
48 };
49 
50 
62 {
67 };
68 
71 {
76 };
77 
79 struct GnssStatus
80 {
85 };
86 
91 typedef boost::function<void(const bool &available)> service_availability_handler;
92 typedef boost::function<void(boost::system::error_code error_code, GnssPosition& last_position)> get_position_handler_function;
93 typedef boost::function<void(boost::system::error_code error_code, GnssPosition& next_position)> get_periodic_position_handler_function;
94 typedef boost::function<void(boost::system::error_code error_code, GnssStatus& current_status)> get_gnss_status_handler_function;
95 typedef boost::function<void(boost::system::error_code error_code, tm date)> get_time_date_handler_function;
96 typedef boost::function<void(boost::system::error_code error_code, GnssInfo type, const std::string& value)> get_info_handler_function;
97 typedef boost::function<void(boost::system::error_code error_code, GnssPowerStatus pwr_stat)> power_status_handler_function;
98 typedef boost::function<void(boost::system::error_code error_code)> result_handler_function;
99 } //dpyGnss
100 #endif //GNSS_TYPES
101 
102 
108 {
109 public:
114  virtual void NewPosition(const GnssPosition& position) = 0;
118  virtual ~GnssObserver()
119  {
120  }
121 };
122 
127 class Gnss
128 {
129 
130 private:
134  boost::shared_ptr<GnssClient> mClient;
135 public:
136 
137  explicit Gnss(std::string ip = "127.0.0.1");
138  virtual ~Gnss();
139 
141 #ifndef TESTING
142  bool isAlive();
143  void monitorServiceAvailability_S(dpyGnss::service_availability_handler handler);
144  void monitorServiceAvailability_U();
145 
146  //Asynchronous operations
147  //From Deepsy 18.03
148  void getPeriodicPosition_S(dpyGnss::get_periodic_position_handler_function handler);
149  void getPeriodicPosition_U();
150  void asyncSetPowerStatus(dpyGnss::GnssPowerStatus power_stat, dpyGnss::result_handler_function handler);
151  void asyncGetPowerStatus(dpyGnss::power_status_handler_function handler);
152  void asyncGetLastPosition(dpyGnss::get_position_handler_function handler);
153  void asyncGetStoredTimeDate(dpyGnss::get_time_date_handler_function handler);
154  void asyncGetModuleInfo(dpyGnss::GnssInfo info, dpyGnss::get_info_handler_function handler);
155  void asyncPerformSoftwareReset(dpyGnss::SwResetType reset_type, dpyGnss::result_handler_function handler);
156  void asyncPerformHardwareReset(dpyGnss::result_handler_function handler);
157  //From Deepsy 18.10
158  void asyncGetStatus(dpyGnss::get_gnss_status_handler_function handler);
159  void getPeriodicStatus_S(dpyGnss::get_gnss_status_handler_function handler);
160  void getPeriodicStatus_U();
161 
162  // void getStatus(dpyGnss::get_gnss_status_handler_function handler);
163 
164  //Observer
165  boost::system::error_code subscribe(GnssObserver *observer);
166  boost::system::error_code unsubscribe(GnssObserver *observer);
167 
168  //Synchronous operations
169  boost::system::error_code setPowerStatus(dpyGnss::GnssPowerStatus &power_stat);
170  boost::system::error_code getPowerStatus(dpyGnss::GnssPowerStatus &pwr_stat);
171  boost::system::error_code getLastPosition(GnssPosition &last_position);
172  boost::system::error_code getStoredTimeDate(tm &gnssdatetime);
173  boost::system::error_code getModuleInfo(dpyGnss::GnssInfo info, std::string& value);
174  boost::system::error_code performSoftwareReset(dpyGnss::SwResetType reset_type);
175  boost::system::error_code performHardwareReset();
176 
177  //From Deepsy 19.04
178  void asyncStartSimulationMode(dpyGnss::SimulationMode simulation_type, std::string file_path,dpyGnss::result_handler_function handler);
179  void asyncStopSimulationMode(dpyGnss::result_handler_function handler);
180 
181 
182 #else
183  virtual bool isAlive();
184  virtual void monitorServiceAvailability_S(dpyGnss::service_availability_handler handler);
185  virtual void monitorServiceAvailability_U();
186 
187  virtual void getPeriodicPosition_S(dpyGnss::get_periodic_position_handler_function handler);
188  virtual void getPeriodicPosition_U();
189  virtual void asyncSetPowerStatus(dpyGnss::GnssPowerStatus power_stat, dpyGnss::result_handler_function handler);
190  virtual void asyncGetPowerStatus(dpyGnss::power_status_handler_function handler);
191  virtual void asyncGetLastPosition(dpyGnss::get_position_handler_function handler);
192  virtual void asyncGetStoredTimeDate(dpyGnss::get_time_date_handler_function handler);
193  virtual void asyncGetModuleInfo(dpyGnss::GnssInfo info, dpyGnss::get_info_handler_function handler);
194  virtual void asyncPerformSoftwareReset(dpyGnss::SwResetType reset_type, dpyGnss::result_handler_function handler);
195  virtual void asyncPerformHardwareReset(dpyGnss::result_handler_function handler);
196  //From Deepsy 18.10
197  virtual void asyncGetStatus(dpyGnss::get_gnss_status_handler_function handler);
198  virtual void getPeriodicStatus_S(dpyGnss::get_gnss_status_handler_function handler);
199  virtual void getPeriodicStatus_U();
200 
201  // void getStatus(dpyGnss::get_gnss_status_handler_function handler);
202 
203  //Observer
204  virtual boost::system::error_code subscribe(GnssObserver *observer);
205  virtual boost::system::error_code unsubscribe(GnssObserver *observer);
206 
207  //Synchronous operations
208  virtual boost::system::error_code setPowerStatus(dpyGnss::GnssPowerStatus &power_stat);
209  virtual boost::system::error_code getPowerStatus(dpyGnss::GnssPowerStatus &pwr_stat);
210  virtual boost::system::error_code getLastPosition(GnssPosition &last_position);
211  virtual boost::system::error_code getStoredTimeDate(tm &gnssdatetime);
212  virtual boost::system::error_code getModuleInfo(dpyGnss::GnssInfo info, std::string& value);
213  virtual boost::system::error_code performSoftwareReset(dpyGnss::SwResetType reset_type);
214  virtual boost::system::error_code performHardwareReset();
215 
216  //From Deepsy 19.04
217  virtual void asyncStartSimulationMode(dpyGnss::SimulationMode simulation_type, std::string file_path,dpyGnss::result_handler_function handler);
218  virtual void asyncStopSimulationMode(dpyGnss::result_handler_function handler);
219 
220 #endif
221 };
Gnss firmware version.
Definition: gnssApi.h:74
AntenaStatus antenna_stat
Current AntenaStatus, please check dpyGnss::AntenaStatus documentation to be able to interpret this v...
Definition: gnssApi.h:82
boost::function< void(boost::system::error_code error_code, GnssStatus &current_status)> get_gnss_status_handler_function
Prototype of the handler function for setPositionSubscriberHandler method.
Definition: gnssApi.h:94
Plain position text will be used to simulate positions.
Definition: gnssApi.h:30
NMEA format text will be used to simulate positions.
Definition: gnssApi.h:31
Gnss low power consumption mode.
Definition: gnssApi.h:38
dpyGnssPosition::QualityIndicator fix_quality
Current FIX status. Module is FIXED if different from NO_FIX.
Definition: gnssApi.h:83
Class that defines a position.
Definition: gnssPosition.h:36
boost::function< void(boost::system::error_code error_code, GnssPowerStatus pwr_stat)> power_status_handler_function
Prototype of the handler function for generateEventMsg method.
Definition: gnssApi.h:97
Warm start reset.
Definition: gnssApi.h:46
Gnss Manufacturer.
Definition: gnssApi.h:72
SwResetType
Defines the possible ways of performing a GNSS Reset.
Definition: gnssApi.h:43
Defines the status information structure that is obtained within a GNSS STATUS.
Definition: gnssApi.h:79
Deepsy Gnss namespace that includes the different enums, structs or method signatures that should be ...
boost::function< void(boost::system::error_code error_code, GnssInfo type, const std::string &value)> get_info_handler_function
Prototype of the handler function for getModemInfo method.
Definition: gnssApi.h:96
Antenna problem detected : short circuit.
Definition: gnssApi.h:64
boost::function< void(const bool &available)> service_availability_handler
Prototype of the handler function used to monitor service availability.
Definition: gnssApi.h:91
boost::function< void(boost::system::error_code error_code)> result_handler_function
Prototype of the handler function for obtaining result of the different operations.
Definition: gnssApi.h:98
Client class.
Definition: gnssClient.h:14
Gnss full functionality mode.
Definition: gnssApi.h:39
SimulationMode
Possible simulation modes.
Definition: gnssApi.h:29
GnssPowerStatus pwr_status
Current GnssPowerStatus.
Definition: gnssApi.h:81
AntenaStatus
Defines the possible status in which the antenna can be.
Definition: gnssApi.h:61
Antenna has been enabled and has voltage supply. Check interpretation of this value in the documentat...
Definition: gnssApi.h:66
Gnss Model.
Definition: gnssApi.h:73
boost::function< void(boost::system::error_code error_code, GnssPosition &next_position)> get_periodic_position_handler_function
Prototype of the handler function for setPositionSubscriberHandler method.
Definition: gnssApi.h:93
virtual ~GnssObserver()
Destructor.
Definition: gnssApi.h:118
GnssInfo
Defines the possible information that can be queried.
Definition: gnssApi.h:70
boost::function< void(boost::system::error_code error_code, tm date)> get_time_date_handler_function
Prototype of the handler function for getStoredTimeDate method.
Definition: gnssApi.h:95
Gnss Observer class.
Definition: gnssApi.h:107
boost::function< void(boost::system::error_code error_code, GnssPosition &last_position)> get_position_handler_function
Prototype of the handler function for getLastPosition method.
Definition: gnssApi.h:92
GnssPowerStatus
Defines the possible GNSS POWER states that the gnss can be in.
Definition: gnssApi.h:35
Gnss functions are not available.
Definition: gnssApi.h:37
No antenna has been detected.
Definition: gnssApi.h:65
Gnss protocol version used by the receiver.
Definition: gnssApi.h:75
Hot start reset.
Definition: gnssApi.h:45
Antenna voltage supply is disabled.
Definition: gnssApi.h:63
Main application.
Definition: gnssApi.h:127
QualityIndicator
Defines the posible FIX quality indicators.
Definition: gnssPosition.h:20
Cold start reset.
Definition: gnssApi.h:47
bool simulation_mode_active
Information about the status of the GNSS in terms of operation mode (real/simulation). If active, the positions received are not real , but simulated from a file.
Definition: gnssApi.h:84