Typica is a free program for professional coffee roasters. https://typica.us
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

productionroaster.xml 29KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749
  1. <window id="basicWindow">
  2. <layout type="vertical">
  3. <splitter type = "vertical" id = "main">
  4. <splitter type = "horizontal" id = "indicators" />
  5. <widget id="widget">
  6. <layout type="horizontal" id="controlpanel">
  7. <button name="Start Batch" type="push" id="startbutton" />
  8. <button name="Stop Batch" type="annotation" id="stopbutton" annotation="End" />
  9. </layout>
  10. </widget>
  11. <splitter type="horizontal" id="logsplit">
  12. <measurementtable id="log" />
  13. <graph id="graph" />
  14. </splitter>
  15. </splitter>
  16. </layout>
  17. <menu name="File">
  18. <item id="open" shortcut="Ctrl+O">Open…</item>
  19. <item id="save" shortcut="Ctrl+S">Save…</item>
  20. <item id="print" shortcut="Ctrl+P">Print…</item>
  21. <item id="export">Export CSV…</item>
  22. <item id="svgexport">Export XHTML+SVG…</item>
  23. <item id="quit" shortcut="Ctrl+Q">Quit</item>
  24. </menu>
  25. <menu name="Batch">
  26. <item id="new" shortcut="Ctrl+N">New Batch…</item>
  27. <item id="compare">Load Additional Profiles...</item>
  28. </menu>
  29. <menu name="Log">
  30. <item id="showC">Display Celsius</item>
  31. <item id="showF">Display Fahrenheit</item>
  32. <item id="setSample">New Sample Parameters</item>
  33. <separator />
  34. <item id="clear" shortcut="Ctrl+L">Clear Log</item>
  35. <separator />
  36. <item id="ms">Millisecond View</item>
  37. <item id="1s">1 Second View</item>
  38. <item id="5s">5 Second View</item>
  39. <item id="10s">10 Second View</item>
  40. <item id="15s">15 Second View</item>
  41. <item id="30s">30 Second View</item>
  42. <item id="1m">1 Minute View</item>
  43. <separator />
  44. <item id="manual" shortcut="Ctrl+E">Manual Entry</item>
  45. </menu>
  46. <menu name="Graph">
  47. <item id="unshift">Reset Translation</item>
  48. </menu>
  49. <program>
  50. <![CDATA[
  51. var window = this;
  52. var targetOffset = 0;
  53. var gtrans = 0;
  54. var targetDetector = new ThresholdDetector;
  55. window.targetcolumnname = "";
  56. var currentDetector = new ThresholdDetector;
  57. var translationChannel = -1;
  58. targetDetector.timeForValue.connect(function(value) {
  59. targetOffset = value;
  60. });
  61. var epoch = new QTime;
  62. epoch = epoch.currentTime;
  63. var translationCurrentColumn = -1;
  64. var configModel = new DeviceTreeModel;
  65. var rootIndex = configModel.index(roasterlist.currentIndex, 0);
  66. var channels = new Array();
  67. var annotationButtons = new Array();
  68. var nidevices = new Array();
  69. var temperatureDisplays = new Array();
  70. var columnNames = new Array();
  71. var modbusdevices = new Array();
  72. var indicatorPanel = findChildObject(this, 'indicators');
  73. var annotationPanel = findChildObject(this, 'controlpanel');
  74. var log = findChildObject(this, 'log');
  75. var tabControls = new Array();
  76. var start = findChildObject(this, 'startbutton');
  77. var stop = findChildObject(this, 'stopbutton');
  78. stop.enabled = false;
  79. tabControls.push(start);
  80. tabControls.push(stop);
  81. var nsparam = findChildObject(this, 'setSample');
  82. nsparam.enabled = false;
  83. var graph = findChildObject(this, 'graph');
  84. var hasTranslated = false;
  85. var externtrans = undefined;
  86. window.translateLoadedSeries = function(translation) {
  87. var lc = Number(QSettings.value("liveColumn"));
  88. for(var i = 1; i < lc - 1; i++)
  89. {
  90. graph.setSeriesTranslation(i, translation);
  91. }
  92. };
  93. window.translateCurrentSeries = function(translation) {
  94. var lc = Number(QSettings.value("liveColumn"));
  95. for(var i = 0; i < columnNames.length; i++)
  96. {
  97. graph.setSeriesTranslation(lc + i, translation);
  98. }
  99. };
  100. var selectedRoasterName = configModel.data(rootIndex, 0);
  101. var machineReference = configModel.referenceElement(configModel.data(rootIndex, 32));
  102. var selectedRoasterID = machineReference.databaseid;
  103. if(configModel.hasChildren(rootIndex)) {
  104. for(var i = 0; i < configModel.rowCount(rootIndex); i++) {
  105. var driverIndex = configModel.index(i, 0, rootIndex);
  106. var driverReference = configModel.referenceElement(configModel.data(driverIndex, 32));
  107. if(driverReference.driver == "nidaqmxbase" || driverReference.driver == "nidaqmx") {
  108. if(configModel.hasChildren(driverIndex)) {
  109. for(var j = 0; j < configModel.rowCount(driverIndex); j++) {
  110. var deviceIndex = configModel.index(j, 0, driverIndex);
  111. var deviceReference = configModel.referenceElement(configModel.data(deviceIndex, 32));
  112. if(deviceReference.driver == "nidaqmxbase9211series" || deviceReference.driver == "nidaqmx9211series") {
  113. var device = new DAQ(deviceReference.deviceID, driverReference.driver);
  114. nidevices.push(device);
  115. var DAQChannels = 0;
  116. if(configModel.hasChildren(deviceIndex)) {
  117. for(var k = 0; k < configModel.rowCount(deviceIndex); k++) {
  118. var channelIndex = configModel.index(k, 0, deviceIndex);
  119. var channelReference = configModel.referenceElement(configModel.data(channelIndex, 32));
  120. if(channelReference.driver == "ni9211seriestc") {
  121. var channel;
  122. if(channelReference.type == "J") {
  123. channel = device.newChannel(DAQ.Fahrenheit, DAQ.TypeJ);
  124. }
  125. else if(channelReference.type == "K") {
  126. channel = device.newChannel(DAQ.Fahrenheit, DAQ.TypeK);
  127. }
  128. else if(channelReference.type == "T") {
  129. channel = device.newChannel(DAQ.Fahrenheit, DAQ.TypeT);
  130. }
  131. else if(channelReference.type == "B") {
  132. channel = device.newChannel(DAQ.Fahrenheit, DAQ.TypeB);
  133. }
  134. else if(channelReference.type == "E") {
  135. channel = device.newChannel(DAQ.Fahrenheit, DAQ.TypeE);
  136. }
  137. else if(channelReference.type == "N") {
  138. channel = device.newChannel(DAQ.Fahrenheit, DAQ.TypeN);
  139. }
  140. else if(channelReference.type == "R") {
  141. channel = device.newChannel(DAQ.Fahrenheit, DAQ.TypeR);
  142. }
  143. else if(channelReference.type == "S") {
  144. channel = device.newChannel(DAQ.Fahrenheit, DAQ.TypeS);
  145. }
  146. channels.push(channel);
  147. columnNames.push(channelReference.columnname);
  148. DAQChannels++;
  149. var indicator = new TemperatureDisplay;
  150. temperatureDisplays.push(indicator);
  151. var decorator = new WidgetDecorator(indicator, configModel.data(channelIndex, 0), 2);
  152. channel.newData.connect(indicator.setValue);
  153. indicatorPanel.addWidget(decorator);
  154. }
  155. }
  156. switch(DAQChannels) {
  157. case 1:
  158. device.setClockRate(4);
  159. break;
  160. case 2:
  161. device.setClockRate(2);
  162. break;
  163. case 3:
  164. device.setClockRate(1.5);
  165. break;
  166. case 4:
  167. device.setClockRate(1);
  168. break;
  169. }
  170. device.start();
  171. }
  172. }
  173. else if(deviceReference.driver == "nidaqmxtc01")
  174. {
  175. var device = new DAQ(deviceReference.deviceID, "nidaqmx");
  176. var channel;
  177. if(deviceReference.type == "J")
  178. {
  179. channel = device.newChannel(DAQ.Fahrenheit, DAQ.TypeJ);
  180. }
  181. else if(deviceReference.type == "K")
  182. {
  183. channel = device.newChannel(DAQ.Fahrenheit, DAQ.TypeK);
  184. }
  185. else if(deviceReference.type == "T")
  186. {
  187. channel = device.newChannel(DAQ.Fahrenheit, DAQ.TypeT);
  188. }
  189. else if(deviceReference.type == "B")
  190. {
  191. channel = device.newChannel(DAQ.Fahrenheit, DAQ.TypeB);
  192. }
  193. else if(deviceReference.type == "E")
  194. {
  195. channel = device.newChannel(DAQ.Fahrenheit, DAQ.TypeE);
  196. }
  197. else if(deviceReference.type == "N")
  198. {
  199. channel = device.newChannel(DAQ.Fahrenheit, DAQ.TypeN);
  200. }
  201. else if(deviceReference.type == "R")
  202. {
  203. channel = device.newChannel(DAQ.Fahrenheit, DAQ.TypeR);
  204. }
  205. else if(deviceReference.type == "S")
  206. {
  207. channel = device.newChannel(DAQ.Fahrenheit, DAQ.TypeS);
  208. }
  209. channels.push(channel);
  210. columnNames.push(deviceReference.columnname);
  211. var indicator = new TemperatureDisplay;
  212. temperatureDisplays.push(indicator);
  213. var decorator = new WidgetDecorator(indicator, configModel.data(deviceIndex, 0), 2);
  214. channel.newData.connect(indicator.setValue);
  215. indicatorPanel.addWidget(decorator);
  216. device.start();
  217. nidevices.push(device);
  218. }
  219. }
  220. }
  221. }
  222. else if(driverReference.driver == "modbusrtu")
  223. {
  224. var device = new ModbusRTUDevice(configModel, driverIndex);
  225. modbusdevices.push(device);
  226. var pvchannel = device.pVChannel();
  227. channels.push(pvchannel);
  228. columnNames.push(driverReference.pvcolname);
  229. var indicator = new TemperatureDisplay;
  230. temperatureDisplays.push(indicator);
  231. var decorator = new WidgetDecorator(indicator, configModel.data(driverIndex, 0) + " PV", 2);
  232. pvchannel.newData.connect(indicator.setValue);
  233. indicatorPanel.addWidget(decorator);
  234. if(driverReference.sVEnabled == "true")
  235. {
  236. var svchannel = device.sVChannel();
  237. channels.push(svchannel);
  238. columnNames.push(driverReference.svcolname);
  239. var indicator = new TemperatureDisplay;
  240. temperatureDisplays.push(indicator);
  241. var decorator = new WidgetDecorator(indicator, configModel.data(driverIndex, 0) + " SV", 2);
  242. svchannel.newData.connect(indicator.setValue);
  243. indicatorPanel.addWidget(decorator);
  244. }
  245. if(driverReference.sVWritable == "true")
  246. {
  247. var outputControl = new AnnotationSpinBox;
  248. device.SVLowerChanged.connect(function(min) {
  249. outputControl.minimum = min;
  250. });
  251. outputControl.minimum = device.SVLower();
  252. device.SVUpperChanged.connect(function(max) {
  253. outputControl.maximum = max;
  254. });
  255. outputControl.maximum = device.SVUpper();
  256. device.SVDecimalChanged.connect(function(prec) {
  257. outputControl.decimals = prec;
  258. });
  259. outputControl.decimals = device.decimals();
  260. outputControl.editingFinished.connect(function() {
  261. device.outputSV(outputControl.value);
  262. });
  263. var layout = new QBoxLayout;
  264. var label = new QLabel("Change SV");
  265. layout.addWidget(label, 0, 2);
  266. layout.addWidget(outputControl, 0, 1);
  267. annotationPanel.addLayout(layout);
  268. tabControls.push(outputControl);
  269. }
  270. }
  271. else if(driverReference.driver == "annotationbutton")
  272. {
  273. var button = new AnnotationButton(driverReference.buttontext);
  274. button.setAnnotation(driverReference.annotationtext);
  275. annotationButtons.push(button);
  276. annotationPanel.addWidget(button);
  277. tabControls.push(button);
  278. }
  279. else if(driverReference.driver == "reconfigurablebutton")
  280. {
  281. var button = new AnnotationButton(driverReference.buttontext);
  282. button.setAnnotation(driverReference.annotationtext);
  283. annotationButtons.push(button);
  284. annotationPanel.addWidget(button);
  285. tabControls.push(button);
  286. nsparam.enabled = true;
  287. nsparam.triggered.connect(function() {
  288. var setParam = createWindow("sampleParameters");
  289. setParam.windowTitle = "Typica - Set Sample Parameters";
  290. setParam.button = button;
  291. });
  292. }
  293. else if(driverReference.driver == "annotationspinbox")
  294. {
  295. var layout = new QBoxLayout;
  296. var label = new QLabel(driverReference.label);
  297. layout.addWidget(label, 0, 2);
  298. var spinbox = new AnnotationSpinBox;
  299. spinbox.setPretext(driverReference.pretext);
  300. spinbox.setPosttext(driverReference.posttext);
  301. spinbox.minimum = driverReference.minimum;
  302. spinbox.maximum = driverReference.maximum;
  303. spinbox.decimals = driverReference.precision;
  304. layout.addWidget(spinbox, 0, 1);
  305. annotationPanel.addLayout(layout);
  306. annotationButtons.push(spinbox);
  307. tabControls.push(spinbox);
  308. }
  309. else if(driverReference.driver == "freeannotation")
  310. {
  311. var layout = new QBoxLayout;
  312. var label = new QLabel(driverReference.labeltext);
  313. var control = new QLineEdit;
  314. layout.addWidget(label, 0, 2);
  315. layout.addWidget(control, 0, 1);
  316. annotationPanel.addLayout(layout);
  317. tabControls.push(control);
  318. control.returnPressed.connect(function() {
  319. for(var i = window.firstTempColumn; i < window.annotationColumn; i++) {
  320. log.newAnnotation(control.text, i, window.annotationColumn);
  321. }
  322. });
  323. }
  324. else if(driverReference.driver == "linearspline")
  325. {
  326. var colname = driverReference.source;
  327. for(var j = 0; j < columnNames.length; j++)
  328. {
  329. if(columnNames[j] == colname)
  330. {
  331. var calibrator = new LinearSplineInterpolator;
  332. var sv = driverReference.sourcevalues;
  333. var dv = driverReference.destinationvalues;
  334. var sourcevalues = sv.slice(2, sv.length-2).split(",");
  335. var destvalues = dv.slice(2, dv.length-2).split(",");
  336. if(sourcevalues.length > 1 && destvalues.length == sourcevalues.length)
  337. {
  338. for(var k = 0; k < sourcevalues.length; k++)
  339. {
  340. calibrator.add_pair(Number(sourcevalues[k]),Number(destvalues[k]));
  341. }
  342. var indicator = new TemperatureDisplay;
  343. temperatureDisplays.push(indicator);
  344. var decorator = new WidgetDecorator(indicator, configModel.data(driverIndex, 0), 2);
  345. channels[j].newData.connect(calibrator.newMeasurement);
  346. calibrator.newData.connect(indicator.setValue);
  347. channels.push(calibrator);
  348. columnNames.push(driverReference.destination);
  349. indicatorPanel.addWidget(decorator);
  350. }
  351. break;
  352. }
  353. }
  354. }
  355. else if(driverReference.driver == "translation")
  356. {
  357. var colname = driverReference.column;
  358. window.targetcolumnname = colname;
  359. for(var j = 0; j < columnNames.length; j++)
  360. {
  361. if(columnNames[j] == colname)
  362. {
  363. translationChannel = j;
  364. var indicator = new TemperatureDisplay;
  365. indicator.digitCount = 4;
  366. externtrans = indicator;
  367. indicator.display(0);
  368. var decorator = new WidgetDecorator(indicator, configModel.data(driverIndex, 0), 2);
  369. indicatorPanel.addWidget(decorator);
  370. currentDetector.timeForValue.connect(function(value) {
  371. if(!hasTranslated)
  372. {
  373. var currentOffset = value;
  374. if(targetOffset != 0)
  375. {
  376. var translation = currentOffset - targetOffset;
  377. externtrans.display(translation);
  378. gtrans = translation;
  379. if(translation > 0)
  380. {
  381. window.translateLoadedSeries(translation);
  382. }
  383. else
  384. {
  385. window.translateCurrentSeries(-translation);
  386. }
  387. }
  388. }
  389. hasTranslated = true;
  390. });
  391. var resetTranslation = findChildObject(this, 'unshift');
  392. resetTranslation.triggered.connect(function() {
  393. if(gtrans > 0) {
  394. window.translateLoadedSeries(-gtrans);
  395. }
  396. else {
  397. window.translateCurrentSeries(gtrans);
  398. }
  399. gtrans = 0;
  400. indicator.display(0);
  401. });
  402. }
  403. }
  404. targetDetector.setThreshold(driverReference.FValue);
  405. currentDetector.setThreshold(driverReference.FValue);
  406. }
  407. else if(driverReference.driver == "rate")
  408. {
  409. var primaryColumn = driverReference.column;
  410. for(var j = 0; j < columnNames.length; j++)
  411. {
  412. if(columnNames[j] == primaryColumn)
  413. {
  414. var rate = new RateOfChange(driverReference.cache, driverReference.scale);
  415. channels[j].newData.connect(rate.newMeasurement);
  416. var indicator = new TemperatureDisplay;
  417. indicator.setRelativeMode(true);
  418. indicator.display(0);
  419. indicator.digitCount = 9;
  420. var decorator = new WidgetDecorator(indicator, configModel.data(driverIndex, 0), 2);
  421. indicatorPanel.addWidget(decorator);
  422. rate.measurement.connect(indicator.setValue);
  423. temperatureDisplays.push(indicator);
  424. }
  425. }
  426. }
  427. }
  428. }
  429. for(var i = 1; i < tabControls.length; i++)
  430. {
  431. setTabOrder(tabControls[i-1], tabControls[i]);
  432. }
  433. log.setHeaderData(0, "Time");
  434. for(var i = 0; i < columnNames.length; i++) {
  435. log.setHeaderData(i + 1, columnNames[i]);
  436. }
  437. log.setHeaderData(columnNames.length + 1, "Note");
  438. for(var i = 0; i < channels.length; i++) {
  439. log.addToCurrentColumnSet(i + 1);
  440. }
  441. var timer = new TimerDisplay;
  442. timer.displayFormat = "mm:ss";
  443. timer.autoReset = true;
  444. var btdecorator = new WidgetDecorator(timer, "Batch Timer", 2);
  445. indicatorPanel.addWidget(btdecorator);
  446. var vsplit = findChildObject(this, 'main');
  447. var isplit = findChildObject(this, 'indicators');
  448. var lsplit = findChildObject(this, 'logsplit');
  449. window.aboutToClose.connect(function() {
  450. for(var i = 0; i < nidevices.length; i++)
  451. {
  452. nidevices[i].stop();
  453. nidevices[i].deleteLater();
  454. }
  455. for(var i = 0; i < modbusdevices.length; i++)
  456. {
  457. modbusdevices[i].deleteLater();
  458. }
  459. delete nidevices;
  460. delete modbusdevices;
  461. window.saveSizeAndPosition("window");
  462. vsplit.saveState("script/mainSplitter");
  463. isplit.saveState("script/instrumentSplitter");
  464. lsplit.saveState("script/logSplitter");
  465. log.saveState("script/log", 7);
  466. window.navigationWindow.loggingWindow = undefined;
  467. });
  468. this.restoreSizeAndPosition('window');
  469. vsplit.restoreState("script/mainSplitter");
  470. isplit.restoreState("script/instrumentSplitter");
  471. lsplit.restoreState("script/logSplitter");
  472. log.restoreState("script/log", 7);
  473. var offsets = new Array();
  474. var zeroemitters = new Array();
  475. var adapters = new Array();
  476. for(var i = 0; i < channels.length; i++) {
  477. var offset = new MeasurementTimeOffset(epoch);
  478. offsets.push(offset);
  479. channels[i].newData.connect(offset.newMeasurement);
  480. var adapter = new MeasurementAdapter(i + 1);
  481. adapters.push(adapter);
  482. offset.measurement.connect(adapter.newMeasurement);
  483. var emitter = new ZeroEmitter(i + 1);
  484. zeroemitters.push(emitter);
  485. channels[i].newData.connect(emitter.newMeasurement);
  486. emitter.measurement.connect(log.newMeasurement);
  487. emitter.measurement.connect(graph.newMeasurement);
  488. }
  489. start.clicked.connect(function() {
  490. start.enabled = false;
  491. hasTranslated = false;
  492. var epoch = new QTime();
  493. epoch = epoch.currentTime();
  494. for(var i = 0; i < offsets.length; i++)
  495. {
  496. offsets[i].setZeroTime(epoch);
  497. zeroemitters[i].emitZero();
  498. adapters[i].measurement.connect(log.newMeasurement);
  499. adapters[i].measurement.connect(graph.newMeasurement);
  500. }
  501. timer.startTimer();
  502. if(typeof(currentBatchInfo) == 'undefined') { } else {
  503. query = new QSqlQuery();
  504. query.exec("SELECT now()::timestamp without time zone");
  505. query.next();
  506. var result = query.value(0);
  507. query = query.invalidate();
  508. var timefield = findChildObject(currentBatchInfo, 'time');
  509. timefield.text = result.replace('T', ' ');
  510. }
  511. if(translationChannel >= 0)
  512. {
  513. offsets[translationChannel].measurement.connect(currentDetector.newMeasurement);
  514. }
  515. if(typeof(externtrans) != 'undefined') {
  516. externtrans.display(0);
  517. }
  518. stop.enabled = true;
  519. window.windowModified = true;
  520. });
  521. for(var i = 0; i < annotationButtons.length; i++) {
  522. if(channels.length > 0)
  523. {
  524. annotationButtons[i].annotation.connect(log.newAnnotation);
  525. annotationButtons[i].setTemperatureColumn(1);
  526. annotationButtons[i].setAnnotationColumn(channels.length + 1);
  527. annotationButtons[i].annotation.connect(function(note, tcol, ncol) {
  528. for(var i = tcol; i < ncol; i++) {
  529. log.newAnnotation(note, i, ncol);
  530. }
  531. });
  532. }
  533. }
  534. start.setFocus();
  535. stop.annotation.connect(log.newAnnotation);
  536. stop.clicked.connect(timer.stopTimer);
  537. stop.setTemperatureColumn(1);
  538. stop.setAnnotationColumn(channels.length + 1);
  539. QSettings.setValue("liveColumn", 1);
  540. var lc = 1;
  541. stop.clicked.connect(function() {
  542. stop.enabled = false;
  543. for(var i = 0; i < adapters.length; i++)
  544. {
  545. adapters[i].measurement.disconnect(log.newMeasurement);
  546. adapters[i].measurement.disconnect(graph.newMeasurement);
  547. }
  548. if(typeof(currentBatchInfo) == 'undefined') { } else {
  549. lc = Number(QSettings.value("liveColumn"));
  550. var duration = log.lastTime(lc);
  551. var durfield = findChildObject(currentBatchInfo, 'duration');
  552. durfield.text = duration;
  553. log.clearOutputColumns();
  554. for(var i = 0; i < channels.length; i++)
  555. {
  556. log.addOutputTemperatureColumn(lc + i);
  557. }
  558. log.addOutputAnnotationColumn(lc + channels.length);
  559. var filename = log.saveTemporary();
  560. currentBatchInfo.tempData = filename;
  561. currentBatchInfo.raise();
  562. currentBatchInfo.activateWindow();
  563. }
  564. if(translationChannel >= 0)
  565. {
  566. offsets[translationChannel].measurement.disconnect(currentDetector.newMeasurement);
  567. }
  568. start.enabled = true;
  569. window.windowModified = false;
  570. });
  571. stop.annotation.connect(function(note, tcol, ncol) {
  572. for(var i = tcol; i < ncol; i++) {
  573. log.newAnnotation(note, i, ncol);
  574. }
  575. });
  576. var quitMenu = findChildObject(this, 'quit');
  577. quitMenu.triggered.connect(function() {
  578. window.close();
  579. Application.quit();
  580. });
  581. var v1 = findChildObject(this, 'ms');
  582. v1.triggered.connect(log.LOD_ms);
  583. var v2 = findChildObject(this, '1s');
  584. v2.triggered.connect(log.LOD_1s);
  585. var v3 = findChildObject(this, '5s');
  586. v3.triggered.connect(log.LOD_5s);
  587. var v4 = findChildObject(this, '10s');
  588. v4.triggered.connect(log.LOD_10s);
  589. var v5 = findChildObject(this, '15s');
  590. v5.triggered.connect(log.LOD_15s);
  591. var v6 = findChildObject(this, '30s');
  592. v6.triggered.connect(log.LOD_30s);
  593. var v7 = findChildObject(this, '1m');
  594. v7.triggered.connect(log.LOD_1m);
  595. var showC = findChildObject(this, 'showC');
  596. showC.triggered.connect(function() {
  597. for(var i = 0; i < temperatureDisplays.length; i++)
  598. {
  599. temperatureDisplays[i].setDisplayUnits(Units.Celsius);
  600. }
  601. log.setDisplayUnits(Units.Celsius);
  602. graph.showC();
  603. });
  604. var showF = findChildObject(this, 'showF');
  605. showF.triggered.connect(function() {
  606. for(var i = 0; i < temperatureDisplays.length; i++)
  607. {
  608. temperatureDisplays[i].setDisplayUnits(Units.Fahrenheit);
  609. }
  610. log.setDisplayUnits(Units.Fahrenheit);
  611. graph.showF();
  612. });
  613. var clear = findChildObject(this, 'clear');
  614. clear.triggered.connect(log.clear);
  615. clear.triggered.connect(graph.clear);
  616. clear.triggered.connect(function() {
  617. window.windowTitle = "Typica";
  618. log.setHeaderData(0, "Time");
  619. QSettings.setValue("liveColumn", 1);
  620. window.postLoadColumnSetup(0);
  621. if(typeof(externtrans) != 'undefined') {
  622. externtrans.display(0);
  623. }
  624. });
  625. var openMenu = findChildObject(this, 'open');
  626. var compareMenu = findChildObject(this, 'compare');
  627. compareMenu.triggered.connect(function() {
  628. QSettings.setValue('cseries', lc+1);
  629. var history = createWindow("history");
  630. history.windowTitle = 'Typica - Roasting Log';
  631. });
  632. var printMenu = findChildObject(this, 'print');
  633. printMenu.triggered.connect(function() {
  634. var exportWindow = createWindow("print");
  635. exportWindow.windowTitle = "Typica - Print";
  636. exportWindow.log = log;
  637. });
  638. var svgExportMenu = findChildObject(this, 'svgexport');
  639. svgExportMenu.triggered.connect(function() {
  640. var exportWindow = createWindow("exportWindow");
  641. exportWindow.windowTitle = "Typica - Export XHTML+SVG";
  642. exportWindow.log = log;
  643. });
  644. openMenu.triggered.connect(function() {
  645. var filename = QFileDialog.getOpenFileName(window, 'Open Log…', QSettings.value('script/lastDir', '') + '/');
  646. if(filename != '') {
  647. var file = new QFile(filename);
  648. var input = new XMLInput(file, 1);
  649. targetseries = -1;
  650. input.newTemperatureColumn.connect(log.setHeaderData);
  651. input.newTemperatureColumn.connect(function(col, text) {
  652. if(text == window.targetcolumnname) {
  653. targetseries = col;
  654. }
  655. });
  656. input.newAnnotationColumn.connect(log.setHeaderData);
  657. input.measure.connect(graph.newMeasurement);
  658. input.measure.connect(log.newMeasurement);
  659. input.measure.connect(function(data, series) {
  660. if(series == targetseries) {
  661. targetDetector.newMeasurement(data);
  662. }
  663. });
  664. input.annotation.connect(log.newAnnotation);
  665. input.annotation.connect(function(note, tcol, ncol) {
  666. for(var i = tcol; i < ncol; i++) {
  667. log.newAnnotation(note, i, ncol);
  668. }
  669. });
  670. var lc;
  671. input.lastColumn.connect(function(c) {
  672. lc = c;
  673. QSettings.setValue("liveColumn", c + 1);
  674. window.postLoadColumnSetup(c);
  675. });
  676. input.input();
  677. window.windowTitle = 'Typica - ' + baseName(filename);
  678. QSettings.setValue("script/lastDir", dir(filename));
  679. log.newAnnotation("End", 1, lc);
  680. }
  681. });
  682. window.postLoadColumnSetup = function(c) {
  683. for(var i = 0; i < adapters.length; i++)
  684. {
  685. adapters[i].setColumn(c + i + 1);
  686. zeroemitters[i].setColumn(c + i + 1);
  687. log.setHeaderData(c + i + 1, columnNames[i]);
  688. }
  689. log.setHeaderData(c + columnNames.length + 1, "Note");
  690. stop.setTemperatureColumn(c + 1);
  691. stop.setAnnotationColumn(c + columnNames.length + 1);
  692. for(var i = 0; i < annotationButtons.length; i++)
  693. {
  694. annotationButtons[i].setTemperatureColumn(c + 1);
  695. annotationButtons[i].setAnnotationColumn(c + columnNames.length + 1);
  696. }
  697. log.clearCurrentColumnSet();
  698. for(var i = 0; i < channels.length; i++) {
  699. log.addToCurrentColumnSet(c + i + 1);
  700. }
  701. window.firstTempColumn = c + 1;
  702. window.annotationColumn = c + columnNames.length + 1;
  703. }
  704. var saveMenu = findChildObject(this, 'save');
  705. saveMenu.triggered.connect(function() {
  706. var filename = QFileDialog.getSaveFileName(window, "Save Log As…", QSettings.value("script/lastDir", "") + "/");
  707. if(filename != "") {
  708. var lc = Number(QSettings.value("liveColumn"));
  709. var file = new QFile(filename);
  710. log.clearOutputColumns();
  711. for(var i = 0; i < columnNames.length; i++)
  712. {
  713. log.addOutputTemperatureColumn(lc + i);
  714. }
  715. log.addOutputAnnotationColumn(lc + columnNames.length);
  716. log.saveXML(file);
  717. QSettings.setValue("script/lastDir", dir(filename));
  718. }
  719. });
  720. var exportMenu = findChildObject(this, 'export');
  721. exportMenu.triggered.connect(function() {
  722. var filename = QFileDialog.getSaveFileName(window, "Export CSV As…", QSettings.value("script/lastDir", "") + "/");
  723. if(filename != "") {
  724. var lc = Number(QSettings.value("liveColumn"));
  725. var file = new QFile(filename);
  726. log.clearOutputColumns();
  727. for(var i = 0; i < columnNames.length; i++)
  728. {
  729. log.addOutputTemperatureColumn(lc + i);
  730. }
  731. log.addOutputAnnotationColumn(lc + columnNames.length);
  732. log.saveCSV(file);
  733. QSettings.setValue("script/lastDir", dir(filename));
  734. }
  735. });
  736. var manual = findChildObject(this, 'manual');
  737. manual.triggered.connect(function() {
  738. var entry = new LogEditWindow();
  739. entry.show();
  740. });
  741. var newMenu = findChildObject(this, 'new');
  742. newMenu.triggered.connect(function() {
  743. var bwindow = createWindow("batchWindow");
  744. bwindow.windowTitle = "Typica - New Batch";
  745. });
  746. window.postLoadColumnSetup(0);
  747. ]]>
  748. </program>
  749. </window>