direcs  2012-09-30
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
laserThread.h
Go to the documentation of this file.
1 /*************************************************************************
2  * Copyright (C) Markus Knapp *
3  * www.direcs.de *
4  * *
5  * This file is part of direcs. *
6  * *
7  * direcs is free software: you can redistribute it and/or modify it *
8  * under the terms of the GNU General Public License as published *
9  * by the Free Software Foundation, version 3 of the License. *
10  * *
11  * direcs is distributed in the hope that it will be useful, *
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14  * GNU General Public License for more details. *
15  * *
16  * You should have received a copy of the GNU General Public License *
17  * along with direcs. If not, see <http://www.gnu.org/licenses/>. *
18  * *
19  *************************************************************************/
20 
21 #ifndef LASERTHREAD_H
22 #define LASERTHREAD_H
23 
24 #include "laserSickS300.h"
25 #include "inifile.h" // for reading the sim values
26 #include <QThread>
27 
28 
35 class LaserThread : public QThread
36 {
37  Q_OBJECT
38 
39  public:
40  LaserThread();
41  ~LaserThread();
42  void stop();
43  virtual void run();
44 
48  float getValue(short int laserScanner, int angle);
49 
55  int getFlag(short int laserScanner, int angle);
56 
62  void setType(short int laserScanner, QString laserType);
63 
71  void setFlag(short int laserScanner, int angle, int flag);
72 
79  void setSerialPort(short int laserScanner, QString serialPort);
80 
87  void setMounting(short int laserScanner, QString mounting);
88 
94  void setAngle(short int laserScanner, int angle);
95 
101  void setResolution(short int laserScanner, float resolution);
102 
108  int getAngle(short int laserScanner);
109 
115  float getResolution(short int laserScanner);
116 
122  bool isConnected(short int laserScanner);
123 
124 
125  public slots:
129  void setSimulationMode(bool state);
130 
135  void saveLaserData();
136 
141  void setMeasureMode(bool state);
142 
143 
144  signals:
149 
153  void laserDataCompleteRear(QList <float> laserScannerValuesRear, QList <int> laserScannerFlagsRear);
154 
160  void message(QString text);
161 
165  void sendNetworkString(QString text);
166 
171  void systemerror(int errorlevel);
172 
173 
174  private:
177  bool readSimulationValues();
178  //mutable QMutex mutex; // make this class thread-safe
179  volatile bool stopped;
180  unsigned char laserscannerTypeFront;
181  unsigned char laserscannerTypeRear;
194 
195  SickS300 *laserS300; // the object for the S300 laserscanner
196  Inifile *inifile1; // for reading simulation values
197  Inifile *inifileLaserdata; // for writing the current laser values to a file
198 
199  // Every thread sleeps some time, for having a bit more time fo the other threads!
200  // Time in milliseconds
201  static const unsigned long THREADSLEEPTIME = 50; // Default: 250 ms
202 
203  // FIXME: put this to the ini-file or so. Fix also: read_parameters() in laser.cpp !!
204  static const unsigned char LMS = 0; // this is temporary
205  static const unsigned char PLS = 1; // this is temporary
206  static const unsigned char HOKUYO_URG = 2; // this is not in use, but according to laser.h, direcs_laser_laser_type_t
207  static const unsigned char SIMULATED_LASER = 3; // this is not in use, but according to laser.h, direcs_laser_laser_type_t
208  static const unsigned char S300 = 4; // this is temporary
209  static const unsigned char NONE = 255;
210 
211  QList <float> laserScannerValuesFront;
212  QList <float> laserScannerValuesRear;
213 
215  QList <int> laserScannerFlagsRear;
216 
217  QList <float> simulationValuesFront;
218  QList <float> simulationValuesRear;
219 
223 // static const unsigned char DISTANCE = 0;
224 // static const unsigned char FLAG = 1;
225 
229  static const short int LASER1 = 1;
230  static const short int LASER2 = 2;
231  static const short int LASER3 = 4;
232  static const short int LASER4 = 8;
233  static const short int LASER5 = 16;
234 
235  // the tags for the laser lines
236  static const int FREEWAY = 0;
237  static const int OBSTACLE = 1;
238 
243  static const short int MAXERRORS = 2;
244 };
245 
246 #endif