Typica is a free program for professional coffee roasters. https://typica.us
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

productionroaster.xml 29KB

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