direcs  2012-09-30
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
plotThread.cpp
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 #include "plotThread.h"
22 
24 {
25  stopped = false;
26 
27  // copy the pointer from the original object
28  sensThread = s;
29 
30  //----------------------------------------
31  // initialize array with values (x and y)
32  //----------------------------------------
33  // x values = seconds
34  for (int i=0; i<SIZE; i++)
35  {
36  xval1[i] = i;
37  xval2[i] = i;
38  xval3[i] = i;
39  xval4[i] = i;
40  xval5[i] = i;
41  xval6[i] = i;
42  xvalHeartbeat[i] = i;
43 
44  yval1[i] = 0;
45  yval2[i] = 0;
46  yval3[i] = 0;
47  yval4[i] = 0;
48  yval5[i] = 0;
49  yvalHeartbeat[i] = 0;
50  }
51 }
52 
53 
55 {
56 }
57 
58 
60 {
61  stopped = true;
62 }
63 
64 
66 {
67  //
68  // start "threading"...
69  //
70  while (!stopped)
71  {
72  // let the thread sleep some time
73  // for having more time for the other threads
74  msleep(THREADSLEEPTIME);
75 
76 
77  //------------------------------------------------------
78  // get value from sensor motor 1
79  //------------------------------------------------------
80  // shift the values
81  // (and delete the first one)
82  for (int i=1; i<SIZE; i++)
83  {
84  yval1[i-1] = yval1[i];
85  }
86 
87  // get a motor sensor value
88  // the last value (second 60) is the latest (the read value)!
90 
91  //--------------
92  // e m i t
93  //--------------
94  emit plotDataComplete1(xval1, yval1, SIZE);
95 
96 
97  //------------------------------------------------------
98  // get value from sensor motor 2
99  //------------------------------------------------------
100  // shift the values
101  // (and delete the first one)
102  for (int i=1; i<SIZE; i++)
103  {
104  yval2[i-1] = yval2[i];
105  }
106 
107  // get a motor sensor value
108  // the last value (second 60) is the latest (the read value)!
110 
111  //--------------
112  // e m i t
113  //--------------
114  emit plotDataComplete2(xval2, yval2, SIZE);
115 
116 
117  //------------------------------------------------------
118  // get value from sensor motor 3
119  //------------------------------------------------------
120  // shift the values
121  // (and delete the first one)
122  for (int i=1; i<SIZE; i++)
123  {
124  yval3[i-1] = yval3[i];
125  }
126 
127  // get a motor sensor value
128  // the last value (second 60) is the latest (the read value)!
130 
131  //--------------
132  // e m i t
133  //--------------
134  emit plotDataComplete3(xval3, yval3, SIZE);
135 
136 
137  //------------------------------------------------------
138  // get value from sensor motor 4
139  //------------------------------------------------------
140  // shift the values
141  // (and delete the first one)
142  for (int i=1; i<SIZE; i++)
143  {
144  yval4[i-1] = yval4[i];
145  }
146 
147  // get a motor sensor value
148  // the last value (second 60) is the latest (the read value)!
150 
151  //--------------
152  // e m i t
153  //--------------
154  emit plotDataComplete4(xval4, yval4, SIZE);
155 
156 
157  //------------------------------------------------------
158  // get value from voltage sensor 1
159  //------------------------------------------------------
160  // shift the values
161  // (and delete the first one)
162  for (int i=1; i<SIZE; i++)
163  {
164  yval5[i-1] = yval5[i];
165  }
166 
167  // get the sensor value
168  // the last value (second 60) is the latest (the read value)!
170 
171  //--------------
172  // e m i t
173  //--------------
174  emit plotDataComplete5(xval5, yval5, SIZE);
175 
176 
177  //------------------------------------------------------
178  // get value from voltage sensor 2
179  //------------------------------------------------------
180  // shift the values
181  // (and delete the first one)
182  for (int i=1; i<SIZE; i++)
183  {
184  yval6[i-1] = yval6[i];
185  }
186 
187  // get the sensor value
188  // the last value (second 60) is the latest (the read value)!
190 
191  //--------------
192  // e m i t
193  //--------------
194  emit plotDataComplete6(xval6, yval6, SIZE);
195 
196 
197  //------------------------------------------------------
198  // get values for heartbeat values
199  //------------------------------------------------------
200  // shift the values
201  // (and delete the first one)
202  for (int i=1; i<SIZE; i++)
203  {
204  yvalHeartbeat[i-1] = yvalHeartbeat[i];
205  }
206 
207  // get the sensor value
208  // the last value (second 60) is the latest (the read value)!
210 
211  //--------------
212  // e m i t
213  //--------------
215  }
216  stopped = false;
217 }