Changeset 42 in pacpussensors for trunk/Sick/SickSocket.h


Ignore:
Timestamp:
04/01/14 14:47:39 (10 years ago)
Author:
cfougera
Message:

Last version

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Sick/SickSocket.h

    r37 r42  
    33//  filename:   SickSocket.h
    44//
    5 //  author:     Gerald Dherbomez & Cyril Fougeray
     5//  author:     Gerald Dherbomez
     6//              Modified by Cyril Fougeray
    67//              Copyright Heudiasyc UMR UTC/CNRS 6599
    78//
     
    3132class SickLMSSensor;
    3233
     34/**
     35 * @brief The SickFrame class
     36 */
    3337class SickFrame
    3438{
    3539public:
     40    /**
     41     * @brief SickFrame constructor
     42     */
    3643    SickFrame()
    3744    {
     
    4148    }
    4249   
     50    /// Destructor
    4351    ~SickFrame()
    4452    {
     
    4654    }
    4755   
    48     qint64 size;
    49     road_time_t time;
    50     char * msg;
     56    qint64 size; //!< Size of incoming packet.
     57    road_time_t time; //!< Time when packet is received.
     58    char * msg; //!< Packet (raw data).
    5159};
    5260
    53 // forward declaration
    54 
     61/**
     62 * @brief The SickFrameEvent class
     63 * QEvent that encapsulates packets.
     64 */
    5565class SickFrameEvent
    5666        : public QEvent
    5767{
    5868public:
     69    /// Constructor
    5970    SickFrameEvent()
    6071            : QEvent((QEvent::Type)(QEvent::User + 522))
    6172    {}
    6273   
     74    /// Destructor
    6375    ~SickFrameEvent()
    6476    {}
    6577   
     78    /// Packet data
    6679    SickFrame * frame;
    6780};
    6881
     82/**
     83 * @brief The SickSocket class
     84 * Handles the ethernet connection with the remote sensor.
     85 */
    6986class SickSocket
    7087        : public QObject
     
    7390 
    7491public:
     92    /// Constructor
    7593    SickSocket(AbstractSickSensor * parent);
     94
     95    /// Destructor
    7696    ~SickSocket();
    7797
    7898public Q_SLOTS:
    79     // enable the connection to the server
     99    /// Enable the connection to the server
    80100    void connectToServer(QString host, int port);
    81101
    82     //avertit que le socket est connecté
     102    /// Warns about connection of the socket and launch configuration of the socket.
    83103    int socketConnected();
    84104
    85     // appelé lorsque de nouvelles données sont arrivées sur le socket
     105    /** Called when incoming data is received. Create an event and send it to the sensor's handler. @see AbstractSickComponent */
    86106    void socketReadyRead(); 
    87107
    88     // close the connection with the server
     108    /// Close the connection with the server
    89109    void closeSocket() { socket->close(); }
    90110
    91     // fonction d'envoi des données au télémètre
     111    /**
     112     * @brief sendToServer Sends data to the remote lidar.
     113     * @param data Data to be sent, translated in ASCII.
     114     */
    92115    void sendToServer(QString data);
    93116Q_SIGNALS:
    94     // signal emis pour demander la configuration du télémètre
     117    /// Asked for configuring sensor.
    95118    void configuration();
    96119
    97120protected slots:
    98 
    99     // le socket est fermé par le serveur
     121    /// Says to the user the connection is closed.
    100122    void socketConnectionClosed();
    101123
    102     // une erreur est survenue
     124    /// Warns the user an error occured
    103125    void socketError(QAbstractSocket::SocketError e);
    104126
    105127private:
     128    /// Socket
    106129    QTcpSocket *socket;
     130
     131    /// Mutex to use socket resource.
    107132    QMutex mutex;
    108133
     134    /// Parent (contains slots to connect to in order to pass the received data).
    109135    AbstractSickSensor *myParent;
    110136};
Note: See TracChangeset for help on using the changeset viewer.