Neal Wilson преди 9 години
родител
ревизия
8eeda42468
променени са 1 файла, в които са добавени 262 реда и са изтрити 0 реда
  1. 262
    0
      src/typica.w

+ 262
- 0
src/typica.w Целия файл

@@ -10554,6 +10554,7 @@ Q_PROPERTY(bool running READ isRunning)@/
10554 10554
 Q_PROPERTY(QTime resetValue READ resetValue WRITE setResetValue)@/
10555 10555
 Q_PROPERTY(QString displayFormat READ displayFormat WRITE setDisplayFormat)@/
10556 10556
 Q_PROPERTY(bool autoReset READ autoReset WRITE setAutoReset)@/
10557
+Q_PROPERTY(QString value READ value)@/
10557 10558
 
10558 10559
 @ A number of private variables are used to implement this class.
10559 10560
 
@@ -19273,6 +19274,267 @@ CoolingTimerConfWidget::staticMetaObject);
19273 19274
 @<Class implementations@>=
19274 19275
 @<CoolingTimerConfWidget implementation@>
19275 19276
 
19277
+@ The other two timer types are intended for measuring ranges of interest
19278
+within a batch. These have more configuration options. First is the range
19279
+timer. Someone setting this up needs to decide how the timer is started.
19280
+Sensible options include starting the timer at the start of the batch,
19281
+starting the timer when a button is pressed, or starting the timer when a set
19282
+point is reached on the ascent of a named data series. Stopping the timer is
19283
+also a configurable concern. This will be stopped at the end of the batch,
19284
+but it might be stopped sooner on reaching some threshold or when a button is
19285
+pressed. There are also questions of how the information is persisted with the
19286
+roasting records.
19287
+
19288
+@<Class declarations@>=
19289
+class RangeTimerConfWidget : public BasicDeviceConfigurationWidget
19290
+{
19291
+    @[Q_OBJECT@]@;
19292
+    public:@/
19293
+        @[Q_INVOKABLE@]@, RangeTimerConfWidget(DeviceTreeModel *model, const QModelIndex &index);
19294
+    @[private slots@]:@/
19295
+        void updateStartButtonText(const QString &text);
19296
+        void updateStopButtonText(const QString &text);
19297
+        void updateStartColumnName(const QString &text);
19298
+        void updateStopColumnName(const QString &text);
19299
+        void updateStartValue(const QString &text);
19300
+        void updateStopValue(const QString &text);
19301
+        void updateStartTrigger(int option);
19302
+        void updateStopTrigger(int option);
19303
+};
19304
+
19305
+@ The constructor sets up controls for configuring these details.
19306
+
19307
+@<RangeTimerConfWidget implementation@>=
19308
+RangeTimerConfWidget::RangeTimerConfWidget(DeviceTreeModel *model, const QModelIndex &index)
19309
+: BasicDeviceConfigurationWidget(model, index)
19310
+{
19311
+    QVBoxLayout *layout = new QVBoxLayout;
19312
+    
19313
+    QGroupBox *startConfigurationGroup = new QGroupBox(tr("Start trigger"));
19314
+    QRadioButton *startBatchOption = new QRadioButton(tr("Start of batch"));
19315
+    QRadioButton *buttonOption = new QRadioButton(tr("Manual"));
19316
+    QRadioButton *thresholdOption = new QRadioButton(tr("At temperature"));
19317
+    QButtonGroup *startOptionGroup = new QButtonGroup;
19318
+    startOptionGroup->addButton(startBatchOption, 1);
19319
+    startOptionGroup->addButton(buttonOption, 2);
19320
+    startOptionGroup->addButton(thresholdOption, 3);
19321
+    startBatchOption->setChecked(true);
19322
+    QGridLayout *startOptions = new QGridLayout;
19323
+    startOptions->addWidget(startBatchOption, 0, 0);
19324
+    startOptions->addWidget(buttonOption, 1, 0);
19325
+    startOptions->addWidget(thresholdOption, 2, 0);
19326
+    QLabel *buttonTextLabel = new QLabel(tr("Button Text: "));
19327
+    QLineEdit *buttonTextEdit = new QLineEdit;
19328
+    QHBoxLayout *buttonTextOptions = new QHBoxLayout;
19329
+    buttonTextOptions->addWidget(buttonTextLabel);
19330
+    buttonTextOptions->addWidget(buttonTextEdit);
19331
+    startOptions->addLayout(buttonTextOptions, 1, 1);
19332
+    QFormLayout *thresholdOptions = new QFormLayout;
19333
+    QLineEdit *startColumnName = new QLineEdit;
19334
+    QLineEdit *startValue = new QLineEdit;
19335
+    thresholdOptions->addRow(tr("Column Name: "), startColumnName);
19336
+    thresholdOptions->addRow(tr("Value: "), startValue);
19337
+    startOptions->addLayout(thresholdOptions, 2, 1);
19338
+    startConfigurationGroup->setLayout(startOptions);
19339
+    layout->addWidget(startConfigurationGroup);
19340
+    
19341
+    QGroupBox *stopConfigurationGroup = new QGroupBox(tr("Stop trigger"));
19342
+    QRadioButton *stopBatchOption = new QRadioButton(tr("End of batch"));
19343
+    QRadioButton *stopButtonOption = new QRadioButton(tr("Manual"));
19344
+    QRadioButton *stopThresholdOption = new QRadioButton(tr("At temperature"));
19345
+    QButtonGroup *stopOptionGroup = new QButtonGroup;
19346
+    stopOptionGroup->addButton(stopBatchOption, 1);
19347
+    stopOptionGroup->addButton(stopButtonOption, 2);
19348
+    stopOptionGroup->addButton(stopThresholdOption, 3);
19349
+    stopBatchOption->setChecked(true);
19350
+    QGridLayout *stopOptions = new QGridLayout;
19351
+    stopOptions->addWidget(stopBatchOption, 0, 0);
19352
+    stopOptions->addWidget(stopButtonOption, 1, 0);
19353
+    stopOptions->addWidget(stopThresholdOption, 2, 0);
19354
+    QLabel *stopButtonLabel = new QLabel(tr("Button Text: "));
19355
+    QLineEdit *stopButtonEdit = new QLineEdit;
19356
+    QHBoxLayout *stopButtonTextOptions = new QHBoxLayout;
19357
+    stopButtonTextOptions->addWidget(stopButtonLabel);
19358
+    stopButtonTextOptions->addWidget(stopButtonEdit);
19359
+    stopOptions->addLayout(stopButtonTextOptions, 1, 1);
19360
+    QLineEdit *stopColumnName = new QLineEdit;
19361
+    QLineEdit *stopValue = new QLineEdit;
19362
+    QFormLayout *stopThresholdOptions = new QFormLayout;
19363
+    stopThresholdOptions->addRow(tr("Column Name: "), stopColumnName);
19364
+    stopThresholdOptions->addRow(tr("Value: "), stopValue);
19365
+    stopOptions->addLayout(stopThresholdOptions, 2, 1);
19366
+    stopConfigurationGroup->setLayout(stopOptions);
19367
+    layout->addWidget(stopConfigurationGroup);
19368
+    
19369
+    @<Get device configuration data for current node@>@;
19370
+    for(int i = 0; i < configData.size(); i++)
19371
+    {
19372
+        node = configData.at(i).toElement();
19373
+        if(node.attribute("name") == "startbuttontext")
19374
+        {
19375
+            buttonTextEdit->setText(node.attribute("value"));
19376
+        }
19377
+        else if(node.attribute("name") == "stopbuttontext")
19378
+        {
19379
+            stopButtonEdit->setText(node.attribute("value"));
19380
+        }
19381
+        else if(node.attribute("name") == "startcolumnname")
19382
+        {
19383
+            startColumnName->setText(node.attribute("value"));
19384
+        }
19385
+        else if(node.attribute("name") == "stopcolumnname")
19386
+        {
19387
+            stopColumnName->setText(node.attribute("value"));
19388
+        }
19389
+        else if(node.attribute("name") == "startvalue")
19390
+        {
19391
+            startValue->setText(node.attribute("value"));
19392
+        }
19393
+        else if(node.attribute("name") == "stopvalue")
19394
+        {
19395
+            stopValue->setText(node.attribute("value"));
19396
+        }
19397
+        else if(node.attribute("name") == "starttrigger")
19398
+        {
19399
+            if(node.attribute("value") == "batch")
19400
+            {
19401
+                startBatchOption->setChecked(true);
19402
+            }
19403
+            else if(node.attribute("value") == "manual")
19404
+            {
19405
+                buttonOption->setChecked(true);
19406
+            }
19407
+            else if(node.attribute("value") == "value")
19408
+            {
19409
+                thresholdOption->setChecked(true);
19410
+            }
19411
+        }
19412
+        else if(node.attribute("name") == "stoptrigger")
19413
+        {
19414
+            if(node.attribute("value") == "batch")
19415
+            {
19416
+                stopBatchOption->setChecked(true);
19417
+            }
19418
+            else if(node.attribute("value") == "manual")
19419
+            {
19420
+                stopButtonOption->setChecked(true);
19421
+            }
19422
+            else if(node.attribute("value") == "value")
19423
+            {
19424
+                stopThresholdOption->setChecked(true);
19425
+            }
19426
+        }
19427
+    }
19428
+    updateStartButtonText(buttonTextEdit->text());
19429
+    updateStopButtonText(stopButtonEdit->text());
19430
+    updateStartColumnName(startColumnName->text());
19431
+    updateStopColumnName(stopColumnName->text());
19432
+    updateStartValue(startValue->text());
19433
+    updateStopValue(stopValue->text());
19434
+    updateStartTrigger(startOptionGroup->checkedId());
19435
+    updateStopTrigger(stopOptionGroup->checkedId());
19436
+    
19437
+    setLayout(layout);
19438
+    
19439
+    connect(buttonTextEdit, SIGNAL(textChanged(QString)),
19440
+            this, SLOT(updateStartButtonText(QString)));
19441
+    connect(stopButtonEdit, SIGNAL(textChanged(QString)),
19442
+            this, SLOT(updateStopButtonText(QString)));
19443
+    connect(startColumnName, SIGNAL(textChanged(QString)),
19444
+            this, SLOT(updateStartColumnName(QString)));
19445
+    connect(stopColumnName, SIGNAL(textChanged(QString)),
19446
+            this, SLOT(updateStopColumnName(QString)));
19447
+    connect(startValue, SIGNAL(textChanged(QString)),
19448
+            this, SLOT(updateStartValue(QString)));
19449
+    connect(stopValue, SIGNAL(textChanged(QString)),
19450
+            this, SLOT(updateStopValue(QString)));
19451
+    connect(startOptionGroup, SIGNAL(buttonClicked(int)),
19452
+            this, SLOT(updateStartTrigger(int)));
19453
+    connect(stopOptionGroup, SIGNAL(buttonClicked(int)),
19454
+            this, SLOT(updateStopTrigger(int)));
19455
+}
19456
+
19457
+@ Small methods update the configuration as usual.
19458
+
19459
+@<RangeTimerConfWidget implementation@>=
19460
+void RangeTimerConfWidget::updateStartButtonText(const QString &text)
19461
+{
19462
+    updateAttribute("startbuttontext", text);
19463
+}
19464
+
19465
+void RangeTimerConfWidget::updateStopButtonText(const QString &text)
19466
+{
19467
+    updateAttribute("stopbuttontext", text);
19468
+}
19469
+
19470
+void RangeTimerConfWidget::updateStartColumnName(const QString &text)
19471
+{
19472
+    updateAttribute("startcolumnname", text);
19473
+}
19474
+
19475
+void RangeTimerConfWidget::updateStopColumnName(const QString &text)
19476
+{
19477
+    updateAttribute("stopcolumnname", text);
19478
+}
19479
+
19480
+void RangeTimerConfWidget::updateStartValue(const QString &text)
19481
+{
19482
+    updateAttribute("startvalue", text);
19483
+}
19484
+
19485
+void RangeTimerConfWidget::updateStopValue(const QString &text)
19486
+{
19487
+    updateAttribute("stopvalue", text);
19488
+}
19489
+
19490
+void RangeTimerConfWidget::updateStartTrigger(int option)
19491
+{
19492
+    switch(option)
19493
+    {
19494
+        case 1:
19495
+            updateAttribute("starttrigger", "batch");
19496
+            break;
19497
+        case 2:
19498
+            updateAttribute("starttrigger", "manual");
19499
+            break;
19500
+        case 3:
19501
+            updateAttribute("starttrigger", "value");
19502
+            break;
19503
+        default:
19504
+            break;
19505
+    }
19506
+}
19507
+
19508
+void RangeTimerConfWidget::updateStopTrigger(int option)
19509
+{
19510
+    switch(option)
19511
+    {
19512
+        case 1:
19513
+            updateAttribute("stoptrigger", "batch");
19514
+            break;
19515
+        case 2:
19516
+            updateAttribute("stoptrigger", "manual");
19517
+            break;
19518
+        case 3:
19519
+            updateAttribute("stoptrigger", "value");
19520
+            break;
19521
+        default:
19522
+            break;
19523
+    }
19524
+}
19525
+
19526
+
19527
+
19528
+@ The widget is registered with the configuration system.
19529
+@<Register device configuration widgets@>=
19530
+app.registerDeviceConfigurationWidget("rangetimer",
19531
+RangeTimerConfWidget::staticMetaObject);
19532
+
19533
+@ The implementation chunk for now is in the main source file.
19534
+
19535
+@<Class implementations@>=
19536
+@<RangeTimerConfWidget implementation@>
19537
+
19276 19538
 @* Profile Translation Configuration Widget.
19277 19539
 
19278 19540
 \noindent Configuring profile translation requires knowing which column to use

Loading…
Отказ
Запис