Typica is a free program for professional coffee roasters. https://typica.us
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

productionroaster.xml 52KB

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