|
@@ -2,19 +2,126 @@
|
2
|
2
|
<layout type="vertical">
|
3
|
3
|
<layout type="horizontal">
|
4
|
4
|
<button type="push" id="target" name="Load profile as target" />
|
5
|
|
- <button type="push" id="viewprofile" name="View profile" />
|
6
|
5
|
<button type="push" id="compare" name="Compare profile" />
|
7
|
|
- <button type="push" id="edit" name="Edit" />
|
8
|
6
|
</layout>
|
9
|
|
- <webview id="view" />
|
|
7
|
+ <tabbar id="tabs" />
|
|
8
|
+ <layout type="stack" id="pages">
|
|
9
|
+ <page>
|
|
10
|
+ <layout type="vertical">
|
|
11
|
+ <webview id="view" />
|
|
12
|
+ </layout>
|
|
13
|
+ </page>
|
|
14
|
+ <page>
|
|
15
|
+ <layout type="vertical">
|
|
16
|
+ <splitter type="horizontal" id="logsplit">
|
|
17
|
+ <measurementtable id="log">
|
|
18
|
+ <column>Time</column>
|
|
19
|
+ <column>Bean</column>
|
|
20
|
+ <column>Air</column>
|
|
21
|
+ <column>Note</column>
|
|
22
|
+ </measurementtable>
|
|
23
|
+ <graph id="graph" />
|
|
24
|
+ </splitter>
|
|
25
|
+ </layout>
|
|
26
|
+ </page>
|
|
27
|
+ <page>
|
|
28
|
+ <layout type="vertical">
|
|
29
|
+ <layout type="horizontal">
|
|
30
|
+ <label>Roasted Weight: </label>
|
|
31
|
+ <line id="roasted" validator="numeric" />
|
|
32
|
+ <line id="roastunit" writable="false" />
|
|
33
|
+ <stretch />
|
|
34
|
+ </layout>
|
|
35
|
+ <label>Degree of Roast</label>
|
|
36
|
+ <layout type="horizontal">
|
|
37
|
+ <label>Whole Bean:</label>
|
|
38
|
+ <roastcoloredit id="wholecolor" />
|
|
39
|
+ <stretch />
|
|
40
|
+ </layout>
|
|
41
|
+ <label id="wholespec">-</label>
|
|
42
|
+ <layout type="horizontal">
|
|
43
|
+ <label>Ground:</label>
|
|
44
|
+ <roastcoloredit id="groundcolor" />
|
|
45
|
+ <stretch />
|
|
46
|
+ </layout>
|
|
47
|
+ <label id="groundspec">-</label>
|
|
48
|
+ <button type="check" name="Approved" id="approval" />
|
|
49
|
+ <layout type="horizontal">
|
|
50
|
+ <label>Annotation</label>
|
|
51
|
+ <textarea id="annotation" />
|
|
52
|
+ </layout>
|
|
53
|
+ <button type="push" id="submit" name="Save" />
|
|
54
|
+ <stretch />
|
|
55
|
+ </layout>
|
|
56
|
+ </page>
|
|
57
|
+ <page>
|
|
58
|
+ <layout type="vertical">
|
|
59
|
+
|
|
60
|
+ </layout>
|
|
61
|
+ </page>
|
|
62
|
+ </layout>
|
10
|
63
|
</layout>
|
11
|
|
- <menu name="File">
|
12
|
|
- <item id="save" shortcut="Ctrl+S">Save...</item>
|
13
|
|
- <item id="print" shortcut="Ctrl+P">Print...</item>
|
14
|
|
- </menu>
|
|
64
|
+ <menu name="File">
|
|
65
|
+ <item id="save" shortcut="Ctrl+S">Save Profile...</item>
|
|
66
|
+ <item id="print" shortcut="Ctrl+P">Print Report...</item>
|
|
67
|
+ </menu>
|
|
68
|
+ <menu name="Log">
|
|
69
|
+ <item id="showC">Display Celsius</item>
|
|
70
|
+ <item id="showF">Display Fahrenheit</item>
|
|
71
|
+ <separator />
|
|
72
|
+ <item id="ms">Millisecond View</item>
|
|
73
|
+ <item id="1s">1 Second View</item>
|
|
74
|
+ <item id="5s">5 Second View</item>
|
|
75
|
+ <item id="10s">10 Second View</item>
|
|
76
|
+ <item id="15s">15 Second View</item>
|
|
77
|
+ <item id="30s">30 Second View</item>
|
|
78
|
+ <item id="1m">1 Minute View</item>
|
|
79
|
+ </menu>
|
15
|
80
|
<program>
|
16
|
81
|
<![CDATA[
|
17
|
82
|
var window = this;
|
|
83
|
+ var tabs = findChildObject(this, 'tabs');
|
|
84
|
+ tabs.addTab("Report");
|
|
85
|
+ tabs.addTab("Profile");
|
|
86
|
+ tabs.addTab("Edit");
|
|
87
|
+ tabs.addTab("Batch Tag");
|
|
88
|
+ var pages = findChildObject(this, 'pages');
|
|
89
|
+ tabs.currentChanged.connect(function(index) {
|
|
90
|
+ pages.setCurrentIndex(index);
|
|
91
|
+ });
|
|
92
|
+ var log = findChildObject(this, 'log');
|
|
93
|
+ var graph = findChildObject(this, 'graph');
|
|
94
|
+ var showC = findChildObject(this, 'showC');
|
|
95
|
+ showC.triggered.connect(function() {
|
|
96
|
+ log.setDisplayUnits(Units.Celsius);
|
|
97
|
+ graph.showC();
|
|
98
|
+ });
|
|
99
|
+ var showF = findChildObject(this, 'showF');
|
|
100
|
+ showF.triggered.connect(function() {
|
|
101
|
+ log.setDisplayUnits(Units.Fahrenheit);
|
|
102
|
+ graph.showF();
|
|
103
|
+ });
|
|
104
|
+ var v1 = findChildObject(this, 'ms');
|
|
105
|
+ v1.triggered.connect(log.LOD_ms);
|
|
106
|
+ var v2 = findChildObject(this, '1s');
|
|
107
|
+ v2.triggered.connect(log.LOD_1s);
|
|
108
|
+ var v3 = findChildObject(this, '5s');
|
|
109
|
+ v3.triggered.connect(log.LOD_5s);
|
|
110
|
+ var v4 = findChildObject(this, '10s');
|
|
111
|
+ v4.triggered.connect(log.LOD_10s);
|
|
112
|
+ var v5 = findChildObject(this, '15s');
|
|
113
|
+ v5.triggered.connect(log.LOD_15s);
|
|
114
|
+ var v6 = findChildObject(this, '30s');
|
|
115
|
+ v6.triggered.connect(log.LOD_30s);
|
|
116
|
+ var v7 = findChildObject(this, '1m');
|
|
117
|
+ v7.triggered.connect(log.LOD_1m);
|
|
118
|
+ var splitter = findChildObject(this, 'logsplit');
|
|
119
|
+ splitter.restoreState("script/offlineViewSplitter");
|
|
120
|
+ window.saveTemperatureColumns = new Array();
|
|
121
|
+ window.saveAnnotationColumns = new Array();
|
|
122
|
+ this.aboutToClose.connect(function() {
|
|
123
|
+ splitter.saveState("script/batchdetails/profileSplitter");
|
|
124
|
+ });
|
18
|
125
|
var unit = QSettings.value("script/history_unit", 1);
|
19
|
126
|
var conversion = 1;
|
20
|
127
|
if(unit == 0)
|
|
@@ -31,8 +138,6 @@
|
31
|
138
|
var fileID;
|
32
|
139
|
var target = findChildObject(this, 'target');
|
33
|
140
|
var compare = findChildObject(this, 'compare');
|
34
|
|
- var edit = findChildObject(this, 'edit');
|
35
|
|
- edit.enabled = false;
|
36
|
141
|
if(typeof(Windows.loggingWindow) == "undefined") {
|
37
|
142
|
compare.enabled = false;
|
38
|
143
|
target.enabled = false;
|
|
@@ -44,10 +149,6 @@
|
44
|
149
|
var approval;
|
45
|
150
|
var annotation;
|
46
|
151
|
var roastWeight;
|
47
|
|
- edit.clicked.connect(function() {
|
48
|
|
- var editWindow = createWindow("editBatchDetails");
|
49
|
|
- editWindow.loadData(window, tableReference, rowReference, batchTime, machine, approval, annotation, roastWeight, unit);
|
50
|
|
- });
|
51
|
152
|
compare.clicked.connect(function() {
|
52
|
153
|
var query = new QSqlQuery;
|
53
|
154
|
query.prepare("SELECT file, name FROM files WHERE id = :id");
|
|
@@ -113,58 +214,24 @@
|
113
|
214
|
log.newAnnotation(TTR("batchDetails", "End"), 1, lc);
|
114
|
215
|
query = query.invalidate();
|
115
|
216
|
});
|
116
|
|
- var viewbutton = findChildObject(this, 'viewprofile');
|
117
|
|
- viewbutton.clicked.connect(function() {
|
118
|
|
- var query = new QSqlQuery;
|
119
|
|
- query.prepare("SELECT file, name FROM files WHERE id = :id");
|
120
|
|
- query.bind(":id", Number(fileID));
|
|
217
|
+ var approvalButton = findChildObject(this, 'approval');
|
|
218
|
+ var annotationField = findChildObject(this, 'annotation');
|
|
219
|
+ var roastedEdit = findChildObject(this, 'roasted');
|
|
220
|
+ var unitEdit = findChildObject(this, 'roastunit');
|
|
221
|
+ var wholecolor = findChildObject(this, 'wholecolor');
|
|
222
|
+ var groundcolor = findChildObject(this, 'groundcolor');
|
|
223
|
+ window.loadBatch = function(mref, tref) {
|
|
224
|
+ machine = mref;
|
|
225
|
+ batchTime = tref;
|
|
226
|
+ var query = new QSqlQuery();
|
|
227
|
+ var q = "WITH names AS ( WITH greens AS ( SELECT unnest(unroasted_id) AS gitem, machine, time FROM roasting_log WHERE machine = :machine AND time = :time) SELECT array_agg((SELECT name FROM items WHERE id = greens.gitem) || ' (' || gitem || ')') AS names, max(greens.machine) AS machine, max(greens.time) AS time FROM greens LIMIT 1) SELECT (SELECT name FROM items WHERE id = roasted_id), duration, names, unroasted_quantity, (unroasted_total_quantity/:c1)::numeric(12,3), (roasted_quantity/:c2)::numeric(12,3), approval, files, annotation, (SELECT file FROM files WHERE id = files[1]) AS file, additional_data FROM names, roasting_log WHERE roasting_log.machine = names.machine AND roasting_log.time = names.time";
|
|
228
|
+ query.prepare(q);
|
|
229
|
+ query.bind(":machine", mref);
|
|
230
|
+ query.bind(":time", tref);
|
|
231
|
+ query.bind(":c1", conversion);
|
|
232
|
+ query.bind(":c2", conversion);
|
121
|
233
|
query.exec();
|
122
|
|
- if(query.next()) {
|
123
|
|
- var viewer = createWindow('offline');
|
124
|
|
- var buffer = new QBuffer(query.value(0));
|
125
|
|
- var pname = query.value(1);
|
126
|
|
- query = query.invalidate();
|
127
|
|
- var input = new XMLInput(buffer, 1);
|
128
|
|
- var graph = findChildObject(viewer, 'graph');
|
129
|
|
- var log = findChildObject(viewer, 'log');
|
130
|
|
- input.newTemperatureColumn.connect(log.setHeaderData);
|
131
|
|
- input.newTemperatureColumn.connect(function(column) {
|
132
|
|
- viewer.saveTemperatureColumns.push(column);
|
133
|
|
- });
|
134
|
|
- input.newAnnotationColumn.connect(log.setHeaderData);
|
135
|
|
- input.newAnnotationColumn.connect(function(column) {
|
136
|
|
- viewer.saveAnnotationColumns.push(column);
|
137
|
|
- });
|
138
|
|
- input.measure.connect(graph.newMeasurement);
|
139
|
|
- input.measure.connect(log.newMeasurement);
|
140
|
|
- input.annotation.connect(log.newAnnotation);
|
141
|
|
- var lc;
|
142
|
|
- input.lastColumn.connect(function(c) {
|
143
|
|
- lc = c;
|
144
|
|
- if(c < 3) {
|
145
|
|
- log.setHeaderData(3, "");
|
146
|
|
- }
|
147
|
|
- });
|
148
|
|
- input.annotation.connect(function(note, tcol, ncol) {
|
149
|
|
- for(var i = tcol; i < ncol; i++) {
|
150
|
|
- log.newAnnotation(note, i, ncol);
|
151
|
|
- }
|
152
|
|
- });
|
153
|
|
- viewer.windowTitle = "Typica - " + pname;
|
154
|
|
- viewer.raise();
|
155
|
|
- viewer.activateWindow();
|
156
|
|
- graph.updatesEnabled = false;
|
157
|
|
- log.updatesEnabled = false;
|
158
|
|
- input.input();
|
159
|
|
- log.updatesEnabled = true;
|
160
|
|
- graph.updatesEnabled = true;
|
161
|
|
- log.newAnnotation("End", 1, lc);
|
162
|
|
- }
|
163
|
|
- query = query.invalidate();
|
164
|
|
- });
|
165
|
|
- window.loadData = function(table, row) {
|
166
|
|
- tableReference = table;
|
167
|
|
- rowReference = row;
|
|
234
|
+ query.next();
|
168
|
235
|
var buffer = new QBuffer;
|
169
|
236
|
buffer.open(3);
|
170
|
237
|
var output = new XmlWriter(buffer);
|
|
@@ -173,26 +240,25 @@
|
173
|
240
|
output.writeStartElement("html");
|
174
|
241
|
output.writeAttribute("xmlns", "http://www.w3.org/1999/xhtml");
|
175
|
242
|
output.writeStartElement("head");
|
176
|
|
- output.writeTextElement("title", TTR("batchDetails", "Batch Details"));
|
|
243
|
+ output.writeTextElement("title", "Batch Details");
|
177
|
244
|
output.writeEndElement();
|
178
|
245
|
output.writeStartElement("body");
|
179
|
246
|
output.writeStartElement("div");
|
180
|
247
|
output.writeAttribute("style", "float: left; padding-right: 10px");
|
181
|
248
|
output.writeStartElement("p");
|
182
|
249
|
output.writeTextElement("strong", TTR("batchDetails", "Roasted Coffee: "));
|
183
|
|
- output.writeTextElement("span", table.data(row, 2));
|
|
250
|
+ output.writeTextElement("span", query.value(0));
|
184
|
251
|
output.writeEndElement();
|
185
|
252
|
output.writeEndElement();
|
186
|
253
|
output.writeStartElement("div");
|
187
|
254
|
output.writeAttribute("style", "float: left");
|
188
|
255
|
output.writeStartElement("p");
|
189
|
|
- output.writeTextElement("strong", TTR("batchDetails", "Roasted On: "));
|
190
|
|
- batchTime = table.data(row, 0);
|
|
256
|
+ output.writeTextElement("strong", TTR("batchDetails", "Roasted At: "));
|
191
|
257
|
output.writeTextElement("span", batchTime);
|
192
|
258
|
output.writeEndElement();
|
193
|
259
|
output.writeStartElement("p");
|
194
|
260
|
output.writeTextElement("strong", TTR("batchDetails", "Batch Duration: "));
|
195
|
|
- output.writeTextElement("span", table.data(row, 6));
|
|
261
|
+ output.writeTextElement("span", query.value(1));
|
196
|
262
|
output.writeEndElement();
|
197
|
263
|
output.writeEndElement();
|
198
|
264
|
output.writeStartElement("div");
|
|
@@ -202,38 +268,21 @@
|
202
|
268
|
output.writeStartElement("thead");
|
203
|
269
|
output.writeStartElement("tr");
|
204
|
270
|
output.writeTextElement("th", TTR("batchDetails", "Green Coffee"));
|
205
|
|
- output.writeTextElement("th", TTR("batchDetails", "Weight (") + unitText + ")");
|
|
271
|
+ output.writeTextElement("th", TTR("batchDetails", "Weight") + "(" + unitText + ")");
|
206
|
272
|
output.writeEndElement();
|
207
|
273
|
output.writeEndElement();
|
208
|
274
|
output.writeStartElement("tbody");
|
209
|
|
- var query = new QSqlQuery();
|
210
|
|
- query.prepare("SELECT unroasted_id, unroasted_quantity, approval, files, annotation, (unroasted_total_quantity/:c1)::numeric(12,3), (roasted_quantity/:c2)::numeric(12,3) FROM roasting_log WHERE time = :time AND machine = :machine");
|
211
|
|
- query.bind(":time", batchTime);
|
212
|
|
- query.bind(":c1", conversion);
|
213
|
|
- query.bind(":c2", conversion);
|
214
|
|
- machine = table.data(row, 1);
|
215
|
|
- query.bind(":machine", machine);
|
216
|
|
- query.exec();
|
217
|
|
- query.next();
|
218
|
|
- approval = query.value(2);
|
219
|
|
- annotation = query.value(4);
|
220
|
|
- var items = sqlToArray(query.value(0));
|
221
|
|
- var quantities = sqlToArray(query.value(1));
|
222
|
|
- var nameQuery = new QSqlQuery();
|
223
|
|
- nameQuery.prepare("SELECT name FROM items WHERE id = :id");
|
|
275
|
+ var items = sqlToArray(query.value(2));
|
|
276
|
+ var quantities = sqlToArray(query.value(3));
|
224
|
277
|
for(var i = 0; i < items.length; i++) {
|
225
|
278
|
output.writeStartElement("tr");
|
226
|
|
- nameQuery.bind(":id", items[i]);
|
227
|
|
- nameQuery.exec();
|
228
|
|
- nameQuery.next();
|
229
|
|
- output.writeTextElement("td", nameQuery.value(0) + " (" + items[i] + ")");
|
|
279
|
+ output.writeTextElement("td", items[i]);
|
230
|
280
|
output.writeStartElement("td");
|
231
|
281
|
output.writeAttribute("align", "center");
|
232
|
|
- output.writeCharacters((Number(quantities[i])/conversion).toFixed(3));
|
|
282
|
+ output.writeCharacters(Number(quantities[i]/conversion).toFixed(3));
|
233
|
283
|
output.writeEndElement();
|
234
|
284
|
output.writeEndElement();
|
235
|
285
|
}
|
236
|
|
- nameQuery = nameQuery.invalidate();
|
237
|
286
|
output.writeEndElement();
|
238
|
287
|
output.writeStartElement("tfoot");
|
239
|
288
|
output.writeStartElement("tr");
|
|
@@ -243,7 +292,7 @@
|
243
|
292
|
output.writeEndElement();
|
244
|
293
|
output.writeStartElement("td");
|
245
|
294
|
output.writeAttribute("align", "center");
|
246
|
|
- output.writeCharacters(query.value(5));
|
|
295
|
+ output.writeCharacters(query.value(4));
|
247
|
296
|
output.writeEndElement();
|
248
|
297
|
output.writeEndElement();
|
249
|
298
|
output.writeStartElement("tr");
|
|
@@ -253,8 +302,7 @@
|
253
|
302
|
output.writeEndElement();
|
254
|
303
|
output.writeStartElement("td");
|
255
|
304
|
output.writeAttribute("align", "center");
|
256
|
|
- output.writeCharacters(query.value(6));
|
257
|
|
- roastWeight = query.value(6);
|
|
305
|
+ output.writeCharacters(query.value(5));
|
258
|
306
|
output.writeEndElement();
|
259
|
307
|
output.writeEndElement();
|
260
|
308
|
output.writeStartElement("tr");
|
|
@@ -264,23 +312,27 @@
|
264
|
312
|
output.writeEndElement();
|
265
|
313
|
output.writeStartElement("td");
|
266
|
314
|
output.writeAttribute("align", "center");
|
267
|
|
- output.writeCharacters(table.data(row, 5));
|
268
|
|
- output.writeCharacters("%");
|
|
315
|
+ if(Number(query.value(4)) > 0) {
|
|
316
|
+ output.writeCharacters(Number(((Number(query.value(4)) - Number(query.value(5)))/Number(query.value(4))) * 100).toFixed(2));
|
|
317
|
+ output.writeCharacters("%");
|
|
318
|
+ } else {
|
|
319
|
+ output.writeCharacters("unknown");
|
|
320
|
+ }
|
269
|
321
|
output.writeEndElement();
|
270
|
322
|
output.writeEndElement();
|
271
|
323
|
output.writeEndElement();
|
272
|
324
|
output.writeEndElement();
|
273
|
325
|
output.writeStartElement("p");
|
274
|
326
|
output.writeTextElement("strong", TTR("batchDetails", "Approved: "));
|
275
|
|
- output.writeCharacters(approval);
|
|
327
|
+ output.writeCharacters(query.value(6));
|
276
|
328
|
output.writeEndElement();
|
277
|
329
|
output.writeStartElement("p");
|
278
|
330
|
output.writeTextElement("strong", TTR("batchDetails", "Files: "));
|
279
|
|
- output.writeCharacters(query.value(3));
|
|
331
|
+ output.writeCharacters(query.value(7));
|
280
|
332
|
output.writeEndElement();
|
281
|
333
|
output.writeStartElement("p");
|
282
|
334
|
output.writeTextElement("strong", TTR("batchDetails", "Annotations:"));
|
283
|
|
- var files = sqlToArray(query.value(3));
|
|
335
|
+ var files = sqlToArray(query.value(7));
|
284
|
336
|
var annotations = annotationFromRecord(files[0]);
|
285
|
337
|
fileID = files[0];
|
286
|
338
|
var buffer2 = new QBuffer("<points>"+annotations+"</points>");
|
|
@@ -301,16 +353,16 @@
|
301
|
353
|
output.writeStartElement("thead");
|
302
|
354
|
output.writeStartElement("tr");
|
303
|
355
|
for(var i = 0; i < seriesHeaders.length; i++) {
|
304
|
|
- output.writeTextElement("th", seriesHeaders[i]);
|
|
356
|
+ output.writeTextElement("th", seriesHeaders[i]);
|
305
|
357
|
}
|
306
|
358
|
output.writeEndElement();
|
307
|
359
|
output.writeEndElement();
|
308
|
360
|
buffer2.open(1);
|
309
|
361
|
var rq = 'for $t in doc($profile) //tuple return (string($t/time), ";", ';
|
310
|
362
|
for(var i = 0; i < seriesHeaders.length - 2; i++) {
|
311
|
|
- rq = rq + 'string($t/temperature[' + Number(i+1) + ']), ";", ';
|
|
363
|
+ rq += 'string($t/temperature[' + Number(i+1) + ']), ";", ';
|
312
|
364
|
}
|
313
|
|
- rq = rq + 'string($t/annotation), "~")';
|
|
365
|
+ rq += 'string($t/annotation), "~")';
|
314
|
366
|
colQuery.setQuery(rq);
|
315
|
367
|
var annotationData = colQuery.exec();
|
316
|
368
|
colQuery = colQuery.invalidate();
|
|
@@ -328,8 +380,7 @@
|
328
|
380
|
}
|
329
|
381
|
if(j > 0 && j < annotationRow.length - 1) {
|
330
|
382
|
output.writeCharacters(Number(annotationRow[j].replace(/^\s+|\s+$/g,"")).toFixed(2));
|
331
|
|
- }
|
332
|
|
- else {
|
|
383
|
+ } else {
|
333
|
384
|
output.writeCharacters(annotationRow[j].replace(/^\s+|\s+$/g,""));
|
334
|
385
|
}
|
335
|
386
|
output.writeEndElement();
|
|
@@ -338,16 +389,65 @@
|
338
|
389
|
}
|
339
|
390
|
output.writeEndElement();
|
340
|
391
|
output.writeEndElement();
|
341
|
|
- output.writeCharacters(annotation);
|
|
392
|
+ output.writeCharacters(query.value(8));
|
342
|
393
|
output.writeEndElement();
|
343
|
394
|
output.writeEndElement();
|
344
|
395
|
output.writeEndElement();
|
345
|
396
|
output.writeEndDocument();
|
346
|
397
|
dataView.setContent(buffer);
|
347
|
398
|
buffer.close();
|
|
399
|
+ log.clear();
|
|
400
|
+ graph.clear();
|
|
401
|
+ var buffer3 = new QBuffer(query.value(9));
|
|
402
|
+ var input = new XMLInput(buffer3, 1);
|
|
403
|
+ input.newTemperatureColumn.connect(log.setHeaderData);
|
|
404
|
+ input.newAnnotationColumn.connect(log.setHeaderData);
|
|
405
|
+ var lc;
|
|
406
|
+ input.lastColumn.connect(function(c) {
|
|
407
|
+ lc = c;
|
|
408
|
+ if(c < 3) {
|
|
409
|
+ log.setHeaderData(3, "");
|
|
410
|
+ }
|
|
411
|
+ });
|
|
412
|
+ input.measure.connect(graph.newMeasurement);
|
|
413
|
+ input.measure.connect(log.newMeasurement);
|
|
414
|
+ input.annotation.connect(function(note,tcol,ncol) {
|
|
415
|
+ for(var i = tcol; i < ncol; i++) {
|
|
416
|
+ log.newAnnotation(note, i, ncol);
|
|
417
|
+ }
|
|
418
|
+ });
|
|
419
|
+ graph.updatesEnabled = false;
|
|
420
|
+ log.updatesEnabled = false;
|
|
421
|
+ input.input();
|
|
422
|
+ log.updatesEnabled = true;
|
|
423
|
+ graph.updatesEnabled = true;
|
|
424
|
+ log.newAnnotation("End", 1, lc);
|
|
425
|
+ if(query.value(6) == "true") {
|
|
426
|
+ approvalButton.checked = true;
|
|
427
|
+ }
|
|
428
|
+ annotationField.plainText = query.value(8);
|
|
429
|
+ unitEdit.text = unitText;
|
|
430
|
+ roastedEdit.text = query.value(5);
|
|
431
|
+ if(query.value(10).length > 0) {
|
|
432
|
+ var extradata = JSON.parse(query.value(10));
|
|
433
|
+ if(extradata.color) {
|
|
434
|
+ if(extradata.color.whole) {
|
|
435
|
+ wholecolor.value = extradata.color.whole;
|
|
436
|
+ } else {
|
|
437
|
+ wholecolor.value = "";
|
|
438
|
+ }
|
|
439
|
+ if(extradata.color.ground) {
|
|
440
|
+ groundcolor.value = extradata.color.ground;
|
|
441
|
+ } else {
|
|
442
|
+ groundcolor.value = "";
|
|
443
|
+ }
|
|
444
|
+ } else {
|
|
445
|
+ wholecolor.value = "";
|
|
446
|
+ groundcolor.value = "";
|
|
447
|
+ }
|
|
448
|
+ }
|
348
|
449
|
query = query.invalidate();
|
349
|
|
- edit.enabled = true;
|
350
|
|
- };
|
|
450
|
+ }
|
351
|
451
|
var saveMenu = findChildObject(this, 'save');
|
352
|
452
|
saveMenu.triggered.connect(function() {
|
353
|
453
|
var filename = QFileDialog.getSaveFileName(window, TTR("batchDetails", "Save Log As..."), QSettings.value("script/lastDir", "") + "/");
|
|
@@ -355,6 +455,32 @@
|
355
|
455
|
saveFileFromDatabase(fileID, filename);
|
356
|
456
|
}
|
357
|
457
|
});
|
|
458
|
+ var submit = findChildObject(this, 'submit');
|
|
459
|
+ submit.clicked.connect(function() {
|
|
460
|
+ var query = new QSqlQuery;
|
|
461
|
+ query.prepare("UPDATE roasting_log SET roasted_quantity = :roasted, approval = :approval, annotation = :annotation, additional_data = :extradata WHERE time = :time AND machine = :machine");
|
|
462
|
+ query.bind(":approval", approvalButton.checked);
|
|
463
|
+ query.bind(":annotation", annotationField.plainText);
|
|
464
|
+ query.bind(":roasted", Number(Number(roastedEdit.text)*conversion));
|
|
465
|
+ var extradata = new Object;
|
|
466
|
+ var colordata = new Object;
|
|
467
|
+ if(wholecolor.value.length > 0) {
|
|
468
|
+ colordata.whole = wholecolor.value;
|
|
469
|
+ }
|
|
470
|
+ if(groundcolor.value.length > 0) {
|
|
471
|
+ colordata.ground = groundcolor.value;
|
|
472
|
+ }
|
|
473
|
+ if(colordata.whole || colordata.ground) {
|
|
474
|
+ extradata.color = colordata;
|
|
475
|
+ }
|
|
476
|
+ query.bind(":extradata", JSON.stringify(extradata));
|
|
477
|
+ query.bind(":time", batchTime);
|
|
478
|
+ query.bind(":machine", Number(machine));
|
|
479
|
+ query.exec();
|
|
480
|
+ window.loadBatch(machine, batchTime);
|
|
481
|
+ displayInfo(TTR("batchDetails", "Batch Data Saved"),
|
|
482
|
+ TTR("roastspec", "New batch details saved"));
|
|
483
|
+ });
|
358
|
484
|
]]>
|
359
|
485
|
</program>
|
360
|
486
|
</window>
|