direcs  2012-09-30
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
plotThread.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 PLOTTHREAD_H
22 #define PLOTTHREAD_H
23 
24 //-------------------------------------------------------------------
25 #include <qwt_plot.h>
26 #include <qwt_plot_marker.h>
27 #include <qwt_plot_curve.h>
28 #include <qwt_plot_layout.h>
29 #include <qwt_legend.h>
30 #include <qwt_data.h>
31 #include <qwt_text.h>
32 //-------------------------------------------------------------------
33 #include "sensorThread.h"
34 //-------------------------------------------------------------------
35 #include <QThread>
36 //-------------------------------------------------------------------
37 
44 class PlotThread : public QThread
45 {
46  Q_OBJECT
47 
48  public:
50  ~PlotThread();
51  void stop();
52  virtual void run();
53 
54 
55  signals:
56  void plotDataComplete1(double *xval1, double *yval1, int size);
57  void plotDataComplete2(double *xval2, double *yval2, int size);
58  void plotDataComplete3(double *xval3, double *yval3, int size);
59  void plotDataComplete4(double *xval4, double *yval4, int size);
60  void plotDataComplete5(double *xval4, double *yval4, int size);
61  void plotDataComplete6(double *xval4, double *yval4, int size);
62  void plotDataCompleteHeartbeat(double *xval4, double *yval4, int size);
63 
64 
65  private:
67  volatile bool stopped;
68 
69  // Every thread sleeps some time, for having a bit more time fo the other threads!
70  // Time in milliseconds
71  static const unsigned long THREADSLEEPTIME = 500; // Default: 1000 ms
72 
73  //====================================
74  // array holding the plot values
75  static const int SIZE = 60;
76  double xval1[SIZE];
77  double yval1[SIZE];
78  //====================================
79  double xval2[SIZE];
80  double yval2[SIZE];
81  //====================================
82  double xval3[SIZE];
83  double yval3[SIZE];
84  //====================================
85  double xval4[SIZE];
86  double yval4[SIZE];
87  //====================================
88  double xval5[SIZE];
89  double yval5[SIZE];
90  //====================================
91  double xval6[SIZE];
92  double yval6[SIZE];
93  //====================================
96  //====================================
97 
98  static const short int MOTORSENSOR1 = 0;
99  static const short int MOTORSENSOR2 = 1;
100  static const short int MOTORSENSOR3 = 2;
101  static const short int MOTORSENSOR4 = 3;
102 
103  static const short int VOLTAGESENSOR1 = 0;
104  static const short int VOLTAGESENSOR2 = 1;
105 };
106 
107 #endif