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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206
  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.setWeighCommand(driverReference.weighcommand);
  632. scale.setCommandTerminator(driverReference.commandterminator);
  633. scale.open(3);
  634. window.scales.push(scale);
  635. }
  636. else if(driverReference.driver == "coolingtimer")
  637. {
  638. var coolingTimer = new TimerDisplay();
  639. coolingTimer.setDisplayFormat("mm:ss");
  640. var decorator = new WidgetDecorator(coolingTimer, configModel.data(driverIndex, 0), 2);
  641. indicatorPanel.addWidget(decorator);
  642. coolingTimer.setTimerMode(1);
  643. coolingTimer.setAutoReset(true);
  644. var timeValue = new QTime();
  645. timeValue = timeValue.fromString(driverReference.reset, "mm:ss");
  646. coolingTimer.setResetValue(timeValue);
  647. stop.clicked.connect(coolingTimer.startTimer);
  648. }
  649. else if(driverReference.driver == "rangetimer")
  650. {
  651. rangetimers.push(new TimerDisplay());
  652. var rangeTimer = rangetimers[rangetimers.length - 1];
  653. rangeTimer.setDisplayFormat("mm:ss");
  654. var decorator = new WidgetDecorator(rangeTimer, configModel.data(driverIndex, 0), 2);
  655. indicatorPanel.addWidget(decorator);
  656. stop.clicked.connect(rangeTimer.stopTimer);
  657. start.clicked.connect(rangeTimer.reset);
  658. if(driverReference.starttrigger == "batch")
  659. {
  660. start.clicked.connect(rangeTimer.startTimer);
  661. }
  662. else if(driverReference.starttrigger == "manual")
  663. {
  664. var startButton = new AnnotationButton(driverReference.startbuttontext);
  665. startButton.clicked.connect(rangeTimer.startTimer);
  666. annotationPanel.addWidget(startButton);
  667. tabControls.push(button);
  668. }
  669. else if(driverReference.starttrigger == "value")
  670. {
  671. var startTrigger = new ThresholdDetector();
  672. startTrigger.setThreshold(Number(driverReference.startvalue));
  673. var scope = new Object;
  674. scope.invoke = function() {
  675. if(timer.running && !(arguments.callee.rangeTimer.running))
  676. {
  677. arguments.callee.rangeTimer.startTimer();
  678. }
  679. };
  680. scope.invoke.rangeTimer = rangeTimer;
  681. startTrigger.timeForValue.connect(scope.invoke);
  682. for(var j = 0; j < columnNames.length; j++)
  683. {
  684. if(columnNames[j] == driverReference.startcolumnname)
  685. {
  686. channels[j].newData.connect(startTrigger.newMeasurement);
  687. }
  688. }
  689. }
  690. stop.clicked.connect(rangeTimer.stopTimer)
  691. if(driverReference.stoptrigger == "manual")
  692. {
  693. var stopButton = new AnnotationButton(driverReference.stopbuttontext);
  694. stopButton.clicked.connect(rangeTimer.stopTimer);
  695. annotationPanel.addWidget(stopButton);
  696. tabControls.push(button);
  697. }
  698. else if(driverReference.stoptrigger == "value")
  699. {
  700. var stopTrigger = new ThresholdDetector();
  701. stopTrigger.setThreshold(Number(driverReference.stopvalue));
  702. stopTrigger.timeForValue.connect(rangeTimer.stopTimer);
  703. for(var j = 0; j < columnNames.length; j++)
  704. {
  705. if(columnNames[j] == driverReference.stopcolumnname)
  706. {
  707. channels[j].newData.connect(stopTrigger.newMeasurement);
  708. }
  709. }
  710. }
  711. rangeTimer.reportingName = configModel.data(driverIndex, 0);
  712. rangeTimer.report = function() {
  713. return "" + this.reportingName + ": " + this.value;
  714. };
  715. }
  716. else if(driverReference.driver = "multirangetimer")
  717. {
  718. var rangeTimer = new TimerDisplay();
  719. rangeTimer.setDisplayFormat("mm:ss");
  720. var decorator = new WidgetDecorator(rangeTimer, configModel.data(driverIndex, 0), 2);
  721. indicatorPanel.addWidget(decorator);
  722. var rangenames = driverReference.rangenames;
  723. var endtemps = driverReference.endtemps;
  724. var names = rangenames.slice(2, rangenames.length - 2).split(", ");
  725. rangeTimer.rangeNames = new Array();
  726. for(var j = 0; j < names.length; j++)
  727. {
  728. var name = names[j].slice(1, names[j].length - 1);
  729. rangeTimer.rangeNames.push(name);
  730. }
  731. rangeTimer.rangeEnds = new Array();
  732. var ends = endtemps.slice(2, endtemps.length - 2).split(", ");
  733. for(var j = 0; j < ends.length; j++)
  734. {
  735. rangeTimer.rangeEnds.push(Number(ends[j]));
  736. }
  737. rangeTimer.currentRange = 0;
  738. rangeTimer.results = new Array();
  739. rangeTimer.trigger = new ThresholdDetector();
  740. for(var j = 0; j < columnNames.length; j++)
  741. {
  742. if(columnNames[j] == driverReference.trigger)
  743. {
  744. channels[j].newData.connect(rangeTimer.trigger.newMeasurement);
  745. }
  746. }
  747. rangeTimer.startRanges = function() {
  748. arguments.callee.timer.currentRange = 0;
  749. arguments.callee.timer.results.splice(0, arguments.callee.timer.results.length);
  750. arguments.callee.timer.trigger.setThreshold(arguments.callee.timer.rangeEnds[0]);
  751. };
  752. rangeTimer.startRanges.timer = rangeTimer;
  753. start.clicked.connect(rangeTimer.startTimer);
  754. start.clicked.connect(rangeTimer.startRanges);
  755. rangeTimer.transition = function() {
  756. arguments.callee.timer.stopTimer();
  757. arguments.callee.timer.results.push(arguments.callee.timer.value);
  758. arguments.callee.timer.reset();
  759. arguments.callee.timer.startTimer();
  760. arguments.callee.timer.currentRange++;
  761. if(arguments.callee.timer.currentRange <= arguments.callee.timer.rangeEnds.length)
  762. {
  763. arguments.callee.timer.trigger.setThreshold(arguments.callee.timer.rangeEnds[arguments.callee.timer.currentRange]);
  764. }
  765. };
  766. rangeTimer.transition.timer = rangeTimer;
  767. rangeTimer.trigger.timeForValue.connect(rangeTimer.transition);
  768. stop.clicked.connect(rangeTimer.transition);
  769. stop.clicked.connect(rangeTimer.stopTimer);
  770. rangeTimer.report = function() {
  771. var retval = "";
  772. for(var j = 0; j < arguments.callee.timer.results.length; j++)
  773. {
  774. retval += arguments.callee.timer.rangeNames[j] + ": " + arguments.callee.timer.results[j] + "\n";
  775. }
  776. return retval;
  777. };
  778. rangeTimer.report.timer = rangeTimer;
  779. rangetimers.push(rangeTimer);
  780. }
  781. }
  782. }
  783. for(var i = 1; i < tabControls.length; i++)
  784. {
  785. setTabOrder(tabControls[i-1], tabControls[i]);
  786. }
  787. log.setHeaderData(0, "Time");
  788. var channelSkip = 0;
  789. for(var i = 0; i < columnNames.length; i++) {
  790. if(channelVisibility[i]) {
  791. log.setHeaderData(i + 1 - channelSkip, columnNames[i]);
  792. log.addToCurrentColumnSet(i + 1 - channelSkip);
  793. }
  794. else {
  795. channelSkip++;
  796. }
  797. }
  798. log.setHeaderData(columnNames.length + 1 - channelSkip, TTR("basicWindow", "Note"));
  799. var timer = new TimerDisplay;
  800. timer.displayFormat = "mm:ss";
  801. timer.autoReset = true;
  802. var btdecorator = new WidgetDecorator(timer, TTR("basicWindow", "Batch Timer"), 2);
  803. indicatorPanel.addWidget(btdecorator);
  804. var vsplit = findChildObject(this, 'main');
  805. var isplit = findChildObject(this, 'indicators');
  806. var lsplit = findChildObject(this, 'logsplit');
  807. window.aboutToClose.connect(function() {
  808. for(var i = 0; i < nidevices.length; i++)
  809. {
  810. nidevices[i].stop();
  811. nidevices[i].deleteLater();
  812. }
  813. for(var i = 0; i < modbusdevices.length; i++)
  814. {
  815. modbusdevices[i].deleteLater();
  816. }
  817. for(var i = 0; i < dataqsdkdevices.length; i++)
  818. {
  819. dataqsdkdevices[i].deleteLater();
  820. }
  821. for(var i = 0; i < jsdevices.length; i++)
  822. {
  823. jsdevices[i].stop();
  824. jsdevices[i].deleteLater();
  825. }
  826. for(var i = 0; i < pdevices.length; i++)
  827. {
  828. pdevices[i].stop();
  829. pdevices[i].deleteLater();
  830. }
  831. delete nidevices;
  832. delete modbusdevices;
  833. delete dataqsdkdevices;
  834. delete jsdevices;
  835. delete pdevices;
  836. window.saveSizeAndPosition("window");
  837. vsplit.saveState("script/loggingView/" + roasterIndex + "/mainSplitter");
  838. QSettings.setValue("script/loggingView/" + roasterIndex + "/instrumentCount", isplit.count());
  839. isplit.saveState("script/loggingView/" + roasterIndex + "/instrumentSplitter");
  840. lsplit.saveState("script/loggingView/" + roasterIndex + "/logSplitter");
  841. log.saveState("script/log", 7);
  842. window.navigationWindow.loggingWindow = undefined;
  843. Windows.loggingWindow = undefined;
  844. });
  845. this.restoreSizeAndPosition('window');
  846. vsplit.restoreState("script/loggingView/" + roasterIndex + "/mainSplitter");
  847. if(QSettings.value("script/loggingView/" + roasterIndex + "/instrumentCount") == isplit.count()) {
  848. isplit.restoreState("script/loggingView/" + roasterIndex + "/instrumentSplitter");
  849. }
  850. lsplit.restoreState("script/loggingView/" + roasterIndex + "/logSplitter");
  851. log.restoreState("script/log", 7);
  852. var offsets = new Array();
  853. var zeroemitters = new Array();
  854. var adapters = new Array();
  855. channelSkip = 0;
  856. for(var i = 0; i < channels.length; i++) {
  857. if(channelVisibility[i]) {
  858. var offset = new MeasurementTimeOffset(epoch);
  859. offsets.push(offset);
  860. channels[i].newData.connect(offset.newMeasurement);
  861. var adapter = new MeasurementAdapter(i + 1 - channelSkip);
  862. adapters.push(adapter);
  863. offset.measurement.connect(adapter.newMeasurement);
  864. var emitter = new ZeroEmitter(i + 1);
  865. zeroemitters.push(emitter);
  866. channels[i].newData.connect(emitter.newMeasurement);
  867. emitter.measurement.connect(log.newMeasurement);
  868. emitter.measurement.connect(graph.newMeasurement);
  869. } else {
  870. channelSkip++;
  871. }
  872. }
  873. var offsetForChannel = function(c) {
  874. var retval = -1;
  875. for(var i = 0; i <= c; i++) {
  876. if(channelVisibility[i]) {
  877. retval++;
  878. }
  879. }
  880. return retval;
  881. };
  882. start.clicked.connect(function() {
  883. start.enabled = false;
  884. hasTranslated = false;
  885. var epoch = new QTime();
  886. epoch = epoch.currentTime();
  887. for(var i = 0; i < offsets.length; i++)
  888. {
  889. offsets[i].setZeroTime(epoch);
  890. zeroemitters[i].emitZero();
  891. adapters[i].measurement.connect(log.newMeasurement);
  892. adapters[i].measurement.connect(graph.newMeasurement);
  893. }
  894. for(var i = 0; i < rateadapters.length; i++)
  895. {
  896. rateoffsets[i].setZeroTime(epoch);
  897. ratezeros[i].emitZero();
  898. rateadapters[i].measurement.connect(graph.newMeasurement);
  899. }
  900. timer.startTimer();
  901. if(typeof(currentBatchInfo) == 'undefined') { } else {
  902. query = new QSqlQuery();
  903. query.exec("SELECT now()::timestamp without time zone");
  904. query.next();
  905. var result = query.value(0);
  906. query = query.invalidate();
  907. var timefield = findChildObject(currentBatchInfo, 'time');
  908. timefield.text = result.replace('T', ' ');
  909. }
  910. if(translationChannel >= 0)
  911. {
  912. offsets[offsetForChannel(translationChannel)].measurement.connect(currentDetector.newMeasurement);
  913. }
  914. if(typeof(externtrans) != 'undefined') {
  915. externtrans.display(0);
  916. }
  917. stop.enabled = true;
  918. window.windowModified = true;
  919. graph.setTimeIndicatorEnabled(true);
  920. });
  921. for(var i = 0; i < annotationButtons.length; i++) {
  922. if(channels.length > 0)
  923. {
  924. annotationButtons[i].annotation.connect(log.newAnnotation);
  925. annotationButtons[i].setTemperatureColumn(1);
  926. annotationButtons[i].setAnnotationColumn(channels.length - channelSkip + 1);
  927. annotationButtons[i].annotation.connect(function(note, tcol, ncol) {
  928. for(var i = tcol; i < ncol; i++) {
  929. log.newAnnotation(note, i, ncol);
  930. }
  931. });
  932. }
  933. }
  934. start.setFocus();
  935. stop.annotation.connect(log.newAnnotation);
  936. stop.clicked.connect(timer.stopTimer);
  937. stop.setTemperatureColumn(1);
  938. stop.setAnnotationColumn(channels.length - channelSkip + 1);
  939. QSettings.setValue("liveColumn", 1);
  940. var lc = 1;
  941. stop.clicked.connect(function() {
  942. stop.enabled = false;
  943. for(var i = 0; i < adapters.length; i++)
  944. {
  945. adapters[i].measurement.disconnect(log.newMeasurement);
  946. adapters[i].measurement.disconnect(graph.newMeasurement);
  947. }
  948. for(var i = 0; i < rateadapters.length; i++)
  949. {
  950. rateadapters[i].measurement.disconnect(graph.newMeasurement);
  951. }
  952. if(typeof(currentBatchInfo) == 'undefined') { } else {
  953. lc = Number(QSettings.value("liveColumn"));
  954. var duration = log.lastTime(lc);
  955. var durfield = findChildObject(currentBatchInfo, 'duration');
  956. durfield.text = duration;
  957. log.clearOutputColumns();
  958. channelSkip = 0;
  959. for(var i = 0; i < channels.length; i++) {
  960. if(channelVisibility[i]) {
  961. if(channelType[i] == "T") {
  962. log.addOutputTemperatureColumn(lc + i - channelSkip);
  963. }
  964. else {
  965. log.addOutputControlColumn(lc + i - channelSkip);
  966. }
  967. } else {
  968. channelSkip++;
  969. }
  970. }
  971. log.addOutputAnnotationColumn(lc + channels.length - channelSkip);
  972. var filename = log.saveTemporary();
  973. currentBatchInfo.tempData = filename;
  974. currentBatchInfo.endBatch();
  975. var notes = findChildObject(currentBatchInfo, 'annotation');
  976. for(var i = 0; i < rangetimers.length; i++)
  977. {
  978. notes.append(rangetimers[i].report());
  979. }
  980. currentBatchInfo.raise();
  981. currentBatchInfo.activateWindow();
  982. }
  983. if(translationChannel >= 0)
  984. {
  985. offsets[offsetForChannel(translationChannel)].measurement.disconnect(currentDetector.newMeasurement);
  986. }
  987. start.enabled = true;
  988. window.windowModified = false;
  989. graph.setTimeIndicatorEnabled(false);
  990. });
  991. stop.annotation.connect(function(note, tcol, ncol) {
  992. for(var i = tcol; i < ncol; i++) {
  993. log.newAnnotation(note, i, ncol);
  994. }
  995. });
  996. var quitMenu = findChildObject(this, 'quit');
  997. quitMenu.triggered.connect(function() {
  998. window.close();
  999. Application.quit();
  1000. });
  1001. var v1 = findChildObject(this, 'ms');
  1002. v1.triggered.connect(log.LOD_ms);
  1003. var v2 = findChildObject(this, '1s');
  1004. v2.triggered.connect(log.LOD_1s);
  1005. var v3 = findChildObject(this, '5s');
  1006. v3.triggered.connect(log.LOD_5s);
  1007. var v4 = findChildObject(this, '10s');
  1008. v4.triggered.connect(log.LOD_10s);
  1009. var v5 = findChildObject(this, '15s');
  1010. v5.triggered.connect(log.LOD_15s);
  1011. var v6 = findChildObject(this, '30s');
  1012. v6.triggered.connect(log.LOD_30s);
  1013. var v7 = findChildObject(this, '1m');
  1014. v7.triggered.connect(log.LOD_1m);
  1015. var showC = findChildObject(this, 'showC');
  1016. showC.triggered.connect(function() {
  1017. for(var i = 0; i < temperatureDisplays.length; i++)
  1018. {
  1019. temperatureDisplays[i].setDisplayUnits(Units.Celsius);
  1020. }
  1021. log.setDisplayUnits(Units.Celsius);
  1022. graph.showC();
  1023. QSettings.setValue("temperatureUnit", "C");
  1024. });
  1025. var showF = findChildObject(this, 'showF');
  1026. showF.triggered.connect(function() {
  1027. for(var i = 0; i < temperatureDisplays.length; i++)
  1028. {
  1029. temperatureDisplays[i].setDisplayUnits(Units.Fahrenheit);
  1030. }
  1031. log.setDisplayUnits(Units.Fahrenheit);
  1032. graph.showF();
  1033. QSettings.setValue("temperatureUnit", "F");
  1034. });
  1035. if(QSettings.value("temperatureUnit", "F") == "C")
  1036. {
  1037. showC.trigger();
  1038. }
  1039. var clear = findChildObject(this, 'clear');
  1040. clear.triggered.connect(log.clear);
  1041. clear.triggered.connect(graph.clear);
  1042. clear.triggered.connect(function() {
  1043. window.windowTitle = "Typica [*]";
  1044. log.setHeaderData(0, "Time");
  1045. QSettings.setValue("liveColumn", 1);
  1046. window.postLoadColumnSetup(0);
  1047. if(typeof(externtrans) != 'undefined') {
  1048. externtrans.display(0);
  1049. }
  1050. });
  1051. var openMenu = findChildObject(this, 'open');
  1052. var compareMenu = findChildObject(this, 'compare');
  1053. compareMenu.triggered.connect(function() {
  1054. QSettings.setValue('cseries', lc+1);
  1055. var history = createReport("historyreport.xml");
  1056. history.windowTitle = TTR("basicWindow", "Typica - Roasting Log");
  1057. });
  1058. var printMenu = findChildObject(this, 'print');
  1059. printMenu.triggered.connect(function() {
  1060. var exportWindow = createWindow("print");
  1061. exportWindow.windowTitle = TTR("basicWindow", "Typica - Print");
  1062. exportWindow.log = log;
  1063. });
  1064. var svgExportMenu = findChildObject(this, 'svgexport');
  1065. svgExportMenu.triggered.connect(function() {
  1066. var exportWindow = createWindow("exportWindow");
  1067. exportWindow.windowTitle = TTR("basicWindow", "Typica - Export XHTML+SVG");
  1068. exportWindow.log = log;
  1069. });
  1070. openMenu.triggered.connect(function() {
  1071. var filename = QFileDialog.getOpenFileName(window, TTR("basicWindow", "Open Log..."), QSettings.value('script/lastDir', '') + '/');
  1072. if(filename != '') {
  1073. var file = new QFile(filename);
  1074. var input = new XMLInput(file, 1);
  1075. targetseries = -1;
  1076. input.newTemperatureColumn.connect(log.setHeaderData);
  1077. input.newTemperatureColumn.connect(function(col, text) {
  1078. if(text == window.targetcolumnname) {
  1079. targetseries = col;
  1080. }
  1081. });
  1082. input.newAnnotationColumn.connect(log.setHeaderData);
  1083. input.measure.connect(graph.newMeasurement);
  1084. input.measure.connect(log.newMeasurement);
  1085. input.measure.connect(function(data, series) {
  1086. if(series == targetseries) {
  1087. targetDetector.newMeasurement(data);
  1088. }
  1089. });
  1090. input.annotation.connect(log.newAnnotation);
  1091. input.annotation.connect(function(note, tcol, ncol) {
  1092. for(var i = tcol; i < ncol; i++) {
  1093. log.newAnnotation(note, i, ncol);
  1094. }
  1095. });
  1096. var lc;
  1097. input.lastColumn.connect(function(c) {
  1098. lc = c;
  1099. QSettings.setValue("liveColumn", c + 1);
  1100. window.postLoadColumnSetup(c);
  1101. });
  1102. graph.updatesEnabled = false;
  1103. log.updatesEnabled = false;
  1104. input.input();
  1105. log.updatesEnabled = true;
  1106. graph.updatesEnabled = true;
  1107. window.windowTitle = 'Typica - [*]' + baseName(filename);
  1108. QSettings.setValue("script/lastDir", dir(filename));
  1109. log.newAnnotation(TTR("basicWindow", "End"), 1, lc);
  1110. }
  1111. });
  1112. var columnName = function(c) {
  1113. var visibleColumns = 0;
  1114. for(var i = 0; i < channels.length; i++) {
  1115. if(channelVisibility[i]) {
  1116. visibleColumns++;
  1117. }
  1118. if(c == visibleColumns - 1) {
  1119. return columnNames[i];
  1120. }
  1121. }
  1122. return "";
  1123. };
  1124. window.postLoadColumnSetup = function(c) {
  1125. for(var i = 0; i < adapters.length; i++)
  1126. {
  1127. adapters[i].setColumn(c + i + 1);
  1128. zeroemitters[i].setColumn(c + i + 1);
  1129. log.setHeaderData(c + i + 1, columnName(i));
  1130. }
  1131. log.setHeaderData(c + columnNames.length + 1 - channelSkip, TTR("basicWindow", "Note"));
  1132. stop.setTemperatureColumn(c + 1);
  1133. stop.setAnnotationColumn(c + columnNames.length + 1 - channelSkip);
  1134. for(var i = 0; i < annotationButtons.length; i++)
  1135. {
  1136. annotationButtons[i].setTemperatureColumn(c + 1);
  1137. annotationButtons[i].setAnnotationColumn(c + columnNames.length + 1 - channelSkip);
  1138. }
  1139. log.clearCurrentColumnSet();
  1140. for(var i = 0; i < channels.length - channelSkip; i++) {
  1141. log.addToCurrentColumnSet(c + i + 1);
  1142. }
  1143. window.firstTempColumn = c + 1;
  1144. window.annotationColumn = c + columnNames.length - channelSkip + 1;
  1145. }
  1146. var saveMenu = findChildObject(this, 'save');
  1147. saveMenu.triggered.connect(function() {
  1148. var filename = QFileDialog.getSaveFileName(window, TTR("basicWindow", "Save Log As..."), QSettings.value("script/lastDir", "") + "/");
  1149. if(filename != "") {
  1150. var lc = Number(QSettings.value("liveColumn"));
  1151. var file = new QFile(filename);
  1152. log.clearOutputColumns();
  1153. channelSkip = 0;
  1154. for(var i = 0; i < channels.length; i++)
  1155. {
  1156. if(channelVisibility[i]) {
  1157. if(channelType[i] == "T") {
  1158. log.addOutputTemperatureColumn(lc + i - channelSkip);
  1159. }
  1160. else {
  1161. log.addOutputControlColumn(lc + i - channelSkip);
  1162. }
  1163. } else {
  1164. channelSkip++;
  1165. }
  1166. }
  1167. log.addOutputAnnotationColumn(lc + columnNames.length - channelSkip);
  1168. log.saveXML(file);
  1169. QSettings.setValue("script/lastDir", dir(filename));
  1170. }
  1171. });
  1172. var exportMenu = findChildObject(this, 'export');
  1173. exportMenu.triggered.connect(function() {
  1174. var filename = QFileDialog.getSaveFileName(window, TTR("basicWindow", "Export CSV As..."), QSettings.value("script/lastDir", "") + "/");
  1175. if(filename != "") {
  1176. var lc = Number(QSettings.value("liveColumn"));
  1177. var file = new QFile(filename);
  1178. log.clearOutputColumns();
  1179. for(var i = 0; i < columnNames.length - channelSkip; i++)
  1180. {
  1181. log.addOutputTemperatureColumn(lc + i);
  1182. }
  1183. log.addOutputAnnotationColumn(lc + columnNames.length - channelSkip);
  1184. log.saveCSV(file);
  1185. QSettings.setValue("script/lastDir", dir(filename));
  1186. }
  1187. });
  1188. var manual = findChildObject(this, 'manual');
  1189. manual.triggered.connect(function() {
  1190. var entry = new LogEditWindow();
  1191. entry.show();
  1192. });
  1193. var newMenu = findChildObject(this, 'new');
  1194. newMenu.triggered.connect(function() {
  1195. var bwindow = createWindow("batchWindow");
  1196. bwindow.windowTitle = TTR("basicWindow", "Typica - [*]New Batch");
  1197. });
  1198. var newSampleMenu = findChildObject(this, 'newsample');
  1199. newSampleMenu.triggered.connect(function() {
  1200. var bwindow = createWindow("sampleRoastingBatch");
  1201. });
  1202. window.postLoadColumnSetup(0);
  1203. Windows.loggingWindow = window;
  1204. ]]>
  1205. </program>
  1206. </window>