Typica is a free program for professional coffee roasters. https://typica.us
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

productionroaster.xml 54KB

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