|
@@ -4,6 +4,17 @@
|
4
|
4
|
<separator />
|
5
|
5
|
<item id="quitItem" shortcut="ctrl+Q">Quit</item>
|
6
|
6
|
</menu>
|
|
7
|
+ <menu name="Log">
|
|
8
|
+ <item id="clear" shortcut="Ctrl+L">Clear Log</item>
|
|
9
|
+ <separator />
|
|
10
|
+ <item id="ms">Millisecond View</item>
|
|
11
|
+ <item id="1s">1 Second View</item>
|
|
12
|
+ <item id="5s">5 Second View</item>
|
|
13
|
+ <item id="10s">10 Second View</item>
|
|
14
|
+ <item id="15s">15 Second View</item>
|
|
15
|
+ <item id="30s">30 Second View</item>
|
|
16
|
+ <item id="1m">1 Minute View</item>
|
|
17
|
+ </menu>
|
7
|
18
|
<layout type="vertical">
|
8
|
19
|
<tabbar id="tabs"/>
|
9
|
20
|
<layout type="stack" id="pages">
|
|
@@ -27,7 +38,7 @@
|
27
|
38
|
</row>
|
28
|
39
|
<row>
|
29
|
40
|
<column><label>Weight:</label></column>
|
30
|
|
- <column><line id="sampleGreenWeight" /></column>
|
|
41
|
+ <column><line id="sampleGreenWeight" validator="numeric">0.0</line></column>
|
31
|
42
|
<column><sqldrop id="sampleGreenUnit" /></column>
|
32
|
43
|
</row>
|
33
|
44
|
<row>
|
|
@@ -36,7 +47,7 @@
|
36
|
47
|
</row>
|
37
|
48
|
<row>
|
38
|
49
|
<column><label>Arrival Date:</label></column>
|
39
|
|
- <column><line id="sampleGreenArrivalDate" /></column>
|
|
50
|
+ <column><calendar id="sampleGreenArrivalDate" /></column>
|
40
|
51
|
</row>
|
41
|
52
|
</layout>
|
42
|
53
|
<label>Additional Details:</label>
|
|
@@ -75,7 +86,7 @@
|
75
|
86
|
</row>
|
76
|
87
|
<row>
|
77
|
88
|
<column><label>Weight:</label></column>
|
78
|
|
- <column><line id="roastedWeight" validator="numeric" /></column>
|
|
89
|
+ <column><line id="roastedWeight" validator="numeric">0.0</line></column>
|
79
|
90
|
</row>
|
80
|
91
|
<row>
|
81
|
92
|
<column><label>Time:</label></column>
|
|
@@ -94,15 +105,25 @@
|
94
|
105
|
</page>
|
95
|
106
|
<page>
|
96
|
107
|
<layout type="vertical">
|
|
108
|
+ <layout type="horizontal">
|
|
109
|
+ <label>Time Increment (s):</label>
|
|
110
|
+ <line id="timeincrement" validator="numeric">30</line>
|
|
111
|
+ <stretch />
|
|
112
|
+ <label>Time:</label>
|
|
113
|
+ <timeedit id="currenttime" />
|
|
114
|
+ <stretch />
|
|
115
|
+ <label>Temperature:</label>
|
|
116
|
+ <line id="currenttemperature" validator="numeric" />
|
|
117
|
+ <label>Note:</label>
|
|
118
|
+ <line id="currentnote" />
|
|
119
|
+ <button name="Add Measurement" id="addmeasurement" type="push" />
|
|
120
|
+ </layout>
|
97
|
121
|
<splitter type="horizontal" id="roastdatasplit">
|
98
|
122
|
<measurementtable id="log" />
|
99
|
123
|
<graph id="graph" />
|
100
|
124
|
</splitter>
|
101
|
125
|
</layout>
|
102
|
126
|
</page>
|
103
|
|
- <page>
|
104
|
|
-
|
105
|
|
- </page>
|
106
|
127
|
</layout>
|
107
|
128
|
<layout type="horizontal">
|
108
|
129
|
<stretch />
|
|
@@ -113,12 +134,21 @@
|
113
|
134
|
<![CDATA[
|
114
|
135
|
var window = this;
|
115
|
136
|
this.windowTitle = "Typica - Manual Log Entry";
|
|
137
|
+ window.windowReady.connect(function() {
|
|
138
|
+ if(machineModel.rowCount() == 0) {
|
|
139
|
+ displayError(TTR("manualLogEntry", "Configuration Required"),
|
|
140
|
+ TTR("manualLogEntry", "Please configure a roaster."));
|
|
141
|
+ window.close();
|
|
142
|
+ }
|
|
143
|
+ });
|
116
|
144
|
quitItem = findChildObject(this, 'quitItem');
|
117
|
145
|
quitItem.triggered.connect(function() {
|
118
|
146
|
Application.quit();
|
119
|
147
|
});
|
120
|
148
|
pluginContext = {};
|
121
|
149
|
pluginContext.table = findChildObject(this, 'log');
|
|
150
|
+ pluginContext.table.setHeaderData(1, "Temp");
|
|
151
|
+ pluginContext.table.setHeaderData(2, "Note");
|
122
|
152
|
pluginContext.graph = findChildObject(this, 'graph');
|
123
|
153
|
pluginContext.preRun = function() {
|
124
|
154
|
var filename = QFileDialog.getOpenFileName(window, TTR("manualLogEntry", "Import"), QSettings.value('script/lastDir', '') + '/');
|
|
@@ -145,7 +175,6 @@
|
145
|
175
|
tabs = findChildObject(this, 'tabs');
|
146
|
176
|
tabs.addTab("Batch Data");
|
147
|
177
|
tabs.addTab("Roast Data");
|
148
|
|
- tabs.addTab("Roast Data Configuration");
|
149
|
178
|
pages = findChildObject(this, 'pages');
|
150
|
179
|
tabs.currentChanged.connect(function(index) {
|
151
|
180
|
pages.setCurrentIndex(index);
|
|
@@ -188,6 +217,117 @@
|
188
|
217
|
QSettings.setValue("script/manual_unit", greenUnitIndex);
|
189
|
218
|
sampleGreenUnit.setCurrentIndex(greenUnitIndex);
|
190
|
219
|
});
|
|
220
|
+ timeincrement = findChildObject(this, 'timeincrement');
|
|
221
|
+ currenttime = findChildObject(this, 'currenttime');
|
|
222
|
+ currenttemperature = findChildObject(this, 'currenttemperature');
|
|
223
|
+ currentnote = findChildObject(this, 'currentnote');
|
|
224
|
+ addmeasurement = findChildObject(this, 'addmeasurement');
|
|
225
|
+ addmeasurement.clicked.connect(function() {
|
|
226
|
+ pluginContext.newMeasurement(new Measurement(Number(currenttemperature.text), currenttime.time), 1);
|
|
227
|
+ if(currentnote.text.length > 0) {
|
|
228
|
+ pluginContext.table.newAnnotation(currentnote.text, 1, 2);
|
|
229
|
+ }
|
|
230
|
+ currentnote.text = "";
|
|
231
|
+ var t = QTime();
|
|
232
|
+ t = t.fromString(currenttime.time, "hh:mm:ss");
|
|
233
|
+ t = t.addSecs(30);
|
|
234
|
+ currenttime.time = t;
|
|
235
|
+ currenttemperature.text = "";
|
|
236
|
+ });
|
|
237
|
+ currenttemperature.returnPressed.connect(addmeasurement.clicked);
|
|
238
|
+ currentnote.returnPressed.connect(addmeasurement.clicked);
|
|
239
|
+ var v1 = findChildObject(this, 'ms');
|
|
240
|
+ v1.triggered.connect(pluginContext.table.LOD_ms);
|
|
241
|
+ var v2 = findChildObject(this, '1s');
|
|
242
|
+ v2.triggered.connect(pluginContext.table.LOD_1s);
|
|
243
|
+ var v3 = findChildObject(this, '5s');
|
|
244
|
+ v3.triggered.connect(pluginContext.table.LOD_5s);
|
|
245
|
+ var v4 = findChildObject(this, '10s');
|
|
246
|
+ v4.triggered.connect(pluginContext.table.LOD_10s);
|
|
247
|
+ var v5 = findChildObject(this, '15s');
|
|
248
|
+ v5.triggered.connect(pluginContext.table.LOD_15s);
|
|
249
|
+ var v6 = findChildObject(this, '30s');
|
|
250
|
+ v6.triggered.connect(pluginContext.table.LOD_30s);
|
|
251
|
+ var v7 = findChildObject(this, '1m');
|
|
252
|
+ v7.triggered.connect(pluginContext.table.LOD_1m);
|
|
253
|
+ var clear = findChildObject(this, 'clear');
|
|
254
|
+ clear.triggered.connect(pluginContext.table.clear);
|
|
255
|
+ clear.triggered.connect(pluginContext.graph.clear);
|
|
256
|
+ clear.triggered.connect(function() {
|
|
257
|
+ currenttime.time = QTime(0, 0, 0, 0);
|
|
258
|
+ currenttemperature.text = "";
|
|
259
|
+ currentnote.text = "";
|
|
260
|
+ });
|
|
261
|
+ var sampleGreenName = findChildObject(this, 'sampleGreenName');
|
|
262
|
+ var sampleGreenWeight = findChildObject(this, 'sampleGreenWeight');
|
|
263
|
+ var productionGreenTable = findChildObject(this, 'productionGreenTable');
|
|
264
|
+ var greenModel = productionGreenTable.model();
|
|
265
|
+ var greenTotal = 0.0;
|
|
266
|
+ var updateGreenTable = function() {
|
|
267
|
+ var deleteRow = -1;
|
|
268
|
+ while((deleteRow = productionGreenTable.findData("delete", 0)) > -1) {
|
|
269
|
+ if(productionGreenTable.data(deleteRow, 0, 0) == "Delete") {
|
|
270
|
+ productionGreenTable.removeRow(productionGreenTable.findData("delete", 0));
|
|
271
|
+ } else {
|
|
272
|
+ break;
|
|
273
|
+ }
|
|
274
|
+ }
|
|
275
|
+ greenTotal = productionGreenTable.columnSum(1, 0);
|
|
276
|
+ productionGreenTable.resizeColumnToContents(0);
|
|
277
|
+ };
|
|
278
|
+ greenModel.dataChanged.connect(updateGreenTable);
|
|
279
|
+ var validateInputs = function() {
|
|
280
|
+ if(batchType.currentIndex == 0) {
|
|
281
|
+ /* Sample batch */
|
|
282
|
+ if(sampleGreenName.text.length == 0) {
|
|
283
|
+ tabs.setCurrentIndex(0);
|
|
284
|
+ displayError(TTR("manualLogEntry", "Data Entry Error"),
|
|
285
|
+ TTR("manualLogEntry", "Please enter a green coffee name."));
|
|
286
|
+ return false;
|
|
287
|
+ }
|
|
288
|
+ if(Number(sampleGreenWeight.text) <= 0 || isNaN(sampleGreenWeight.text)) {
|
|
289
|
+ tabs.setCurrentIndex(0);
|
|
290
|
+ displayError(TTR("manualLogEntry", "Data Entry Error"),
|
|
291
|
+ TTR("manualLogEntry", "Green coffee weight must be a number greater than 0."));
|
|
292
|
+ return false;
|
|
293
|
+ }
|
|
294
|
+ } else {
|
|
295
|
+ /* Production batch */
|
|
296
|
+ var itemArray = productionGreenTable.columnArray(0, 32).split("\\s*,\\s*");
|
|
297
|
+ var weightArray = productionGreenTable.columnArray(1, 0).split("\\s*,\\s*");
|
|
298
|
+ if((itemArray.length != weightArray.length) || (itemArray.length == 0)) {
|
|
299
|
+ tabs.setCurrentIndex(0);
|
|
300
|
+ displayError(TTR("manualLogEntry", "Data Entry Error"),
|
|
301
|
+ TTR("manualLogEntry", "Please check that at least one green coffee has been selected and each green coffee has a valid weight"));
|
|
302
|
+ return false;
|
|
303
|
+ }
|
|
304
|
+ if(Number(greenTotal) <= 0) {
|
|
305
|
+ tabs.setCurrentIndex(0);
|
|
306
|
+ displayError(TTR("manualLogEntry", "DataEntryError"),
|
|
307
|
+ TTR("manualLogEntry", "Total green coffee weight must be a number greater than 0."));
|
|
308
|
+ return false;
|
|
309
|
+ }
|
|
310
|
+ if(roastedItem.currentIndex == 0) {
|
|
311
|
+ tabs.setCurrentIndex(0);
|
|
312
|
+ displayError(TTR("manualLogEntry", "DataEntryError"),
|
|
313
|
+ TTR("manualLogEntry", "Please select a roasted coffee item."));
|
|
314
|
+ return false;
|
|
315
|
+ }
|
|
316
|
+ }
|
|
317
|
+ return true;
|
|
318
|
+ };
|
|
319
|
+ var roastDataExists = function() {
|
|
320
|
+ return (pluginContext.table.rowCount() > 0);
|
|
321
|
+ }
|
|
322
|
+ var doSubmit = function() {
|
|
323
|
+ window.close();
|
|
324
|
+ }
|
|
325
|
+ var submit = findChildObject(this, 'submit');
|
|
326
|
+ submit.clicked.connect(function() {
|
|
327
|
+ if(validateInputs()) {
|
|
328
|
+ doSubmit();
|
|
329
|
+ }
|
|
330
|
+ });
|
191
|
331
|
]]>
|
192
|
332
|
</program>
|
193
|
333
|
</window>
|