source: pacpusframework/branches/2.0-beta1/include/PacpusCityVIP/Lidar/sensor/AlascaSocket.h@ 89

Last change on this file since 89 was 89, checked in by morasjul, 11 years ago

PACPUS 2.0 Beta deployed in new branch

Major changes:
-Add communication interface between components
-Add examples for communications interface (TestComponents)
-Move to Qt5 support

  • Property svn:executable set to *
File size: 2.2 KB
Line 
1/*********************************************************************
2// created: 2007/11/13 - 10:49
3// filename: AlascaSocket.h
4//
5// author: Gerald Dherbomez
6// Copyright Heudiasyc UMR UTC/CNRS 6599
7//
8// version: $Id: $
9//
10// purpose: Defintion of the AlascaSocket class
11// Management of the socket connection with the Alasca
12*********************************************************************/
13
14#ifndef _ALASCASOCKET_H_
15#define _ALASCASOCKET_H_
16
17#include <cmath>
18#include <QObject>
19#include <QTcpSocket>
20#include <QMutex>
21#include <QEvent>
22
23#include "kernel/road_time.h"
24
25namespace pacpus {
26
27class AlascaFrame
28{
29public:
30 AlascaFrame()
31 {
32 size = 0;
33 time = 0;
34 msg = NULL;
35 }
36
37 ~AlascaFrame()
38 {
39 delete[] msg; // check for NULL is not necessary
40 }
41
42 int size;
43 road_time_t time;
44 char * msg;
45};
46
47// forward declaration
48class AlascaComponent;
49
50class AlascaFrameEvent
51 : public QEvent
52{
53public:
54 AlascaFrameEvent()
55 : QEvent((QEvent::Type)(QEvent::User + 522))
56 {}
57
58 ~AlascaFrameEvent()
59 {}
60
61 AlascaFrame * frame;
62};
63
64class AlascaSocket
65 : public QObject
66{
67 Q_OBJECT
68
69public:
70 AlascaSocket(QObject * parent);
71 ~AlascaSocket();
72
73public Q_SLOTS:
74 // enable the connection to the server
75 void connectToServer(QString host, int port);
76
77 //avertit que le socket est connecté
78 int socketConnected();
79
80 // appelé lorsque de nouvelles données sont arrivées sur le socket
81 void socketReadyRead();
82
83 // close the connection with the server
84 void closeSocket() { socket->close(); }
85
86Q_SIGNALS:
87 // signal emis pour demander la configuration du télémètre
88 void configuration();
89
90protected slots:
91 // fonction d'envoi des données au télémètre
92 void sendToServer(QString data);
93
94
95 // le socket est fermé par le serveur
96 void socketConnectionClosed();
97
98 // une erreur est survenue
99 void socketError(QAbstractSocket::SocketError e);
100
101private:
102 QTcpSocket *socket;
103 QMutex mutex;
104
105 AlascaComponent * myParent;
106};
107
108} // namespace pacpus
109
110#endif
Note: See TracBrowser for help on using the repository browser.