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

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