[37] | 1 | /*********************************************************************
|
---|
| 2 | // created: 2014-02-02
|
---|
| 3 | // filename: AbstractSickSensor.h
|
---|
| 4 | //
|
---|
| 5 | // author: Cyril Fougeray
|
---|
| 6 | // Copyright Heudiasyc UMR UTC/CNRS 6599
|
---|
| 7 | //
|
---|
| 8 | // version: $Id: $
|
---|
| 9 | //
|
---|
| 10 | // purpose: Abstract class to implement Sick sensors threads
|
---|
| 11 | //
|
---|
| 12 | *********************************************************************/
|
---|
| 13 |
|
---|
| 14 | #ifndef ABSTRACTSICKSENSOR_H
|
---|
| 15 | #define ABSTRACTSICKSENSOR_H
|
---|
| 16 |
|
---|
| 17 | #include <QThread>
|
---|
| 18 | #include "SickSocket.h"
|
---|
| 19 |
|
---|
| 20 | namespace pacpus {
|
---|
| 21 |
|
---|
| 22 | /// To separate data in UTC file = "UTC\0"
|
---|
| 23 | static const int32_t UTC_MAGIC_WORD = 0x55544300;
|
---|
| 24 |
|
---|
| 25 | /**
|
---|
| 26 | * \brief Structure used to stored Sick data between several decoding processes
|
---|
| 27 | *
|
---|
| 28 | * Note that data coming from sensors are split in IP packets. In order to get the
|
---|
| 29 | * whole message in one block, MessagePacket is used to reconstitue the raw data.
|
---|
| 30 | * As we want to reconstitute the message, it is useful to know if another packet
|
---|
| 31 | * belonging to the message was previously received. Also, the time of the reception of
|
---|
| 32 | * the first packet is carried into the structure in order to trace scans.
|
---|
| 33 | */
|
---|
| 34 | struct MessagePacket {
|
---|
| 35 | road_time_t time;
|
---|
| 36 | std::string data;
|
---|
| 37 | bool previousData;
|
---|
| 38 | };
|
---|
| 39 |
|
---|
| 40 |
|
---|
| 41 | /**
|
---|
| 42 | * @brief The AbstractSickSensor class
|
---|
| 43 | *
|
---|
| 44 | * The AbstractSickSensor class provides the abstract model for implementing sensor
|
---|
| 45 | * interfaces using SickComponent, used with the PACPUS Framework.
|
---|
| 46 | */
|
---|
| 47 | class AbstractSickSensor : public QThread
|
---|
| 48 | {
|
---|
| 49 | Q_OBJECT
|
---|
| 50 | public:
|
---|
| 51 | void run(){}
|
---|
| 52 |
|
---|
| 53 | virtual void stopActivity() = 0 ; /*!< to stop the processing thread */
|
---|
| 54 | virtual void startActivity() = 0; /*!< to start the processing thread */
|
---|
| 55 |
|
---|
| 56 | SickSocket * S_socket;
|
---|
| 57 |
|
---|
| 58 | signals:
|
---|
| 59 |
|
---|
| 60 | public slots:
|
---|
| 61 | /**
|
---|
| 62 | * @brief customEvent is a slot called when connected to a signal.
|
---|
| 63 | * @param e QEvent that carries information from sensor.
|
---|
| 64 | *
|
---|
| 65 | * Sick sensor interface implementation uses this slot to get data from the remote sensor,
|
---|
| 66 | * using IP packets. As long as Sick sensors use TCP/IP interface, it is advised to use this
|
---|
| 67 | * slot to get the packets from the device.
|
---|
| 68 | * @see SickFrameEvent
|
---|
| 69 | */
|
---|
| 70 | virtual void customEvent(QEvent * e) = 0;
|
---|
| 71 |
|
---|
| 72 | protected:
|
---|
| 73 | /// The SickLDMRS IP or hostname
|
---|
| 74 | QString host_;
|
---|
| 75 |
|
---|
| 76 | /// The SickLDMRS port
|
---|
| 77 | int port_;
|
---|
| 78 |
|
---|
| 79 | /// If data need to be recorded, set this member to true.
|
---|
| 80 | bool recording;
|
---|
| 81 | };
|
---|
| 82 |
|
---|
| 83 | }
|
---|
| 84 |
|
---|
| 85 | #endif // ABSTRACTSICKSENSOR_H
|
---|