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 29KB

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