Browse Source

Fallback batch details if a record does not have green coffee

Neal Wilson 3 years ago
parent
commit
630058ed74
Signed by: Neal Wilson <neal@typica.us> GPG Key ID: 2A0BDDE701E66EB9
1 changed files with 297 additions and 208 deletions
  1. 297
    208
      config/Windows/batchdetailsnew.xml

+ 297
- 208
config/Windows/batchdetailsnew.xml View File

@@ -163,7 +163,7 @@
163 163
                 var buffer = new QBuffer(query.value(0));
164 164
                 var pname = query.value(1);
165 165
                 query = query.invalidate();
166
-				Windows.loggingWindow.loadPlan(buffer, pname);
166
+                Windows.loggingWindow.loadPlan(buffer, pname);
167 167
             });
168 168
             var approvalButton = findChildObject(this, 'approval');
169 169
             var annotationField = findChildObject(this, 'annotation');
@@ -182,236 +182,325 @@
182 182
                 query.bind(":c1", conversion);
183 183
                 query.bind(":c2", conversion);
184 184
                 query.exec();
185
-                query.next();
186
-                var buffer = new QBuffer;
187
-                buffer.open(3);
188
-                var output = new XmlWriter(buffer);
189
-                output.writeStartDocument("1.0");
190
-                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">');
191
-                output.writeStartElement("html");
192
-                output.writeAttribute("xmlns", "http://www.w3.org/1999/xhtml");
193
-                output.writeStartElement("head");
194
-                output.writeTextElement("title", "Batch Details");
195
-                output.writeEndElement();
196
-                output.writeStartElement("body");
197
-                output.writeStartElement("div");
198
-                output.writeAttribute("style", "float: left; padding-right: 10px");
199
-                output.writeStartElement("p");
200
-                output.writeTextElement("strong", TTR("batchDetails", "Roasted Coffee: "));
201
-                output.writeTextElement("span", query.value(0));
202
-                output.writeEndElement();
203
-                output.writeEndElement();
204
-                output.writeStartElement("div");
205
-                output.writeAttribute("style", "float: left");
206
-                output.writeStartElement("p");
207
-                output.writeTextElement("strong", TTR("batchDetails", "Roasted At: "));
208
-                output.writeTextElement("span", batchTime);
209
-                output.writeEndElement();
210
-                output.writeStartElement("p");
211
-                output.writeTextElement("strong", TTR("batchDetails", "Batch Duration: "));
212
-                output.writeTextElement("span", query.value(1));
213
-                output.writeEndElement();
214
-                output.writeEndElement();
215
-                output.writeStartElement("div");
216
-                output.writeAttribute("style", "clear: both");
217
-                output.writeEndElement();
218
-                output.writeStartElement("table");
219
-                output.writeStartElement("thead");
220
-                output.writeStartElement("tr");
221
-                output.writeTextElement("th", TTR("batchDetails", "Green Coffee"));
222
-                output.writeTextElement("th", TTR("batchDetails", "Weight") + "(" + unitText + ")");
223
-                output.writeEndElement();
224
-                output.writeEndElement();
225
-                output.writeStartElement("tbody");
226
-                var items = sqlToArray(query.value(2));
227
-                var quantities = sqlToArray(query.value(3));
228
-                for(var i = 0; i < items.length; i++) {
185
+                if(query.next()) {
186
+                    var buffer = new QBuffer;
187
+                    buffer.open(3);
188
+                    var output = new XmlWriter(buffer);
189
+                    output.writeStartDocument("1.0");
190
+                    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">');
191
+                    output.writeStartElement("html");
192
+                    output.writeAttribute("xmlns", "http://www.w3.org/1999/xhtml");
193
+                    output.writeStartElement("head");
194
+                    output.writeTextElement("title", "Batch Details");
195
+                    output.writeEndElement();
196
+                    output.writeStartElement("body");
197
+                    output.writeStartElement("div");
198
+                    output.writeAttribute("style", "float: left; padding-right: 10px");
199
+                    output.writeStartElement("p");
200
+                    output.writeTextElement("strong", TTR("batchDetails", "Roasted Coffee: "));
201
+                    output.writeTextElement("span", query.value(0));
202
+                    output.writeEndElement();
203
+                    output.writeEndElement();
204
+                    output.writeStartElement("div");
205
+                    output.writeAttribute("style", "float: left");
206
+                    output.writeStartElement("p");
207
+                    output.writeTextElement("strong", TTR("batchDetails", "Roasted At: "));
208
+                    output.writeTextElement("span", batchTime);
209
+                    output.writeEndElement();
210
+                    output.writeStartElement("p");
211
+                    output.writeTextElement("strong", TTR("batchDetails", "Batch Duration: "));
212
+                    output.writeTextElement("span", query.value(1));
213
+                    output.writeEndElement();
214
+                    output.writeEndElement();
215
+                    output.writeStartElement("div");
216
+                    output.writeAttribute("style", "clear: both");
217
+                    output.writeEndElement();
218
+                    output.writeStartElement("table");
219
+                    output.writeStartElement("thead");
220
+                    output.writeStartElement("tr");
221
+                    output.writeTextElement("th", TTR("batchDetails", "Green Coffee"));
222
+                    output.writeTextElement("th", TTR("batchDetails", "Weight") + "(" + unitText + ")");
223
+                    output.writeEndElement();
224
+                    output.writeEndElement();
225
+                    output.writeStartElement("tbody");
226
+                    var items = sqlToArray(query.value(2));
227
+                    var quantities = sqlToArray(query.value(3));
228
+                    for(var i = 0; i < items.length; i++) {
229
+                        output.writeStartElement("tr");
230
+                        output.writeTextElement("td", items[i]);
231
+                        output.writeStartElement("td");
232
+                        output.writeAttribute("align", "center");
233
+                        output.writeCharacters(Number(quantities[i]/conversion).toFixed(3));
234
+                        output.writeEndElement();
235
+                        output.writeEndElement();
236
+                    }
237
+                    output.writeEndElement();
238
+                    output.writeStartElement("tfoot");
229 239
                     output.writeStartElement("tr");
230
-                    output.writeTextElement("td", items[i]);
240
+                    output.writeStartElement("td");
241
+                    output.writeAttribute("align", "right");
242
+                    output.writeTextElement("strong", TTR("batchDetails", "Green Total:"));
243
+                    output.writeEndElement();
231 244
                     output.writeStartElement("td");
232 245
                     output.writeAttribute("align", "center");
233
-                    output.writeCharacters(Number(quantities[i]/conversion).toFixed(3));
246
+                    output.writeCharacters(query.value(4));
234 247
                     output.writeEndElement();
235 248
                     output.writeEndElement();
236
-                }
237
-                output.writeEndElement();
238
-                output.writeStartElement("tfoot");
239
-                output.writeStartElement("tr");
240
-                output.writeStartElement("td");
241
-                output.writeAttribute("align", "right");
242
-                output.writeTextElement("strong", TTR("batchDetails", "Green Total:"));
243
-                output.writeEndElement();
244
-                output.writeStartElement("td");
245
-                output.writeAttribute("align", "center");
246
-                output.writeCharacters(query.value(4));
247
-                output.writeEndElement();
248
-                output.writeEndElement();
249
-                output.writeStartElement("tr");
250
-                output.writeStartElement("td");
251
-                output.writeAttribute("align", "right");
252
-                output.writeTextElement("strong", TTR("batchDetails", "Roasted Weight:"));
253
-                output.writeEndElement();
254
-                output.writeStartElement("td");
255
-                output.writeAttribute("align", "center");
256
-                output.writeCharacters(query.value(5));
257
-                output.writeEndElement();
258
-                output.writeEndElement();
259
-                output.writeStartElement("tr");
260
-                output.writeStartElement("td");
261
-                output.writeAttribute("align", "right");
262
-                output.writeTextElement("strong", TTR("batchDetails", "Weight Loss:"));
263
-                output.writeEndElement();
264
-                output.writeStartElement("td");
265
-                output.writeAttribute("align", "center");
266
-                if(Number(query.value(4)) > 0) {
267
-                    output.writeCharacters(Number(((Number(query.value(4)) - Number(query.value(5)))/Number(query.value(4))) * 100).toFixed(2));
268
-                    output.writeCharacters("%");
269
-                } else {
270
-                    output.writeCharacters("unknown");
271
-                }
272
-                output.writeEndElement();
273
-                output.writeEndElement();
274
-                output.writeEndElement();
275
-                output.writeEndElement();
276
-                if(query.value(10).length > 0) {
277
-                    var extradata = JSON.parse(query.value(10));
278
-                    if(extradata.color) {
279
-                        output.writeStartElement("p");
280
-                        output.writeTextElement("strong", TTR("batchDetails", "Degree of Roast"));
281
-                        output.writeEndElement();
282
-                        if(extradata.color.whole) {
283
-                            wholecolor.value = extradata.color.whole;
249
+                    output.writeStartElement("tr");
250
+                    output.writeStartElement("td");
251
+                    output.writeAttribute("align", "right");
252
+                    output.writeTextElement("strong", TTR("batchDetails", "Roasted Weight:"));
253
+                    output.writeEndElement();
254
+                    output.writeStartElement("td");
255
+                    output.writeAttribute("align", "center");
256
+                    output.writeCharacters(query.value(5));
257
+                    output.writeEndElement();
258
+                    output.writeEndElement();
259
+                    output.writeStartElement("tr");
260
+                    output.writeStartElement("td");
261
+                    output.writeAttribute("align", "right");
262
+                    output.writeTextElement("strong", TTR("batchDetails", "Weight Loss:"));
263
+                    output.writeEndElement();
264
+                    output.writeStartElement("td");
265
+                    output.writeAttribute("align", "center");
266
+                    if(Number(query.value(4)) > 0) {
267
+                        output.writeCharacters(Number(((Number(query.value(4)) - Number(query.value(5)))/Number(query.value(4))) * 100).toFixed(2));
268
+                        output.writeCharacters("%");
269
+                    } else {
270
+                        output.writeCharacters("unknown");
271
+                    }
272
+                    output.writeEndElement();
273
+                    output.writeEndElement();
274
+                    output.writeEndElement();
275
+                    output.writeEndElement();
276
+                    if(query.value(10).length > 0) {
277
+                        var extradata = JSON.parse(query.value(10));
278
+                        if(extradata.color) {
284 279
                             output.writeStartElement("p");
285
-                            output.writeTextElement("strong", TTR("batchDetails", "Whole Bean: "));
286
-                            output.writeTextElement("span", extradata.color.whole);
280
+                            output.writeTextElement("strong", TTR("batchDetails", "Degree of Roast"));
287 281
                             output.writeEndElement();
282
+                            if(extradata.color.whole) {
283
+                                wholecolor.value = extradata.color.whole;
284
+                                output.writeStartElement("p");
285
+                                output.writeTextElement("strong", TTR("batchDetails", "Whole Bean: "));
286
+                                output.writeTextElement("span", extradata.color.whole);
287
+                                output.writeEndElement();
288
+                            } else {
289
+                                wholecolor.value = "";
290
+                            }
291
+                            if(extradata.color.ground) {
292
+                                groundcolor.value = extradata.color.ground;
293
+                                output.writeStartElement("p");
294
+                                output.writeTextElement("strong", TTR("batchDetails", "Ground: "));
295
+                                output.writeTextElement("span", extradata.color.ground);
296
+                                output.writeEndElement();
297
+                            } else {
298
+                                groundcolor.value = "";
299
+                            }
288 300
                         } else {
289 301
                             wholecolor.value = "";
290
-                        }
291
-                        if(extradata.color.ground) {
292
-                            groundcolor.value = extradata.color.ground;
293
-                            output.writeStartElement("p");
294
-                            output.writeTextElement("strong", TTR("batchDetails", "Ground: "));
295
-                            output.writeTextElement("span", extradata.color.ground);
296
-                            output.writeEndElement();
297
-                        } else {
298 302
                             groundcolor.value = "";
299 303
                         }
300 304
                     } else {
301 305
                         wholecolor.value = "";
302 306
                         groundcolor.value = "";
303 307
                     }
304
-                } else {
305
-                    wholecolor.value = "";
306
-                    groundcolor.value = "";
307
-                }
308
-                output.writeStartElement("p");
309
-                output.writeTextElement("strong", TTR("batchDetails", "Approved: "));
310
-                output.writeCharacters(query.value(6));
311
-                output.writeEndElement();
312
-                output.writeStartElement("p");
313
-                output.writeTextElement("strong", TTR("batchDetails", "Files: "));
314
-                output.writeCharacters(query.value(7));
315
-                output.writeEndElement();
316
-                output.writeStartElement("p");
317
-                output.writeTextElement("strong", TTR("batchDetails", "Annotations:"));
318
-                var files = sqlToArray(query.value(7));
319
-                var annotations = annotationFromRecord(files[0]);
320
-                fileID = files[0];
321
-                var buffer2 = new QBuffer("<points>"+annotations+"</points>");
322
-                buffer2.open(1);
323
-                var colQuery = new XQuery;
324
-                colQuery.bind("profile", buffer2);
325
-                colQuery.setQuery('for $i in doc($profile)//tuple[1]/temperature/@series return (string($i), ";")');
326
-                var result = colQuery.exec();
327
-                buffer2.close();
328
-                var seriesHeaders = new Array();
329
-                seriesHeaders.push(TTR("batchDetails", "Time"));
330
-                var records = result.split(";");
331
-                for(var i = 0; i < records.length - 1; i++) {
332
-                    seriesHeaders.push(records[i].replace(/^\s+|\s+$/g,""));
333
-                }
334
-                seriesHeaders.push(TTR("batchDetails", "Note"));
335
-                output.writeStartElement("table");
336
-                output.writeStartElement("thead");
337
-                output.writeStartElement("tr");
338
-                for(var i = 0; i < seriesHeaders.length; i++) {
339
-                    output.writeTextElement("th", seriesHeaders[i]);
340
-                }
341
-                output.writeEndElement();
342
-                output.writeEndElement();
343
-                buffer2.open(1);
344
-                var rq = 'for $t in doc($profile) //tuple return (string($t/time), ";", ';
345
-                for(var i = 0; i < seriesHeaders.length - 2; i++) {
346
-                    rq += 'string($t/temperature[' + Number(i+1) + ']), ";", ';
347
-                }
348
-                rq += 'string($t/annotation), "~")';
349
-                colQuery.setQuery(rq);
350
-                var annotationData = colQuery.exec();
351
-                colQuery = colQuery.invalidate();
352
-                buffer2.close();
353
-                output.writeStartElement("tbody");
354
-                var annotationRecords = annotationData.split("~");
355
-                for(var i = 0; i < annotationRecords.length - 1; i++) {
308
+                    output.writeStartElement("p");
309
+                    output.writeTextElement("strong", TTR("batchDetails", "Approved: "));
310
+                    output.writeCharacters(query.value(6));
311
+                    output.writeEndElement();
312
+                    output.writeStartElement("p");
313
+                    output.writeTextElement("strong", TTR("batchDetails", "Files: "));
314
+                    output.writeCharacters(query.value(7));
315
+                    output.writeEndElement();
316
+                    output.writeStartElement("p");
317
+                    output.writeTextElement("strong", TTR("batchDetails", "Annotations:"));
318
+                    var files = sqlToArray(query.value(7));
319
+                    var annotations = annotationFromRecord(files[0]);
320
+                    fileID = files[0];
321
+                    var buffer2 = new QBuffer("<points>"+annotations+"</points>");
322
+                    buffer2.open(1);
323
+                    var colQuery = new XQuery;
324
+                    colQuery.bind("profile", buffer2);
325
+                    colQuery.setQuery('for $i in doc($profile)//tuple[1]/temperature/@series return (string($i), ";")');
326
+                    var result = colQuery.exec();
327
+                    buffer2.close();
328
+                    var seriesHeaders = new Array();
329
+                    seriesHeaders.push(TTR("batchDetails", "Time"));
330
+                    var records = result.split(";");
331
+                    for(var i = 0; i < records.length - 1; i++) {
332
+                        seriesHeaders.push(records[i].replace(/^\s+|\s+$/g,""));
333
+                    }
334
+                    seriesHeaders.push(TTR("batchDetails", "Note"));
335
+                    output.writeStartElement("table");
336
+                    output.writeStartElement("thead");
356 337
                     output.writeStartElement("tr");
357
-                    var annotationRow = annotationRecords[i].split(";");
358
-                    for(var j = 0; j < annotationRow.length; j++) {
359
-                        output.writeStartElement("td");
360
-                        output.writeAttribute("style", "border-left: 1px solid #000000");
361
-                        if(j > 0) {
362
-                            output.writeAttribute("align", "center");
363
-                        }
364
-                        if(j > 0 && j < annotationRow.length - 1) {
365
-                            output.writeCharacters(Number(annotationRow[j].replace(/^\s+|\s+$/g,"")).toFixed(2));
366
-                        } else {
367
-                            output.writeCharacters(annotationRow[j].replace(/^\s+|\s+$/g,""));
338
+                    for(var i = 0; i < seriesHeaders.length; i++) {
339
+                        output.writeTextElement("th", seriesHeaders[i]);
340
+                    }
341
+                    output.writeEndElement();
342
+                    output.writeEndElement();
343
+                    buffer2.open(1);
344
+                    var rq = 'for $t in doc($profile) //tuple return (string($t/time), ";", ';
345
+                    for(var i = 0; i < seriesHeaders.length - 2; i++) {
346
+                        rq += 'string($t/temperature[' + Number(i+1) + ']), ";", ';
347
+                    }
348
+                    rq += 'string($t/annotation), "~")';
349
+                    colQuery.setQuery(rq);
350
+                    var annotationData = colQuery.exec();
351
+                    colQuery = colQuery.invalidate();
352
+                    buffer2.close();
353
+                    output.writeStartElement("tbody");
354
+                    var annotationRecords = annotationData.split("~");
355
+                    for(var i = 0; i < annotationRecords.length - 1; i++) {
356
+                        output.writeStartElement("tr");
357
+                        var annotationRow = annotationRecords[i].split(";");
358
+                        for(var j = 0; j < annotationRow.length; j++) {
359
+                            output.writeStartElement("td");
360
+                            output.writeAttribute("style", "border-left: 1px solid #000000");
361
+                            if(j > 0) {
362
+                                output.writeAttribute("align", "center");
363
+                            }
364
+                            if(j > 0 && j < annotationRow.length - 1) {
365
+                                output.writeCharacters(Number(annotationRow[j].replace(/^\s+|\s+$/g,"")).toFixed(2));
366
+                            } else {
367
+                                output.writeCharacters(annotationRow[j].replace(/^\s+|\s+$/g,""));
368
+                            }
369
+                            output.writeEndElement();
368 370
                         }
369 371
                         output.writeEndElement();
370 372
                     }
371 373
                     output.writeEndElement();
372
-                }
373
-                output.writeEndElement();
374
-                output.writeEndElement();
375
-                output.writeCharacters(query.value(8));
376
-                output.writeEndElement();
377
-                output.writeEndElement();
378
-                output.writeEndElement();
379
-                output.writeEndDocument();
380
-                dataView.setContent(buffer);
381
-                buffer.close();
382
-                log.clear();
383
-                graph.clear();
384
-                var buffer3 = new QBuffer(query.value(9));
385
-                var input = new XMLInput(buffer3, 1);
386
-                input.newTemperatureColumn.connect(log.setHeaderData);
387
-                input.newAnnotationColumn.connect(log.setHeaderData);
388
-                var lc;
389
-                input.lastColumn.connect(function(c) {
390
-                    lc = c;
391
-                    if(c < 3) {
392
-                        log.setHeaderData(3, "");
374
+                    output.writeEndElement();
375
+                    output.writeCharacters(query.value(8));
376
+                    output.writeEndElement();
377
+                    output.writeEndElement();
378
+                    output.writeEndElement();
379
+                    output.writeEndDocument();
380
+                    dataView.setContent(buffer);
381
+                    buffer.close();
382
+                    log.clear();
383
+                    graph.clear();
384
+                    var buffer3 = new QBuffer(query.value(9));
385
+                    var input = new XMLInput(buffer3, 1);
386
+                    input.newTemperatureColumn.connect(log.setHeaderData);
387
+                    input.newAnnotationColumn.connect(log.setHeaderData);
388
+                    var lc;
389
+                    input.lastColumn.connect(function(c) {
390
+                        lc = c;
391
+                        if(c < 3) {
392
+                            log.setHeaderData(3, "");
393
+                        }
394
+                    });
395
+                    input.measure.connect(graph.newMeasurement);
396
+                    input.measure.connect(log.newMeasurement);
397
+                    input.annotation.connect(function(note,tcol,ncol) {
398
+                        for(var i = tcol; i < ncol; i++) {
399
+                            log.newAnnotation(note, i, ncol);
400
+                        }
401
+                    });
402
+                    graph.updatesEnabled = false;
403
+                    log.updatesEnabled = false;
404
+                    input.input();
405
+                    log.updatesEnabled = true;
406
+                    graph.updatesEnabled = true;
407
+                    log.newAnnotation("End", 1, lc);
408
+                    if(query.value(6) == "true") {
409
+                        approvalButton.checked = true;
393 410
                     }
394
-                });
395
-                input.measure.connect(graph.newMeasurement);
396
-                input.measure.connect(log.newMeasurement);
397
-                input.annotation.connect(function(note,tcol,ncol) {
398
-                    for(var i = tcol; i < ncol; i++) {
399
-                        log.newAnnotation(note, i, ncol);
411
+                    annotationField.plainText = query.value(8);
412
+                    unitEdit.text = unitText;
413
+                    roastedEdit.text = query.value(5);
414
+                    drawTag(query.value(11), query.value(0));
415
+                } else {
416
+                    print("Something is wrong with batch data on machine " + machine + " at time " + batchTime);
417
+                    print("Attempting alternate query. Edit and Batch Tag tabs will not work.");
418
+                    query.prepare("SELECT unroasted_id, unroasted_quantity, unroasted_total_quantity, roasted_id, roasted_quantity, transaction_type, annotation, duration, approval, files, person, additional_data FROM roasting_log WHERE time = :tref AND machine = :mref");
419
+                    query.bind(":tref", batchTime);
420
+                    query.bind(":mref", machine);
421
+                    query.exec();
422
+                    if(query.next()) {
423
+                        var buffer = new QBuffer;
424
+                        buffer.open(3);
425
+                        var output = new XmlWriter(buffer);
426
+                        output.writeStartDocument("1.0");
427
+                        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">');
428
+                        output.writeStartElement("html");
429
+                        output.writeAttribute("xmlns", "http://www.w3.org/1999/xhtml");
430
+                        output.writeStartElement("head");
431
+                        output.writeTextElement("title", "Batch Details");
432
+                        output.writeEndElement();
433
+                        output.writeStartElement("body");
434
+                        output.writeTextElement("p", "Something is wrong with the data for this batch. Falling back to a less detailed view.");
435
+                        output.writeTextElement("p", "unroasted_id: " + query.value(0));
436
+                        output.writeTextElement("p", "unroasted_quantity: " + query.value(1));
437
+                        output.writeTextElement("p", "unroasted_total_quantity: " + query.value(2));
438
+                        output.writeTextElement("p", "roasted_id: " + query.value(3));
439
+                        output.writeTextElement("p", "roasted_quantity: " + query.value(4));
440
+                        output.writeTextElement("p", "transaction_type: " + query.value(5));
441
+                        output.writeTextElement("p", "annotation: " + query.value(6));
442
+                        output.writeTextElement("p", "duration: " + query.value(7));
443
+                        output.writeTextElement("p", "approval: " + query.value(8));
444
+                        output.writeTextElement("p", "files: " + query.value(9));
445
+                        var files = sqlToArray(query.value(9));
446
+                        fileID = files[0];
447
+                        output.writeTextElement("p", "person: " + query.value(10));
448
+                        output.writeTextElement("p", "additional_data: " + query.value(11));
449
+                        output.writeEndElement();
450
+                        output.writeEndElement();
451
+                        output.writeEndDocument();
452
+                        dataView.setContent(buffer);
453
+                        buffer.close();
454
+                        query.prepare("SELECT file FROM files WHERE id = :id");
455
+                        query.bind(":id", fileID);
456
+                        query.exec();
457
+                        if(query.next())
458
+                        {
459
+                            var buffer = new QBuffer(query.value(0));
460
+                            var input = new XMLInput(buffer, 1);
461
+                            input.newTemperatureColumn.connect(log.setHeaderData);
462
+                            input.newAnnotationColumn.connect(log.setHeaderData);
463
+                            var lc;
464
+                            input.lastColumn.connect(function(c) {
465
+                                lc = c;
466
+                                if(c < 3) {
467
+                                    log.setHeaderData(3, "");
468
+                                }
469
+                            });
470
+                            input.measure.connect(graph.newMeasurement);
471
+                            input.measure.connect(log.newMeasurement);
472
+                            input.annotation.connect(function(note,tcol,ncol) {
473
+                                for(var i = tcol; i < ncol; i++) {
474
+                                    log.newAnnotation(note, i, ncol);
475
+                                }
476
+                            });
477
+                            graph.updatesEnabled = false;
478
+                            log.updatesEnabled = false;
479
+                            input.input();
480
+                            log.updatesEnabled = true;
481
+                            graph.updatesEnabled = true;
482
+                            log.newAnnotation("End", 1, lc);
483
+                        }
484
+                    } else {
485
+                        var buffer = new QBuffer;
486
+                        buffer.open(3);
487
+                        var output = new XmlWriter(buffer);
488
+                        output.writeStartDocument("1.0");
489
+                        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">');
490
+                        output.writeStartElement("html");
491
+                        output.writeAttribute("xmlns", "http://www.w3.org/1999/xhtml");
492
+                        output.writeStartElement("head");
493
+                        output.writeTextElement("title", "Batch Details");
494
+                        output.writeEndElement();
495
+                        output.writeStartElement("body");
496
+                        output.writeTextElement("p", "Record not found on machine: " + machine + " at time: " + batchTime);
497
+                        output.writeEndElement();
498
+                        output.writeEndElement();
499
+                        output.writeEndDocument();
500
+                        dataView.setContent(buffer);
501
+                        buffer.close();
400 502
                     }
401
-                });
402
-                graph.updatesEnabled = false;
403
-                log.updatesEnabled = false;
404
-                input.input();
405
-                log.updatesEnabled = true;
406
-                graph.updatesEnabled = true;
407
-                log.newAnnotation("End", 1, lc);
408
-                if(query.value(6) == "true") {
409
-                    approvalButton.checked = true;
410 503
                 }
411
-                annotationField.plainText = query.value(8);
412
-                unitEdit.text = unitText;
413
-                roastedEdit.text = query.value(5);
414
-                drawTag(query.value(11), query.value(0));
415 504
                 query = query.invalidate();
416 505
             }
417 506
             var saveMenu = findChildObject(this, 'save');

Loading…
Cancel
Save