Browse Source

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

Neal Wilson 8 years ago
parent
commit
3662712508
12 changed files with 774 additions and 780 deletions
  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 View File

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

+ 17
- 15
src/daterangeselector.cpp View File

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

+ 1
- 1
src/daterangeselector.h View File

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

+ 2
- 2
src/draglabel.cpp View File

1
-/*1002:*/
1
+/*1014:*/
2
 #line 33 "./scales.w"
2
 #line 33 "./scales.w"
3
 
3
 
4
 #include "draglabel.h"
4
 #include "draglabel.h"
26
 }
26
 }
27
 }
27
 }
28
 
28
 
29
-/*:1002*/
29
+/*:1014*/

+ 2
- 2
src/draglabel.h View File

1
-/*1001:*/
1
+/*1013:*/
2
 #line 13 "./scales.w"
2
 #line 13 "./scales.w"
3
 
3
 
4
 #ifndef TypicaDragLabelInclude
4
 #ifndef TypicaDragLabelInclude
17
 
17
 
18
 #endif
18
 #endif
19
 
19
 
20
-/*:1001*/
20
+/*:1013*/

+ 1
- 1
src/helpmenu.cpp View File

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

+ 1
- 1
src/licensewindow.cpp View File

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

+ 6
- 6
src/scale.cpp View File

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

+ 6
- 2
src/scale.h View File

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

+ 2
- 17
src/thresholdannotation.w View File

39
     QLineEdit *source = new QLineEdit;
39
     QLineEdit *source = new QLineEdit;
40
     layout->addRow(tr("Source column name:"), source);
40
     layout->addRow(tr("Source column name:"), source);
41
     QDoubleSpinBox *value = new QDoubleSpinBox;
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
     value->setDecimals(2);
44
     value->setDecimals(2);
60
     layout->addRow(tr("Threshold value:"), value);
45
     layout->addRow(tr("Threshold value:"), value);
61
     QComboBox *direction = new QComboBox;
46
     QComboBox *direction = new QComboBox;

+ 723
- 730
src/typica.cpp
File diff suppressed because it is too large
View File


+ 12
- 2
src/typica.w View File

8222
     signals:@/
8222
     signals:@/
8223
         void timeForValue(double);
8223
         void timeForValue(double);
8224
     private:@/
8224
     private:@/
8225
+        bool previousValueValid;
8225
         double previousValue;
8226
         double previousValue;
8226
         double threshold;
8227
         double threshold;
8227
         EdgeDirection currentDirection;
8228
         EdgeDirection currentDirection;
8230
 @ This class emits the time in seconds when a given measurement crosses the
8231
 @ This class emits the time in seconds when a given measurement crosses the
8231
 threshold value in the appropriate direction.
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
 @<ThresholdDetector Implementation@>=
8241
 @<ThresholdDetector Implementation@>=
8234
 void ThresholdDetector::newMeasurement(Measurement measure)
8242
 void ThresholdDetector::newMeasurement(Measurement measure)
8235
 {
8243
 {
8236
     if((currentDirection == Ascending && previousValue < threshold &&
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
         if((currentDirection == Ascending && measure.temperature() >= threshold) ||
8248
         if((currentDirection == Ascending && measure.temperature() >= threshold) ||
8241
            (currentDirection == Descending && measure.temperature() <= threshold))
8249
            (currentDirection == Descending && measure.temperature() <= threshold))
8248
         }
8256
         }
8249
     }
8257
     }
8250
     previousValue = measure.temperature();
8258
     previousValue = measure.temperature();
8259
+    previousValueValid = true;
8251
 }
8260
 }
8252
 
8261
 
8253
 ThresholdDetector::ThresholdDetector(double value) : QObject(NULL),
8262
 ThresholdDetector::ThresholdDetector(double value) : QObject(NULL),
8263
+    previousValueValid(false),
8254
     previousValue(-1), threshold(value), currentDirection(Ascending)
8264
     previousValue(-1), threshold(value), currentDirection(Ascending)
8255
 {
8265
 {
8256
     /* Nothing needs to be done here. */
8266
     /* Nothing needs to be done here. */

Loading…
Cancel
Save