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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203
  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="newsample">New Sample Batch…</item>
  28. <item id="compare">Load Additional Profiles...</item>
  29. </menu>
  30. <menu name="Log">
  31. <item id="showC">Display Celsius</item>
  32. <item id="showF">Display Fahrenheit</item>
  33. <item id="setSample">New Sample Parameters</item>
  34. <separator />
  35. <item id="clear" shortcut="Ctrl+L">Clear Log</item>
  36. <separator />
  37. <item id="ms">Millisecond View</item>
  38. <item id="1s">1 Second View</item>
  39. <item id="5s">5 Second View</item>
  40. <item id="10s">10 Second View</item>
  41. <item id="15s">15 Second View</item>
  42. <item id="30s">30 Second View</item>
  43. <item id="1m">1 Minute View</item>
  44. <separator />
  45. <item id="manual" shortcut="Ctrl+E">Manual Entry</item>
  46. </menu>
  47. <menu name="Graph">
  48. <item id="unshift">Reset Translation</item>
  49. </menu>
  50. <program>
  51. <![CDATA[
  52. var window = this;
  53. var targetOffset = 0;
  54. var gtrans = 0;
  55. var targetDetector = new ThresholdDetector;
  56. window.targetcolumnname = "";
  57. var currentDetector = new ThresholdDetector;
  58. var translationChannel = -1;
  59. targetDetector.timeForValue.connect(function(value) {
  60. targetOffset = value;
  61. });
  62. var epoch = new QTime;
  63. epoch = epoch.currentTime;
  64. var translationCurrentColumn = -1;
  65. var configModel = new DeviceTreeModel;
  66. var rootIndex = configModel.index(roasterlist.currentIndex, 0);
  67. var roasterIndex = roasterlist.currentIndex;
  68. var channels = new Array();
  69. var annotationButtons = new Array();
  70. var rangetimers = new Array();
  71. var nidevices = new Array();
  72. var dataqsdkdevices = new Array();
  73. var jsdevices = new Array();
  74. var pdevices = new Array();
  75. var temperatureDisplays = new Array();
  76. var columnNames = new Array();
  77. var modbusdevices = new Array();
  78. var rateCalculators = new Array();
  79. var rateadapters = new Array();
  80. var rateoffsets = new Array();
  81. var ratezeros = new Array();
  82. var channelType = new Array();
  83. window.scales = new Array();
  84. var channelVisibility = new Array();
  85. var indicatorPanel = findChildObject(this, 'indicators');
  86. var annotationPanel = findChildObject(this, 'controlpanel');
  87. var log = findChildObject(this, 'log');
  88. var tabControls = new Array();
  89. var start = findChildObject(this, 'startbutton');
  90. var stop = findChildObject(this, 'stopbutton');
  91. stop.enabled = false;
  92. tabControls.push(start);
  93. tabControls.push(stop);
  94. var nsparam = findChildObject(this, 'setSample');
  95. nsparam.enabled = false;
  96. var graph = findChildObject(this, 'graph');
  97. var hasTranslated = false;
  98. var externtrans = undefined;
  99. window.translateLoadedSeries = function(translation) {
  100. var lc = Number(QSettings.value("liveColumn"));
  101. for(var i = 1; i < lc - 1; i++)
  102. {
  103. graph.setSeriesTranslation(i, translation);
  104. }
  105. };
  106. window.translateCurrentSeries = function(translation) {
  107. var lc = Number(QSettings.value("liveColumn"));
  108. for(var i = 0; i < columnNames.length; i++)
  109. {
  110. graph.setSeriesTranslation(lc + i, translation);
  111. }
  112. };
  113. var selectedRoasterName = configModel.data(rootIndex, 0);
  114. var machineReference = configModel.referenceElement(configModel.data(rootIndex, 32));
  115. var selectedRoasterID = machineReference.databaseid;
  116. var checkCapacity = machineReference.checkcapacity;
  117. var maxCapacity = machineReference.capacity;
  118. var capacityUnit = machineReference.capacityunit;
  119. var poundsCapacity;
  120. var convertToPounds = function(w, u) {
  121. switch(u) {
  122. case "g":
  123. return w * 0.0022;
  124. case "oz":
  125. return w * 0.0625;
  126. case "Kg":
  127. return w * 2.2;
  128. }
  129. return w;
  130. };
  131. if(checkCapacity == "true") {
  132. poundsCapacity = convertToPounds(maxCapacity, capacityUnit);
  133. }
  134. if(configModel.hasChildren(rootIndex)) {
  135. for(var i = 0; i < configModel.rowCount(rootIndex); i++) {
  136. var driverIndex = configModel.index(i, 0, rootIndex);
  137. var driverReference = configModel.referenceElement(configModel.data(driverIndex, 32));
  138. if(driverReference.driver == "nidaqmxbase" || driverReference.driver == "nidaqmx") {
  139. if(configModel.hasChildren(driverIndex)) {
  140. for(var j = 0; j < configModel.rowCount(driverIndex); j++) {
  141. var deviceIndex = configModel.index(j, 0, driverIndex);
  142. var deviceReference = configModel.referenceElement(configModel.data(deviceIndex, 32));
  143. if(deviceReference.driver == "nidaqmxbase9211series" || deviceReference.driver == "nidaqmx9211series") {
  144. var device = new DAQ(deviceReference.deviceID, driverReference.driver);
  145. nidevices.push(device);
  146. var DAQChannels = 0;
  147. if(configModel.hasChildren(deviceIndex)) {
  148. for(var k = 0; k < configModel.rowCount(deviceIndex); k++) {
  149. var channelIndex = configModel.index(k, 0, deviceIndex);
  150. var channelReference = configModel.referenceElement(configModel.data(channelIndex, 32));
  151. if(channelReference.driver == "ni9211seriestc") {
  152. var channel;
  153. if(channelReference.type == "J") {
  154. channel = device.newChannel(DAQ.Fahrenheit, DAQ.TypeJ);
  155. }
  156. else if(channelReference.type == "K") {
  157. channel = device.newChannel(DAQ.Fahrenheit, DAQ.TypeK);
  158. }
  159. else if(channelReference.type == "T") {
  160. channel = device.newChannel(DAQ.Fahrenheit, DAQ.TypeT);
  161. }
  162. else if(channelReference.type == "B") {
  163. channel = device.newChannel(DAQ.Fahrenheit, DAQ.TypeB);
  164. }
  165. else if(channelReference.type == "E") {
  166. channel = device.newChannel(DAQ.Fahrenheit, DAQ.TypeE);
  167. }
  168. else if(channelReference.type == "N") {
  169. channel = device.newChannel(DAQ.Fahrenheit, DAQ.TypeN);
  170. }
  171. else if(channelReference.type == "R") {
  172. channel = device.newChannel(DAQ.Fahrenheit, DAQ.TypeR);
  173. }
  174. else if(channelReference.type == "S") {
  175. channel = device.newChannel(DAQ.Fahrenheit, DAQ.TypeS);
  176. }
  177. channels.push(channel);
  178. channelType.push("T");
  179. columnNames.push(channelReference.columnname);
  180. DAQChannels++;
  181. if(channelReference.hidden == "true") {
  182. channelVisibility.push(false);
  183. } else {
  184. channelVisibility.push(true);
  185. var indicator = new TemperatureDisplay;
  186. temperatureDisplays.push(indicator);
  187. var decorator = new WidgetDecorator(indicator, configModel.data(channelIndex, 0), 2);
  188. channel.newData.connect(indicator.setValue);
  189. indicatorPanel.addWidget(decorator);
  190. }
  191. }
  192. }
  193. switch(DAQChannels) {
  194. case 1:
  195. device.setClockRate(4);
  196. break;
  197. case 2:
  198. device.setClockRate(2);
  199. break;
  200. case 3:
  201. device.setClockRate(1.5);
  202. break;
  203. case 4:
  204. device.setClockRate(1);
  205. break;
  206. }
  207. device.start();
  208. }
  209. }
  210. else if(deviceReference.driver == "nidaqmxtc01")
  211. {
  212. var device = new DAQ(deviceReference.deviceID, "nidaqmx");
  213. var channel;
  214. if(deviceReference.type == "J")
  215. {
  216. channel = device.newChannel(DAQ.Fahrenheit, DAQ.TypeJ);
  217. }
  218. else if(deviceReference.type == "K")
  219. {
  220. channel = device.newChannel(DAQ.Fahrenheit, DAQ.TypeK);
  221. }
  222. else if(deviceReference.type == "T")
  223. {
  224. channel = device.newChannel(DAQ.Fahrenheit, DAQ.TypeT);
  225. }
  226. else if(deviceReference.type == "B")
  227. {
  228. channel = device.newChannel(DAQ.Fahrenheit, DAQ.TypeB);
  229. }
  230. else if(deviceReference.type == "E")
  231. {
  232. channel = device.newChannel(DAQ.Fahrenheit, DAQ.TypeE);
  233. }
  234. else if(deviceReference.type == "N")
  235. {
  236. channel = device.newChannel(DAQ.Fahrenheit, DAQ.TypeN);
  237. }
  238. else if(deviceReference.type == "R")
  239. {
  240. channel = device.newChannel(DAQ.Fahrenheit, DAQ.TypeR);
  241. }
  242. else if(deviceReference.type == "S")
  243. {
  244. channel = device.newChannel(DAQ.Fahrenheit, DAQ.TypeS);
  245. }
  246. channels.push(channel);
  247. channelType.push("T");
  248. columnNames.push(deviceReference.columnname);
  249. if(deviceReference.hidden == "true") {
  250. channelVisibility.push(false);
  251. } else {
  252. channelVisibility.push(true);
  253. var indicator = new TemperatureDisplay;
  254. temperatureDisplays.push(indicator);
  255. var decorator = new WidgetDecorator(indicator, configModel.data(deviceIndex, 0), 2);
  256. channel.newData.connect(indicator.setValue);
  257. indicatorPanel.addWidget(decorator);
  258. }
  259. device.start();
  260. nidevices.push(device);
  261. }
  262. }
  263. }
  264. }
  265. else if(driverReference.driver == "dataqsdk") {
  266. var device;
  267. if(driverReference.autoSelect == "true") {
  268. device = new DataqSdkDevice(driverReference.deviceNumber);
  269. }
  270. else {
  271. device = new DataqSdkDevice(driverReference.port);
  272. }
  273. var sampleRate = 6;
  274. if(configModel.hasChildren(driverIndex)) {
  275. for(var j = 0; j < configModel.rowCount(driverIndex); j++) {
  276. var channelIndex = configModel.index(j, 0, driverIndex);
  277. var channelReference = configModel.referenceElement(configModel.data(channelIndex, 32));
  278. var indicator = new TemperatureDisplay;
  279. var unit;
  280. if(channelReference.type == "Temperature") {
  281. unit = Units.Fahrenheit;
  282. channelType.push("T");
  283. temperatureDisplays.push(indicator);
  284. }
  285. else {
  286. unit = Units.Unitless;
  287. indicator.setDisplayUnits(Units.Unitless);
  288. channelType.push("C");
  289. indicator.digitCount = 6;
  290. }
  291. var channel = device.newChannel(unit);
  292. var calibrator = new LinearCalibrator;
  293. calibrator.measuredLower = channelReference.calibrationMeasuredLower;
  294. calibrator.measuredUpper = channelReference.calibrationMeasuredUpper;
  295. calibrator.mappedLower = channelReference.calibrationMappedLower;
  296. calibrator.mappedUpper = channelReference.calibrationMappedUpper;
  297. calibrator.sensitivity = channelReference.calibrationSensitivity;
  298. if(channelReference.calibrationClosedInterval == 'true') {
  299. calibrator.closedRange = true;
  300. }
  301. // device.setSmoothingEnabled(j) = channelReference.smoothing;
  302. channel.newData.connect(calibrator.newMeasurement)
  303. channels.push(calibrator);
  304. columnNames.push(channelReference.column);
  305. if(channelReference.hidden == "true") {
  306. channelVisibility.push(false);
  307. } else {
  308. channelVisibility.push(true);
  309. var decorator = new WidgetDecorator(indicator, configModel.data(channelIndex, 0), 2);
  310. calibrator.newData.connect(indicator.setValue);
  311. indicatorPanel.addWidget(decorator);
  312. }
  313. }
  314. sampleRate /= configModel.rowCount(driverIndex);
  315. }
  316. device.setClockRate(sampleRate);
  317. device.start();
  318. dataqsdkdevices.push(device);
  319. }
  320. else if(driverReference.driver == "modbusrtu")
  321. {
  322. var device = new ModbusRTUDevice(configModel, driverIndex);
  323. modbusdevices.push(device);
  324. var pvchannel = device.pVChannel();
  325. channels.push(pvchannel);
  326. channelType.push("T");
  327. columnNames.push(driverReference.pvcolname);
  328. if(driverReference.pvhidden == "true") {
  329. channelVisibility.push(false);
  330. } else {
  331. channelVisibility.push(true);
  332. var indicator = new TemperatureDisplay;
  333. temperatureDisplays.push(indicator);
  334. var decorator = new WidgetDecorator(indicator, configModel.data(driverIndex, 0) + " PV", 2);
  335. pvchannel.newData.connect(indicator.setValue);
  336. indicatorPanel.addWidget(decorator);
  337. }
  338. if(driverReference.sVEnabled == "true")
  339. {
  340. var svchannel = device.sVChannel();
  341. channels.push(svchannel);
  342. channelType.push("C");
  343. columnNames.push(driverReference.svcolname);
  344. if(driverReference.svhidden == "true") {
  345. channelVisibility.push(false);
  346. } else {
  347. channelVisibility.push(true);
  348. var indicator = new TemperatureDisplay;
  349. temperatureDisplays.push(indicator);
  350. var decorator = new WidgetDecorator(indicator, configModel.data(driverIndex, 0) + " SV", 2);
  351. svchannel.newData.connect(indicator.setValue);
  352. indicatorPanel.addWidget(decorator);
  353. }
  354. }
  355. if(driverReference.sVWritable == "true")
  356. {
  357. var outputControl = new AnnotationSpinBox;
  358. device.SVLowerChanged.connect(function(min) {
  359. outputControl.minimum = min;
  360. });
  361. outputControl.minimum = device.SVLower();
  362. device.SVUpperChanged.connect(function(max) {
  363. outputControl.maximum = max;
  364. });
  365. outputControl.maximum = device.SVUpper();
  366. device.SVDecimalChanged.connect(function(prec) {
  367. outputControl.decimals = prec;
  368. });
  369. outputControl.decimals = device.decimals();
  370. outputControl.editingFinished.connect(function() {
  371. device.outputSV(outputControl.value);
  372. });
  373. var layout = new QBoxLayout;
  374. var label = new QLabel("Change SV");
  375. layout.addWidget(label, 0, 2);
  376. layout.addWidget(outputControl, 0, 1);
  377. annotationPanel.addLayout(layout);
  378. tabControls.push(outputControl);
  379. }
  380. }
  381. else if(driverReference.driver == "unsupporteddevice")
  382. {
  383. var device = createDevice(driverIndex);
  384. for(var j = 0; j < device.channelCount(); j++) {
  385. channels.push(device.getChannel(j));
  386. columnNames.push(device.channelColumnName(j));
  387. var unit = device.expectedChannelUnit(j);
  388. if(unit == Units.Fahrenheit) {
  389. channelType.push("T");
  390. } else {
  391. channelType.push("C");
  392. }
  393. if(device.isChannelHidden(j)) {
  394. channelVisibility.push(false);
  395. } else {
  396. channelVisibility.push(true);
  397. var indicator = new TemperatureDisplay;
  398. if(unit == Units.Unitless) {
  399. indicator.setDisplayUnits(Units.Unitless);
  400. indicator.digitCount = 6;
  401. }
  402. temperatureDisplays.push(indicator);
  403. var decorator = new WidgetDecorator(indicator, device.channelIndicatorText(j), 2);
  404. device.getChannel(j).newData.connect(indicator.setValue);
  405. indicatorPanel.addWidget(decorator);
  406. }
  407. }
  408. device.start();
  409. jsdevices.push(device);
  410. }
  411. else if(driverReference.driver == "phidgets1048")
  412. {
  413. var device = new PhidgetsTemperatureSensor(driverIndex);
  414. for(var j = 0; j < device.channelCount(); j++) {
  415. channels.push(device.getChannel(j));
  416. columnNames.push(device.channelColumnName(j));
  417. channelType.push("T");
  418. if(device.isChannelHidden(j)) {
  419. channelVisibility.push(false);
  420. } else {
  421. channelVisibility.push(true);
  422. var indicator = new TemperatureDisplay;
  423. temperatureDisplays.push(indicator);
  424. var decorator = new WidgetDecorator(indicator, device.channelIndicatorText(j), 2);
  425. device.getChannel(j).newData.connect(indicator.setValue);
  426. indicatorPanel.addWidget(decorator);
  427. }
  428. }
  429. device.start();
  430. pdevices.push(device);
  431. }
  432. else if(driverReference.driver == "annotationbutton")
  433. {
  434. var button = new AnnotationButton(driverReference.buttontext);
  435. button.setAnnotation(driverReference.annotationtext);
  436. annotationButtons.push(button);
  437. annotationPanel.addWidget(button);
  438. tabControls.push(button);
  439. }
  440. else if(driverReference.driver == "valueannotation")
  441. {
  442. var checker = new ValueAnnotation;
  443. var valuesSetting = driverReference.measuredValues;
  444. var notesSetting = driverReference.annotations;
  445. var valuesList = valuesSetting.slice(2, valuesSetting.length-2).split(",");
  446. var notesList = notesSetting.slice(2, notesSetting.length-2).split(",");
  447. if(valuesList.length > 1 && notesList.length == valuesList.length) {
  448. for(var j = 0; j < valuesList.length; j++) {
  449. checker.setAnnotation(Number(valuesList[j]), notesList[j]);
  450. }
  451. }
  452. if(driverReference.emitOnStart == "true") {
  453. start.clicked.connect(checker.annotate);
  454. }
  455. var colname = driverReference.source;
  456. for(var j = 0; j < columnNames.length; j++) {
  457. if(columnNames[j] == colname) {
  458. channels[j].newData.connect(checker.newMeasurement);
  459. break;
  460. }
  461. }
  462. annotationButtons.push(checker);
  463. }
  464. else if(driverReference.driver == "reconfigurablebutton")
  465. {
  466. var button = new AnnotationButton(driverReference.buttontext);
  467. button.setAnnotation(driverReference.annotationtext);
  468. annotationButtons.push(button);
  469. annotationPanel.addWidget(button);
  470. tabControls.push(button);
  471. nsparam.enabled = true;
  472. nsparam.triggered.connect(function() {
  473. var setParam = createWindow("sampleParameters");
  474. setParam.windowTitle = "Typica - Set Sample Parameters";
  475. setParam.button = button;
  476. });
  477. }
  478. else if(driverReference.driver == "annotationspinbox")
  479. {
  480. var layout = new QBoxLayout;
  481. var label = new QLabel(driverReference.label);
  482. layout.addWidget(label, 0, 2);
  483. var spinbox = new AnnotationSpinBox;
  484. spinbox.setPretext(driverReference.pretext);
  485. spinbox.setPosttext(driverReference.posttext);
  486. spinbox.minimum = driverReference.minimum;
  487. spinbox.maximum = driverReference.maximum;
  488. spinbox.decimals = driverReference.precision;
  489. layout.addWidget(spinbox, 0, 1);
  490. annotationPanel.addLayout(layout);
  491. annotationButtons.push(spinbox);
  492. tabControls.push(spinbox);
  493. }
  494. else if(driverReference.driver == "freeannotation")
  495. {
  496. var layout = new QBoxLayout;
  497. var label = new QLabel(driverReference.labeltext);
  498. var control = new QLineEdit;
  499. layout.addWidget(label, 0, 2);
  500. layout.addWidget(control, 0, 1);
  501. annotationPanel.addLayout(layout);
  502. tabControls.push(control);
  503. control.returnPressed.connect(function() {
  504. for(var i = window.firstTempColumn; i < window.annotationColumn; i++) {
  505. log.newAnnotation(control.text, i, window.annotationColumn);
  506. }
  507. });
  508. }
  509. else if(driverReference.driver == "linearspline")
  510. {
  511. var colname = driverReference.source;
  512. for(var j = 0; j < columnNames.length; j++)
  513. {
  514. if(columnNames[j] == colname)
  515. {
  516. var calibrator = new LinearSplineInterpolator;
  517. var sv = driverReference.sourcevalues;
  518. var dv = driverReference.destinationvalues;
  519. var sourcevalues = sv.slice(2, sv.length-2).split(",");
  520. var destvalues = dv.slice(2, dv.length-2).split(",");
  521. if(sourcevalues.length > 1 && destvalues.length == sourcevalues.length)
  522. {
  523. for(var k = 0; k < sourcevalues.length; k++)
  524. {
  525. calibrator.add_pair(Number(sourcevalues[k]),Number(destvalues[k]));
  526. }
  527. var indicator = new TemperatureDisplay;
  528. temperatureDisplays.push(indicator);
  529. var decorator = new WidgetDecorator(indicator, configModel.data(driverIndex, 0), 2);
  530. channels[j].newData.connect(calibrator.newMeasurement);
  531. calibrator.newData.connect(indicator.setValue);
  532. channels.push(calibrator);
  533. // Channel hiding is not yet configurable for this.
  534. // I'm not sure if there's any need to allow this
  535. // to be hidden at present.
  536. channelVisibility.push(true);
  537. channelType.push(channelType[j]);
  538. columnNames.push(driverReference.destination);
  539. indicatorPanel.addWidget(decorator);
  540. }
  541. break;
  542. }
  543. }
  544. }
  545. else if(driverReference.driver == "translation")
  546. {
  547. var colname = driverReference.column;
  548. window.targetcolumnname = colname;
  549. for(var j = 0; j < columnNames.length; j++)
  550. {
  551. if(columnNames[j] == colname)
  552. {
  553. translationChannel = j;
  554. var indicator = new TemperatureDisplay;
  555. indicator.digitCount = 4;
  556. externtrans = indicator;
  557. indicator.display(0);
  558. var decorator = new WidgetDecorator(indicator, configModel.data(driverIndex, 0), 2);
  559. indicatorPanel.addWidget(decorator);
  560. currentDetector.timeForValue.connect(function(value) {
  561. if(!hasTranslated)
  562. {
  563. var currentOffset = value;
  564. if(targetOffset != 0)
  565. {
  566. var translation = currentOffset - targetOffset;
  567. externtrans.display(translation);
  568. gtrans = translation;
  569. if(translation > 0)
  570. {
  571. window.translateLoadedSeries(translation);
  572. }
  573. else
  574. {
  575. window.translateCurrentSeries(-translation);
  576. }
  577. }
  578. }
  579. hasTranslated = true;
  580. });
  581. var resetTranslation = findChildObject(this, 'unshift');
  582. resetTranslation.triggered.connect(function() {
  583. if(gtrans > 0) {
  584. window.translateLoadedSeries(-gtrans);
  585. }
  586. else {
  587. window.translateCurrentSeries(gtrans);
  588. }
  589. gtrans = 0;
  590. indicator.display(0);
  591. });
  592. }
  593. }
  594. targetDetector.setThreshold(driverReference.FValue);
  595. currentDetector.setThreshold(driverReference.FValue);
  596. }
  597. else if(driverReference.driver == "rate")
  598. {
  599. var primaryColumn = driverReference.column;
  600. for(var j = 0; j < columnNames.length; j++)
  601. {
  602. if(columnNames[j] == primaryColumn)
  603. {
  604. var rate = new RateOfChange(driverReference.cache, driverReference.scale);
  605. channels[j].newData.connect(rate.newMeasurement);
  606. var indicator = new TemperatureDisplay;
  607. indicator.setRelativeMode(true);
  608. indicator.display(0);
  609. indicator.digitCount = 9;
  610. var decorator = new WidgetDecorator(indicator, configModel.data(driverIndex, 0), 2);
  611. indicatorPanel.addWidget(decorator);
  612. rate.newData.connect(indicator.setValue);
  613. temperatureDisplays.push(indicator);
  614. channels.push(rate);
  615. // This cannot at present be configured to be
  616. // hidden.
  617. channelVisibility.push(true);
  618. channelType.push("T");
  619. columnNames.push(configModel.data(driverIndex, 0));
  620. }
  621. }
  622. }
  623. else if(driverReference.driver == "scale")
  624. {
  625. var scale = new SerialScale(driverReference.port);
  626. scale.setDataBits(8);
  627. scale.setBaudRate(driverReference.baudrate);
  628. scale.setParity(driverReference.parity);
  629. scale.setStopBits(driverReference.stopbits);
  630. scale.setFlowControl(driverReference.flowcontrol);
  631. scale.open(3);
  632. window.scales.push(scale);
  633. }
  634. else if(driverReference.driver == "coolingtimer")
  635. {
  636. var coolingTimer = new TimerDisplay();
  637. coolingTimer.setDisplayFormat("mm:ss");
  638. var decorator = new WidgetDecorator(coolingTimer, configModel.data(driverIndex, 0), 2);
  639. indicatorPanel.addWidget(decorator);
  640. coolingTimer.setTimerMode(1);
  641. coolingTimer.setAutoReset(true);
  642. var timeValue = new QTime();
  643. timeValue = timeValue.fromString(driverReference.reset, "mm:ss");
  644. coolingTimer.setResetValue(timeValue);
  645. stop.clicked.connect(coolingTimer.startTimer);
  646. }
  647. else if(driverReference.driver == "rangetimer")
  648. {
  649. rangetimers.push(new TimerDisplay());
  650. var rangeTimer = rangetimers[rangetimers.length - 1];
  651. rangeTimer.setDisplayFormat("mm:ss");
  652. var decorator = new WidgetDecorator(rangeTimer, configModel.data(driverIndex, 0), 2);
  653. indicatorPanel.addWidget(decorator);
  654. stop.clicked.connect(rangeTimer.stopTimer);
  655. start.clicked.connect(rangeTimer.reset);
  656. if(driverReference.starttrigger == "batch")
  657. {
  658. start.clicked.connect(rangeTimer.startTimer);
  659. }
  660. else if(driverReference.starttrigger == "manual")
  661. {
  662. var startButton = new AnnotationButton(driverReference.startbuttontext);
  663. startButton.clicked.connect(rangeTimer.startTimer);
  664. annotationPanel.addWidget(startButton);
  665. tabControls.push(button);
  666. }
  667. else if(driverReference.starttrigger == "value")
  668. {
  669. var startTrigger = new ThresholdDetector();
  670. startTrigger.setThreshold(Number(driverReference.startvalue));
  671. var scope = new Object;
  672. scope.invoke = function() {
  673. if(timer.running && !(arguments.callee.rangeTimer.running))
  674. {
  675. arguments.callee.rangeTimer.startTimer();
  676. }
  677. };
  678. scope.invoke.rangeTimer = rangeTimer;
  679. startTrigger.timeForValue.connect(scope.invoke);
  680. for(var j = 0; j < columnNames.length; j++)
  681. {
  682. if(columnNames[j] == driverReference.startcolumnname)
  683. {
  684. channels[j].newData.connect(startTrigger.newMeasurement);
  685. }
  686. }
  687. }
  688. stop.clicked.connect(rangeTimer.stopTimer)
  689. if(driverReference.stoptrigger == "manual")
  690. {
  691. var stopButton = new AnnotationButton(driverReference.stopbuttontext);
  692. stopButton.clicked.connect(rangeTimer.stopTimer);
  693. annotationPanel.addWidget(stopButton);
  694. tabControls.push(button);
  695. }
  696. else if(driverReference.stoptrigger == "value")
  697. {
  698. var stopTrigger = new ThresholdDetector();
  699. stopTrigger.setThreshold(Number(driverReference.stopvalue));
  700. stopTrigger.timeForValue.connect(rangeTimer.stopTimer);
  701. for(var j = 0; j < columnNames.length; j++)
  702. {
  703. if(columnNames[j] == driverReference.stopcolumnname)
  704. {
  705. channels[j].newData.connect(stopTrigger.newMeasurement);
  706. }
  707. }
  708. }
  709. rangeTimer.reportingName = configModel.data(driverIndex, 0);
  710. rangeTimer.report = function() {
  711. return "" + this.reportingName + ": " + this.value;
  712. };
  713. }
  714. else if(driverReference.driver = "multirangetimer")
  715. {
  716. var rangeTimer = new TimerDisplay();
  717. rangeTimer.setDisplayFormat("mm:ss");
  718. var decorator = new WidgetDecorator(rangeTimer, configModel.data(driverIndex, 0), 2);
  719. indicatorPanel.addWidget(decorator);
  720. var rangenames = driverReference.rangenames;
  721. var endtemps = driverReference.endtemps;
  722. var names = rangenames.slice(2, rangenames.length - 2).split(", ");
  723. rangeTimer.rangeNames = new Array();
  724. for(var j = 0; j < names.length; j++)
  725. {
  726. var name = names[j].slice(1, names[j].length - 1);
  727. rangeTimer.rangeNames.push(name);
  728. }
  729. rangeTimer.rangeEnds = new Array();
  730. var ends = endtemps.slice(2, endtemps.length - 2).split(", ");
  731. for(var j = 0; j < ends.length; j++)
  732. {
  733. rangeTimer.rangeEnds.push(Number(ends[j]));
  734. }
  735. rangeTimer.currentRange = 0;
  736. rangeTimer.results = new Array();
  737. rangeTimer.trigger = new ThresholdDetector();
  738. for(var j = 0; j < columnNames.length; j++)
  739. {
  740. if(columnNames[j] == driverReference.trigger)
  741. {
  742. channels[j].newData.connect(rangeTimer.trigger.newMeasurement);
  743. }
  744. }
  745. rangeTimer.startRanges = function() {
  746. arguments.callee.timer.currentRange = 0;
  747. arguments.callee.timer.results.splice(0, arguments.callee.timer.results.length);
  748. arguments.callee.timer.trigger.setThreshold(arguments.callee.timer.rangeEnds[0]);
  749. };
  750. rangeTimer.startRanges.timer = rangeTimer;
  751. start.clicked.connect(rangeTimer.startTimer);
  752. start.clicked.connect(rangeTimer.startRanges);
  753. rangeTimer.transition = function() {
  754. arguments.callee.timer.stopTimer();
  755. arguments.callee.timer.results.push(arguments.callee.timer.value);
  756. arguments.callee.timer.reset();
  757. arguments.callee.timer.startTimer();
  758. arguments.callee.timer.currentRange++;
  759. if(arguments.callee.timer.currentRange <= arguments.callee.timer.rangeEnds.length)
  760. {
  761. arguments.callee.timer.trigger.setThreshold(arguments.callee.timer.rangeEnds[arguments.callee.timer.currentRange]);
  762. }
  763. };
  764. rangeTimer.transition.timer = rangeTimer;
  765. rangeTimer.trigger.timeForValue.connect(rangeTimer.transition);
  766. stop.clicked.connect(rangeTimer.transition);
  767. stop.clicked.connect(rangeTimer.stopTimer);
  768. rangeTimer.report = function() {
  769. var retval = "";
  770. for(var j = 0; j < arguments.callee.timer.results.length; j++)
  771. {
  772. retval += arguments.callee.timer.rangeNames[j] + ": " + arguments.callee.timer.results[j] + "\n";
  773. }
  774. return retval;
  775. };
  776. rangeTimer.report.timer = rangeTimer;
  777. rangetimers.push(rangeTimer);
  778. }
  779. }
  780. }
  781. for(var i = 1; i < tabControls.length; i++)
  782. {
  783. setTabOrder(tabControls[i-1], tabControls[i]);
  784. }
  785. log.setHeaderData(0, "Time");
  786. var channelSkip = 0;
  787. for(var i = 0; i < columnNames.length; i++) {
  788. if(channelVisibility[i]) {
  789. log.setHeaderData(i + 1 - channelSkip, columnNames[i]);
  790. log.addToCurrentColumnSet(i + 1 - channelSkip);
  791. }
  792. else {
  793. channelSkip++;
  794. }
  795. }
  796. log.setHeaderData(columnNames.length + 1 - channelSkip, "Note");
  797. var timer = new TimerDisplay;
  798. timer.displayFormat = "mm:ss";
  799. timer.autoReset = true;
  800. var btdecorator = new WidgetDecorator(timer, "Batch Timer", 2);
  801. indicatorPanel.addWidget(btdecorator);
  802. var vsplit = findChildObject(this, 'main');
  803. var isplit = findChildObject(this, 'indicators');
  804. var lsplit = findChildObject(this, 'logsplit');
  805. window.aboutToClose.connect(function() {
  806. for(var i = 0; i < nidevices.length; i++)
  807. {
  808. nidevices[i].stop();
  809. nidevices[i].deleteLater();
  810. }
  811. for(var i = 0; i < modbusdevices.length; i++)
  812. {
  813. modbusdevices[i].deleteLater();
  814. }
  815. for(var i = 0; i < dataqsdkdevices.length; i++)
  816. {
  817. dataqsdkdevices[i].deleteLater();
  818. }
  819. for(var i = 0; i < jsdevices.length; i++)
  820. {
  821. jsdevices[i].stop();
  822. jsdevices[i].deleteLater();
  823. }
  824. for(var i = 0; i < pdevices.length; i++)
  825. {
  826. pdevices[i].stop();
  827. pdevices[i].deleteLater();
  828. }
  829. delete nidevices;
  830. delete modbusdevices;
  831. delete dataqsdkdevices;
  832. delete jsdevices;
  833. delete pdevices;
  834. window.saveSizeAndPosition("window");
  835. vsplit.saveState("script/loggingView/" + roasterIndex + "/mainSplitter");
  836. QSettings.setValue("script/loggingView/" + roasterIndex + "/instrumentCount", isplit.count());
  837. isplit.saveState("script/loggingView/" + roasterIndex + "/instrumentSplitter");
  838. lsplit.saveState("script/loggingView/" + roasterIndex + "/logSplitter");
  839. log.saveState("script/log", 7);
  840. window.navigationWindow.loggingWindow = undefined;
  841. Windows.loggingWindow = undefined;
  842. });
  843. this.restoreSizeAndPosition('window');
  844. vsplit.restoreState("script/loggingView/" + roasterIndex + "/mainSplitter");
  845. if(QSettings.value("script/loggingView/" + roasterIndex + "/instrumentCount") == isplit.count()) {
  846. isplit.restoreState("script/loggingView/" + roasterIndex + "/instrumentSplitter");
  847. }
  848. lsplit.restoreState("script/loggingView/" + roasterIndex + "/logSplitter");
  849. log.restoreState("script/log", 7);
  850. var offsets = new Array();
  851. var zeroemitters = new Array();
  852. var adapters = new Array();
  853. channelSkip = 0;
  854. for(var i = 0; i < channels.length; i++) {
  855. if(channelVisibility[i]) {
  856. var offset = new MeasurementTimeOffset(epoch);
  857. offsets.push(offset);
  858. channels[i].newData.connect(offset.newMeasurement);
  859. var adapter = new MeasurementAdapter(i + 1 - channelSkip);
  860. adapters.push(adapter);
  861. offset.measurement.connect(adapter.newMeasurement);
  862. var emitter = new ZeroEmitter(i + 1);
  863. zeroemitters.push(emitter);
  864. channels[i].newData.connect(emitter.newMeasurement);
  865. emitter.measurement.connect(log.newMeasurement);
  866. emitter.measurement.connect(graph.newMeasurement);
  867. } else {
  868. channelSkip++;
  869. }
  870. }
  871. var offsetForChannel = function(c) {
  872. var retval = -1;
  873. for(var i = 0; i <= c; i++) {
  874. if(channelVisibility[i]) {
  875. retval++;
  876. }
  877. }
  878. return retval;
  879. };
  880. start.clicked.connect(function() {
  881. start.enabled = false;
  882. hasTranslated = false;
  883. var epoch = new QTime();
  884. epoch = epoch.currentTime();
  885. for(var i = 0; i < offsets.length; i++)
  886. {
  887. offsets[i].setZeroTime(epoch);
  888. zeroemitters[i].emitZero();
  889. adapters[i].measurement.connect(log.newMeasurement);
  890. adapters[i].measurement.connect(graph.newMeasurement);
  891. }
  892. for(var i = 0; i < rateadapters.length; i++)
  893. {
  894. rateoffsets[i].setZeroTime(epoch);
  895. ratezeros[i].emitZero();
  896. rateadapters[i].measurement.connect(graph.newMeasurement);
  897. }
  898. timer.startTimer();
  899. if(typeof(currentBatchInfo) == 'undefined') { } else {
  900. query = new QSqlQuery();
  901. query.exec("SELECT now()::timestamp without time zone");
  902. query.next();
  903. var result = query.value(0);
  904. query = query.invalidate();
  905. var timefield = findChildObject(currentBatchInfo, 'time');
  906. timefield.text = result.replace('T', ' ');
  907. }
  908. if(translationChannel >= 0)
  909. {
  910. offsets[offsetForChannel(translationChannel)].measurement.connect(currentDetector.newMeasurement);
  911. }
  912. if(typeof(externtrans) != 'undefined') {
  913. externtrans.display(0);
  914. }
  915. stop.enabled = true;
  916. window.windowModified = true;
  917. graph.setTimeIndicatorEnabled(true);
  918. });
  919. for(var i = 0; i < annotationButtons.length; i++) {
  920. if(channels.length > 0)
  921. {
  922. annotationButtons[i].annotation.connect(log.newAnnotation);
  923. annotationButtons[i].setTemperatureColumn(1);
  924. annotationButtons[i].setAnnotationColumn(channels.length - channelSkip + 1);
  925. annotationButtons[i].annotation.connect(function(note, tcol, ncol) {
  926. for(var i = tcol; i < ncol; i++) {
  927. log.newAnnotation(note, i, ncol);
  928. }
  929. });
  930. }
  931. }
  932. start.setFocus();
  933. stop.annotation.connect(log.newAnnotation);
  934. stop.clicked.connect(timer.stopTimer);
  935. stop.setTemperatureColumn(1);
  936. stop.setAnnotationColumn(channels.length - channelSkip + 1);
  937. QSettings.setValue("liveColumn", 1);
  938. var lc = 1;
  939. stop.clicked.connect(function() {
  940. stop.enabled = false;
  941. for(var i = 0; i < adapters.length; i++)
  942. {
  943. adapters[i].measurement.disconnect(log.newMeasurement);
  944. adapters[i].measurement.disconnect(graph.newMeasurement);
  945. }
  946. for(var i = 0; i < rateadapters.length; i++)
  947. {
  948. rateadapters[i].measurement.disconnect(graph.newMeasurement);
  949. }
  950. if(typeof(currentBatchInfo) == 'undefined') { } else {
  951. lc = Number(QSettings.value("liveColumn"));
  952. var duration = log.lastTime(lc);
  953. var durfield = findChildObject(currentBatchInfo, 'duration');
  954. durfield.text = duration;
  955. log.clearOutputColumns();
  956. channelSkip = 0;
  957. for(var i = 0; i < channels.length; i++) {
  958. if(channelVisibility[i]) {
  959. if(channelType[i] == "T") {
  960. log.addOutputTemperatureColumn(lc + i - channelSkip);
  961. }
  962. else {
  963. log.addOutputControlColumn(lc + i - channelSkip);
  964. }
  965. } else {
  966. channelSkip++;
  967. }
  968. }
  969. log.addOutputAnnotationColumn(lc + channels.length - channelSkip);
  970. var filename = log.saveTemporary();
  971. currentBatchInfo.tempData = filename;
  972. var notes = findChildObject(currentBatchInfo, 'annotation');
  973. for(var i = 0; i < rangetimers.length; i++)
  974. {
  975. notes.append(rangetimers[i].report());
  976. }
  977. currentBatchInfo.raise();
  978. currentBatchInfo.activateWindow();
  979. }
  980. if(translationChannel >= 0)
  981. {
  982. offsets[offsetForChannel(translationChannel)].measurement.disconnect(currentDetector.newMeasurement);
  983. }
  984. start.enabled = true;
  985. window.windowModified = false;
  986. graph.setTimeIndicatorEnabled(false);
  987. });
  988. stop.annotation.connect(function(note, tcol, ncol) {
  989. for(var i = tcol; i < ncol; i++) {
  990. log.newAnnotation(note, i, ncol);
  991. }
  992. });
  993. var quitMenu = findChildObject(this, 'quit');
  994. quitMenu.triggered.connect(function() {
  995. window.close();
  996. Application.quit();
  997. });
  998. var v1 = findChildObject(this, 'ms');
  999. v1.triggered.connect(log.LOD_ms);
  1000. var v2 = findChildObject(this, '1s');
  1001. v2.triggered.connect(log.LOD_1s);
  1002. var v3 = findChildObject(this, '5s');
  1003. v3.triggered.connect(log.LOD_5s);
  1004. var v4 = findChildObject(this, '10s');
  1005. v4.triggered.connect(log.LOD_10s);
  1006. var v5 = findChildObject(this, '15s');
  1007. v5.triggered.connect(log.LOD_15s);
  1008. var v6 = findChildObject(this, '30s');
  1009. v6.triggered.connect(log.LOD_30s);
  1010. var v7 = findChildObject(this, '1m');
  1011. v7.triggered.connect(log.LOD_1m);
  1012. var showC = findChildObject(this, 'showC');
  1013. showC.triggered.connect(function() {
  1014. for(var i = 0; i < temperatureDisplays.length; i++)
  1015. {
  1016. temperatureDisplays[i].setDisplayUnits(Units.Celsius);
  1017. }
  1018. log.setDisplayUnits(Units.Celsius);
  1019. graph.showC();
  1020. QSettings.setValue("temperatureUnit", "C");
  1021. });
  1022. var showF = findChildObject(this, 'showF');
  1023. showF.triggered.connect(function() {
  1024. for(var i = 0; i < temperatureDisplays.length; i++)
  1025. {
  1026. temperatureDisplays[i].setDisplayUnits(Units.Fahrenheit);
  1027. }
  1028. log.setDisplayUnits(Units.Fahrenheit);
  1029. graph.showF();
  1030. QSettings.setValue("temperatureUnit", "F");
  1031. });
  1032. if(QSettings.value("temperatureUnit", "F") == "C")
  1033. {
  1034. showC.trigger();
  1035. }
  1036. var clear = findChildObject(this, 'clear');
  1037. clear.triggered.connect(log.clear);
  1038. clear.triggered.connect(graph.clear);
  1039. clear.triggered.connect(function() {
  1040. window.windowTitle = "Typica [*]";
  1041. log.setHeaderData(0, "Time");
  1042. QSettings.setValue("liveColumn", 1);
  1043. window.postLoadColumnSetup(0);
  1044. if(typeof(externtrans) != 'undefined') {
  1045. externtrans.display(0);
  1046. }
  1047. });
  1048. var openMenu = findChildObject(this, 'open');
  1049. var compareMenu = findChildObject(this, 'compare');
  1050. compareMenu.triggered.connect(function() {
  1051. QSettings.setValue('cseries', lc+1);
  1052. var history = createReport("historyreport.xml");
  1053. history.windowTitle = 'Typica - Roasting Log';
  1054. });
  1055. var printMenu = findChildObject(this, 'print');
  1056. printMenu.triggered.connect(function() {
  1057. var exportWindow = createWindow("print");
  1058. exportWindow.windowTitle = "Typica - Print";
  1059. exportWindow.log = log;
  1060. });
  1061. var svgExportMenu = findChildObject(this, 'svgexport');
  1062. svgExportMenu.triggered.connect(function() {
  1063. var exportWindow = createWindow("exportWindow");
  1064. exportWindow.windowTitle = "Typica - Export XHTML+SVG";
  1065. exportWindow.log = log;
  1066. });
  1067. openMenu.triggered.connect(function() {
  1068. var filename = QFileDialog.getOpenFileName(window, 'Open Log…', QSettings.value('script/lastDir', '') + '/');
  1069. if(filename != '') {
  1070. var file = new QFile(filename);
  1071. var input = new XMLInput(file, 1);
  1072. targetseries = -1;
  1073. input.newTemperatureColumn.connect(log.setHeaderData);
  1074. input.newTemperatureColumn.connect(function(col, text) {
  1075. if(text == window.targetcolumnname) {
  1076. targetseries = col;
  1077. }
  1078. });
  1079. input.newAnnotationColumn.connect(log.setHeaderData);
  1080. input.measure.connect(graph.newMeasurement);
  1081. input.measure.connect(log.newMeasurement);
  1082. input.measure.connect(function(data, series) {
  1083. if(series == targetseries) {
  1084. targetDetector.newMeasurement(data);
  1085. }
  1086. });
  1087. input.annotation.connect(log.newAnnotation);
  1088. input.annotation.connect(function(note, tcol, ncol) {
  1089. for(var i = tcol; i < ncol; i++) {
  1090. log.newAnnotation(note, i, ncol);
  1091. }
  1092. });
  1093. var lc;
  1094. input.lastColumn.connect(function(c) {
  1095. lc = c;
  1096. QSettings.setValue("liveColumn", c + 1);
  1097. window.postLoadColumnSetup(c);
  1098. });
  1099. graph.updatesEnabled = false;
  1100. log.updatesEnabled = false;
  1101. input.input();
  1102. log.updatesEnabled = true;
  1103. graph.updatesEnabled = true;
  1104. window.windowTitle = 'Typica - [*]' + baseName(filename);
  1105. QSettings.setValue("script/lastDir", dir(filename));
  1106. log.newAnnotation("End", 1, lc);
  1107. }
  1108. });
  1109. var columnName = function(c) {
  1110. var visibleColumns = 0;
  1111. for(var i = 0; i < channels.length; i++) {
  1112. if(channelVisibility[i]) {
  1113. visibleColumns++;
  1114. }
  1115. if(c == visibleColumns - 1) {
  1116. return columnNames[i];
  1117. }
  1118. }
  1119. return "";
  1120. };
  1121. window.postLoadColumnSetup = function(c) {
  1122. for(var i = 0; i < adapters.length; i++)
  1123. {
  1124. adapters[i].setColumn(c + i + 1);
  1125. zeroemitters[i].setColumn(c + i + 1);
  1126. log.setHeaderData(c + i + 1, columnName(i));
  1127. }
  1128. log.setHeaderData(c + columnNames.length + 1 - channelSkip, "Note");
  1129. stop.setTemperatureColumn(c + 1);
  1130. stop.setAnnotationColumn(c + columnNames.length + 1 - channelSkip);
  1131. for(var i = 0; i < annotationButtons.length; i++)
  1132. {
  1133. annotationButtons[i].setTemperatureColumn(c + 1);
  1134. annotationButtons[i].setAnnotationColumn(c + columnNames.length + 1 - channelSkip);
  1135. }
  1136. log.clearCurrentColumnSet();
  1137. for(var i = 0; i < channels.length - channelSkip; i++) {
  1138. log.addToCurrentColumnSet(c + i + 1);
  1139. }
  1140. window.firstTempColumn = c + 1;
  1141. window.annotationColumn = c + columnNames.length - channelSkip + 1;
  1142. }
  1143. var saveMenu = findChildObject(this, 'save');
  1144. saveMenu.triggered.connect(function() {
  1145. var filename = QFileDialog.getSaveFileName(window, "Save Log As…", QSettings.value("script/lastDir", "") + "/");
  1146. if(filename != "") {
  1147. var lc = Number(QSettings.value("liveColumn"));
  1148. var file = new QFile(filename);
  1149. log.clearOutputColumns();
  1150. channelSkip = 0;
  1151. for(var i = 0; i < channels.length; i++)
  1152. {
  1153. if(channelVisibility[i]) {
  1154. if(channelType[i] == "T") {
  1155. log.addOutputTemperatureColumn(lc + i - channelSkip);
  1156. }
  1157. else {
  1158. log.addOutputControlColumn(lc + i - channelSkip);
  1159. }
  1160. } else {
  1161. channelSkip++;
  1162. }
  1163. }
  1164. log.addOutputAnnotationColumn(lc + columnNames.length - channelSkip);
  1165. log.saveXML(file);
  1166. QSettings.setValue("script/lastDir", dir(filename));
  1167. }
  1168. });
  1169. var exportMenu = findChildObject(this, 'export');
  1170. exportMenu.triggered.connect(function() {
  1171. var filename = QFileDialog.getSaveFileName(window, "Export CSV As…", QSettings.value("script/lastDir", "") + "/");
  1172. if(filename != "") {
  1173. var lc = Number(QSettings.value("liveColumn"));
  1174. var file = new QFile(filename);
  1175. log.clearOutputColumns();
  1176. for(var i = 0; i < columnNames.length - channelSkip; i++)
  1177. {
  1178. log.addOutputTemperatureColumn(lc + i);
  1179. }
  1180. log.addOutputAnnotationColumn(lc + columnNames.length - channelSkip);
  1181. log.saveCSV(file);
  1182. QSettings.setValue("script/lastDir", dir(filename));
  1183. }
  1184. });
  1185. var manual = findChildObject(this, 'manual');
  1186. manual.triggered.connect(function() {
  1187. var entry = new LogEditWindow();
  1188. entry.show();
  1189. });
  1190. var newMenu = findChildObject(this, 'new');
  1191. newMenu.triggered.connect(function() {
  1192. var bwindow = createWindow("batchWindow");
  1193. bwindow.windowTitle = "Typica - [*]New Batch";
  1194. });
  1195. var newSampleMenu = findChildObject(this, 'newsample');
  1196. newSampleMenu.triggered.connect(function() {
  1197. var bwindow = createWindow("sampleRoastingBatch");
  1198. });
  1199. window.postLoadColumnSetup(0);
  1200. Windows.loggingWindow = window;
  1201. ]]>
  1202. </program>
  1203. </window>