Typica is a free program for professional coffee roasters. https://typica.us
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <window id="optime">
  2. <layout type="vertical">
  3. <layout type="horizontal">
  4. <label>Machine:</label>
  5. <sqldrop data="0" display="1" showdata="true" id="machine">
  6. <query>SELECT id, name FROM machine ORDER BY name</query>
  7. </sqldrop>
  8. <stretch />
  9. </layout>
  10. <layout type="horizontal">
  11. <label>Start Time:</label>
  12. <line id="starttime" writable="false" />
  13. <button name="Start Roaster" type="push" id="start" />
  14. </layout>
  15. <layout type="horizontal">
  16. <label>Stop Time:</label>
  17. <line id="stoptime" writable="false" />
  18. <button name="Stop Roaster" type="push" id="stop" />
  19. </layout>
  20. <layout type="horizontal">
  21. <label>Duration:</label>
  22. <line id="duration" writable="false" />
  23. <button name="Submit" type="push" id="submit" />
  24. </layout>
  25. </layout>
  26. <program>
  27. <![CDATA[
  28. var window = this;
  29. var startbutton = findChildObject(this, "start");
  30. var stopbutton = findChildObject(this, "stop");
  31. var submitbutton = findChildObject(this, "submit");
  32. stopbutton.setEnabled(false);
  33. submitbutton.setEnabled(false);
  34. var startline = findChildObject(this, "starttime");
  35. var stopline = findChildObject(this, "stoptime");
  36. var durationline = findChildObject(this, "duration");
  37. var machine = findChildObject(this, "machine");
  38. machine.currentIndex = QSettings.value("lastMachineStarted", 0);
  39. machine['currentIndexChanged(int)'].connect(function() {
  40. QSettings.setValue("lastMachineStarted", machine.currentIndex);
  41. });
  42. startbutton.clicked.connect(function() {
  43. query = new QSqlQuery();
  44. query.exec("SELECT now()::timestamp without time zone");
  45. query.next();
  46. var result = query.value(0);
  47. query = query.invalidate();
  48. startline.text = result.replace('T', ' ');
  49. stopbutton.setEnabled(true);
  50. });
  51. stopbutton.clicked.connect(function() {
  52. query = new QSqlQuery();
  53. query.exec("SELECT now()::timestamp without time zone");
  54. query.next();
  55. var result = query.value(0);
  56. stopline.text = result.replace('T', ' ');
  57. var q = "SELECT '" + stopline.text + "'::timestamp - '" + startline.text + "'::timestamp";
  58. query.exec(q);
  59. query.next();
  60. durationline.text = query.value(0);
  61. query = query.invalidate();
  62. submitbutton.setEnabled(true);
  63. });
  64. submitbutton.clicked.connect(function() {
  65. query = new QSqlQuery();
  66. var q = "INSERT INTO operational_time (machine, start_time, end_time, duration) VALUES (:machine, :start, :stop, :duration)";
  67. query.prepare(q);
  68. query.bind(":machine", machine.currentData());
  69. query.bind(":start", startline.text);
  70. query.bind(":stop", stopline.text);
  71. query.bind(":duration", durationline.text);
  72. query.exec();
  73. query = query.invalidate();
  74. window.close();
  75. });
  76. ]]>
  77. </program>
  78. </window>