123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760 |
- <window id="exportWindow">
- <layout type="vertical">
- <layout type="horizontal">
- <label>Title:</label>
- <line id="title" />
- </layout>
- <layout type="horizontal">
- <label>Subtitle:</label>
- <line id="subtitle" />
- </layout>
- <layout type="horizontal">
- <label>% weight loss:</label>
- <line id="loss" validator="numeric" />
- <label>Tolerance:</label>
- <line id="tolerance" validator="numeric" />
- </layout>
- <layout type="horizontal">
- <label>Additional notes:</label>
- <line id="notes" />
- </layout>
- <layout type="horizontal">
- <label>Measurement column:</label>
- <line id="addmeasurement" validator="integer" />
- <button name="Add column" type="push" id="ambutton" />
- <line id="mcols" writable="false" />
- </layout>
- <layout type="horizontal">
- <label>Annotation column:</label>
- <line id="addnote" validator="integer" />
- <button name="Add column" type="push" id="anbutton" />
- <line id="ncols" writable="false" />
- </layout>
- <button name="Export" type="push" id="export" />
- </layout>
- <program>
- <![CDATA[
- var window = this;
- var exportButton = findChildObject(this, 'export');
- exportButton.enable = false;
- var mcoldisp = findChildObject(this, 'mcols');
- mcoldisp.enable = false;
- var ncoldisp = findChildObject(this, 'ncols');
- ncoldisp.enable = false;
- var mbutton = findChildObject(this, 'ambutton');
- var msource = findChildObject(this, 'addmeasurement');
- var mdest = findChildObject(this, 'mcols');
- mbutton.clicked.connect(function() {
- if(window.marray === undefined)
- {
- window.marray = new Array();
- }
- window.marray.push(Number(msource.text));
- mdest.text = window.marray.toString();
- msource.text = '';
- if(window.narray === undefined)
- {} else { exportButton.enable = true;}
- });
- var abutton = findChildObject(window, 'anbutton');
- var asource = findChildObject(window, 'addnote');
- var adest = findChildObject(window, 'ncols');
- abutton.clicked.connect(function() {
- if(window.narray === undefined)
- {
- window.narray = new Array();
- }
- window.narray.push(Number(asource.text));
- adest.text = window.narray.toString();
- asource.text = '';
- if(window.marray === undefined)
- { } else { exportButton.enable = true;}
- });
- var titleField = findChildObject(window, 'title');
- var subTitleField = findChildObject(window, 'subtitle');
- exportButton.clicked.connect(function() {
- var filename = QFileDialog.getSaveFileName(window, "Export XHTML+SVG As...", QSettings.value("script/lastDir", "") + "/");
- if(filename != "")
- {
- window.log.clearOutputColumns();
- for(var i = 0; i < window.marray.length; i++)
- {
- window.log.addOutputTemperatureColumn(window.marray[i]);
- }
- for(var i = 0; i < window.narray.length; i++)
- {
- window.log.addOutputAnnotationColumn(window.narray[i]);
- }
- var unitdesc = log.displayUnits();
- if(unitdesc != 10144)
- {
- log.setDisplayUnits(10144);
- }
- var tempFilename = log.saveTemporary();
- log.setDisplayUnits(unitdesc);
- var sourceFile = new QFile(tempFilename);
- sourceFile.open(3);
- var destFile = new QFile(filename);
- destFile.remove();
- destFile.open(3);
- var input = new XmlReader(sourceFile);
- var output = new XmlWriter(destFile);
- output.writeStartDocument("1.0");
- 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">');
- output.writeStartElement("html");
- output.writeAttribute("xmlns", "http://www.w3.org/1999/xhtml");
- output.writeStartElement("head");
- output.writeStartElement("title");
- output.writeCDATA(titleField.text);
- output.writeEndElement();
- output.writeEndElement();
- output.writeStartElement("body");
- output.writeStartElement("h1");
- output.writeAttribute("style", "font-size:100%;font-weight:bold");
- output.writeCDATA(titleField.text);
- output.writeEndElement();
- output.writeStartElement("h2");
- output.writeAttribute("style", "font-size:100%;font-weight:normal");
- output.writeCDATA(subTitleField.text);
- output.writeEndElement();
- output.writeStartElement("div");
- output.writeAttribute("style", "width:7.5in");
- output.writeStartElement("div");
- output.writeAttribute("style", "float:left;width:2.5in");
- output.writeStartElement("table");
- output.writeStartElement("tr");
- output.writeStartElement("th");
- output.writeCDATA("Time");
- output.writeEndElement();
- input.readNext();
- var colMap = new Array();
- var tempMap = new Array();
- while(input.name() != "roast")
- {
- if(input.isStartElement())
- {
- if(input.name() == "tempseries")
- {
- colMap.push(input.attribute("name"));
- tempMap.push(input.attribute("name"));
- }
- if(input.name() == "noteseries")
- {
- colMap.push(input.attribute("name"));
- }
- }
- input.readNext();
- }
- print("Column definitions read");
- for(var i = 0; i < colMap.length; i++)
- {
- output.writeStartElement("th");
- output.writeCDATA(colMap[i]);
- output.writeEndElement();
- }
- print("Column headers output");
- output.writeEndElement();
- var rowBuffer = new Array();
- var nextTime = 0;
- input.readNext();
- var inputReady = false;
- var annotationRead = false;
- var tm = 0;
- var ts = 0;
- while(!input.atEnd())
- {
- if(input.isStartElement())
- {
- if(input.name() == "time")
- {
- rowBuffer[0] = input.readElementText();
- inputReady = true;
- }
- if(input.name() == "temperature")
- {
- for (var i = 0; i < colMap.length; i++)
- {
- if(colMap[i] == input.attribute("series"))
- {
- if(log.displayUnits() == 10143)
- {
- rowBuffer[i + 1] = Math.floor((input.readElementText() - 32) * 5 / 9);
- }
- else
- {
- rowBuffer[i + 1] = Math.floor(input.readElementText());
- }
- break;
- }
- }
- }
- if(input.name() == "annotation")
- {
- for (var i = 0; i < colMap.length; i++)
- {
- if(colMap[i] == input.attribute("series"))
- {
- rowBuffer[i + 1] = input.readElementText();
- break;
- }
- }
- annotationRead = true;
- }
- if(input.name() == "tuple")
- {
- if(inputReady)
- {
- var ta1 = rowBuffer[0].split(":");
- var ta2 = ta1[1].split(".");
- if(Number(ta1[0]) == tm)
- {
- if(Number(ta2[0]) == ts)
- {
- annotationRead = false;
- output.writeStartElement("tr");
- for(var i = 0; i < rowBuffer.length; i++)
- {
- output.writeStartElement("td");
- output.writeAttribute("align", "center");
- output.writeAttribute("style", "font-size: 80%");
- if(i == 0)
- {
- output.writeCDATA(rowBuffer[i].split(".")[0]);
- }
- else
- {
- output.writeCDATA(rowBuffer[i]);
- }
- output.writeEndElement();
- }
- output.writeEndElement();
- nextTime += 30;
- tm = Math.floor(nextTime / 60);
- ts = nextTime % 60;
- }
- }
- if(annotationRead)
- {
- output.writeStartElement("tr");
- for(var i = 0; i < rowBuffer.length; i++)
- {
- output.writeStartElement("td");
- output.writeAttribute("align", "center");
- output.writeAttribute("style", "font-size: 80%");
- output.writeCDATA(rowBuffer[i]);
- output.writeEndElement();
- }
- output.writeEndElement();
- annotationRead = false;
- }
- }
- rowBuffer = new Array();
- }
- }
- input.readNext();
- }
- output.writeStartElement("tr");
- for(var i = 0; i < rowBuffer.length; i++)
- {
- output.writeStartElement("td");
- output.writeAttribute("align", "center");
- output.writeAttribute("style", "font-size: 80%");
- output.writeCDATA(rowBuffer[i]);
- output.writeEndElement();
- }
- output.writeEndElement();
- output.writeEndElement();
- output.writeEndElement();
- output.writeStartElement("div");
- output.writeAttribute("style", "width=4.5in;float=right");
- output.writeStartElement("svg");
- output.writeAttribute("xmlns", "http://www.w3.org/2000/svg");
- output.writeAttribute("version", "1.1");
- output.writeAttribute("width", "4.5in");
- output.writeAttribute("height", "3.4in");
- output.writeAttribute("viewbox", "0 0 400 400");
- output.writeStartElement("rect");
- output.writeAttribute("width", "4.5in");
- output.writeAttribute("height", "3.4in");
- output.writeAttribute("style", "fill:none;stroke-width:3;stroke:rgb(64,64,64)");
- output.writeEndElement();
- output.writeStartElement("text");
- output.writeAttribute("x", "0.1in");
- output.writeAttribute("y", "1.3in");
- output.writeAttribute("font-size", "12");
- output.writeAttribute("transform", "rotate(-90 40,150)");
- if(log.displayUnits() == 10143)
- {
- output.writeCDATA("Temperature (°C)");
- }
- else
- {
- output.writeCDATA("Temperature (°F)");
- }
- output.writeEndElement();
- output.writeStartElement("text");
- output.writeAttribute("x", "1.9in");
- output.writeAttribute("y", "3.3in");
- output.writeAttribute("font-size", "12");
- output.writeCDATA("Time (minutes)");
- output.writeEndElement();
- output.writeStartElement("line");
- output.writeAttribute("x1", "0.4in");
- output.writeAttribute("x2", "0.4in");
- output.writeAttribute("y1", "0.1in");
- output.writeAttribute("y2", "2.9in");
- output.writeAttribute("style", "stroke:rgb(0,0,0);stroke-width:1");
- output.writeEndElement();
- output.writeStartElement("line");
- output.writeAttribute("x1", "0.5in");
- output.writeAttribute("x2", "4.4in");
- output.writeAttribute("y1", "3in");
- output.writeAttribute("y2", "3in");
- output.writeAttribute("style", "stroke:rgb(0,0,0);stroke-width:1");
- output.writeEndElement();
- output.writeStartElement("line");
- output.writeAttribute("x1", "0.4in");
- output.writeAttribute("x2", "4.4in");
- output.writeAttribute("y1", "2.9in");
- output.writeAttribute("y2", "2.9in");
- output.writeAttribute("style", "stroke:rgb(0,0,0);stroke-width:1");
- output.writeEndElement();
- if(log.displayUnits() != 10143)
- {
- output.writeStartElement("text");
- output.writeAttribute("x", "0.3in");
- output.writeAttribute("y", "2.95in");
- output.writeAttribute("font-size", "12");
- output.writeCDATA("0");
- output.writeEndElement();
- }
- if(log.displayUnits() == 10143)
- {
- output.writeStartElement("line");
- output.writeAttribute("x1", "0.4in");
- output.writeAttribute("x2", "4.4in");
- output.writeAttribute("y1", "2.22in");
- output.writeAttribute("y2", "2.22in");
- output.writeAttribute("style", "stroke:rgb(0,0,0);stroke-width:1");
- output.writeEndElement();
- output.writeStartElement("text");
- output.writeAttribute("x", "0.18in");
- output.writeAttribute("y", "2.27in");
- output.writeAttribute("font-size", "12");
- output.writeCDATA("50");
- output.writeEndElement();
- output.writeStartElement("line");
- output.writeAttribute("x1", "0.4in");
- output.writeAttribute("x2", "4.4in");
- output.writeAttribute("y1", "1.71in");
- output.writeAttribute("y2", "1.71in");
- output.writeAttribute("style", "stroke:rgb(0,0,0);stroke-width:1");
- output.writeEndElement();
- output.writeStartElement("text");
- output.writeAttribute("x", "0.18in");
- output.writeAttribute("y", "1.76in");
- output.writeAttribute("font-size", "12");
- output.writeCDATA("100");
- output.writeEndElement();
- output.writeStartElement("line");
- output.writeAttribute("x1", "0.4in");
- output.writeAttribute("x2", "4.4in");
- output.writeAttribute("y1", "1.21in");
- output.writeAttribute("y2", "1.21in");
- output.writeAttribute("style", "stroke:rgb(0,0,0);stroke-width:1");
- output.writeEndElement();
- output.writeStartElement("text");
- output.writeAttribute("x", "0.18in");
- output.writeAttribute("y", "1.26in");
- output.writeAttribute("font-size", "12");
- output.writeCDATA("150");
- output.writeEndElement();
- output.writeStartElement("line");
- output.writeAttribute("x1", "0.4in");
- output.writeAttribute("x2", "4.4in");
- output.writeAttribute("y1", "0.7in");
- output.writeAttribute("y2", "0.7in");
- output.writeAttribute("style", "stroke:rgb(0,0,0);stroke-width:1");
- output.writeEndElement();
- output.writeStartElement("text");
- output.writeAttribute("x", "0.18in");
- output.writeAttribute("y", "0.75in");
- output.writeAttribute("font-size", "12");
- output.writeCDATA("200");
- output.writeEndElement();
- output.writeStartElement("line");
- output.writeAttribute("x1", "0.4in");
- output.writeAttribute("x2", "4.4in");
- output.writeAttribute("y1", "0.2in");
- output.writeAttribute("y2", "0.2in");
- output.writeAttribute("style", "stroke:rgb(0,0,0);stroke-width:1");
- output.writeEndElement();
- output.writeStartElement("text");
- output.writeAttribute("x", "0.18in");
- output.writeAttribute("y", "0.25in");
- output.writeAttribute("font-size", "12");
- output.writeCDATA("250");
- output.writeEndElement();
- }
- else
- {
- output.writeStartElement("line");
- output.writeAttribute("x1", "0.4in");
- output.writeAttribute("x2", "4.4in");
- output.writeAttribute("y1", "2.34in");
- output.writeAttribute("y2", "2.34in");
- output.writeAttribute("style", "stroke:rgb(0,0,0);stroke-width:1");
- output.writeEndElement();
- output.writeStartElement("text");
- output.writeAttribute("x", "0.18in");
- output.writeAttribute("y", "2.39in");
- output.writeAttribute("font-size", "12");
- output.writeCDATA("100");
- output.writeEndElement();
- output.writeStartElement("line");
- output.writeAttribute("x1", "0.4in");
- output.writeAttribute("x2", "4.4in");
- output.writeAttribute("y1", "1.78in");
- output.writeAttribute("y2", "1.78in");
- output.writeAttribute("style", "stroke:rgb(0,0,0);stroke-width:1");
- output.writeEndElement();
- output.writeStartElement("text");
- output.writeAttribute("x", "0.18in");
- output.writeAttribute("y", "1.83in");
- output.writeAttribute("font-size", "12");
- output.writeCDATA("200");
- output.writeEndElement();
- output.writeStartElement("line");
- output.writeAttribute("x1", "0.4in");
- output.writeAttribute("x2", "4.4in");
- output.writeAttribute("y1", "1.22in");
- output.writeAttribute("y2", "1.22in");
- output.writeAttribute("style", "stroke:rgb(0,0,0);stroke-width:1");
- output.writeEndElement();
- output.writeStartElement("text");
- output.writeAttribute("x", "0.18in");
- output.writeAttribute("y", "1.27in");
- output.writeAttribute("font-size", "12");
- output.writeCDATA("300");
- output.writeEndElement();
- output.writeStartElement("line");
- output.writeAttribute("x1", "0.4in");
- output.writeAttribute("x2", "4.4in");
- output.writeAttribute("y1", "0.66in");
- output.writeAttribute("y2", "0.66in");
- output.writeAttribute("style", "stroke:rgb(0,0,0);stroke-width:1");
- output.writeEndElement();
- output.writeStartElement("text");
- output.writeAttribute("x", "0.18in");
- output.writeAttribute("y", "0.71in");
- output.writeAttribute("font-size", "12");
- output.writeCDATA("400");
- output.writeEndElement();
- output.writeStartElement("line");
- output.writeAttribute("x1", "0.4in");
- output.writeAttribute("x2", "4.4in");
- output.writeAttribute("y1", "0.1in");
- output.writeAttribute("y2", "0.1in");
- output.writeAttribute("style", "stroke:rgb(0,0,0);stroke-width:1");
- output.writeEndElement();
- output.writeStartElement("text");
- output.writeAttribute("x", "0.18in");
- output.writeAttribute("y", "0.15in");
- output.writeAttribute("font-size", "12");
- output.writeCDATA("500");
- output.writeEndElement();
- }
- output.writeStartElement("line");
- output.writeAttribute("x1", "0.5in");
- output.writeAttribute("x2", "0.5in");
- output.writeAttribute("y1", "2.95in");
- output.writeAttribute("y2", "3.05in");
- output.writeAttribute("style", "stroke:rgb(0,0,0);stroke-width:1");
- output.writeEndElement();
- output.writeStartElement("text");
- output.writeAttribute("x", "0.47in");
- output.writeAttribute("y", "3.16in");
- output.writeAttribute("font-size", "12");
- output.writeCDATA("0");
- output.writeEndElement();
- output.writeStartElement("line");
- output.writeAttribute("x1", "0.89in");
- output.writeAttribute("x2", "0.89in");
- output.writeAttribute("y1", "2.95in");
- output.writeAttribute("y2", "3.05in");
- output.writeAttribute("style", "stroke:rgb(0,0,0);stroke-width:1");
- output.writeEndElement();
- output.writeStartElement("text");
- output.writeAttribute("x", "0.86in");
- output.writeAttribute("y", "3.16in");
- output.writeAttribute("font-size", "12");
- output.writeCDATA("2");
- output.writeEndElement();
- output.writeStartElement("line");
- output.writeAttribute("x1", "1.28in");
- output.writeAttribute("x2", "1.28in");
- output.writeAttribute("y1", "2.95in");
- output.writeAttribute("y2", "3.05in");
- output.writeAttribute("style", "stroke:rgb(0,0,0);stroke-width:1");
- output.writeEndElement();
- output.writeStartElement("text");
- output.writeAttribute("x", "1.25in");
- output.writeAttribute("y", "3.16in");
- output.writeAttribute("font-size", "12");
- output.writeCDATA("4");
- output.writeEndElement();
- output.writeStartElement("line");
- output.writeAttribute("x1", "1.67in");
- output.writeAttribute("x2", "1.67in");
- output.writeAttribute("y1", "2.95in");
- output.writeAttribute("y2", "3.05in");
- output.writeAttribute("style", "stroke:rgb(0,0,0);stroke-width:1");
- output.writeEndElement();
- output.writeStartElement("text");
- output.writeAttribute("x", "1.64in");
- output.writeAttribute("y", "3.16in");
- output.writeAttribute("font-size", "12");
- output.writeCDATA("6");
- output.writeEndElement();
- output.writeStartElement("line");
- output.writeAttribute("x1", "2.06in");
- output.writeAttribute("x2", "2.06in");
- output.writeAttribute("y1", "2.95in");
- output.writeAttribute("y2", "3.05in");
- output.writeAttribute("style", "stroke:rgb(0,0,0);stroke-width:1");
- output.writeEndElement();
- output.writeStartElement("text");
- output.writeAttribute("x", "2.03in");
- output.writeAttribute("y", "3.16in");
- output.writeAttribute("font-size", "12");
- output.writeCDATA("8");
- output.writeEndElement();
- output.writeStartElement("line");
- output.writeAttribute("x1", "2.45in");
- output.writeAttribute("x2", "2.45in");
- output.writeAttribute("y1", "2.95in");
- output.writeAttribute("y2", "3.05in");
- output.writeAttribute("style", "stroke:rgb(0,0,0);stroke-width:1");
- output.writeEndElement();
- output.writeStartElement("text");
- output.writeAttribute("x", "2.39in");
- output.writeAttribute("y", "3.16in");
- output.writeAttribute("font-size", "12");
- output.writeCDATA("10");
- output.writeEndElement();
- output.writeStartElement("line");
- output.writeAttribute("x1", "2.84in");
- output.writeAttribute("x2", "2.84in");
- output.writeAttribute("y1", "2.95in");
- output.writeAttribute("y2", "3.05in");
- output.writeAttribute("style", "stroke:rgb(0,0,0);stroke-width:1");
- output.writeEndElement();
- output.writeStartElement("text");
- output.writeAttribute("x", "2.78in");
- output.writeAttribute("y", "3.16in");
- output.writeAttribute("font-size", "12");
- output.writeCDATA("12");
- output.writeEndElement();
- output.writeStartElement("line");
- output.writeAttribute("x1", "3.23in");
- output.writeAttribute("x2", "3.23in");
- output.writeAttribute("y1", "2.95in");
- output.writeAttribute("y2", "3.05in");
- output.writeAttribute("style", "stroke:rgb(0,0,0);stroke-width:1");
- output.writeEndElement();
- output.writeStartElement("text");
- output.writeAttribute("x", "3.17in");
- output.writeAttribute("y", "3.16in");
- output.writeAttribute("font-size", "12");
- output.writeCDATA("14");
- output.writeEndElement();
- output.writeStartElement("line");
- output.writeAttribute("x1", "3.62in");
- output.writeAttribute("x2", "3.62in");
- output.writeAttribute("y1", "2.95in");
- output.writeAttribute("y2", "3.05in");
- output.writeAttribute("style", "stroke:rgb(0,0,0);stroke-width:1");
- output.writeEndElement();
- output.writeStartElement("text");
- output.writeAttribute("x", "3.56in");
- output.writeAttribute("y", "3.16in");
- output.writeAttribute("font-size", "12");
- output.writeCDATA("16");
- output.writeEndElement();
- output.writeStartElement("line");
- output.writeAttribute("x1", "4.01in");
- output.writeAttribute("x2", "4.01in");
- output.writeAttribute("y1", "2.95in");
- output.writeAttribute("y2", "3.05in");
- output.writeAttribute("style", "stroke:rgb(0,0,0);stroke-width:1");
- output.writeEndElement();
- output.writeStartElement("text");
- output.writeAttribute("x", "3.95in");
- output.writeAttribute("y", "3.16in");
- output.writeAttribute("font-size", "12");
- output.writeCDATA("18");
- output.writeEndElement();
- output.writeStartElement("line");
- output.writeAttribute("x1", "4.4in");
- output.writeAttribute("x2", "4.4in");
- output.writeAttribute("y1", "2.95in");
- output.writeAttribute("y2", "3.05in");
- output.writeAttribute("style", "stroke:rgb(0,0,0);stroke-width:1");
- output.writeEndElement();
- output.writeStartElement("text");
- output.writeAttribute("x", "4.34in");
- output.writeAttribute("y", "3.16in");
- output.writeAttribute("font-size", "12");
- output.writeCDATA("20");
- output.writeEndElement();
- sourceFile.close();
- sourceFile.open(3);
- input = new XmlReader(sourceFile);
- var lineStyles = new Array();
- lineStyles.push("stroke:rgb(255,0,0);stroke-width:1");
- lineStyles.push("stroke:rgb(0,255,0);stroke-width:1");
- lineStyles.push("stroke:rgb(0,0,255);stroke-width:1");
- lineStyles.push("stroke:rgb(255,255,0);stroke-width:1");
- lineStyles.push("stroke:rgb(255,0,255);stroke-width:1");
- lineStyles.push("stroke:rgb(0,255,255);stroke-width:1");
- var check1 = false;
- var drawable = false;
- var previousX;
- var currentX;
- var previousY = new Array();
- input.readNext();
- while(!input.atEnd())
- {
- if(input.isStartElement())
- {
- if(input.name() == "time")
- {
- if(check1)
- {
- previousX = currentX;
- }
- var tstring = input.readElementText();
- var tsplit1 = tstring.split(":");
- var tsplit2 = tsplit1[1].split(".");
- currentX = 0.5 + (Number(tsplit1[0])*0.195) + (Number(tsplit2[0])*0.00325);// + (Number(tsplit2[1]) * 0.00000325);
- if(check1)
- {
- drawable = true;
- }
- check1 = true;
- }
- if(input.name() == "temperature")
- {
- var series;
- for(var i = 0; i < tempMap.length; i++)
- {
- if(tempMap[i] == input.attribute("series"))
- {
- series = i;
- break;
- }
- }
- var currentY = 2.9 - Number(input.readElementText()) * 0.0056;
- if(drawable)
- {
- output.writeStartElement("line");
- output.writeAttribute("style", lineStyles[series % 6]);
- output.writeAttribute("x1", String(previousX)+"in");
- output.writeAttribute("x2", String(currentX)+"in");
- output.writeAttribute("y1", String(previousY[series])+"in");
- output.writeAttribute("y2", String(currentY)+"in");
- output.writeEndElement();
- }
- previousY[series] = currentY;
- }
- }
- input.readNext();
- }
- sourceFile.remove();
- sourceFile.close();
- output.writeEndElement();
- output.writeStartElement("div");
- output.writeAttribute("style", "margin-left:3in;margin-top:0.5in");
- var lossField = findChildObject(window, 'loss');
- var tolField = findChildObject(window, 'tolerance');
- if(lossField.text != "")
- {
- output.writeStartElement("p");
- output.writeCDATA("Weight loss: ");
- output.writeCDATA(lossField.text);
- if(tolField.text != "")
- {
- output.writeCDATA("±");
- output.writeCDATA(tolField.text);
- }
- output.writeCDATA("%");
- output.writeEndElement();
- output.writeStartElement("table");
- output.writeStartElement("tr");
- output.writeStartElement("th");
- output.writeCDATA("Roasted");
- output.writeEndElement();
- output.writeStartElement("th");
- output.writeCDATA("Green");
- output.writeEndElement();
- output.writeEndElement();
- var green;
- var roasted;
- var loss = (Number(lossField.text) + Number(tolField.text)) / 100;
- for(roasted = 1; roasted < 30; roasted++)
- {
- green = (1/-(loss-1)) * roasted;
- if(green > 30)
- {
- break;
- }
- if(roasted % 5 == 0)
- {
- output.writeStartElement("tr");
- output.writeStartElement("td");
- output.writeAttribute("align", "center");
- output.writeCDATA(roasted);
- output.writeEndElement();
- output.writeStartElement("td");
- output.writeAttribute("align", "center");
- output.writeCDATA(green.toFixed(2));
- output.writeEndElement();
- output.writeEndElement();
- }
- }
- roasted--;
- if(roasted % 5 > 0)
- {
- green = (1/-(loss-1)) * roasted;
- output.writeStartElement("tr");
- output.writeStartElement("td");
- output.writeAttribute("align", "center");
- output.writeCDATA(roasted);
- output.writeEndElement();
- output.writeStartElement("td");
- output.writeAttribute("align", "center");
- output.writeCDATA(green.toFixed(2));
- output.writeEndElement();
- output.writeEndElement();
- }
- output.writeEndElement();
- }
- var noteField = findChildObject(window, 'notes');
- if(noteField.text != "")
- {
- output.writeStartElement("p");
- output.writeCDATA(noteField.text);
- output.writeEndElement();
- }
- output.writeEndElement();
- output.writeEndElement();
- output.writeEndElement();
- output.writeEndElement();
- output.writeEndDocument();
- destFile.close();
- QSettings.setValue("script/lastDir", dir(filename));
- window.close();
- }
- });
- ]]>
- </program>
- </window>
|