Selaa lähdekoodia

Update generated files and make ThresholdDetector operate in a more generally correct fashion

Neal Wilson 8 vuotta sitten
vanhempi
commit
3662712508
12 muutettua tiedostoa jossa 774 lisäystä ja 780 poistoa
  1. 1
    1
      src/abouttypica.cpp
  2. 17
    15
      src/daterangeselector.cpp
  3. 1
    1
      src/daterangeselector.h
  4. 2
    2
      src/draglabel.cpp
  5. 2
    2
      src/draglabel.h
  6. 1
    1
      src/helpmenu.cpp
  7. 1
    1
      src/licensewindow.cpp
  8. 6
    6
      src/scale.cpp
  9. 6
    2
      src/scale.h
  10. 2
    17
      src/thresholdannotation.w
  11. 723
    730
      src/typica.cpp
  12. 12
    2
      src/typica.w

+ 1
- 1
src/abouttypica.cpp Näytä tiedosto

@@ -17,7 +17,7 @@ aboutFile.close();
17 17
 setCentralWidget(banner);
18 18
 }
19 19
 
20
-#line 6592 "./typica.w"
20
+#line 6595 "./typica.w"
21 21
 
22 22
 /*:276*/
23 23
 #line 36 "./abouttypica.w"

+ 17
- 15
src/daterangeselector.cpp Näytä tiedosto

@@ -12,7 +12,7 @@
12 12
 #include "daterangeselector.h"
13 13
 
14 14
 /*668:*/
15
-#line 115 "./daterangeselector.w"
15
+#line 117 "./daterangeselector.w"
16 16
 
17 17
 CustomDateRangePopup::CustomDateRangePopup(QWidget*parent):
18 18
 QWidget(parent,Qt::Popup),startDateSelector(new QCalendarWidget),
@@ -56,7 +56,7 @@ setLayout(outerLayout);
56 56
 }
57 57
 
58 58
 /*:668*//*669:*/
59
-#line 163 "./daterangeselector.w"
59
+#line 165 "./daterangeselector.w"
60 60
 
61 61
 void CustomDateRangePopup::hideEvent(QHideEvent*)
62 62
 {
@@ -64,7 +64,7 @@ emit hidingPopup();
64 64
 }
65 65
 
66 66
 /*:669*//*670:*/
67
-#line 172 "./daterangeselector.w"
67
+#line 174 "./daterangeselector.w"
68 68
 
69 69
 void CustomDateRangePopup::applyRange()
70 70
 {
@@ -79,7 +79,7 @@ hide();
79 79
 }
80 80
 
81 81
 /*:670*//*671:*/
82
-#line 189 "./daterangeselector.w"
82
+#line 191 "./daterangeselector.w"
83 83
 
84 84
 void CustomDateRangePopup::validateRange()
85 85
 {
@@ -97,7 +97,7 @@ applyButton->setEnabled(true);
97 97
 #line 81 "./daterangeselector.w"
98 98
 
99 99
 /*672:*/
100
-#line 207 "./daterangeselector.w"
100
+#line 209 "./daterangeselector.w"
101 101
 
102 102
 DateRangeSelector::DateRangeSelector(QWidget*parent):
103 103
 QWidget(parent),quickSelector(new QComboBox(this)),
@@ -109,7 +109,7 @@ QDate currentDate= QDate::currentDate();
109 109
 
110 110
 QHBoxLayout*layout= new QHBoxLayout;
111 111
 /*673:*/
112
-#line 236 "./daterangeselector.w"
112
+#line 238 "./daterangeselector.w"
113 113
 
114 114
 quickSelector->addItem("Yesterday",QVariant(QStringList()<<
115 115
 currentDate.addDays(-1).toString(Qt::ISODate)));
@@ -189,7 +189,7 @@ quickSelector->addItem("Lifetime");
189 189
 quickSelector->addItem("Custom");
190 190
 
191 191
 /*:673*/
192
-#line 217 "./daterangeselector.w"
192
+#line 219 "./daterangeselector.w"
193 193
 
194 194
 QToolButton*customButton= new QToolButton;
195 195
 customButton->setIcon(QIcon::fromTheme("office-calendar",
@@ -202,7 +202,7 @@ connect(customButton,SIGNAL(clicked()),this,SLOT(toggleCustom()));
202 202
 }
203 203
 
204 204
 /*:672*//*674:*/
205
-#line 319 "./daterangeselector.w"
205
+#line 321 "./daterangeselector.w"
206 206
 
207 207
 void DateRangeSelector::updateRange(int index)
208 208
 {
@@ -218,7 +218,7 @@ emit rangeUpdated(quickSelector->itemData(quickSelector->currentIndex()));
218 218
 }
219 219
 
220 220
 /*:674*//*675:*/
221
-#line 336 "./daterangeselector.w"
221
+#line 338 "./daterangeselector.w"
222 222
 
223 223
 void DateRangeSelector::popupHidden()
224 224
 {
@@ -228,7 +228,7 @@ quickSelector->setCurrentIndex(lastIndex);
228 228
 }
229 229
 
230 230
 /*:675*//*676:*/
231
-#line 347 "./daterangeselector.w"
231
+#line 349 "./daterangeselector.w"
232 232
 
233 233
 void DateRangeSelector::setCustomRange(QVariant range)
234 234
 {
@@ -239,7 +239,7 @@ quickSelector->setCurrentIndex(lastIndex);
239 239
 }
240 240
 
241 241
 /*:676*//*677:*/
242
-#line 362 "./daterangeselector.w"
242
+#line 364 "./daterangeselector.w"
243 243
 
244 244
 void DateRangeSelector::toggleCustom()
245 245
 {
@@ -280,7 +280,7 @@ customRangeSelector= NULL;
280 280
 }
281 281
 
282 282
 /*:677*//*678:*/
283
-#line 404 "./daterangeselector.w"
283
+#line 406 "./daterangeselector.w"
284 284
 
285 285
 QVariant DateRangeSelector::currentRange()
286 286
 {
@@ -288,7 +288,7 @@ return quickSelector->itemData(lastIndex);
288 288
 }
289 289
 
290 290
 /*:678*//*679:*/
291
-#line 412 "./daterangeselector.w"
291
+#line 414 "./daterangeselector.w"
292 292
 
293 293
 void DateRangeSelector::setCurrentIndex(int index)
294 294
 {
@@ -301,7 +301,7 @@ return quickSelector->currentIndex();
301 301
 }
302 302
 
303 303
 /*:679*//*680:*/
304
-#line 432 "./daterangeselector.w"
304
+#line 434 "./daterangeselector.w"
305 305
 
306 306
 void DateRangeSelector::setLifetimeRange(QString startDate,QString endDate)
307 307
 {
@@ -310,7 +310,7 @@ QVariant(QStringList()<<startDate<<endDate));
310 310
 }
311 311
 
312 312
 /*:680*//*681:*/
313
-#line 442 "./daterangeselector.w"
313
+#line 444 "./daterangeselector.w"
314 314
 
315 315
 void DateRangeSelector::removeIndex(int index)
316 316
 {
@@ -322,7 +322,9 @@ quickSelector->removeItem(index);
322 322
 
323 323
 
324 324
 #ifdef __unix__
325
+#ifndef __linux__
325 326
 #include "moc_daterangeselector.cpp"
326 327
 #endif
328
+#endif
327 329
 
328 330
 /*:666*/

+ 1
- 1
src/daterangeselector.h Näytä tiedosto

@@ -10,7 +10,7 @@
10 10
 #define TypicaDateRangeSelectorHeader
11 11
 
12 12
 /*667:*/
13
-#line 91 "./daterangeselector.w"
13
+#line 93 "./daterangeselector.w"
14 14
 
15 15
 class CustomDateRangePopup:public QWidget
16 16
 {

+ 2
- 2
src/draglabel.cpp Näytä tiedosto

@@ -1,4 +1,4 @@
1
-/*1002:*/
1
+/*1014:*/
2 2
 #line 33 "./scales.w"
3 3
 
4 4
 #include "draglabel.h"
@@ -26,4 +26,4 @@ drag->exec();
26 26
 }
27 27
 }
28 28
 
29
-/*:1002*/
29
+/*:1014*/

+ 2
- 2
src/draglabel.h Näytä tiedosto

@@ -1,4 +1,4 @@
1
-/*1001:*/
1
+/*1013:*/
2 2
 #line 13 "./scales.w"
3 3
 
4 4
 #ifndef TypicaDragLabelInclude
@@ -17,4 +17,4 @@ void mousePressEvent(QMouseEvent*event);
17 17
 
18 18
 #endif
19 19
 
20
-/*:1001*/
20
+/*:1013*/

+ 1
- 1
src/helpmenu.cpp Näytä tiedosto

@@ -42,7 +42,7 @@ LicenseWindow*window= new LicenseWindow;
42 42
 window->show();
43 43
 }
44 44
 
45
-#line 4772 "./typica.w"
45
+#line 4775 "./typica.w"
46 46
 
47 47
 #line 1 "./licensewindow.w"
48 48
 /*:207*/

+ 1
- 1
src/licensewindow.cpp Näytä tiedosto

@@ -11,7 +11,7 @@
11 11
 #include <QVariant> 
12 12
 #include <QUrl> 
13 13
 
14
-#line 4774 "./typica.w"
14
+#line 4777 "./typica.w"
15 15
 
16 16
 /*:213*/
17 17
 #line 37 "./licensewindow.w"

+ 6
- 6
src/scale.cpp Näytä tiedosto

@@ -1,4 +1,4 @@
1
-/*1008:*/
1
+/*1020:*/
2 2
 #line 135 "./scales.w"
3 3
 
4 4
 #include "scale.h"
@@ -10,7 +10,7 @@ QextSerialPort(port,QextSerialPort::EventDriven)
10 10
 connect(this,SIGNAL(readyRead()),this,SLOT(dataAvailable()));
11 11
 }
12 12
 
13
-/*:1008*//*1009:*/
13
+/*:1020*//*1021:*/
14 14
 #line 153 "./scales.w"
15 15
 
16 16
 void SerialScale::dataAvailable()
@@ -24,7 +24,7 @@ responseBuffer.clear();
24 24
 }
25 25
 else
26 26
 {
27
-/*1010:*/
27
+/*1022:*/
28 28
 #line 193 "./scales.w"
29 29
 
30 30
 QStringList responseParts= QString(responseBuffer.simplified()).split(' ');
@@ -53,7 +53,7 @@ unit= Units::Ounce;
53 53
 }
54 54
 emit newMeasurement(weight,unit);
55 55
 
56
-/*:1010*/
56
+/*:1022*/
57 57
 #line 165 "./scales.w"
58 58
 
59 59
 responseBuffer.clear();
@@ -61,7 +61,7 @@ responseBuffer.clear();
61 61
 }
62 62
 }
63 63
 
64
-/*:1009*//*1011:*/
64
+/*:1021*//*1023:*/
65 65
 #line 224 "./scales.w"
66 66
 
67 67
 void SerialScale::tare()
@@ -96,4 +96,4 @@ commandTerminator= "\x0A";
96 96
 }
97 97
 }
98 98
 
99
-/*:1011*/
99
+/*:1023*/

+ 6
- 2
src/scale.h Näytä tiedosto

@@ -1,4 +1,4 @@
1
-/*1007:*/
1
+/*1019:*/
2 2
 #line 103 "./scales.w"
3 3
 
4 4
 #ifndef TypicaScaleInclude
@@ -15,14 +15,18 @@ SerialScale(const QString&port);
15 15
 public slots:
16 16
 void tare();
17 17
 void weigh();
18
+void setWeighCommand(const QString&command);
19
+void setCommandTerminator(const QString&terminator);
18 20
 signals:
19 21
 void newMeasurement(double weight,Units::Unit unit);
20 22
 private slots:
21 23
 void dataAvailable();
22 24
 private:
23 25
 QByteArray responseBuffer;
26
+QByteArray weighCommand;
27
+QByteArray commandTerminator;
24 28
 };
25 29
 
26 30
 #endif
27 31
 
28
-/*:1007*/
32
+/*:1019*/

+ 2
- 17
src/thresholdannotation.w Näytä tiedosto

@@ -39,23 +39,8 @@ ThresholdAnnotationConfWidget::ThresholdAnnotationConfWidget(DeviceTreeModel *mo
39 39
     QLineEdit *source = new QLineEdit;
40 40
     layout->addRow(tr("Source column name:"), source);
41 41
     QDoubleSpinBox *value = new QDoubleSpinBox;
42
-
43
-@ A |QDoubleSpinBox| is used for entering the value. By default this allows for
44
-entering data in a range from 0 to 99.99, however this range is inadequate for
45
-many coffee roasting applications. Instead, we allow the full range of the
46
-underlying data type, but as this might be different on different platforms,
47
-another header is required.
48
-
49
-@<Header files to include@>=
50
-#include <limits>
51
-
52
-@ The number of decimal places is limited to 2, however this is an arbitrary
53
-decision which can be raised later if needed.
54
-
55
-@<ThresholdAnnotationConfWidget implementation@>=
56
-
57
-    value->setMinimum(std::numeric_limits<double>::min());
58
-    value->setMaximum(std::numeric_limits<double>::max());
42
+    value->setMinimum(-9999.99);
43
+    value->setMaximum(9999.99);
59 44
     value->setDecimals(2);
60 45
     layout->addRow(tr("Threshold value:"), value);
61 46
     QComboBox *direction = new QComboBox;

+ 723
- 730
src/typica.cpp
File diff suppressed because it is too large
Näytä tiedosto


+ 12
- 2
src/typica.w Näytä tiedosto

@@ -8222,6 +8222,7 @@ class ThresholdDetector : public QObject@/
8222 8222
     signals:@/
8223 8223
         void timeForValue(double);
8224 8224
     private:@/
8225
+        bool previousValueValid;
8225 8226
         double previousValue;
8226 8227
         double threshold;
8227 8228
         EdgeDirection currentDirection;
@@ -8230,12 +8231,19 @@ class ThresholdDetector : public QObject@/
8230 8231
 @ This class emits the time in seconds when a given measurement crosses the
8231 8232
 threshold value in the appropriate direction.
8232 8233
 
8234
+This was previously written with |previousValue| initialized negative and a
8235
+check that |previousValue| was non-negative. When the |ThresholdDetector| is
8236
+connected to a data source representing temperature measurements this is a
8237
+reasonable choice, however it breaks when connected to a rate of change series.
8238
+To make this more generally correct, a boolean is checked to determine if a
8239
+previous value has been set.
8240
+
8233 8241
 @<ThresholdDetector Implementation@>=
8234 8242
 void ThresholdDetector::newMeasurement(Measurement measure)
8235 8243
 {
8236 8244
     if((currentDirection == Ascending && previousValue < threshold &&
8237
-       previousValue >= 0) || (currentDirection == Descending &&
8238
-       previousValue > threshold && previousValue >= 0))
8245
+       previousValueValid) || (currentDirection == Descending &&
8246
+       previousValue > threshold && previousValueValid))
8239 8247
     {
8240 8248
         if((currentDirection == Ascending && measure.temperature() >= threshold) ||
8241 8249
            (currentDirection == Descending && measure.temperature() <= threshold))
@@ -8248,9 +8256,11 @@ void ThresholdDetector::newMeasurement(Measurement measure)
8248 8256
         }
8249 8257
     }
8250 8258
     previousValue = measure.temperature();
8259
+    previousValueValid = true;
8251 8260
 }
8252 8261
 
8253 8262
 ThresholdDetector::ThresholdDetector(double value) : QObject(NULL),
8263
+    previousValueValid(false),
8254 8264
     previousValue(-1), threshold(value), currentDirection(Ascending)
8255 8265
 {
8256 8266
     /* Nothing needs to be done here. */

Loading…
Peruuta
Tallenna