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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726
  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. });
  499. for(var i = 0; i < annotationButtons.length; i++) {
  500. if(channels.length > 0)
  501. {
  502. annotationButtons[i].annotation.connect(log.newAnnotation);
  503. annotationButtons[i].setTemperatureColumn(1);
  504. annotationButtons[i].setAnnotationColumn(channels.length + 1);
  505. annotationButtons[i].annotation.connect(function(note, tcol, ncol) {
  506. for(var i = tcol; i < ncol; i++) {
  507. log.newAnnotation(note, i, ncol);
  508. }
  509. });
  510. }
  511. }
  512. start.setFocus();
  513. stop.annotation.connect(log.newAnnotation);
  514. stop.clicked.connect(timer.stopTimer);
  515. stop.setTemperatureColumn(1);
  516. stop.setAnnotationColumn(channels.length + 1);
  517. QSettings.setValue("liveColumn", 1);
  518. var lc = 1;
  519. stop.clicked.connect(function() {
  520. stop.enabled = false;
  521. for(var i = 0; i < adapters.length; i++)
  522. {
  523. adapters[i].measurement.disconnect(log.newMeasurement);
  524. adapters[i].measurement.disconnect(graph.newMeasurement);
  525. }
  526. if(typeof(currentBatchInfo) == 'undefined') { } else {
  527. lc = Number(QSettings.value("liveColumn"));
  528. var duration = log.lastTime(lc);
  529. var durfield = findChildObject(currentBatchInfo, 'duration');
  530. durfield.text = duration;
  531. log.clearOutputColumns();
  532. for(var i = 0; i < channels.length; i++)
  533. {
  534. log.addOutputTemperatureColumn(lc + i);
  535. }
  536. log.addOutputAnnotationColumn(lc + channels.length);
  537. var filename = log.saveTemporary();
  538. currentBatchInfo.tempData = filename;
  539. currentBatchInfo.raise();
  540. currentBatchInfo.activateWindow();
  541. }
  542. if(translationChannel >= 0)
  543. {
  544. offsets[translationChannel].measurement.disconnect(currentDetector.newMeasurement);
  545. }
  546. start.enabled = true;
  547. });
  548. stop.annotation.connect(function(note, tcol, ncol) {
  549. for(var i = tcol; i < ncol; i++) {
  550. log.newAnnotation(note, i, ncol);
  551. }
  552. });
  553. var quitMenu = findChildObject(this, 'quit');
  554. quitMenu.triggered.connect(function() {
  555. window.close();
  556. Application.quit();
  557. });
  558. var v1 = findChildObject(this, 'ms');
  559. v1.triggered.connect(log.LOD_ms);
  560. var v2 = findChildObject(this, '1s');
  561. v2.triggered.connect(log.LOD_1s);
  562. var v3 = findChildObject(this, '5s');
  563. v3.triggered.connect(log.LOD_5s);
  564. var v4 = findChildObject(this, '10s');
  565. v4.triggered.connect(log.LOD_10s);
  566. var v5 = findChildObject(this, '15s');
  567. v5.triggered.connect(log.LOD_15s);
  568. var v6 = findChildObject(this, '30s');
  569. v6.triggered.connect(log.LOD_30s);
  570. var v7 = findChildObject(this, '1m');
  571. v7.triggered.connect(log.LOD_1m);
  572. var showC = findChildObject(this, 'showC');
  573. showC.triggered.connect(function() {
  574. for(var i = 0; i < temperatureDisplays.length; i++)
  575. {
  576. temperatureDisplays[i].setDisplayUnits(TemperatureDisplay.Celsius);
  577. }
  578. log.setDisplayUnits(TemperatureDisplay.Celsius);
  579. graph.showC();
  580. });
  581. var showF = findChildObject(this, 'showF');
  582. showF.triggered.connect(function() {
  583. for(var i = 0; i < temperatureDisplays.length; i++)
  584. {
  585. temperatureDisplays[i].setDisplayUnits(TemperatureDisplay.Fahrenheit);
  586. }
  587. log.setDisplayUnits(TemperatureDisplay.Fahrenheit);
  588. graph.showF();
  589. });
  590. var clear = findChildObject(this, 'clear');
  591. clear.triggered.connect(log.clear);
  592. clear.triggered.connect(graph.clear);
  593. clear.triggered.connect(function() {
  594. window.windowTitle = "Typica";
  595. log.setHeaderData(0, "Time");
  596. QSettings.setValue("liveColumn", 1);
  597. window.postLoadColumnSetup(0);
  598. if(typeof(externtrans) != 'undefined') {
  599. externtrans.display(0);
  600. }
  601. });
  602. var openMenu = findChildObject(this, 'open');
  603. var compareMenu = findChildObject(this, 'compare');
  604. compareMenu.triggered.connect(function() {
  605. QSettings.setValue('cseries', lc+1);
  606. var history = createWindow("history");
  607. history.windowTitle = 'Typica - Roasting Log';
  608. });
  609. var printMenu = findChildObject(this, 'print');
  610. printMenu.triggered.connect(function() {
  611. var exportWindow = createWindow("print");
  612. exportWindow.windowTitle = "Typica - Print";
  613. exportWindow.log = log;
  614. });
  615. var svgExportMenu = findChildObject(this, 'svgexport');
  616. svgExportMenu.triggered.connect(function() {
  617. var exportWindow = createWindow("exportWindow");
  618. exportWindow.windowTitle = "Typica - Export XHTML+SVG";
  619. exportWindow.log = log;
  620. });
  621. openMenu.triggered.connect(function() {
  622. var filename = QFileDialog.getOpenFileName(window, 'Open Log…', QSettings.value('script/lastDir', '') + '/');
  623. if(filename != '') {
  624. var file = new QFile(filename);
  625. var input = new XMLInput(file, 1);
  626. targetseries = -1;
  627. input.newTemperatureColumn.connect(log.setHeaderData);
  628. input.newTemperatureColumn.connect(function(col, text) {
  629. if(text == window.targetcolumnname) {
  630. targetseries = col;
  631. }
  632. });
  633. input.newAnnotationColumn.connect(log.setHeaderData);
  634. input.measure.connect(graph.newMeasurement);
  635. input.measure.connect(log.newMeasurement);
  636. input.measure.connect(function(data, series) {
  637. if(series == targetseries) {
  638. targetDetector.newMeasurement(data);
  639. }
  640. });
  641. input.annotation.connect(log.newAnnotation);
  642. input.annotation.connect(function(note, tcol, ncol) {
  643. for(var i = tcol; i < ncol; i++) {
  644. log.newAnnotation(note, i, ncol);
  645. }
  646. });
  647. var lc;
  648. input.lastColumn.connect(function(c) {
  649. lc = c;
  650. QSettings.setValue("liveColumn", c + 1);
  651. window.postLoadColumnSetup(c);
  652. });
  653. input.input();
  654. window.windowTitle = 'Typica - ' + baseName(filename);
  655. QSettings.setValue("script/lastDir", dir(filename));
  656. log.newAnnotation("End", 1, lc);
  657. }
  658. });
  659. window.postLoadColumnSetup = function(c) {
  660. for(var i = 0; i < adapters.length; i++)
  661. {
  662. adapters[i].setColumn(c + i + 1);
  663. zeroemitters[i].setColumn(c + i + 1);
  664. log.setHeaderData(c + i + 1, columnNames[i]);
  665. }
  666. log.setHeaderData(c + columnNames.length + 1, "Note");
  667. stop.setTemperatureColumn(c + 1);
  668. stop.setAnnotationColumn(c + columnNames.length + 1);
  669. for(var i = 0; i < annotationButtons.length; i++)
  670. {
  671. annotationButtons[i].setTemperatureColumn(c + 1);
  672. annotationButtons[i].setAnnotationColumn(c + columnNames.length + 1);
  673. }
  674. log.clearCurrentColumnSet();
  675. for(var i = 0; i < channels.length; i++) {
  676. log.addToCurrentColumnSet(c + i + 1);
  677. }
  678. window.firstTempColumn = c + 1;
  679. window.annotationColumn = c + columnNames.length + 1;
  680. }
  681. var saveMenu = findChildObject(this, 'save');
  682. saveMenu.triggered.connect(function() {
  683. var filename = QFileDialog.getSaveFileName(window, "Save Log As…", QSettings.value("script/lastDir", "") + "/");
  684. if(filename != "") {
  685. var lc = Number(QSettings.value("liveColumn"));
  686. var file = new QFile(filename);
  687. log.clearOutputColumns();
  688. for(var i = 0; i < columnNames.length; i++)
  689. {
  690. log.addOutputTemperatureColumn(lc + i);
  691. }
  692. log.addOutputAnnotationColumn(lc + columnNames.length);
  693. log.saveXML(file);
  694. QSettings.setValue("script/lastDir", dir(filename));
  695. }
  696. });
  697. var exportMenu = findChildObject(this, 'export');
  698. exportMenu.triggered.connect(function() {
  699. var filename = QFileDialog.getSaveFileName(window, "Export CSV As…", QSettings.value("script/lastDir", "") + "/");
  700. if(filename != "") {
  701. var lc = Number(QSettings.value("liveColumn"));
  702. var file = new QFile(filename);
  703. log.clearOutputColumns();
  704. for(var i = 0; i < columnNames.length; i++)
  705. {
  706. log.addOutputTemperatureColumn(lc + i);
  707. }
  708. log.addOutputAnnotationColumn(lc + columnNames.length);
  709. log.saveCSV(file);
  710. QSettings.setValue("script/lastDir", dir(filename));
  711. }
  712. });
  713. var manual = findChildObject(this, 'manual');
  714. manual.triggered.connect(function() {
  715. var entry = new LogEditWindow();
  716. entry.show();
  717. });
  718. var newMenu = findChildObject(this, 'new');
  719. newMenu.triggered.connect(function() {
  720. var bwindow = createWindow("batchWindow");
  721. bwindow.windowTitle = "Typica - New Batch";
  722. });
  723. window.postLoadColumnSetup(0);
  724. ]]>
  725. </program>
  726. </window>