Typica is a free program for professional coffee roasters. https://typica.us
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

productionroaster.xml 26KB

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