direcs  2012-09-30
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
consoleGui.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 CONSOLEGUI_H
22 #define CONSOLEGUI_H
23 
24 #include <QObject>
25 #include <QDebug>
26 
27 
32 class ConsoleGui : public QObject
33 {
34  Q_OBJECT
35 
36  public:
37  ConsoleGui();
38  ~ConsoleGui();
39 
40  /*
41  Shows a sensor distance in centimeters (cm) in a text label.
42  @param sensor is the sensor number.
43  @param distance is the distance in cm.
44  void showDistance(int sensor, int distance);
45  */
46 
53  void showDistanceGraphical(int sensor, int distance);
54 
60  void showDrivenDistance(int sensor, int distance);
61 
67  void showAlarm(short int sensor, bool state);
68 
75  void showMotorStatus(unsigned char motor, bool power, unsigned char direction);
76 
77 
78  public slots:
83  void setRobotControls(bool state);
84 
91  void appendLog(QString text, bool CR=true, bool sayIt=false);
92 
100  void appendNetworkLog(QString text, bool CR=true, bool sayIt=false);
101 
102 
109  void appendSerialLog(QString text, bool CR=true);
110 
114  void refreshLaserViewFront(QList <float> laserScannerValues, QList <int> laserScannerFlags);
115 
119  void refreshLaserViewRear(QList <float> laserScannerValues, QList <int> laserScannerFlags);
120 
128  void showLaserFrontAngles(int largestFreeAreaStart, int largestFreeAreaEnd, int centerOfFreeWay, float width);
129 
134  void showPreferredDirection(QString direction);
135 
141  void setLaserscannerAngle(short int laserscanner, int angle);
142 
148  void setLaserscannerResolution(short int laserscanner, float resolution);
149 
150 
151  signals:
155  void shutdown();
156 
160  void initCircuit();
161 
165  void initServos();
166 
171  void drive(const unsigned char command);
172 
177  void resetDrivenDistance(int sensor);
178 
184  void enableRemoteControlListening(bool state);
185 
196  void simulate(bool state);
197 
201  void speak(QString text);
202 
206  void test();
207 
208  private:
209 /*
210  \todo void closeEvent();
211  */
217 
218  bool robotIsOn;
219 
220  static const int SENSORPROGRESSBARMAXIR = 50;
221  static const int SENSORPROGRESSBARMAXUS = 400;
223  static const float AMPERESMAXPLOTCURVE1 = 3000.0;
224  static const float AMPERESMAXPLOTCURVE2 = 3000.0;
225  static const float AMPERESSTEPPLOTCURVE1 = 500.0;
226  static const float AMPERESSTEPPLOTCURVE2 = 500.0;
227 
228  static const bool ON = true;
229  static const bool OFF = false;
231 
232  static const unsigned char START = 7;
233  static const unsigned char STOP = 8;
234  static const unsigned char MOTOR1FW = 10;
235  static const unsigned char MOTOR1BW = 11;
236  static const unsigned char MOTOR1OFF = 12;
237  static const unsigned char MOTOR2FW = 13;
238  static const unsigned char MOTOR2BW = 14;
239  static const unsigned char MOTOR2OFF = 15;
240  static const unsigned char MOTOR3FW = 16;
241  static const unsigned char MOTOR3BW = 17;
242  static const unsigned char MOTOR3OFF = 18;
243  static const unsigned char MOTOR4FW = 19;
244  static const unsigned char MOTOR4BW = 20;
245  static const unsigned char MOTOR4OFF = 21;
246 
247  static const unsigned char CLOCKWISE = 0;
248  static const unsigned char COUNTERCLOCKWISE = 1;
249  static const unsigned char SAME = 3;
250  static const unsigned char MOTOR1 = 10;
251  static const unsigned char MOTOR2 = 20;
252  static const unsigned char MOTOR3 = 30;
253  static const unsigned char MOTOR4 = 40;
254 
261  static const short int SENSOR1 = 1;
262  static const short int SENSOR2 = 2;
263  static const short int SENSOR3 = 4;
264  static const short int SENSOR4 = 8;
265  static const short int SENSOR5 = 16;
266  static const short int SENSOR6 = 32;
267  static const short int SENSOR7 = 64;
268  static const short int SENSOR8 = 128;
269 
271  static const short int SENSOR16 = 256;
273  static const short int NONE = 0;
274 
275  static const short int MOTORSENSOR1 = 0;
276  static const short int MOTORSENSOR2 = 1;
277 
288  static const int FITTOFRAMEFACTOR = 45;
289  static const int STARTZOOMLEVEL = 3;
290 
292  static const int INITIALLASERYPOSFRONT = 100;
293  static const int INITIALLASERYPOSREAR = 100;
294 
296  static const int LASERDISTANCECIRCLES = 27;
298  static const int LASERDISTANCEFIRSTCIRCLE = 82;
300  static const int LASERDISTANCEDISTANCE = 60;
301 
302  // the tags for the laser lines
303  static const int FREEWAY = 0;
304  static const int OBSTACLE = 1;
305  static const int LARGESTFREEWAY = 2;
306  static const int CENTEROFLARGESTFREEWAY = 3;
307 
308  // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
313  //static const unsigned char LASERSCANNERARRAYSIZE = 181;
314 
318  static const short int LASER1 = 1;
319  static const short int LASER2 = 2;
320  static const short int LASER3 = 4;
321  static const short int LASER4 = 8;
322  static const short int LASER5 = 16;
323 };
324 #endif