source: pacpussensors/trunk/Gps/SeptentrioSocket.h@ 63

Last change on this file since 63 was 59, checked in by DHERBOMEZ Gérald, 10 years ago

Integration of new modules:

  • GPS NMEA0183 decoder
  • Span CPT Decoder

Update of:

File size: 2.3 KB
Line 
1/*********************************************************************
2// created: 2008/07/18 - 15:33
3// filename: SeptentrioSocket.h
4//
5// author: Gerald Dherbomez
6// Copyright Heudiasyc UMR UTC/CNRS 6599
7//
8// version: $Id: $
9//
10// purpose:
11//
12*********************************************************************/
13
14
15
16
17#ifndef _SEPTENTRIOSOCKET_H_
18#define _SEPTENTRIOSOCKET_H_
19
20
21#define SBFBLOCK_MAX_LENGTH 4096
22#define MAX_RESOURCES_COUNT 100
23
24#include <QSemaphore>
25#include <QObject>
26#include <QTcpSocket>
27#include <QMutex>
28#include <math.h>
29#include "kernel/road_time.h"
30#include <queue>
31
32
33using namespace std;
34
35
36// forward declaration
37class SeptentrioComponent;
38
39
40////////////////////////
41// Septentrio frame //
42////////////////////////
43/*! \typedef struct SbfFrame
44 \brief Structure containing the received bytes timestamped
45 timestamp expressed in microseconds since 01/01/1970,00:00
46 */
47typedef struct
48{
49 //! timestamp (in microsenconds)
50 road_time_t time;
51 //! timestamp uncertainty
52 road_timerange_t timerange ;
53 //! data
54 unsigned char data[SBFBLOCK_MAX_LENGTH];
55 //! length of valid data;
56 short size;
57} SbfFrame;
58
59
60
61
62class SeptentrioSocket : public QObject
63{
64 Q_OBJECT
65
66public:
67 // constructor
68 SeptentrioSocket();
69 // destructor
70 ~SeptentrioSocket();
71 // the FIFO in which incoming data are buffered
72 queue<SbfFrame> sbfFrames;
73 // the semaphore to alert FIFO update
74 QSemaphore sem;
75
76public slots:
77 // activate the connection to the server
78 void connectToServer(QString host, int port);
79
80 // called as soon as socket is connected
81 int socketConnected();
82
83 // called when new data available on the socket
84 void socketReadyRead();
85
86 // close the connection with the server
87 void closeSocket()
88 {
89 socket_->close();
90 }
91
92 void sendToServer(QString data);
93
94 int ID() {return socket_->socketDescriptor() ;};
95
96protected slots:
97// void sendToServer(QString data);
98
99
100 // socket connection closed by the server
101 void socketConnectionClosed();
102
103 // error on the socket
104 void socketError(QAbstractSocket::SocketError e);
105
106private:
107 // the socket
108 QTcpSocket *socket_;
109
110 // mutex used to serialize access to socket
111 QMutex mutex_;
112
113};
114
115#endif // _SEPTENTRIOSOCKET_H_
Note: See TracBrowser for help on using the repository browser.