90 lines
1.9 KiB
C++
90 lines
1.9 KiB
C++
//
|
|
// Track Daemon
|
|
// Neal Probert
|
|
//
|
|
|
|
/* prevent multiple inclusions */
|
|
#ifndef __TrackDaemon__
|
|
#define __TrackDaemon__
|
|
|
|
/* includes *****************************************************************/
|
|
|
|
#include "bzlib.h"
|
|
|
|
#include "UdpDaemon.h"
|
|
#include "TcpClient.h"
|
|
#include "UdpClient.h"
|
|
#include "Logging.h"
|
|
|
|
#include "GpsdClient.h"
|
|
#include "GpsDevice.h"
|
|
|
|
/* defines ******************************************************************/
|
|
|
|
#define TRACKD_NAME "trackd"
|
|
#define TRACKD_SERVICE "trackd"
|
|
#define TRACKD_PORT "2948"
|
|
|
|
/* macros *******************************************************************/
|
|
|
|
/* structs & typedefs *******************************************************/
|
|
|
|
/* c class definitions ******************************************************/
|
|
|
|
//
|
|
// Listens to OBE HeartBeat messages
|
|
//
|
|
class TrackDaemon : public UdpDaemon, public GpsListener, public Logging {
|
|
// public data
|
|
public:
|
|
|
|
// private data
|
|
private:
|
|
// my name
|
|
char Id[32];
|
|
|
|
// Gpsd client
|
|
GpsdClient Gpsd; // direct from GPSd
|
|
GpsDevice Gps; // or from serial port
|
|
bool bGpsd; // true for Gpsd
|
|
int GpsIn; // Gpsd or Gps
|
|
|
|
// upstream trackd
|
|
UdpClient Track; // listener
|
|
int TrackOut;
|
|
|
|
// NMEA parsing
|
|
|
|
// private methods
|
|
|
|
// static data
|
|
|
|
// public methods
|
|
public:
|
|
// constructors
|
|
TrackDaemon();
|
|
|
|
// destructor
|
|
virtual ~TrackDaemon();
|
|
|
|
// virtual functions
|
|
int ServerSocket(void);
|
|
int ClientInOut( char *buf, int n, int max );
|
|
|
|
// public methods
|
|
int GpsdServer( const char *uri );
|
|
void PositionListener( const PositionFix &Pos, const ErrorInfo &Err );
|
|
void TimeListener( const struct timeval &Time );
|
|
|
|
void SetId( const char *id ) { strncpy(Id,id,sizeof(Id)-1); };
|
|
int TrackOpen( const char *uri );
|
|
int LogOpen( const char *uri );
|
|
|
|
// static methods
|
|
|
|
// private methods
|
|
private:
|
|
};
|
|
|
|
#endif
|