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

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