Typica is a free program for professional coffee roasters. https://typica.us
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

batchdetailsnew.xml 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  1. <window id="batchDetails">
  2. <layout type="vertical">
  3. <layout type="horizontal">
  4. <button type="push" id="target" name="Load profile as target" />
  5. <button type="push" id="viewprofile" name="View profile" />
  6. <button type="push" id="compare" name="Compare profile" />
  7. </layout>
  8. <webview id="view" />
  9. </layout>
  10. <program>
  11. <![CDATA[
  12. var window = this;
  13. dataView = findChildObject(this, 'view');
  14. var fileID;
  15. var target = findChildObject(this, 'target');
  16. var compare = findChildObject(this, 'compare');
  17. if(typeof(navigationwindow.loggingWindow) == "undefined") {
  18. compare.enabled = false;
  19. target.enabled = false;
  20. }
  21. compare.clicked.connect(function() {
  22. var query = new QSqlQuery;
  23. query.prepare("SELECT file, name FROM files WHERE id = :id");
  24. query.bind(":id", Number(fileID));
  25. query.exec();
  26. query.next();
  27. var buffer = new QBuffer(query.value(0));
  28. var pname = query.value(1);
  29. query = query.invalidate();
  30. var startSeries = Number(QSettings.value('cseries', 3));
  31. var nextSeries = startSeries + 2;
  32. QSettings.setValue('cseries', nextSeries);
  33. var input = new XMLInput(buffer, startSeries);
  34. var graph = findChildObject(navigationwindow.loggingWindow, 'graph');
  35. input.measure.connect(graph.newMeasurement);
  36. input.input();
  37. query = query.invalidate();
  38. });
  39. target.clicked.connect(function() {
  40. var query = new QSqlQuery;
  41. query.prepare("SELECT file, name FROM files WHERE id = :id");
  42. query.bind(":id", Number(fileID));
  43. query.exec();
  44. query.next();
  45. var buffer = new QBuffer(query.value(0));
  46. var pname = query.value(1);
  47. query = query.invalidate();
  48. var input = new XMLInput(buffer, 1);
  49. var graph = findChildObject(navigationwindow.loggingWindow, 'graph');
  50. var log = findChildObject(navigationwindow.loggingWindow, 'log');
  51. log.clear();
  52. graph.clear();
  53. input.newTemperatureColumn.connect(log.setHeaderData);
  54. input.newTemperatureColumn.connect(function(col, text) {
  55. if(text == navigationwindow.loggingWindow.targetcolumnname)
  56. {
  57. targetseries = col;
  58. }
  59. });
  60. input.newAnnotationColumn.connect(log.setHeaderData);
  61. input.measure.connect(graph.newMeasurement);
  62. input.measure.connect(log.newMeasurement);
  63. input.measure.connect(function(data, series) {
  64. if(series == targetseries)
  65. {
  66. targetDetector.newMeasurement(data);
  67. }
  68. });
  69. var lc;
  70. input.lastColumn.connect(function(c) {
  71. lc = c;
  72. QSettings.setValue("liveColumn", c + 1);
  73. navigationwindow.loggingWindow.postLoadColumnSetup(c);
  74. });
  75. input.annotation.connect(log.newAnnotation);
  76. input.annotation.connect(function(note, tcol, ncol) {
  77. for(var i = tcol; i < ncol; i++) {
  78. log.newAnnotation(note, i, ncol);
  79. }
  80. });
  81. navigationwindow.loggingWindow.windowTitle = "Typica - " + pname;
  82. navigationwindow.loggingWindow.raise();
  83. navigationwindow.loggingWindow.activateWindow();
  84. input.input();
  85. log.newAnnotation("End", 1, lc);
  86. query = query.invalidate();
  87. });
  88. var viewbutton = findChildObject(this, 'viewprofile');
  89. viewbutton.clicked.connect(function() {
  90. var query = new QSqlQuery;
  91. query.prepare("SELECT file, name FROM files WHERE id = :id");
  92. query.bind(":id", Number(fileID));
  93. query.exec();
  94. if(query.next()) {
  95. var viewer = createWindow('offline');
  96. var buffer = new QBuffer(query.value(0));
  97. var pname = query.value(1);
  98. query = query.invalidate();
  99. var input = new XMLInput(buffer, 1);
  100. var graph = findChildObject(viewer, 'graph');
  101. var log = findChildObject(viewer, 'log');
  102. input.newTemperatureColumn.connect(log.setHeaderData);
  103. input.newTemperatureColumn.connect(function(column) {
  104. viewer.saveTemperatureColumns.push(column);
  105. });
  106. input.newAnnotationColumn.connect(log.setHeaderData);
  107. input.newAnnotationColumn.connect(function(column) {
  108. viewer.saveAnnotationColumns.push(column);
  109. });
  110. input.measure.connect(graph.newMeasurement);
  111. input.measure.connect(log.newMeasurement);
  112. input.annotation.connect(log.newAnnotation);
  113. var lc;
  114. input.lastColumn.connect(function(c) {
  115. lc = c;
  116. if(c < 3)
  117. {
  118. log.setHeaderData(3, "");
  119. }
  120. });
  121. input.annotation.connect(function(note, tcol, ncol) {
  122. for(var i = tcol; i < ncol; i++) {
  123. log.newAnnotation(note, i, ncol);
  124. }
  125. });
  126. viewer.windowTitle = "Typica - " + pname;
  127. viewer.raise();
  128. viewer.activateWindow();
  129. input.input();
  130. log.newAnnotation("End", 1, lc);
  131. }
  132. else {
  133. print("Query returned no results");
  134. }
  135. query = query.invalidate();
  136. });
  137. window.loadData = function(table, row) {
  138. var buffer = new QBuffer;
  139. buffer.open(3);
  140. var output = new XmlWriter(buffer);
  141. output.writeStartDocument("1.0");
  142. output.writeDTD('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN" "http://www.w3.org/2002/04/xhtml-math-svg.dtd">');
  143. output.writeStartElement("html");
  144. output.writeAttribute("xmlns", "http://www.w3.org/1999/xhtml");
  145. output.writeStartElement("head");
  146. output.writeTextElement("title", "Batch Details");
  147. output.writeEndElement();
  148. output.writeStartElement("body");
  149. output.writeStartElement("div");
  150. output.writeAttribute("style", "float: left; padding-right: 10px");
  151. output.writeStartElement("p");
  152. output.writeTextElement("strong", "Roasted Coffee: ");
  153. output.writeTextElement("span", table.data(row, 2));
  154. output.writeEndElement();
  155. output.writeEndElement();
  156. output.writeStartElement("div");
  157. output.writeAttribute("style", "float: left");
  158. output.writeStartElement("p");
  159. output.writeTextElement("strong", "Roasted On: ");
  160. output.writeTextElement("span", table.data(row, 0));
  161. output.writeEndElement();
  162. output.writeStartElement("p");
  163. output.writeTextElement("strong", "Batch Duration: ");
  164. output.writeTextElement("span", table.data(row, 6));
  165. output.writeEndElement();
  166. output.writeEndElement();
  167. output.writeStartElement("div");
  168. output.writeAttribute("style", "clear: both");
  169. output.writeEndElement();
  170. output.writeStartElement("table");
  171. output.writeStartElement("thead");
  172. output.writeStartElement("tr");
  173. output.writeTextElement("th", "Green Coffee");
  174. output.writeTextElement("th", "Weight (lb)");
  175. output.writeEndElement();
  176. output.writeEndElement();
  177. output.writeStartElement("tbody");
  178. var query = new QSqlQuery();
  179. query.prepare("SELECT unroasted_id, unroasted_quantity, approval, files, annotation FROM roasting_log WHERE time = :time AND machine = :machine");
  180. query.bind(":time", table.data(row, 0));
  181. query.bind(":machine", table.data(row, 1));
  182. query.exec();
  183. query.next();
  184. var items = sqlToArray(query.value(0));
  185. var quantities = sqlToArray(query.value(1));
  186. var nameQuery = new QSqlQuery();
  187. nameQuery.prepare("SELECT name FROM items WHERE id = :id");
  188. for(var i = 0; i < items.length; i++) {
  189. output.writeStartElement("tr");
  190. nameQuery.bind(":id", items[i]);
  191. nameQuery.exec();
  192. nameQuery.next();
  193. output.writeTextElement("td", nameQuery.value(0));
  194. output.writeStartElement("td");
  195. output.writeAttribute("align", "center");
  196. output.writeCharacters(quantities[i]);
  197. output.writeEndElement();
  198. output.writeEndElement();
  199. }
  200. nameQuery = nameQuery.invalidate();
  201. output.writeEndElement();
  202. output.writeStartElement("tfoot");
  203. output.writeStartElement("tr");
  204. output.writeStartElement("td");
  205. output.writeAttribute("align", "right");
  206. output.writeTextElement("strong", "Green Total:");
  207. output.writeEndElement();
  208. output.writeStartElement("td");
  209. output.writeAttribute("align", "center");
  210. output.writeCharacters(table.data(row, 3));
  211. output.writeEndElement();
  212. output.writeEndElement();
  213. output.writeStartElement("tr");
  214. output.writeStartElement("td");
  215. output.writeAttribute("align", "right");
  216. output.writeTextElement("strong", "Roasted Weight:");
  217. output.writeEndElement();
  218. output.writeStartElement("td");
  219. output.writeAttribute("align", "center");
  220. output.writeCharacters(table.data(row, 4));
  221. output.writeEndElement();
  222. output.writeEndElement();
  223. output.writeStartElement("tr");
  224. output.writeStartElement("td");
  225. output.writeAttribute("align", "right");
  226. output.writeTextElement("strong", "Weight Loss:");
  227. output.writeEndElement();
  228. output.writeStartElement("td");
  229. output.writeAttribute("align", "center");
  230. output.writeCharacters(table.data(row, 5));
  231. output.writeCharacters("%");
  232. output.writeEndElement();
  233. output.writeEndElement();
  234. output.writeEndElement();
  235. output.writeEndElement();
  236. output.writeStartElement("p");
  237. output.writeTextElement("strong", "Approved: ");
  238. output.writeCharacters(query.value(2));
  239. output.writeEndElement();
  240. output.writeStartElement("p");
  241. output.writeTextElement("strong", "Files: ");
  242. output.writeCharacters(query.value(3)); output.writeEndElement();
  243. output.writeStartElement("p");
  244. output.writeTextElement("strong", "Annotations:");
  245. var files = sqlToArray(query.value(3));
  246. var annotations = annotationFromRecord(files[0]);
  247. fileID = files[0];
  248. var buffer2 = new QBuffer("<points>"+annotations+"</points>");
  249. buffer2.open(1);
  250. var colQuery = new XQuery;
  251. colQuery.bind("profile", buffer2);
  252. colQuery.setQuery('for $i in doc($profile)//tuple[1]/temperature/@series return (string($i), ";")');
  253. var result = colQuery.exec();
  254. buffer2.close();
  255. var seriesHeaders = new Array();
  256. seriesHeaders.push("Time");
  257. var records = result.split(";");
  258. for(var i = 0; i < records.length - 1; i++) {
  259. seriesHeaders.push(records[i].replace(/^\s+|\s+$/g,""));
  260. }
  261. seriesHeaders.push("Note");
  262. output.writeStartElement("table");
  263. output.writeStartElement("thead");
  264. output.writeStartElement("tr");
  265. for(var i = 0; i < seriesHeaders.length; i++) {
  266. output.writeTextElement("th", seriesHeaders[i]);
  267. }
  268. output.writeEndElement();
  269. output.writeEndElement();
  270. buffer2.open(1);
  271. var rq = 'for $t in doc($profile) //tuple return (string($t/time), ";", ';
  272. for(var i = 0; i < seriesHeaders.length - 2; i++) {
  273. rq = rq + 'string($t/temperature[' + Number(i+1) + ']), ";", ';
  274. }
  275. rq = rq + 'string($t/annotation), "~")';
  276. colQuery.setQuery(rq);
  277. var annotationData = colQuery.exec();
  278. buffer2.close();
  279. output.writeStartElement("tbody");
  280. var annotationRecords = annotationData.split("~");
  281. for(var i = 0; i < annotationRecords.length - 1; i++) {
  282. output.writeStartElement("tr");
  283. var annotationRow = annotationRecords[i].split(";");
  284. for(var j = 0; j < annotationRow.length; j++) {
  285. output.writeStartElement("td");
  286. output.writeAttribute("style", "border-left: 1px solid #000000");
  287. if(j > 0) {
  288. output.writeAttribute("align", "center");
  289. }
  290. if(j > 0 && j < annotationRow.length - 1) {
  291. output.writeCharacters(Number(annotationRow[j].replace(/^\s+|\s+$/g,"")).toFixed(2));
  292. }
  293. else {
  294. output.writeCharacters(annotationRow[j].replace(/^\s+|\s+$/g,""));
  295. }
  296. output.writeEndElement();
  297. }
  298. output.writeEndElement();
  299. }
  300. output.writeEndElement();
  301. output.writeEndElement();
  302. output.writeCharacters(query.value(4));
  303. output.writeEndElement();
  304. output.writeEndElement();
  305. output.writeEndElement();
  306. output.writeEndDocument();
  307. dataView.setContent(buffer);
  308. buffer.close();
  309. query = query.invalidate();
  310. };
  311. ]]>
  312. </program>
  313. </window>