Typica is a free program for professional coffee roasters. https://typica.us
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

productionroaster.xml 27KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728
  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. externtrans = indicator;
  366. indicator.display(0);
  367. var decorator = new WidgetDecorator(indicator, configModel.data(driverIndex, 0), 2);
  368. indicatorPanel.addWidget(decorator);
  369. currentDetector.timeForValue.connect(function(value) {
  370. if(!hasTranslated)
  371. {
  372. var currentOffset = value;
  373. if(targetOffset != 0)
  374. {
  375. var translation = currentOffset - targetOffset;
  376. indicator.display(translation);
  377. gtrans = translation;
  378. if(translation > 0)
  379. {
  380. window.translateLoadedSeries(translation);
  381. }
  382. else
  383. {
  384. window.translateCurrentSeries(-translation);
  385. }
  386. }
  387. }
  388. hasTranslated = true;
  389. });
  390. var resetTranslation = findChildObject(this, 'unshift');
  391. resetTranslation.triggered.connect(function() {
  392. if(gtrans > 0) {
  393. window.translateLoadedSeries(-gtrans);
  394. }
  395. else {
  396. window.translateCurrentSeries(gtrans);
  397. }
  398. gtrans = 0;
  399. indicator.display(0);
  400. });
  401. }
  402. }
  403. targetDetector.setThreshold(driverReference.FValue);
  404. currentDetector.setThreshold(driverReference.FValue);
  405. }
  406. }
  407. }
  408. for(var i = 1; i < tabControls.length; i++)
  409. {
  410. setTabOrder(tabControls[i-1], tabControls[i]);
  411. }
  412. log.setHeaderData(0, "Time");
  413. for(var i = 0; i < columnNames.length; i++) {
  414. log.setHeaderData(i + 1, columnNames[i]);
  415. }
  416. log.setHeaderData(columnNames.length + 1, "Note");
  417. for(var i = 0; i < channels.length; i++) {
  418. log.addToCurrentColumnSet(i + 1);
  419. }
  420. var timer = new TimerDisplay;
  421. timer.displayFormat = "mm:ss";
  422. timer.autoReset = true;
  423. var btdecorator = new WidgetDecorator(timer, "Batch Timer", 2);
  424. indicatorPanel.addWidget(btdecorator);
  425. var vsplit = findChildObject(this, 'main');
  426. var isplit = findChildObject(this, 'indicators');
  427. var lsplit = findChildObject(this, 'logsplit');
  428. window.aboutToClose.connect(function() {
  429. for(var i = 0; i < nidevices.length; i++)
  430. {
  431. nidevices[i].stop();
  432. nidevices[i].deleteLater();
  433. }
  434. for(var i = 0; i < modbusdevices.length; i++)
  435. {
  436. modbusdevices[i].deleteLater();
  437. }
  438. delete nidevices;
  439. delete modbusdevices;
  440. window.saveSizeAndPosition("window");
  441. vsplit.saveState("script/mainSplitter");
  442. isplit.saveState("script/instrumentSplitter");
  443. lsplit.saveState("script/logSplitter");
  444. log.saveState("script/log", 7);
  445. window.navigationWindow.loggingWindow = undefined;
  446. });
  447. this.restoreSizeAndPosition('window');
  448. vsplit.restoreState("script/mainSplitter");
  449. isplit.restoreState("script/instrumentSplitter");
  450. lsplit.restoreState("script/logSplitter");
  451. log.restoreState("script/log", 7);
  452. var offsets = new Array();
  453. var zeroemitters = new Array();
  454. var adapters = new Array();
  455. for(var i = 0; i < channels.length; i++) {
  456. var offset = new MeasurementTimeOffset(epoch);
  457. offsets.push(offset);
  458. channels[i].newData.connect(offset.newMeasurement);
  459. var adapter = new MeasurementAdapter(i + 1);
  460. adapters.push(adapter);
  461. offset.measurement.connect(adapter.newMeasurement);
  462. var emitter = new ZeroEmitter(i + 1);
  463. zeroemitters.push(emitter);
  464. channels[i].newData.connect(emitter.newMeasurement);
  465. emitter.measurement.connect(log.newMeasurement);
  466. emitter.measurement.connect(graph.newMeasurement);
  467. }
  468. start.clicked.connect(function() {
  469. start.enabled = false;
  470. hasTranslated = false;
  471. var epoch = new QTime();
  472. epoch = epoch.currentTime();
  473. for(var i = 0; i < offsets.length; i++)
  474. {
  475. offsets[i].setZeroTime(epoch);
  476. zeroemitters[i].emitZero();
  477. adapters[i].measurement.connect(log.newMeasurement);
  478. adapters[i].measurement.connect(graph.newMeasurement);
  479. }
  480. timer.startTimer();
  481. if(typeof(currentBatchInfo) == 'undefined') { } else {
  482. query = new QSqlQuery();
  483. query.exec("SELECT now()::timestamp without time zone");
  484. query.next();
  485. var result = query.value(0);
  486. query = query.invalidate();
  487. var timefield = findChildObject(currentBatchInfo, 'time');
  488. timefield.text = result.replace('T', ' ');
  489. }
  490. if(translationChannel >= 0)
  491. {
  492. offsets[translationChannel].measurement.connect(currentDetector.newMeasurement);
  493. }
  494. if(typeof(externtrans) != 'undefined') {
  495. externtrans.display(0);
  496. }
  497. stop.enabled = true;
  498. window.windowModified = true;
  499. });
  500. for(var i = 0; i < annotationButtons.length; i++) {
  501. if(channels.length > 0)
  502. {
  503. annotationButtons[i].annotation.connect(log.newAnnotation);
  504. annotationButtons[i].setTemperatureColumn(1);
  505. annotationButtons[i].setAnnotationColumn(channels.length + 1);
  506. annotationButtons[i].annotation.connect(function(note, tcol, ncol) {
  507. for(var i = tcol; i < ncol; i++) {
  508. log.newAnnotation(note, i, ncol);
  509. }
  510. });
  511. }
  512. }
  513. start.setFocus();
  514. stop.annotation.connect(log.newAnnotation);
  515. stop.clicked.connect(timer.stopTimer);
  516. stop.setTemperatureColumn(1);
  517. stop.setAnnotationColumn(channels.length + 1);
  518. QSettings.setValue("liveColumn", 1);
  519. var lc = 1;
  520. stop.clicked.connect(function() {
  521. stop.enabled = false;
  522. for(var i = 0; i < adapters.length; i++)
  523. {
  524. adapters[i].measurement.disconnect(log.newMeasurement);
  525. adapters[i].measurement.disconnect(graph.newMeasurement);
  526. }
  527. if(typeof(currentBatchInfo) == 'undefined') { } else {
  528. lc = Number(QSettings.value("liveColumn"));
  529. var duration = log.lastTime(lc);
  530. var durfield = findChildObject(currentBatchInfo, 'duration');
  531. durfield.text = duration;
  532. log.clearOutputColumns();
  533. for(var i = 0; i < channels.length; i++)
  534. {
  535. log.addOutputTemperatureColumn(lc + i);
  536. }
  537. log.addOutputAnnotationColumn(lc + channels.length);
  538. var filename = log.saveTemporary();
  539. currentBatchInfo.tempData = filename;
  540. currentBatchInfo.raise();
  541. currentBatchInfo.activateWindow();
  542. }
  543. if(translationChannel >= 0)
  544. {
  545. offsets[translationChannel].measurement.disconnect(currentDetector.newMeasurement);
  546. }
  547. start.enabled = true;
  548. window.windowModified = false;
  549. });
  550. stop.annotation.connect(function(note, tcol, ncol) {
  551. for(var i = tcol; i < ncol; i++) {
  552. log.newAnnotation(note, i, ncol);
  553. }
  554. });
  555. var quitMenu = findChildObject(this, 'quit');
  556. quitMenu.triggered.connect(function() {
  557. window.close();
  558. Application.quit();
  559. });
  560. var v1 = findChildObject(this, 'ms');
  561. v1.triggered.connect(log.LOD_ms);
  562. var v2 = findChildObject(this, '1s');
  563. v2.triggered.connect(log.LOD_1s);
  564. var v3 = findChildObject(this, '5s');
  565. v3.triggered.connect(log.LOD_5s);
  566. var v4 = findChildObject(this, '10s');
  567. v4.triggered.connect(log.LOD_10s);
  568. var v5 = findChildObject(this, '15s');
  569. v5.triggered.connect(log.LOD_15s);
  570. var v6 = findChildObject(this, '30s');
  571. v6.triggered.connect(log.LOD_30s);
  572. var v7 = findChildObject(this, '1m');
  573. v7.triggered.connect(log.LOD_1m);
  574. var showC = findChildObject(this, 'showC');
  575. showC.triggered.connect(function() {
  576. for(var i = 0; i < temperatureDisplays.length; i++)
  577. {
  578. temperatureDisplays[i].setDisplayUnits(TemperatureDisplay.Celsius);
  579. }
  580. log.setDisplayUnits(TemperatureDisplay.Celsius);
  581. graph.showC();
  582. });
  583. var showF = findChildObject(this, 'showF');
  584. showF.triggered.connect(function() {
  585. for(var i = 0; i < temperatureDisplays.length; i++)
  586. {
  587. temperatureDisplays[i].setDisplayUnits(TemperatureDisplay.Fahrenheit);
  588. }
  589. log.setDisplayUnits(TemperatureDisplay.Fahrenheit);
  590. graph.showF();
  591. });
  592. var clear = findChildObject(this, 'clear');
  593. clear.triggered.connect(log.clear);
  594. clear.triggered.connect(graph.clear);
  595. clear.triggered.connect(function() {
  596. window.windowTitle = "Typica";
  597. log.setHeaderData(0, "Time");
  598. QSettings.setValue("liveColumn", 1);
  599. window.postLoadColumnSetup(0);
  600. if(typeof(externtrans) != 'undefined') {
  601. externtrans.display(0);
  602. }
  603. });
  604. var openMenu = findChildObject(this, 'open');
  605. var compareMenu = findChildObject(this, 'compare');
  606. compareMenu.triggered.connect(function() {
  607. QSettings.setValue('cseries', lc+1);
  608. var history = createWindow("history");
  609. history.windowTitle = 'Typica - Roasting Log';
  610. });
  611. var printMenu = findChildObject(this, 'print');
  612. printMenu.triggered.connect(function() {
  613. var exportWindow = createWindow("print");
  614. exportWindow.windowTitle = "Typica - Print";
  615. exportWindow.log = log;
  616. });
  617. var svgExportMenu = findChildObject(this, 'svgexport');
  618. svgExportMenu.triggered.connect(function() {
  619. var exportWindow = createWindow("exportWindow");
  620. exportWindow.windowTitle = "Typica - Export XHTML+SVG";
  621. exportWindow.log = log;
  622. });
  623. openMenu.triggered.connect(function() {
  624. var filename = QFileDialog.getOpenFileName(window, 'Open Log…', QSettings.value('script/lastDir', '') + '/');
  625. if(filename != '') {
  626. var file = new QFile(filename);
  627. var input = new XMLInput(file, 1);
  628. targetseries = -1;
  629. input.newTemperatureColumn.connect(log.setHeaderData);
  630. input.newTemperatureColumn.connect(function(col, text) {
  631. if(text == window.targetcolumnname) {
  632. targetseries = col;
  633. }
  634. });
  635. input.newAnnotationColumn.connect(log.setHeaderData);
  636. input.measure.connect(graph.newMeasurement);
  637. input.measure.connect(log.newMeasurement);
  638. input.measure.connect(function(data, series) {
  639. if(series == targetseries) {
  640. targetDetector.newMeasurement(data);
  641. }
  642. });
  643. input.annotation.connect(log.newAnnotation);
  644. input.annotation.connect(function(note, tcol, ncol) {
  645. for(var i = tcol; i < ncol; i++) {
  646. log.newAnnotation(note, i, ncol);
  647. }
  648. });
  649. var lc;
  650. input.lastColumn.connect(function(c) {
  651. lc = c;
  652. QSettings.setValue("liveColumn", c + 1);
  653. window.postLoadColumnSetup(c);
  654. });
  655. input.input();
  656. window.windowTitle = 'Typica - ' + baseName(filename);
  657. QSettings.setValue("script/lastDir", dir(filename));
  658. log.newAnnotation("End", 1, lc);
  659. }
  660. });
  661. window.postLoadColumnSetup = function(c) {
  662. for(var i = 0; i < adapters.length; i++)
  663. {
  664. adapters[i].setColumn(c + i + 1);
  665. zeroemitters[i].setColumn(c + i + 1);
  666. log.setHeaderData(c + i + 1, columnNames[i]);
  667. }
  668. log.setHeaderData(c + columnNames.length + 1, "Note");
  669. stop.setTemperatureColumn(c + 1);
  670. stop.setAnnotationColumn(c + columnNames.length + 1);
  671. for(var i = 0; i < annotationButtons.length; i++)
  672. {
  673. annotationButtons[i].setTemperatureColumn(c + 1);
  674. annotationButtons[i].setAnnotationColumn(c + columnNames.length + 1);
  675. }
  676. log.clearCurrentColumnSet();
  677. for(var i = 0; i < channels.length; i++) {
  678. log.addToCurrentColumnSet(c + i + 1);
  679. }
  680. window.firstTempColumn = c + 1;
  681. window.annotationColumn = c + columnNames.length + 1;
  682. }
  683. var saveMenu = findChildObject(this, 'save');
  684. saveMenu.triggered.connect(function() {
  685. var filename = QFileDialog.getSaveFileName(window, "Save Log As…", QSettings.value("script/lastDir", "") + "/");
  686. if(filename != "") {
  687. var lc = Number(QSettings.value("liveColumn"));
  688. var file = new QFile(filename);
  689. log.clearOutputColumns();
  690. for(var i = 0; i < columnNames.length; i++)
  691. {
  692. log.addOutputTemperatureColumn(lc + i);
  693. }
  694. log.addOutputAnnotationColumn(lc + columnNames.length);
  695. log.saveXML(file);
  696. QSettings.setValue("script/lastDir", dir(filename));
  697. }
  698. });
  699. var exportMenu = findChildObject(this, 'export');
  700. exportMenu.triggered.connect(function() {
  701. var filename = QFileDialog.getSaveFileName(window, "Export CSV As…", QSettings.value("script/lastDir", "") + "/");
  702. if(filename != "") {
  703. var lc = Number(QSettings.value("liveColumn"));
  704. var file = new QFile(filename);
  705. log.clearOutputColumns();
  706. for(var i = 0; i < columnNames.length; i++)
  707. {
  708. log.addOutputTemperatureColumn(lc + i);
  709. }
  710. log.addOutputAnnotationColumn(lc + columnNames.length);
  711. log.saveCSV(file);
  712. QSettings.setValue("script/lastDir", dir(filename));
  713. }
  714. });
  715. var manual = findChildObject(this, 'manual');
  716. manual.triggered.connect(function() {
  717. var entry = new LogEditWindow();
  718. entry.show();
  719. });
  720. var newMenu = findChildObject(this, 'new');
  721. newMenu.triggered.connect(function() {
  722. var bwindow = createWindow("batchWindow");
  723. bwindow.windowTitle = "Typica - New Batch";
  724. });
  725. window.postLoadColumnSetup(0);
  726. ]]>
  727. </program>
  728. </window>