Typica is a free program for professional coffee roasters. https://typica.us
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

productionroaster.xml 54KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327
  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 = "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. var clear = findChildObject(this, 'clear');
  1167. clear.triggered.connect(log.clear);
  1168. clear.triggered.connect(graph.clear);
  1169. clear.triggered.connect(function() {
  1170. window.windowTitle = "Typica [*]";
  1171. log.setHeaderData(0, "Time");
  1172. QSettings.setValue("liveColumn", 1);
  1173. window.postLoadColumnSetup(0);
  1174. if(typeof(externtrans) != 'undefined') {
  1175. externtrans.display(0);
  1176. }
  1177. resetTranslation.enabled = false;
  1178. setTranslation.enabled = false;
  1179. });
  1180. var openMenu = findChildObject(this, 'open');
  1181. var compareMenu = findChildObject(this, 'compare');
  1182. compareMenu.triggered.connect(function() {
  1183. QSettings.setValue('cseries', lc+1);
  1184. var history = createReport("historyreport.xml");
  1185. history.windowTitle = TTR("basicWindow", "Typica - Roasting Log");
  1186. });
  1187. var printMenu = findChildObject(this, 'print');
  1188. printMenu.triggered.connect(function() {
  1189. var exportWindow = createWindow("print");
  1190. exportWindow.windowTitle = TTR("basicWindow", "Typica - Print");
  1191. exportWindow.log = log;
  1192. });
  1193. var svgExportMenu = findChildObject(this, 'svgexport');
  1194. svgExportMenu.triggered.connect(function() {
  1195. var exportWindow = createWindow("exportWindow");
  1196. exportWindow.windowTitle = TTR("basicWindow", "Typica - Export XHTML+SVG");
  1197. exportWindow.log = log;
  1198. });
  1199. openMenu.triggered.connect(function() {
  1200. var filename = QFileDialog.getOpenFileName(window, TTR("basicWindow", "Open Log..."), QSettings.value('script/lastDir', '') + '/');
  1201. if(filename != '') {
  1202. var file = new QFile(filename);
  1203. var input = new XMLInput(file, 1);
  1204. targetseries = -1;
  1205. input.newTemperatureColumn.connect(log.setHeaderData);
  1206. input.newTemperatureColumn.connect(function(col, text) {
  1207. if(text == window.targetcolumnname) {
  1208. targetseries = col;
  1209. }
  1210. });
  1211. input.newAnnotationColumn.connect(log.setHeaderData);
  1212. input.measure.connect(graph.newMeasurement);
  1213. input.measure.connect(log.newMeasurement);
  1214. input.measure.connect(function(data, series) {
  1215. if(series == targetseries) {
  1216. targetDetector.newMeasurement(data);
  1217. }
  1218. });
  1219. resetTranslation.enabled = false;
  1220. setTranslation.enabled = false;
  1221. input.annotation.connect(log.newAnnotation);
  1222. input.annotation.connect(function(note, tcol, ncol) {
  1223. for(var i = tcol; i < ncol; i++) {
  1224. log.newAnnotation(note, i, ncol);
  1225. }
  1226. });
  1227. var lc;
  1228. input.lastColumn.connect(function(c) {
  1229. lc = c;
  1230. QSettings.setValue("liveColumn", c + 1);
  1231. window.postLoadColumnSetup(c);
  1232. });
  1233. graph.updatesEnabled = false;
  1234. log.updatesEnabled = false;
  1235. input.input();
  1236. log.updatesEnabled = true;
  1237. graph.updatesEnabled = true;
  1238. window.windowTitle = 'Typica - [*]' + baseName(filename);
  1239. QSettings.setValue("script/lastDir", dir(filename));
  1240. log.newAnnotation(TTR("basicWindow", "End"), 1, lc);
  1241. }
  1242. });
  1243. var columnName = function(c) {
  1244. var visibleColumns = 0;
  1245. for(var i = 0; i < channels.length; i++) {
  1246. if(channelVisibility[i]) {
  1247. visibleColumns++;
  1248. }
  1249. if(c == visibleColumns - 1) {
  1250. return columnNames[i];
  1251. }
  1252. }
  1253. return "";
  1254. };
  1255. window.postLoadColumnSetup = function(c) {
  1256. for(var i = 0; i < adapters.length; i++) {
  1257. adapters[i].setColumn(c + i + 1);
  1258. zeroemitters[i].setColumn(c + i + 1);
  1259. log.setHeaderData(c + i + 1, columnName(i));
  1260. }
  1261. log.setHeaderData(c + columnNames.length + 1 - channelSkip, TTR("basicWindow", "Note"));
  1262. stop.setTemperatureColumn(c + 1);
  1263. stop.setAnnotationColumn(c + columnNames.length + 1 - channelSkip);
  1264. for(var i = 0; i < annotationButtons.length; i++) {
  1265. annotationButtons[i].setTemperatureColumn(c + 1);
  1266. annotationButtons[i].setAnnotationColumn(c + columnNames.length + 1 - channelSkip);
  1267. }
  1268. log.clearCurrentColumnSet();
  1269. for(var i = 0; i < channels.length - channelSkip; i++) {
  1270. log.addToCurrentColumnSet(c + i + 1);
  1271. }
  1272. window.firstTempColumn = c + 1;
  1273. window.annotationColumn = c + columnNames.length - channelSkip + 1;
  1274. }
  1275. var saveMenu = findChildObject(this, 'save');
  1276. saveMenu.triggered.connect(function() {
  1277. var filename = QFileDialog.getSaveFileName(window, TTR("basicWindow", "Save Log As..."), QSettings.value("script/lastDir", "") + "/");
  1278. if(filename != "") {
  1279. var lc = Number(QSettings.value("liveColumn"));
  1280. var file = new QFile(filename);
  1281. log.clearOutputColumns();
  1282. channelSkip = 0;
  1283. for(var i = 0; i < channels.length; i++) {
  1284. if(channelVisibility[i]) {
  1285. if(channelType[i] == "T") {
  1286. log.addOutputTemperatureColumn(lc + i - channelSkip);
  1287. } else {
  1288. log.addOutputControlColumn(lc + i - channelSkip);
  1289. }
  1290. } else {
  1291. channelSkip++;
  1292. }
  1293. }
  1294. log.addOutputAnnotationColumn(lc + columnNames.length - channelSkip);
  1295. log.saveXML(file);
  1296. QSettings.setValue("script/lastDir", dir(filename));
  1297. }
  1298. });
  1299. var exportMenu = findChildObject(this, 'export');
  1300. exportMenu.triggered.connect(function() {
  1301. var filename = QFileDialog.getSaveFileName(window, TTR("basicWindow", "Export CSV As..."), QSettings.value("script/lastDir", "") + "/");
  1302. if(filename != "") {
  1303. var lc = Number(QSettings.value("liveColumn"));
  1304. var file = new QFile(filename);
  1305. log.clearOutputColumns();
  1306. for(var i = 0; i < columnNames.length - channelSkip; i++) {
  1307. log.addOutputTemperatureColumn(lc + i);
  1308. }
  1309. log.addOutputAnnotationColumn(lc + columnNames.length - channelSkip);
  1310. log.saveCSV(file);
  1311. QSettings.setValue("script/lastDir", dir(filename));
  1312. }
  1313. });
  1314. var newMenu = findChildObject(this, 'new');
  1315. newMenu.triggered.connect(function() {
  1316. var bwindow = createWindow("batchWindow");
  1317. bwindow.windowTitle = TTR("basicWindow", "Typica - [*]New Batch");
  1318. });
  1319. var newSampleMenu = findChildObject(this, 'newsample');
  1320. newSampleMenu.triggered.connect(function() {
  1321. var bwindow = createWindow("sampleRoastingBatch");
  1322. });
  1323. window.postLoadColumnSetup(0);
  1324. Windows.loggingWindow = window;
  1325. ]]>
  1326. </program>
  1327. </window>