Browse Source

Configuration settings for Javalytics communication

Neal Wilson 6 years ago
parent
commit
b76634aebf
2 changed files with 95 additions and 1 deletions
  1. 90
    0
      src/colorsettings.w
  2. 5
    1
      src/settings.w

+ 90
- 0
src/colorsettings.w View File

@@ -0,0 +1,90 @@
1
+@* Degree of roast analysis configuration.
2
+
3
+\noindent \pn{} 1.9 adds support for communicating with the Javalytics
4
+JAV-RDA-D degree of roast analyzer from Madison Instruments, and with it, the
5
+ability to track roast color data. There are some settings that are specific to
6
+this device which need to be configurable, but saving roast color data need not
7
+be manufacturer specific and manual data entry options should be provided for
8
+people choosing devices without a communications option.
9
+
10
+If support for additional devices is added in the future, these settings may
11
+need to be redesigned to better support competing options. There is also an
12
+assumption that only one of these machines will be in use at one time from any
13
+given instance of \pn{}.
14
+
15
+@<Class declarations@>=
16
+class ColorSettingsWidget : public QWidget@/
17
+{@/
18
+    @[Q_OBJECT@]@;
19
+    public:@/
20
+        ColorSettingsWidget();@/
21
+    @[public slots@]:@/
22
+        void updateEnable(bool enable);
23
+        void updateAddress(const QString &address);
24
+        void updateScale(int sccale);
25
+};
26
+
27
+@ There are several options available for configuring supported hardware, but
28
+for the initial implementation the preference is to keep things as simple as
29
+possible, adding support for additional features only as requested. As such,
30
+the current options are whether to communicate with external hardware at all,
31
+the IP address of the device, and the scale to request when taking measurements
32
+from \pn{}.
33
+
34
+Testing indicates that when batch numbering is enabled, it is still better to
35
+not send an explicit batch number to the device. Sending a number that is equal
36
+or lower than one used previously results in a silent failure while not sending
37
+a number when this feature is enabled results in the next number in the
38
+sequence being chosen automatically.
39
+
40
+@<ColorSettingsWidget implementation@>=
41
+ColorSettingsWidget::ColorSettingsWidget() : QWidget(NULL)
42
+{
43
+    QFormLayout *layout = new QFormLayout;
44
+    QCheckBox *enable = new QCheckBox(tr("Enable Javalytics communication"));
45
+    QSettings settings;
46
+    enable->setChecked(settings.value("settings/color/javalytics/enable", false).toBool());
47
+    QLineEdit *address = new QLineEdit();
48
+    address->setText(settings.value("settings/color/javalytics/address", "192.168.1.10").toString());
49
+    QSpinBox *scale = new QSpinBox();
50
+    scale->setMinimum(1);
51
+    scale->setMaximum(4);
52
+    scale->setValue(settings.value("settings/color/javalytics/scale", 1).toInt());
53
+    connect(enable, SIGNAL(toggled(bool)), this, SLOT(updateEnable(bool)));
54
+    connect(address, SIGNAL(textChanged(QString)), this, SLOT(updateAddress(QString)));
55
+    connect(scale, SIGNAL(valueChanged(int)), this, SLOT(updateScale(int)));
56
+    layout->addRow(enable);
57
+    layout->addRow(tr("IP Address:"), address);
58
+    layout->addRow(tr("Scale Number:"), scale);
59
+    updateEnable(enable->isChecked());
60
+    updateAddress(address->text());
61
+    updateScale(scale->value());
62
+    setLayout(layout);
63
+}
64
+
65
+@ Trivial methods update the settings as their corresponding controls are
66
+edited.
67
+
68
+@<ColorSettingsWidget implementation@>=
69
+void ColorSettingsWidget::updateEnable(bool enable)
70
+{
71
+    QSettings settings;
72
+    settings.setValue("settings/color/javalytics/enable", enable);
73
+}
74
+
75
+void ColorSettingsWidget::updateAddress(const QString &address)
76
+{
77
+    QSettings settings;
78
+    settings.setValue("settings/color/javalytics/address", address);
79
+}
80
+
81
+void ColorSettingsWidget::updateScale(int scale)
82
+{
83
+    QSettings settings;
84
+    settings.setValue("settings/color/javalytics/scale", scale);
85
+}
86
+
87
+@ This is included in typica.cpp.
88
+
89
+@<Class implementations@>=
90
+@<ColorSettingsWidget implementation@>

+ 5
- 1
src/settings.w View File

@@ -31,6 +31,8 @@ SettingsWindow::SettingsWindow() : QMainWindow(NULL)
31 31
 	settingsTab->addTab(deviceSettings, tr("Roasters"));
32 32
 	GraphSettingsWidget *graphSettings = new GraphSettingsWidget;
33 33
 	settingsTab->addTab(graphSettings, tr("Graph"));
34
+	ColorSettingsWidget *colorSettings = new ColorSettingsWidget;
35
+	settingsTab->addTab(colorSettings, tr("Color"));
34 36
 	AdvancedSettingsWidget *advancedSettings = new AdvancedSettingsWidget;
35 37
 	settingsTab->addTab(advancedSettings, tr("Advanced"));
36 38
 	setCentralWidget(settingsTab);
@@ -60,4 +62,6 @@ engine->globalObject().setProperty("SettingsWindow", value);
60 62
 
61 63
 @i graphsettings.w
62 64
 
63
-@i advancedsettings.w
65
+@i colorsettings.w
66
+
67
+@i advancedsettings.w

Loading…
Cancel
Save