Typica is a free program for professional coffee roasters. https://typica.us
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

productionroaster.xml 49KB

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