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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226
  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 == "modbusngport")
  382. {
  383. var device = new ModbusNG(configModel, driverIndex);
  384. modbusdevices.push(device);
  385. for(var j = 0; j < device.channelCount(); j++) {
  386. channels.push(device.getChannel(j));
  387. columnNames.push(device.channelColumnName(j));
  388. channelType.push("T");
  389. if(device.isChannelHidden(j)) {
  390. channelVisibility.push(false);
  391. } else {
  392. channelVisibility.push(true);
  393. var indicator = new TemperatureDisplay;
  394. temperatureDisplays.push(indicator);
  395. var decorator = new WidgetDecorator(indicator, device.channelIndicatorText(j), 2);
  396. device.getChannel(j).newData.connect(indicator.setValue);
  397. indicatorPanel.addWidget(decorator);
  398. }
  399. }
  400. }
  401. else if(driverReference.driver == "unsupporteddevice")
  402. {
  403. var device = createDevice(driverIndex);
  404. for(var j = 0; j < device.channelCount(); j++) {
  405. channels.push(device.getChannel(j));
  406. columnNames.push(device.channelColumnName(j));
  407. var unit = device.expectedChannelUnit(j);
  408. if(unit == Units.Fahrenheit) {
  409. channelType.push("T");
  410. } else {
  411. channelType.push("C");
  412. }
  413. if(device.isChannelHidden(j)) {
  414. channelVisibility.push(false);
  415. } else {
  416. channelVisibility.push(true);
  417. var indicator = new TemperatureDisplay;
  418. if(unit == Units.Unitless) {
  419. indicator.setDisplayUnits(Units.Unitless);
  420. indicator.digitCount = 6;
  421. }
  422. temperatureDisplays.push(indicator);
  423. var decorator = new WidgetDecorator(indicator, device.channelIndicatorText(j), 2);
  424. device.getChannel(j).newData.connect(indicator.setValue);
  425. indicatorPanel.addWidget(decorator);
  426. }
  427. }
  428. device.start();
  429. jsdevices.push(device);
  430. }
  431. else if(driverReference.driver == "phidgets1048")
  432. {
  433. var device = new PhidgetsTemperatureSensor(driverIndex);
  434. for(var j = 0; j < device.channelCount(); j++) {
  435. channels.push(device.getChannel(j));
  436. columnNames.push(device.channelColumnName(j));
  437. channelType.push("T");
  438. if(device.isChannelHidden(j)) {
  439. channelVisibility.push(false);
  440. } else {
  441. channelVisibility.push(true);
  442. var indicator = new TemperatureDisplay;
  443. temperatureDisplays.push(indicator);
  444. var decorator = new WidgetDecorator(indicator, device.channelIndicatorText(j), 2);
  445. device.getChannel(j).newData.connect(indicator.setValue);
  446. indicatorPanel.addWidget(decorator);
  447. }
  448. }
  449. device.start();
  450. pdevices.push(device);
  451. }
  452. else if(driverReference.driver == "annotationbutton")
  453. {
  454. var button = new AnnotationButton(driverReference.buttontext);
  455. button.setAnnotation(driverReference.annotationtext);
  456. annotationButtons.push(button);
  457. annotationPanel.addWidget(button);
  458. tabControls.push(button);
  459. }
  460. else if(driverReference.driver == "valueannotation")
  461. {
  462. var checker = new ValueAnnotation;
  463. var valuesSetting = driverReference.measuredValues;
  464. var notesSetting = driverReference.annotations;
  465. var valuesList = valuesSetting.slice(2, valuesSetting.length-2).split(",");
  466. var notesList = notesSetting.slice(2, notesSetting.length-2).split(",");
  467. if(valuesList.length > 1 && notesList.length == valuesList.length) {
  468. for(var j = 0; j < valuesList.length; j++) {
  469. checker.setAnnotation(Number(valuesList[j]), notesList[j]);
  470. }
  471. }
  472. if(driverReference.emitOnStart == "true") {
  473. start.clicked.connect(checker.annotate);
  474. }
  475. var colname = driverReference.source;
  476. for(var j = 0; j < columnNames.length; j++) {
  477. if(columnNames[j] == colname) {
  478. channels[j].newData.connect(checker.newMeasurement);
  479. break;
  480. }
  481. }
  482. annotationButtons.push(checker);
  483. }
  484. else if(driverReference.driver == "reconfigurablebutton")
  485. {
  486. var button = new AnnotationButton(driverReference.buttontext);
  487. button.setAnnotation(driverReference.annotationtext);
  488. annotationButtons.push(button);
  489. annotationPanel.addWidget(button);
  490. tabControls.push(button);
  491. nsparam.enabled = true;
  492. nsparam.triggered.connect(function() {
  493. var setParam = createWindow("sampleParameters");
  494. setParam.windowTitle = "Typica - Set Sample Parameters";
  495. setParam.button = button;
  496. });
  497. }
  498. else if(driverReference.driver == "annotationspinbox")
  499. {
  500. var layout = new QBoxLayout;
  501. var label = new QLabel(driverReference.label);
  502. layout.addWidget(label, 0, 2);
  503. var spinbox = new AnnotationSpinBox;
  504. spinbox.setPretext(driverReference.pretext);
  505. spinbox.setPosttext(driverReference.posttext);
  506. spinbox.minimum = driverReference.minimum;
  507. spinbox.maximum = driverReference.maximum;
  508. spinbox.decimals = driverReference.precision;
  509. layout.addWidget(spinbox, 0, 1);
  510. annotationPanel.addLayout(layout);
  511. annotationButtons.push(spinbox);
  512. tabControls.push(spinbox);
  513. }
  514. else if(driverReference.driver == "freeannotation")
  515. {
  516. var layout = new QBoxLayout;
  517. var label = new QLabel(driverReference.labeltext);
  518. var control = new QLineEdit;
  519. layout.addWidget(label, 0, 2);
  520. layout.addWidget(control, 0, 1);
  521. annotationPanel.addLayout(layout);
  522. tabControls.push(control);
  523. control.returnPressed.connect(function() {
  524. for(var i = window.firstTempColumn; i < window.annotationColumn; i++) {
  525. log.newAnnotation(control.text, i, window.annotationColumn);
  526. }
  527. });
  528. }
  529. else if(driverReference.driver == "linearspline")
  530. {
  531. var colname = driverReference.source;
  532. for(var j = 0; j < columnNames.length; j++)
  533. {
  534. if(columnNames[j] == colname)
  535. {
  536. var calibrator = new LinearSplineInterpolator;
  537. var sv = driverReference.sourcevalues;
  538. var dv = driverReference.destinationvalues;
  539. var sourcevalues = sv.slice(2, sv.length-2).split(",");
  540. var destvalues = dv.slice(2, dv.length-2).split(",");
  541. if(sourcevalues.length > 1 && destvalues.length == sourcevalues.length)
  542. {
  543. for(var k = 0; k < sourcevalues.length; k++)
  544. {
  545. calibrator.add_pair(Number(sourcevalues[k]),Number(destvalues[k]));
  546. }
  547. var indicator = new TemperatureDisplay;
  548. temperatureDisplays.push(indicator);
  549. var decorator = new WidgetDecorator(indicator, configModel.data(driverIndex, 0), 2);
  550. channels[j].newData.connect(calibrator.newMeasurement);
  551. calibrator.newData.connect(indicator.setValue);
  552. channels.push(calibrator);
  553. // Channel hiding is not yet configurable for this.
  554. // I'm not sure if there's any need to allow this
  555. // to be hidden at present.
  556. channelVisibility.push(true);
  557. channelType.push(channelType[j]);
  558. columnNames.push(driverReference.destination);
  559. indicatorPanel.addWidget(decorator);
  560. }
  561. break;
  562. }
  563. }
  564. }
  565. else if(driverReference.driver == "translation")
  566. {
  567. var colname = driverReference.column;
  568. window.targetcolumnname = colname;
  569. for(var j = 0; j < columnNames.length; j++)
  570. {
  571. if(columnNames[j] == colname)
  572. {
  573. translationChannel = j;
  574. var indicator = new TemperatureDisplay;
  575. indicator.digitCount = 4;
  576. externtrans = indicator;
  577. indicator.display(0);
  578. var decorator = new WidgetDecorator(indicator, configModel.data(driverIndex, 0), 2);
  579. indicatorPanel.addWidget(decorator);
  580. currentDetector.timeForValue.connect(function(value) {
  581. if(!hasTranslated)
  582. {
  583. var currentOffset = value;
  584. if(targetOffset != 0)
  585. {
  586. var translation = currentOffset - targetOffset;
  587. externtrans.display(translation);
  588. gtrans = translation;
  589. if(translation > 0)
  590. {
  591. window.translateLoadedSeries(translation);
  592. }
  593. else
  594. {
  595. window.translateCurrentSeries(-translation);
  596. }
  597. }
  598. }
  599. hasTranslated = true;
  600. });
  601. var resetTranslation = findChildObject(this, 'unshift');
  602. resetTranslation.triggered.connect(function() {
  603. if(gtrans > 0) {
  604. window.translateLoadedSeries(-gtrans);
  605. }
  606. else {
  607. window.translateCurrentSeries(gtrans);
  608. }
  609. gtrans = 0;
  610. indicator.display(0);
  611. });
  612. }
  613. }
  614. targetDetector.setThreshold(driverReference.FValue);
  615. currentDetector.setThreshold(driverReference.FValue);
  616. }
  617. else if(driverReference.driver == "rate")
  618. {
  619. var primaryColumn = driverReference.column;
  620. for(var j = 0; j < columnNames.length; j++)
  621. {
  622. if(columnNames[j] == primaryColumn)
  623. {
  624. var rate = new RateOfChange(driverReference.cache, driverReference.scale);
  625. channels[j].newData.connect(rate.newMeasurement);
  626. var indicator = new TemperatureDisplay;
  627. indicator.setRelativeMode(true);
  628. indicator.display(0);
  629. indicator.digitCount = 9;
  630. var decorator = new WidgetDecorator(indicator, configModel.data(driverIndex, 0), 2);
  631. indicatorPanel.addWidget(decorator);
  632. rate.newData.connect(indicator.setValue);
  633. temperatureDisplays.push(indicator);
  634. channels.push(rate);
  635. // This cannot at present be configured to be
  636. // hidden.
  637. channelVisibility.push(true);
  638. channelType.push("T");
  639. columnNames.push(configModel.data(driverIndex, 0));
  640. }
  641. }
  642. }
  643. else if(driverReference.driver == "scale")
  644. {
  645. var scale = new SerialScale(driverReference.port);
  646. scale.setDataBits(8);
  647. scale.setBaudRate(driverReference.baudrate);
  648. scale.setParity(driverReference.parity);
  649. scale.setStopBits(driverReference.stopbits);
  650. scale.setFlowControl(driverReference.flowcontrol);
  651. scale.setWeighCommand(driverReference.weighcommand);
  652. scale.setCommandTerminator(driverReference.commandterminator);
  653. scale.open(3);
  654. window.scales.push(scale);
  655. }
  656. else if(driverReference.driver == "coolingtimer")
  657. {
  658. var coolingTimer = new TimerDisplay();
  659. coolingTimer.setDisplayFormat("mm:ss");
  660. var decorator = new WidgetDecorator(coolingTimer, configModel.data(driverIndex, 0), 2);
  661. indicatorPanel.addWidget(decorator);
  662. coolingTimer.setTimerMode(1);
  663. coolingTimer.setAutoReset(true);
  664. var timeValue = new QTime();
  665. timeValue = timeValue.fromString(driverReference.reset, "mm:ss");
  666. coolingTimer.setResetValue(timeValue);
  667. stop.clicked.connect(coolingTimer.startTimer);
  668. }
  669. else if(driverReference.driver == "rangetimer")
  670. {
  671. rangetimers.push(new TimerDisplay());
  672. var rangeTimer = rangetimers[rangetimers.length - 1];
  673. rangeTimer.setDisplayFormat("mm:ss");
  674. var decorator = new WidgetDecorator(rangeTimer, configModel.data(driverIndex, 0), 2);
  675. indicatorPanel.addWidget(decorator);
  676. stop.clicked.connect(rangeTimer.stopTimer);
  677. start.clicked.connect(rangeTimer.reset);
  678. if(driverReference.starttrigger == "batch")
  679. {
  680. start.clicked.connect(rangeTimer.startTimer);
  681. }
  682. else if(driverReference.starttrigger == "manual")
  683. {
  684. var startButton = new AnnotationButton(driverReference.startbuttontext);
  685. startButton.clicked.connect(rangeTimer.startTimer);
  686. annotationPanel.addWidget(startButton);
  687. tabControls.push(button);
  688. }
  689. else if(driverReference.starttrigger == "value")
  690. {
  691. var startTrigger = new ThresholdDetector();
  692. startTrigger.setThreshold(Number(driverReference.startvalue));
  693. var scope = new Object;
  694. scope.invoke = function() {
  695. if(timer.running && !(arguments.callee.rangeTimer.running))
  696. {
  697. arguments.callee.rangeTimer.startTimer();
  698. }
  699. };
  700. scope.invoke.rangeTimer = rangeTimer;
  701. startTrigger.timeForValue.connect(scope.invoke);
  702. for(var j = 0; j < columnNames.length; j++)
  703. {
  704. if(columnNames[j] == driverReference.startcolumnname)
  705. {
  706. channels[j].newData.connect(startTrigger.newMeasurement);
  707. }
  708. }
  709. }
  710. stop.clicked.connect(rangeTimer.stopTimer)
  711. if(driverReference.stoptrigger == "manual")
  712. {
  713. var stopButton = new AnnotationButton(driverReference.stopbuttontext);
  714. stopButton.clicked.connect(rangeTimer.stopTimer);
  715. annotationPanel.addWidget(stopButton);
  716. tabControls.push(button);
  717. }
  718. else if(driverReference.stoptrigger == "value")
  719. {
  720. var stopTrigger = new ThresholdDetector();
  721. stopTrigger.setThreshold(Number(driverReference.stopvalue));
  722. stopTrigger.timeForValue.connect(rangeTimer.stopTimer);
  723. for(var j = 0; j < columnNames.length; j++)
  724. {
  725. if(columnNames[j] == driverReference.stopcolumnname)
  726. {
  727. channels[j].newData.connect(stopTrigger.newMeasurement);
  728. }
  729. }
  730. }
  731. rangeTimer.reportingName = configModel.data(driverIndex, 0);
  732. rangeTimer.report = function() {
  733. return "" + this.reportingName + ": " + this.value;
  734. };
  735. }
  736. else if(driverReference.driver = "multirangetimer")
  737. {
  738. var rangeTimer = new TimerDisplay();
  739. rangeTimer.setDisplayFormat("mm:ss");
  740. var decorator = new WidgetDecorator(rangeTimer, configModel.data(driverIndex, 0), 2);
  741. indicatorPanel.addWidget(decorator);
  742. var rangenames = driverReference.rangenames;
  743. var endtemps = driverReference.endtemps;
  744. var names = rangenames.slice(2, rangenames.length - 2).split(", ");
  745. rangeTimer.rangeNames = new Array();
  746. for(var j = 0; j < names.length; j++)
  747. {
  748. var name = names[j].slice(1, names[j].length - 1);
  749. rangeTimer.rangeNames.push(name);
  750. }
  751. rangeTimer.rangeEnds = new Array();
  752. var ends = endtemps.slice(2, endtemps.length - 2).split(", ");
  753. for(var j = 0; j < ends.length; j++)
  754. {
  755. rangeTimer.rangeEnds.push(Number(ends[j]));
  756. }
  757. rangeTimer.currentRange = 0;
  758. rangeTimer.results = new Array();
  759. rangeTimer.trigger = new ThresholdDetector();
  760. for(var j = 0; j < columnNames.length; j++)
  761. {
  762. if(columnNames[j] == driverReference.trigger)
  763. {
  764. channels[j].newData.connect(rangeTimer.trigger.newMeasurement);
  765. }
  766. }
  767. rangeTimer.startRanges = function() {
  768. arguments.callee.timer.currentRange = 0;
  769. arguments.callee.timer.results.splice(0, arguments.callee.timer.results.length);
  770. arguments.callee.timer.trigger.setThreshold(arguments.callee.timer.rangeEnds[0]);
  771. };
  772. rangeTimer.startRanges.timer = rangeTimer;
  773. start.clicked.connect(rangeTimer.startTimer);
  774. start.clicked.connect(rangeTimer.startRanges);
  775. rangeTimer.transition = function() {
  776. arguments.callee.timer.stopTimer();
  777. arguments.callee.timer.results.push(arguments.callee.timer.value);
  778. arguments.callee.timer.reset();
  779. arguments.callee.timer.startTimer();
  780. arguments.callee.timer.currentRange++;
  781. if(arguments.callee.timer.currentRange <= arguments.callee.timer.rangeEnds.length)
  782. {
  783. arguments.callee.timer.trigger.setThreshold(arguments.callee.timer.rangeEnds[arguments.callee.timer.currentRange]);
  784. }
  785. };
  786. rangeTimer.transition.timer = rangeTimer;
  787. rangeTimer.trigger.timeForValue.connect(rangeTimer.transition);
  788. stop.clicked.connect(rangeTimer.transition);
  789. stop.clicked.connect(rangeTimer.stopTimer);
  790. rangeTimer.report = function() {
  791. var retval = "";
  792. for(var j = 0; j < arguments.callee.timer.results.length; j++)
  793. {
  794. retval += arguments.callee.timer.rangeNames[j] + ": " + arguments.callee.timer.results[j] + "\n";
  795. }
  796. return retval;
  797. };
  798. rangeTimer.report.timer = rangeTimer;
  799. rangetimers.push(rangeTimer);
  800. }
  801. }
  802. }
  803. for(var i = 1; i < tabControls.length; i++)
  804. {
  805. setTabOrder(tabControls[i-1], tabControls[i]);
  806. }
  807. log.setHeaderData(0, "Time");
  808. var channelSkip = 0;
  809. for(var i = 0; i < columnNames.length; i++) {
  810. if(channelVisibility[i]) {
  811. log.setHeaderData(i + 1 - channelSkip, columnNames[i]);
  812. log.addToCurrentColumnSet(i + 1 - channelSkip);
  813. }
  814. else {
  815. channelSkip++;
  816. }
  817. }
  818. log.setHeaderData(columnNames.length + 1 - channelSkip, TTR("basicWindow", "Note"));
  819. var timer = new TimerDisplay;
  820. timer.displayFormat = "mm:ss";
  821. timer.autoReset = true;
  822. var btdecorator = new WidgetDecorator(timer, TTR("basicWindow", "Batch Timer"), 2);
  823. indicatorPanel.addWidget(btdecorator);
  824. var vsplit = findChildObject(this, 'main');
  825. var isplit = findChildObject(this, 'indicators');
  826. var lsplit = findChildObject(this, 'logsplit');
  827. window.aboutToClose.connect(function() {
  828. for(var i = 0; i < nidevices.length; i++)
  829. {
  830. nidevices[i].stop();
  831. nidevices[i].deleteLater();
  832. }
  833. for(var i = 0; i < modbusdevices.length; i++)
  834. {
  835. modbusdevices[i].deleteLater();
  836. }
  837. for(var i = 0; i < dataqsdkdevices.length; i++)
  838. {
  839. dataqsdkdevices[i].deleteLater();
  840. }
  841. for(var i = 0; i < jsdevices.length; i++)
  842. {
  843. jsdevices[i].stop();
  844. jsdevices[i].deleteLater();
  845. }
  846. for(var i = 0; i < pdevices.length; i++)
  847. {
  848. pdevices[i].stop();
  849. pdevices[i].deleteLater();
  850. }
  851. delete nidevices;
  852. delete modbusdevices;
  853. delete dataqsdkdevices;
  854. delete jsdevices;
  855. delete pdevices;
  856. window.saveSizeAndPosition("window");
  857. vsplit.saveState("script/loggingView/" + roasterIndex + "/mainSplitter");
  858. QSettings.setValue("script/loggingView/" + roasterIndex + "/instrumentCount", isplit.count());
  859. isplit.saveState("script/loggingView/" + roasterIndex + "/instrumentSplitter");
  860. lsplit.saveState("script/loggingView/" + roasterIndex + "/logSplitter");
  861. log.saveState("script/log", 7);
  862. window.navigationWindow.loggingWindow = undefined;
  863. Windows.loggingWindow = undefined;
  864. });
  865. this.restoreSizeAndPosition('window');
  866. vsplit.restoreState("script/loggingView/" + roasterIndex + "/mainSplitter");
  867. if(QSettings.value("script/loggingView/" + roasterIndex + "/instrumentCount") == isplit.count()) {
  868. isplit.restoreState("script/loggingView/" + roasterIndex + "/instrumentSplitter");
  869. }
  870. lsplit.restoreState("script/loggingView/" + roasterIndex + "/logSplitter");
  871. log.restoreState("script/log", 7);
  872. var offsets = new Array();
  873. var zeroemitters = new Array();
  874. var adapters = new Array();
  875. channelSkip = 0;
  876. for(var i = 0; i < channels.length; i++) {
  877. if(channelVisibility[i]) {
  878. var offset = new MeasurementTimeOffset(epoch);
  879. offsets.push(offset);
  880. channels[i].newData.connect(offset.newMeasurement);
  881. var adapter = new MeasurementAdapter(i + 1 - channelSkip);
  882. adapters.push(adapter);
  883. offset.measurement.connect(adapter.newMeasurement);
  884. var emitter = new ZeroEmitter(i + 1);
  885. zeroemitters.push(emitter);
  886. channels[i].newData.connect(emitter.newMeasurement);
  887. emitter.measurement.connect(log.newMeasurement);
  888. emitter.measurement.connect(graph.newMeasurement);
  889. } else {
  890. channelSkip++;
  891. }
  892. }
  893. var offsetForChannel = function(c) {
  894. var retval = -1;
  895. for(var i = 0; i <= c; i++) {
  896. if(channelVisibility[i]) {
  897. retval++;
  898. }
  899. }
  900. return retval;
  901. };
  902. start.clicked.connect(function() {
  903. start.enabled = false;
  904. hasTranslated = false;
  905. var epoch = new QTime();
  906. epoch = epoch.currentTime();
  907. for(var i = 0; i < offsets.length; i++)
  908. {
  909. offsets[i].setZeroTime(epoch);
  910. zeroemitters[i].emitZero();
  911. adapters[i].measurement.connect(log.newMeasurement);
  912. adapters[i].measurement.connect(graph.newMeasurement);
  913. }
  914. for(var i = 0; i < rateadapters.length; i++)
  915. {
  916. rateoffsets[i].setZeroTime(epoch);
  917. ratezeros[i].emitZero();
  918. rateadapters[i].measurement.connect(graph.newMeasurement);
  919. }
  920. timer.startTimer();
  921. if(typeof(currentBatchInfo) == 'undefined') { } else {
  922. query = new QSqlQuery();
  923. query.exec("SELECT now()::timestamp without time zone");
  924. query.next();
  925. var result = query.value(0);
  926. query = query.invalidate();
  927. var timefield = findChildObject(currentBatchInfo, 'time');
  928. timefield.text = result.replace('T', ' ');
  929. }
  930. if(translationChannel >= 0)
  931. {
  932. offsets[offsetForChannel(translationChannel)].measurement.connect(currentDetector.newMeasurement);
  933. }
  934. if(typeof(externtrans) != 'undefined') {
  935. externtrans.display(0);
  936. }
  937. stop.enabled = true;
  938. window.windowModified = true;
  939. graph.setTimeIndicatorEnabled(true);
  940. });
  941. for(var i = 0; i < annotationButtons.length; i++) {
  942. if(channels.length > 0)
  943. {
  944. annotationButtons[i].annotation.connect(log.newAnnotation);
  945. annotationButtons[i].setTemperatureColumn(1);
  946. annotationButtons[i].setAnnotationColumn(channels.length - channelSkip + 1);
  947. annotationButtons[i].annotation.connect(function(note, tcol, ncol) {
  948. for(var i = tcol; i < ncol; i++) {
  949. log.newAnnotation(note, i, ncol);
  950. }
  951. });
  952. }
  953. }
  954. start.setFocus();
  955. stop.annotation.connect(log.newAnnotation);
  956. stop.clicked.connect(timer.stopTimer);
  957. stop.setTemperatureColumn(1);
  958. stop.setAnnotationColumn(channels.length - channelSkip + 1);
  959. QSettings.setValue("liveColumn", 1);
  960. var lc = 1;
  961. stop.clicked.connect(function() {
  962. stop.enabled = false;
  963. for(var i = 0; i < adapters.length; i++)
  964. {
  965. adapters[i].measurement.disconnect(log.newMeasurement);
  966. adapters[i].measurement.disconnect(graph.newMeasurement);
  967. }
  968. for(var i = 0; i < rateadapters.length; i++)
  969. {
  970. rateadapters[i].measurement.disconnect(graph.newMeasurement);
  971. }
  972. if(typeof(currentBatchInfo) == 'undefined') { } else {
  973. lc = Number(QSettings.value("liveColumn"));
  974. var duration = log.lastTime(lc);
  975. var durfield = findChildObject(currentBatchInfo, 'duration');
  976. durfield.text = duration;
  977. log.clearOutputColumns();
  978. channelSkip = 0;
  979. for(var i = 0; i < channels.length; i++) {
  980. if(channelVisibility[i]) {
  981. if(channelType[i] == "T") {
  982. log.addOutputTemperatureColumn(lc + i - channelSkip);
  983. }
  984. else {
  985. log.addOutputControlColumn(lc + i - channelSkip);
  986. }
  987. } else {
  988. channelSkip++;
  989. }
  990. }
  991. log.addOutputAnnotationColumn(lc + channels.length - channelSkip);
  992. var filename = log.saveTemporary();
  993. currentBatchInfo.tempData = filename;
  994. currentBatchInfo.endBatch();
  995. var notes = findChildObject(currentBatchInfo, 'annotation');
  996. for(var i = 0; i < rangetimers.length; i++)
  997. {
  998. notes.append(rangetimers[i].report());
  999. }
  1000. currentBatchInfo.raise();
  1001. currentBatchInfo.activateWindow();
  1002. }
  1003. if(translationChannel >= 0)
  1004. {
  1005. offsets[offsetForChannel(translationChannel)].measurement.disconnect(currentDetector.newMeasurement);
  1006. }
  1007. start.enabled = true;
  1008. window.windowModified = false;
  1009. graph.setTimeIndicatorEnabled(false);
  1010. });
  1011. stop.annotation.connect(function(note, tcol, ncol) {
  1012. for(var i = tcol; i < ncol; i++) {
  1013. log.newAnnotation(note, i, ncol);
  1014. }
  1015. });
  1016. var quitMenu = findChildObject(this, 'quit');
  1017. quitMenu.triggered.connect(function() {
  1018. window.close();
  1019. Application.quit();
  1020. });
  1021. var v1 = findChildObject(this, 'ms');
  1022. v1.triggered.connect(log.LOD_ms);
  1023. var v2 = findChildObject(this, '1s');
  1024. v2.triggered.connect(log.LOD_1s);
  1025. var v3 = findChildObject(this, '5s');
  1026. v3.triggered.connect(log.LOD_5s);
  1027. var v4 = findChildObject(this, '10s');
  1028. v4.triggered.connect(log.LOD_10s);
  1029. var v5 = findChildObject(this, '15s');
  1030. v5.triggered.connect(log.LOD_15s);
  1031. var v6 = findChildObject(this, '30s');
  1032. v6.triggered.connect(log.LOD_30s);
  1033. var v7 = findChildObject(this, '1m');
  1034. v7.triggered.connect(log.LOD_1m);
  1035. var showC = findChildObject(this, 'showC');
  1036. showC.triggered.connect(function() {
  1037. for(var i = 0; i < temperatureDisplays.length; i++)
  1038. {
  1039. temperatureDisplays[i].setDisplayUnits(Units.Celsius);
  1040. }
  1041. log.setDisplayUnits(Units.Celsius);
  1042. graph.showC();
  1043. QSettings.setValue("temperatureUnit", "C");
  1044. });
  1045. var showF = findChildObject(this, 'showF');
  1046. showF.triggered.connect(function() {
  1047. for(var i = 0; i < temperatureDisplays.length; i++)
  1048. {
  1049. temperatureDisplays[i].setDisplayUnits(Units.Fahrenheit);
  1050. }
  1051. log.setDisplayUnits(Units.Fahrenheit);
  1052. graph.showF();
  1053. QSettings.setValue("temperatureUnit", "F");
  1054. });
  1055. if(QSettings.value("temperatureUnit", "F") == "C")
  1056. {
  1057. showC.trigger();
  1058. }
  1059. var clear = findChildObject(this, 'clear');
  1060. clear.triggered.connect(log.clear);
  1061. clear.triggered.connect(graph.clear);
  1062. clear.triggered.connect(function() {
  1063. window.windowTitle = "Typica [*]";
  1064. log.setHeaderData(0, "Time");
  1065. QSettings.setValue("liveColumn", 1);
  1066. window.postLoadColumnSetup(0);
  1067. if(typeof(externtrans) != 'undefined') {
  1068. externtrans.display(0);
  1069. }
  1070. });
  1071. var openMenu = findChildObject(this, 'open');
  1072. var compareMenu = findChildObject(this, 'compare');
  1073. compareMenu.triggered.connect(function() {
  1074. QSettings.setValue('cseries', lc+1);
  1075. var history = createReport("historyreport.xml");
  1076. history.windowTitle = TTR("basicWindow", "Typica - Roasting Log");
  1077. });
  1078. var printMenu = findChildObject(this, 'print');
  1079. printMenu.triggered.connect(function() {
  1080. var exportWindow = createWindow("print");
  1081. exportWindow.windowTitle = TTR("basicWindow", "Typica - Print");
  1082. exportWindow.log = log;
  1083. });
  1084. var svgExportMenu = findChildObject(this, 'svgexport');
  1085. svgExportMenu.triggered.connect(function() {
  1086. var exportWindow = createWindow("exportWindow");
  1087. exportWindow.windowTitle = TTR("basicWindow", "Typica - Export XHTML+SVG");
  1088. exportWindow.log = log;
  1089. });
  1090. openMenu.triggered.connect(function() {
  1091. var filename = QFileDialog.getOpenFileName(window, TTR("basicWindow", "Open Log..."), QSettings.value('script/lastDir', '') + '/');
  1092. if(filename != '') {
  1093. var file = new QFile(filename);
  1094. var input = new XMLInput(file, 1);
  1095. targetseries = -1;
  1096. input.newTemperatureColumn.connect(log.setHeaderData);
  1097. input.newTemperatureColumn.connect(function(col, text) {
  1098. if(text == window.targetcolumnname) {
  1099. targetseries = col;
  1100. }
  1101. });
  1102. input.newAnnotationColumn.connect(log.setHeaderData);
  1103. input.measure.connect(graph.newMeasurement);
  1104. input.measure.connect(log.newMeasurement);
  1105. input.measure.connect(function(data, series) {
  1106. if(series == targetseries) {
  1107. targetDetector.newMeasurement(data);
  1108. }
  1109. });
  1110. input.annotation.connect(log.newAnnotation);
  1111. input.annotation.connect(function(note, tcol, ncol) {
  1112. for(var i = tcol; i < ncol; i++) {
  1113. log.newAnnotation(note, i, ncol);
  1114. }
  1115. });
  1116. var lc;
  1117. input.lastColumn.connect(function(c) {
  1118. lc = c;
  1119. QSettings.setValue("liveColumn", c + 1);
  1120. window.postLoadColumnSetup(c);
  1121. });
  1122. graph.updatesEnabled = false;
  1123. log.updatesEnabled = false;
  1124. input.input();
  1125. log.updatesEnabled = true;
  1126. graph.updatesEnabled = true;
  1127. window.windowTitle = 'Typica - [*]' + baseName(filename);
  1128. QSettings.setValue("script/lastDir", dir(filename));
  1129. log.newAnnotation(TTR("basicWindow", "End"), 1, lc);
  1130. }
  1131. });
  1132. var columnName = function(c) {
  1133. var visibleColumns = 0;
  1134. for(var i = 0; i < channels.length; i++) {
  1135. if(channelVisibility[i]) {
  1136. visibleColumns++;
  1137. }
  1138. if(c == visibleColumns - 1) {
  1139. return columnNames[i];
  1140. }
  1141. }
  1142. return "";
  1143. };
  1144. window.postLoadColumnSetup = function(c) {
  1145. for(var i = 0; i < adapters.length; i++)
  1146. {
  1147. adapters[i].setColumn(c + i + 1);
  1148. zeroemitters[i].setColumn(c + i + 1);
  1149. log.setHeaderData(c + i + 1, columnName(i));
  1150. }
  1151. log.setHeaderData(c + columnNames.length + 1 - channelSkip, TTR("basicWindow", "Note"));
  1152. stop.setTemperatureColumn(c + 1);
  1153. stop.setAnnotationColumn(c + columnNames.length + 1 - channelSkip);
  1154. for(var i = 0; i < annotationButtons.length; i++)
  1155. {
  1156. annotationButtons[i].setTemperatureColumn(c + 1);
  1157. annotationButtons[i].setAnnotationColumn(c + columnNames.length + 1 - channelSkip);
  1158. }
  1159. log.clearCurrentColumnSet();
  1160. for(var i = 0; i < channels.length - channelSkip; i++) {
  1161. log.addToCurrentColumnSet(c + i + 1);
  1162. }
  1163. window.firstTempColumn = c + 1;
  1164. window.annotationColumn = c + columnNames.length - channelSkip + 1;
  1165. }
  1166. var saveMenu = findChildObject(this, 'save');
  1167. saveMenu.triggered.connect(function() {
  1168. var filename = QFileDialog.getSaveFileName(window, TTR("basicWindow", "Save Log As..."), QSettings.value("script/lastDir", "") + "/");
  1169. if(filename != "") {
  1170. var lc = Number(QSettings.value("liveColumn"));
  1171. var file = new QFile(filename);
  1172. log.clearOutputColumns();
  1173. channelSkip = 0;
  1174. for(var i = 0; i < channels.length; i++)
  1175. {
  1176. if(channelVisibility[i]) {
  1177. if(channelType[i] == "T") {
  1178. log.addOutputTemperatureColumn(lc + i - channelSkip);
  1179. }
  1180. else {
  1181. log.addOutputControlColumn(lc + i - channelSkip);
  1182. }
  1183. } else {
  1184. channelSkip++;
  1185. }
  1186. }
  1187. log.addOutputAnnotationColumn(lc + columnNames.length - channelSkip);
  1188. log.saveXML(file);
  1189. QSettings.setValue("script/lastDir", dir(filename));
  1190. }
  1191. });
  1192. var exportMenu = findChildObject(this, 'export');
  1193. exportMenu.triggered.connect(function() {
  1194. var filename = QFileDialog.getSaveFileName(window, TTR("basicWindow", "Export CSV As..."), QSettings.value("script/lastDir", "") + "/");
  1195. if(filename != "") {
  1196. var lc = Number(QSettings.value("liveColumn"));
  1197. var file = new QFile(filename);
  1198. log.clearOutputColumns();
  1199. for(var i = 0; i < columnNames.length - channelSkip; i++)
  1200. {
  1201. log.addOutputTemperatureColumn(lc + i);
  1202. }
  1203. log.addOutputAnnotationColumn(lc + columnNames.length - channelSkip);
  1204. log.saveCSV(file);
  1205. QSettings.setValue("script/lastDir", dir(filename));
  1206. }
  1207. });
  1208. var manual = findChildObject(this, 'manual');
  1209. manual.triggered.connect(function() {
  1210. var entry = new LogEditWindow();
  1211. entry.show();
  1212. });
  1213. var newMenu = findChildObject(this, 'new');
  1214. newMenu.triggered.connect(function() {
  1215. var bwindow = createWindow("batchWindow");
  1216. bwindow.windowTitle = TTR("basicWindow", "Typica - [*]New Batch");
  1217. });
  1218. var newSampleMenu = findChildObject(this, 'newsample');
  1219. newSampleMenu.triggered.connect(function() {
  1220. var bwindow = createWindow("sampleRoastingBatch");
  1221. });
  1222. window.postLoadColumnSetup(0);
  1223. Windows.loggingWindow = window;
  1224. ]]>
  1225. </program>
  1226. </window>