Typica is a free program for professional coffee roasters. https://typica.us
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

profilehistory.xml 5.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. <window id="profilehistory">
  2. <layout type="vertical">
  3. <layout type="horizontal">
  4. <label>Coffee:</label>
  5. <sqldrop data="0" display="1" showdata="false" editable="false" id="coffees">
  6. <query>SELECT id, name FROM items WHERE category = 'Coffee: Roasted' AND id IN (SELECT item FROM current_items) ORDER BY name</query>
  7. </sqldrop>
  8. <stretch />
  9. </layout>
  10. <splitter type="horizontal" id="outersplitter">
  11. <widget>
  12. <layout type="vertical">
  13. <sqlview id="profilelist" />
  14. </layout>
  15. </widget>
  16. <widget>
  17. <layout type="vertical">
  18. <layout type="horizontal">
  19. <button name="Set as Current Target Roast Profile"
  20. id="setcurrent" type="push" />
  21. <stretch />
  22. </layout>
  23. <splitter type="horizontal">
  24. <measurementtable id="log" />
  25. <graph id = "graph" />
  26. </splitter>
  27. </layout>
  28. </widget>
  29. </splitter>
  30. </layout>
  31. <menu name="File">
  32. <item id="save" shortcut="Ctrl+S">Save...</item>
  33. <item id="export">Export CSV...</item>
  34. </menu>
  35. <menu name="Log">
  36. <item id="showC">Display Celsius</item>
  37. <item id="showF">Display Fahrenheit</item>
  38. <separator />
  39. <item id="ms">Millisecond view</item>
  40. <item id="1s">1 Second View</item>
  41. <item id="5s">5 Second View</item>
  42. <item id="10s">10 Second View</item>
  43. <item id="15s">15 Second View</item>
  44. <item id="30s">30 Second View</item>
  45. <item id="1m">1 Minute View</item>
  46. </menu>
  47. <program>
  48. <![CDATA[
  49. var profileList = findChildObject(this, 'profilelist');
  50. var coffeelist = findChildObject(this, 'coffees');
  51. var graph = findChildObject(this, 'graph');
  52. var log = findChildObject(this, 'log');
  53. var setCurrent = findChildObject(this, 'setcurrent');
  54. setCurrent.enabled = false;
  55. var currentProfileID;
  56. setCurrent.clicked.connect(function() {
  57. var query = new QSqlQuery();
  58. query.prepare("INSERT INTO item_files (time, item, files) VALUES('now', :coffee, :profile)");
  59. query.bind(":coffee", coffeelist.currentData());
  60. query.bind(":profile", "{" + currentProfileID + "}");
  61. query.exec();
  62. query = query.invalidate();
  63. listProfiles(coffeelist.currentData());
  64. });
  65. var listProfiles = function(roastedID) {
  66. q = "SELECT time, files[1] AS profile FROM item_files WHERE item =";
  67. q += roastedID;
  68. q += " ORDER BY time DESC";
  69. profileList.setQuery(q);
  70. };
  71. var displayProfile = function(profileID) {
  72. currentProfileID = profileID;
  73. setCurrent.enabled = true;
  74. var query = new QSqlQuery();
  75. query.prepare("SELECT file FROM files WHERE id = :id");
  76. query.bind(":id", profileID);
  77. query.exec();
  78. if(query.next())
  79. {
  80. var buffer = new QBuffer(query.value(0));
  81. var input = new XMLInput(buffer, 1);
  82. log.clearOutputColumns();
  83. input.newTemperatureColumn.connect(log.setHeaderData);
  84. input.newTemperatureColumn.connect(log.addOutputTemperatureColumn);
  85. input.newAnnotationColumn.connect(log.setHeaderData);
  86. input.newAnnotationColumn.connect(log.addOutputAnnotationColumn);
  87. input.measure.connect(graph.newMeasurement);
  88. input.measure.connect(log.newMeasurement);
  89. var lc;
  90. input.lastColumn.connect(function(c) {
  91. lc = c;
  92. });
  93. input.annotation.connect(function(annotation, mc, nc) {
  94. for(var i = mc; i < lc; i++) {
  95. log.newAnnotation(annotation, i, nc);
  96. }
  97. });
  98. graph.updatesEnabled = false;
  99. log.updatesEnabled = false;
  100. input.input();
  101. log.updatesEnabled = true;
  102. graph.updatesEnabled = true;
  103. }
  104. query = query.invalidate();
  105. };
  106. coffeelist['currentIndexChanged(int)'].connect(function() {
  107. listProfiles(coffeelist.currentData());
  108. setCurrent.enabled = false;
  109. log.clear();
  110. graph.clear();
  111. });
  112. listProfiles(coffeelist.currentData());
  113. profileList.openEntryRow.connect(function(row) {
  114. log.clear();
  115. graph.clear();
  116. displayProfile(profileList.data(row, 1));
  117. });
  118. var v1 = findChildObject(this, 'ms');
  119. v1.triggered.connect(log.LOD_ms);
  120. var v2 = findChildObject(this, '1s');
  121. v2.triggered.connect(log.LOD_1s);
  122. var v3 = findChildObject(this, '5s');
  123. v3.triggered.connect(log.LOD_5s);
  124. var v4 = findChildObject(this, '10s');
  125. v4.triggered.connect(log.LOD_10s);
  126. var v5 = findChildObject(this, '15s');
  127. v5.triggered.connect(log.LOD_15s);
  128. var v6 = findChildObject(this, '30s');
  129. v6.triggered.connect(log.LOD_30s);
  130. var v7 = findChildObject(this, '1m');
  131. v7.triggered.connect(log.LOD_1m);
  132. var showC = findChildObject(this, 'showC');
  133. showC.triggered.connect(function() {
  134. log.setDisplayUnits(Units.Celsius);
  135. graph.showC();
  136. });
  137. var showF = findChildObject(this, 'showF');
  138. showF.triggered.connect(function() {
  139. log.setDisplayUnits(Units.Fahrenheit);
  140. graph.showF();
  141. });
  142. var saveMenu = findChildObject(this, 'save');
  143. saveMenu.triggered.connect(function() {
  144. var filename = QFileDialog.getSaveFileName(window, TTR("basicWindow", "Save Log As..."), QSettings.value("script/lastDir", "") + "/");
  145. if(filename != "") {
  146. var file = new QFile(filename);
  147. log.saveXML(file);
  148. QSettings.setValue("script/lastDir", dir(filename));
  149. }
  150. });
  151. var exportMenu = findChildObject(this, 'export');
  152. exportMenu.triggered.connect(function() {
  153. var filename = QFileDialog.getSaveFileName(window, TTR("basicWindow", "Export CSV As..."), QSettings.value("script/lastDir", "") + "/");
  154. if(filename != "") {
  155. var file = new QFile(filename);
  156. log.saveCSV(file);
  157. QSettings.setValue("script/lastDir", dir(filename));
  158. }
  159. });
  160. ]]>
  161. </program>
  162. </window>