Typica is a free program for professional coffee roasters. https://typica.us
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

colorsettings.w 3.5KB

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