GSI Object Oriented Online Offline (Go4)  GO4-5.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
analysiseditor.js
Go to the documentation of this file.
1 (function(){
2 
3  if (typeof JSROOT != "object") {
4  var e1 = new Error("analysiseditor.js requires JSROOT to be already loaded");
5  e1.source = "analysiseditor.js";
6  throw e1;
7  }
8 
9  if (typeof GO4 != "object") {
10  var e1 = new Error("analysiseditor.js requires GO4 to be already loaded");
11  e1.source = "analysiseditor.js";
12  throw e1;
13  }
14 
15 
16  GO4.EvIOType = {
17  GO4EV_NULL: 0, // no event store/source
18  GO4EV_FILE: 1, // root file with own tree
19  GO4EV_TREE: 2, // branch of singleton tree
20  GO4EV_MBS_FILE: 3, // mbs listmode file (input only)
21  GO4EV_MBS_STREAM: 4, // mbs stream server (input only)
22  GO4EV_MBS_TRANSPORT: 5, // mbs transport server (input only)
23  GO4EV_MBS_EVENTSERVER: 6, // mbs event server (input only)
24  GO4EV_MBS_REVSERV: 7, // remote event server (input only)
25  GO4EV_BACK: 8, // backstore in memory (pseudo-ringbuffer?)
26  GO4EV_USER: 9, // user defined source class
27  GO4EV_MBS_RANDOM: 10 // random generated mbs event
28 
29  }
30 
31  GO4.AnalysisStatusEditor = function(stat) {
32  JSROOT.TBasePainter.call(this, stat);
33  this.stat = stat;
34  this.step;
35  this.changes = [["dummy0", "init0"],["dummy1","init1"]]; // changes array stepwise, index 0 = no step, index = stepindex+1
36  this.showmore= [false, false];
37  this.ClearChanges();
38  this.ClearShowstates();
39  }
40 
41 
42  GO4.AnalysisStatusEditor.prototype = Object.create(JSROOT.TBasePainter.prototype);
43 
44  GO4.AnalysisStatusEditor.prototype.DabcCommand = function(cmd, option, callback) {
45  var pre="";
46  if (this.GetItemName()!="") { // note: check against !=null does not work here!
47  pre = this.GetItemName() + "/"; // suppress / if item name is empty
48  //console.log("Found non null itemname= -"+this.GetItemName()+"-");
49  }
50  pre +="exe.json\?method=";
51  var fullcom = pre + cmd + option;
52 
53  JSROOT.NewHttpRequest(fullcom, 'text', function(res) {
54  console.log("DabcCommand completed.");
55  callback(res!=null);
56  }).send(null);
57  }
58 
59  GO4.AnalysisStatusEditor.prototype.MarkChanged = function(key, step) {
60  // first avoid duplicate keys:
61  var index;
62 
63  for (index = 0; index < this.changes[step].length; index++) {
64  if (this.changes[step][index]== key) return;
65  }
66  this.changes[step].push(key);
67  console.log("Mark changed :%s at step %d", key, step);
68  var id = "#"+this.divid;
69 
70  $(id+" .buttonAnaChangeLabel").show();// show warning sign
71  }
72 
73  // clear changed elements' list, make warning sign invisible
74 GO4.AnalysisStatusEditor.prototype.ClearChanges = function() {
75  var index, step;
76  var numsteps=this.changes.length;
77  for (step = 0; step < numsteps ; step++) {
78  var len=this.changes[step].length;
79  for (index = 0; index < len ; index++) {
80  var removed=this.changes[step].pop();
81  //console.log("Clear changes removed :%s at step %d",removed, step);
82  }
83  }
84  var id = "#"+this.divid;
85  $(id+" .buttonAnaChangeLabel").hide(); // hide warning sign
86 
87  }
88 
89 GO4.AnalysisStatusEditor.prototype.ClearShowstates = function() {
90  var index;
91  var len=this.showmore.length;
92  for (index = 0; index < len ; index++) {
93  var removed=this.showmore.pop();
94  console.log("ClearShowstates removed :%s", removed);
95  }
96 }
97 
98 //scan changed value list and return optionstring to be send to server
99 GO4.AnalysisStatusEditor.prototype.EvaluateChanges = function(optionstring) {
100  var id = "#"+this.divid;
101  var editor=this;
102  var index;
103  var numsteps=this.changes.length;
104  for (step = 0; step < numsteps ; step++) {
105  var len=this.changes[step].length;
106  var stepoptions="";
107  for (index = 0; index < len ; index++) {
108 
109  var key=this.changes[step][index];
110  //console.log("Evaluate change key:%s", key);
111 
112  var theElement=editor.stat.fxStepArray.arr[step];
113  // here mapping of key to editor field:
114  if(key=="stepenabled")
115  {
116  stepoptions+="&"+key+"_"+step+"="+theElement.fbProcessEnabled;
117  }
118  else if(key=="sourceenabled")
119  {
120  stepoptions+="&"+key+"_"+step+"="+theElement.fbSourceEnabled;
121  }
122  else if(key=="storeenabled")
123  {
124  stepoptions+="&"+key+"_"+step+"="+theElement.fbStoreEnabled;
125  }
126  else if(key=="sourcesel")
127  {
128  stepoptions+="&"+key+"_"+step+"="+theElement.fxSourceType.fiID;
129  }
130  else if(key=="sourcename")
131  {
132  stepoptions+="&"+key+"_"+step+"="+theElement.fxSourceType.fName;
133  }
134  else if(key=="sourceport")
135  {
136  stepoptions+="&"+key+"_"+step+"="+theElement.fxSourceType.fiPort;
137  }
138  else if(key=="sourcetmout")
139  {
140  stepoptions+="&"+key+"_"+step+"="+theElement.fxSourceType.fiTimeout;
141  }
142  else if(key=="sourceretry")
143  {
144  stepoptions+="&"+key+"_"+step+"="+theElement.fxSourceType.fiRetryCnt;
145  }
146  else if(key=="sourcefirst")
147  {
148  stepoptions+="&"+key+"_"+step+"="+theElement.fxSourceType.fuStartEvent;
149  }
150  else if(key=="sourcelast")
151  {
152  stepoptions+="&"+key+"_"+step+"="+theElement.fxSourceType.fuStopEvent;
153  }
154  else if(key=="sourceskip")
155  {
156  stepoptions+="&"+key+"_"+step+"="+theElement.fxSourceType.fuEventInterval;
157  }
158  else if(key=="storesel")
159  {
160  stepoptions+="&"+key+"_"+step+"="+theElement.fxStoreType.fiID;
161  }
162  else if(key=="storename")
163  {
164  stepoptions+="&"+key+"_"+step+"="+theElement.fxStoreType.fName;
165  }
166  else if(key=="storesplit")
167  {
168  stepoptions+="&"+key+"_"+step+"="+theElement.fxStoreType.fiSplit;
169  }
170  else if(key=="storebuf")
171  {
172  stepoptions+="&"+key+"_"+step+"="+theElement.fxStoreType.fiBufsize;
173  }
174  else if(key=="storecomp")
175  {
176  stepoptions+="&"+key+"_"+step+"="+theElement.fxStoreType.fiCompression;
177  }
178  else if(key=="storeasf")
179  {
180  stepoptions+="&"+key+"_"+step+"="+theElement.fxStoreType.fiAutosavesize;
181  }
182  else if(key=="storeover")
183  {
184  stepoptions+="&"+key+"_"+step+"="+theElement.fxStoreType.fbOverwrite;
185  }
186  // non step specific options are in step 0 options too:
187 
188  else if(key=="asfname")
189  {
190  stepoptions+="&"+key+"="+editor.stat.fxAutoFileName;
191  }
192 
193  else if(key=="asfenabled")
194  {
195  stepoptions+="&"+key+"="+editor.stat.fbAutoSaveOn;
196  }
197 
198  else if(key=="asftime")
199  {
200  stepoptions+="&"+key+"="+editor.stat.fiAutoSaveInterval;
201  }
202  else if(key=="asfcomp")
203  {
204  stepoptions+="&"+key+"="+editor.stat.fiAutoSaveCompression;
205  }
206  else if(key=="asfoverwrite")
207  {
208  stepoptions+="&"+key+"="+editor.stat.fbAutoSaveOverwrite;
209  }
210  else if(key=="anaprefsname")
211  {
212  stepoptions+="&"+key+"="+editor.stat.fxConfigFileName;
213  }
214 
215  else{
216  console.log("Warning: EvaluateChanges found unknown key:%s", key);
217  }
218 
219 
220 
221  }// for index
222 
223 
224  optionstring+=stepoptions;
225  } // for step
226  console.log("Resulting option string:%s", optionstring);
227  return optionstring;
228 }
229 
230 
231 
232 
233 
234 
235 
236 
237  GO4.AnalysisStatusEditor.prototype.refreshEditor = function()
238  {
239  var id = "#"+this.divid;
240  var editor=this;
241  var stat=this.stat;
242  var names = "";
243 
245  this.ClearShowstates();
246  var tabelement=$(id+" .steptabs");
247  tabelement.tabs( "option", "disabled", [0, 1, 2, 3, 4, 5, 6, 7] );
248  for(var j=0; j<8;++j){
249  $(id +" .steptabs ul:first li:eq("+ j +")").hide(); // disable and hide all tabs
250  }
251  stat.fxStepArray.arr.forEach(function(element, index, array) {
252  tabelement.tabs("enable",index);
253  $(id +" .steptabs ul:first li:eq("+index+") a").text(element.fName);
254  $(id +" .steptabs ul:first li:eq("+index+")").show(); // only show what is really there
255  editor.showmore.push(false); // prepare showmore array for each step
256  //console.log("refreshEditor for step name:"+ element.fName);
257  tabelement.tabs("load",index); // all magic is in the on load event callback
258  //console.log("refreshEditor after issuing load of index:"+ index);
259 
260 
261  }); // for each
262 
264  $(id + " .anaASF_name").val(stat.fxAutoFileName);
265  $(id+" .anaASF_enabled")
266  .prop('checked', stat.fbAutoSaveOn)
267  .click(function() {
268  editor.MarkChanged("asfenabled",0);
269  editor.stat.fbAutoSaveOn=this.checked;
270  });
271 
272 
273  $(id +" .anaASF_time").val(stat.fiAutoSaveInterval);
274  $(id +" .anaASF_compression").val(stat.fiAutoSaveCompression);
275 
276  $(id+" .anaASF_overwrite")
277  .prop('checked', stat.fbAutoSaveOverwrite)
278  .click(function() {
279  editor.MarkChanged("asfoverwrite",0);
280  editor.stat.fbAutoSaveOverwrite= this.checked;
281  });
282 
284  $(id + " .anaprefs_name").val(stat.fxConfigFileName);
285 
286 
287  //console.log("analysis editor: refreshEditor");
288  editor.ClearChanges();
289 
290  }
291 
292 
293  GO4.AnalysisStatusEditor.prototype.showStepEditor = function(pthis, theElement, theIndex)
294 
295  {
296  var id = "#"+this.divid;
297  var editor=this;
298  var showmore=editor.showmore[theIndex];
299  //console.log("showStepEditor for index "+theIndex+" has showmore="+showmore);
300  var storetable=pthis.find(" .step_store");
301  var sourcetable=pthis.find(" .step_source");
302  var enablebox=pthis.find(" .step_box_step_enab");
303  var sourcebox=pthis.find(" .step_box_source_enab");
304  var storebox=pthis.find(" .step_box_store_enab");
305 
306  var sourcesel=pthis.find(" .step_source_select");
307  var sourcemore=pthis.find(" .step_source_expand");
308  var sourceform=pthis.find(" .step_source_form");
309  var sourcename=pthis.find(" .step_source_name");
310  var sourcenamelabel=pthis.find(" .step_source_name_label");
311  var sourcetag=pthis.find(" .step_source_tagfile");
312  var sourcetaglabel=pthis.find(" .step_source_tagfile_label");
313  var sourceport=pthis.find(" .step_source_port");
314  var sourceportlabel=pthis.find(" .step_source_port_label");
315  var sourcetmout=pthis.find(" .step_source_tmout");
316  var sourcetmoutlabel=pthis.find(" .step_source_tmout_label");
317  var sourceretry=pthis.find(" .step_source_retry");
318  var sourceretrylabel=pthis.find(" .step_source_retry_label");
319  var sourceargs=pthis.find(" .step_source_args");
320  var sourceargslabel=pthis.find(" .step_source_args_label");
321  var sourcefirst=pthis.find(" .step_source_firstev");
322  var sourcefirstlabel=pthis.find(" .step_source_firstev_label");
323  var sourcelast=pthis.find(" .step_source_lastev");
324  var sourcelastlabel=pthis.find(" .step_source_lastev_label");
325  var sourceskip=pthis.find(" .step_source_stepev");
326  var sourceskiplabel=pthis.find(" .step_source_stepev_label");
327 
328  var storesel=pthis.find(" .step_store_select");
329  var storename=pthis.find(" .step_store_name");
330  var storesplit=pthis.find(" .step_store_split");
331  var storebuf=pthis.find(" .step_store_buf");
332  var storecomp=pthis.find(" .step_store_comp");
333  var storetreeasf=pthis.find(" .step_store_asf");
334  var storeover=pthis.find(" .step_store_overwrite");
335 
336  // here step control checkboxes and source/store visibility:
337  if (theElement.fbProcessEnabled) {
338  sourcebox.prop('disabled',false);
339  storebox.prop('disabled',false);
340  if (theElement.fbSourceEnabled) {
341  sourcetable.show();
342  } else {
343  sourcetable.hide();
344  }
345  if (theElement.fbStoreEnabled) {
346  storetable.show();
347  } else {
348  storetable.hide();
349  }
350  } else {
351  sourcebox.prop('disabled',true);
352  storebox.prop('disabled',true);
353  sourcetable.hide();
354  storetable.hide();
355  }
356 
357 
358 
359 
360  sourceform.show();
361 
362  //console.log("show step editor with source id:"+theElement.fxSourceType.fiID);
363  switch(theElement.fxSourceType.fiID)
364  {
365  case GO4.EvIOType.GO4EV_FILE:
366  case GO4.EvIOType.GO4EV_MBS_RANDOM:
367  sourceport.hide();
368  sourceportlabel.hide();
369  sourcetmout.hide();
370  sourcetmoutlabel.hide();
371  sourceretry.hide();
372  sourceretrylabel.hide();
373  sourcetag.hide();
374  sourcetaglabel.hide();
375  sourcefirst.hide();
376  sourcefirstlabel.hide();
377  sourcelast.hide();
378  sourcelastlabel.hide()
379  sourceskip.hide();
380  sourceskiplabel.hide();
381  sourceargs.hide();
382  sourceargslabel.hide();
383  break;
384  case GO4.EvIOType.GO4EV_MBS_STREAM:
385  case GO4.EvIOType.GO4EV_MBS_TRANSPORT:
386  case GO4.EvIOType.GO4EV_MBS_EVENTSERVER:
387  case GO4.EvIOType.GO4EV_MBS_REVSERV:
388  if(showmore)
389  {
390  sourceport.show();
391  sourceportlabel.show();
392  sourcetmout.show();
393  sourcetmoutlabel.show();
394  sourceretry.show();
395  sourceretrylabel.show();
396  sourcefirst.show();
397  sourcefirstlabel.show();
398  sourcelast.show();
399  sourcelastlabel.show();
400  sourceskip.show();
401  sourceskiplabel.show();
402  }
403  else
404  {
405  sourceport.hide();
406  sourceportlabel.hide();
407  sourcetmout.hide();
408  sourcetmoutlabel.hide();
409  sourceretry.hide();
410  sourceretrylabel.hide();
411  sourcefirst.hide();
412  sourcefirstlabel.hide();
413  sourcelast.hide();
414  sourcelastlabel.hide();
415  sourceskip.hide();
416  sourceskiplabel.hide();
417  }
418  sourcetag.hide();
419  sourcetaglabel.hide();
420  sourceargs.hide();
421  sourceargslabel.hide();
422 
423 
424  break;
425  case GO4.EvIOType.GO4EV_USER:
426  if(showmore)
427  {
428  sourceport.show();
429  sourceportlabel.show();
430  sourcetmout.show();
431  sourcetmoutlabel.show();
432  sourceargs.show();
433  sourceargslabel.show();
434  }
435  else
436  {
437  sourceport.hide();
438  sourceportlabel.hide();
439  sourcetmout.hide();
440  sourcetmoutlabel.hide();
441  sourceargs.hide();
442  sourceargslabel.hide();
443  }
444  sourceretry.hide();
445  sourceretrylabel.hide();
446  sourcetag.hide();
447  sourcetaglabel.hide();
448  sourcefirst.hide();
449  sourcefirstlabel.hide();
450  sourcelast.hide();
451  sourcelastlabel.hide();
452  sourceskip.hide();
453  sourceskiplabel.hide();
454  break;
455  default:
456  console.log("showStepEditor WARNING: unknown event source id: "+theElement.fxSourceType.fiID);
457  case GO4.EvIOType.GO4EV_MBS_FILE:
458  if(showmore)
459  {
460  sourcetag.show();
461  sourcetaglabel.show();
462  sourcefirst.show();
463  sourcefirstlabel.show();
464  sourcelast.show();
465  sourcelastlabel.show();
466  sourceskip.show();
467  sourceskiplabel.show();
468  }
469  else
470  {
471  sourcetag.hide();
472  sourcetaglabel.hide();
473  sourcefirst.hide();
474  sourcefirstlabel.hide();
475  sourcelast.hide();
476  sourcelastlabel.hide();
477  sourceskip.hide();
478  sourceskiplabel.hide();
479  }
480  sourceport.hide();
481  sourceportlabel.hide();
482  sourcetmout.hide();
483  sourcetmoutlabel.hide();
484  sourceretry.hide();
485  sourceretrylabel.hide();
486  sourceargs.hide();
487  sourceargslabel.hide();
488  break;
489  };
490 
491 
492  storesplit.show();
493  storebuf.show();
494  storecomp.show();
495  storetreeasf.show();
496  storeover.show();
497  //console.log("show step editor with store id:"+theElement.fxStoreType.fiID);
498  switch(theElement.fxStoreType.fiID)
499  {
500  default:
501  console.log("showStepEditor WARNING: unknown event store id: "+theElement.fxStoreType.fiID);
502  case GO4.EvIOType.GO4EV_FILE:
503  storecomp.spinner("enable");
504  storetreeasf.spinner("enable");
505  storeover.prop('disabled',false);
506  break;
507  case GO4.EvIOType.GO4EV_BACK:
508  storecomp.spinner("disable");
509  storetreeasf.spinner("disable");
510  storeover.prop('disabled',true);
511  break;
512 
513  };
514 
515 
516  sourcesel.selectmenu("option", "width", sourcetable.width()*0.8); // expand to table width
517  sourcesel.selectmenu('refresh', true);
518 
519  storesel.selectmenu("option", "width", storetable.width()*0.8); // expand to table width
520  storesel.selectmenu('refresh', true);
521 
522 
523  pthis.css("padding","5px");
524 
525  $(id+" .steptabs").tabs("refresh");
526 
527  //console.log("analysis editor: showStepEditor leaving.");
528  }
529 
530  GO4.AnalysisStatusEditor.prototype.fillEditor = function()
531  {
532  var id = "#"+this.divid;
533  var editor=this;
534 
535  $(id +" .steptabs").tabs({
536  heightStyle: "fill",
537  activate : function(event, ui) {
538  //updateElementsSize();
539  //console.log("analysis editor: activated tab: "+ ui.newTab.text());
540  },
541 
542  load: function(event, ui) {
543 
544  // note that load will also be triggered when activating tab!
545  // so we need to backup all changes in local step status theElement!!!
546 
547  var theIndex = ui.tab.index();
548  //console.log("On load function for " + ui.tab.text() + " index=" + theIndex );
549  var pthis=ui.panel;
550  var theElement=editor.stat.fxStepArray.arr[theIndex];
551 
552 // console.log("process enabled="+theElement.fbProcessEnabled + "for theElement: "+theElement.fName);
553 // console.log("source enabled="+theElement.fbSourceEnabled + "for theElement: "+theElement.fName);
554 // console.log("store enabled="+theElement.fbStoreEnabled + "for theElement: "+theElement.fName);
555 
556  var storetable=pthis.find(" .step_store");
557  var sourcetable=pthis.find(" .step_source");
558  var enablebox=pthis.find(" .step_box_step_enab");
559  var sourcebox=pthis.find(" .step_box_source_enab");
560  var storebox=pthis.find(" .step_box_store_enab");
561 
562  var sourcesel=pthis.find(" .step_source_select");
563  var sourcemore=pthis.find(" .step_source_expand");
564  var sourceform=pthis.find(" .step_source_form");
565  var sourcename=pthis.find(" .step_source_name");
566  var sourcetag=pthis.find(" .step_source_tagfile");
567  var sourceport=pthis.find(" .step_source_port");
568  var sourcetmout=pthis.find(" .step_source_tmout");
569  var sourceretry=pthis.find(" .step_source_retry");
570  var sourceargs=pthis.find(" .step_source_args");
571  var sourcefirst=pthis.find(" .step_source_firstev");
572  var sourcelast=pthis.find(" .step_source_lastev");
573  var sourceskip=pthis.find(" .step_source_stepev");
574 
575  var storesel=pthis.find(" .step_store_select");
576  var storename=pthis.find(" .step_store_name");
577  var storesplit=pthis.find(" .step_store_split");
578  var storebuf=pthis.find(" .step_store_buf");
579  var storecomp=pthis.find(" .step_store_comp");
580  var storetreeasf=pthis.find(" .step_store_asf");
581  var storeover=pthis.find(" .step_store_overwrite");
582 
583 
584  enablebox.prop('checked', theElement.fbProcessEnabled)
585  .click(function()
586  {
587  editor.MarkChanged("stepenabled", theIndex);
588  theElement.fbProcessEnabled=this.checked;
589  editor.showStepEditor(pthis, theElement, theIndex);
590 
591  }); // clickfunction
592 
593  sourcebox.prop('checked', theElement.fbSourceEnabled)
594  .click(function()
595  {
596  editor.MarkChanged("sourceenabled", theIndex);
597  theElement.fbSourceEnabled=this.checked;
598  editor.showStepEditor(pthis, theElement, theIndex);
599  }); // clickfunction
600 
601 
602  storebox.prop('checked', theElement.fbStoreEnabled)
603  .click(function()
604  {
605  editor.MarkChanged("storeenabled", theIndex);
606  theElement.fbStoreEnabled=this.checked;
607  editor.showStepEditor(pthis, theElement, theIndex);
608  }); // clickfunction
609 
611  sourcesel.selectmenu({
612  change : function(event, ui) {
613  editor.MarkChanged("sourcesel",theIndex);
614  // change here eventsource status object?!
615  // in javascript we can just add dynamically any missing members!
616  // so exchange of class object is not necessary hopefully...
617 
618  switch(Number(ui.item.value))
619  {
620 
621  case 0:
622  theElement.fxSourceType.fiID=GO4.EvIOType.GO4EV_FILE;
623  break;
624  case 2:
625  theElement.fxSourceType.fiID=GO4.EvIOType.GO4EV_MBS_STREAM;
626  break;
627  case 3:
628  theElement.fxSourceType.fiID=GO4.EvIOType.GO4EV_MBS_TRANSPORT;
629  break;
630  case 4:
631  theElement.fxSourceType.fiID=GO4.EvIOType.GO4EV_MBS_EVENTSERVER;
632  break;
633  case 5:
634  theElement.fxSourceType.fiID=GO4.EvIOType.GO4EV_MBS_REVSERV;
635  break;
636  case 6:
637  theElement.fxSourceType.fiID=GO4.EvIOType.GO4EV_MBS_RANDOM;
638  break;
639  case 7:
640  theElement.fxSourceType.fiID=GO4.EvIOType.GO4EV_USER;
641  break;
642  default:
643  case 1:
644  theElement.fxSourceType.fiID=GO4.EvIOType.GO4EV_MBS_FILE;
645  break;
646 
647  }; // switch
648 
649  // but: we have to set back all values from GUI to theElement and optionally create new members:
650  theElement.fxSourceType.fName=sourcename.val();
651  theElement.fxSourceType.fiPort=sourceport.val();
652  theElement.fxSourceType.fiTimeout=sourcetmout.val();
653  theElement.fxSourceType.fiRetryCnt=sourceretry.val();
654  theElement.fxSourceType.fxTagFile=sourcetag.val();
655  theElement.fxSourceType.fuStartEvent=sourcefirst.val();
656  theElement.fxSourceType.fuStopEvent=sourcelast.val();
657  theElement.fxSourceType.fuEventInterval=sourceskip.val();
658  theElement.fxSourceType.fxExpression=sourceargs.val();
659 
660  editor.showStepEditor(pthis, theElement, theIndex);
661  }
662  }); // source selectmenu change
663 
664 
665  sourcemore.prop('checked', editor.showmore[theIndex]).click(
666  function(){
667  //console.log("show more clickfunction...");
668  var doshow=$(this).prop('checked');
669  if (doshow) {
670  editor.showmore[theIndex]=true;
671  } else {
672  editor.showmore[theIndex]=false;
673  }
674  editor.showStepEditor(pthis, theElement, theIndex);
675  }); // clickfunction
676 
677 
678  sourcename.val(theElement.fxSourceType.fName);
679 // .change(function(){
680 // editor.MarkChanged("sourcename",theIndex);
681 // theElement.fxSourceType.fName=this.value.trim();
682 // }); ;
683 
684  sourceform.submit(
685  function(event) {
686  event.preventDefault(); // do not send automatic request to server!
687  var content= sourcename[0].value;
688  content=content.trim();
689  editor.MarkChanged("sourcename",theIndex);
690  theElement.fxSourceType.fName=content;
691  console.log("Submitting sourcename form with: "+content);
692  });
693 
694 
695  //console.log("on tab load finds source name: "+ theElement.fxSourceType.fName);
696 // sourcename.val(theElement.fxSourceType.fName)
697 // .change(function(){
698 // editor.MarkChanged("sourcename",theIndex);
699 // theElement.fxSourceType.fName=this.value.trim();
700 // });
701 
702 
703 
704 
705 
706  sourceport.spinner({
707  min: 0,
708  max: 100000,
709  step: 1,
710  stop: function( event, ui ) {
711  editor.MarkChanged("sourceport",theIndex);
712  theElement.fxSourceType.fiPort=this.value;
713  //console.log("spinner stop event with thisvalue="+this.value+", ui.value="+ui.value);
714  }
715  });
716 
717  sourcetmout.spinner({
718  min: 0,
719  max: 9999,
720  step: 1,
721  stop: function( event, ui ) {
722  editor.MarkChanged("sourcetmout",theIndex);
723  theElement.fxSourceType.fiTimeout=this.value;
724  }
725 
726 
727  });
728 
729  sourceretry.spinner({
730  min: 0,
731  max: 10000,
732  step: 1,
733  stop: function( event, ui ) {
734  editor.MarkChanged("sourceretry",theIndex);
735  theElement.fxSourceType.fiRetryCnt=this.value;
736  }
737  });
738 
739 
740  sourcefirst.spinner({
741  min: 0,
742  max: 2000000000,
743  step: 1000,
744  stop: function( event, ui ) {
745  editor.MarkChanged("sourcefirst",theIndex);
746  theElement.fxSourceType.fuStartEvent=this.value;
747  }
748  });
749 
750  sourcelast.spinner({
751  min: 0,
752  max: 2000000000,
753  step: 1000,
754  stop: function( event, ui ) {
755  editor.MarkChanged("sourcelast",theIndex);
756  theElement.fxSourceType.fuStopEvent=this.value;
757  }
758  });
759 
760  sourceskip.spinner({
761  min: 0,
762  max: 999999999,
763  step: 1,
764  stop: function( event, ui ) {
765  editor.MarkChanged("sourceskip",theIndex);
766  theElement.fxSourceType.fuEventInterval=this.value;
767  }
768  });
769 
771  storesel.selectmenu({
772  change : function(event, ui) {
773  editor.MarkChanged("storesel",theIndex);
774 
775  //console.log("store selector with value "+ Number(ui.item.value));
776  switch(Number(ui.item.value))
777  {
778 
779  default:
780  case 0:
781  theElement.fxStoreType.fiID=GO4.EvIOType.GO4EV_FILE;
782  break;
783  case 1:
784  theElement.fxStoreType.fiID=GO4.EvIOType.GO4EV_BACK;
785  break;
786  }; // switch
787  theElement.fxStoreType.fName=storename.val();
788  theElement.fxStoreType.fiSplit=storesplit.val();
789  theElement.fxStoreType.fiBufsize=storebuf.val()* 1000.;
790  theElement.fxStoreType.fiCompression=storecomp.val();
791  theElement.fxStoreType.fiAutosavesize=storetreeasf.val();
792 
793 
794 
795  editor.showStepEditor(pthis, theElement, theIndex);
796 
797  } // change function
798  }); // selectmenu
799 
800 
801  //console.log("on tab load finds store name: "+ theElement.fxStoreType.fName);
802  storename.val(theElement.fxStoreType.fName)
803  .change(function(){
804  editor.MarkChanged("storename",theIndex);
805  theElement.fxStoreType.fName=this.value.trim();
806  }); // change function
807 
808 
809  storesplit.spinner({
810  min: 0,
811  max: 99,
812  step: 1,
813  stop: function( event, ui ) {
814  editor.MarkChanged("storesplit",theIndex);
815  theElement.fxStoreType.fiSplit=this.value;
816  }
817  });
818 
819  storebuf.spinner({
820  min: 4,
821  max: 256,
822  step: 1,
823  stop: function( event, ui ) {
824  editor.MarkChanged("storebuf",theIndex);
825  theElement.fxStoreType.fiBufsize=this.value * 1000;
826  }
827  });
828 
829  storecomp.spinner({
830  min: 0,
831  max: 9,
832  step: 1,
833  stop: function( event, ui ) {
834  editor.MarkChanged("storecomp",theIndex);
835  theElement.fxStoreType.fiCompression=this.value;
836  }
837  });
838  storetreeasf.spinner({
839  min: 0,
840  max: 99999,
841  step: 100,
842  stop: function( event, ui ) {
843  editor.MarkChanged("storeasf",theIndex);
844  theElement.fxStoreType.fiAutosavesize=this.value;
845  }
846  });
847 
848  storeover.click(function() {
849  editor.MarkChanged("storeover",theIndex);
850  theElement.fxStoreType.fbOverwrite=this.checked;
851  });
852 
853 
855 
856 
857 
858  // set event source selector and special fields:
859  //console.log("load tab "+theIndex+" sees source id:"+theElement.fxSourceType.fiID);
860  switch(theElement.fxSourceType.fiID)
861  {
862  case GO4.EvIOType.GO4EV_FILE:
863  sourcesel.val(0);
864  break;
865  case GO4.EvIOType.GO4EV_MBS_STREAM:
866  sourcesel.val(2);
867  sourceport.val(theElement.fxSourceType.fiPort);
868  sourcetmout.val(theElement.fxSourceType.fiTimeout);
869  sourceretry.val(theElement.fxSourceType.fiRetryCnt);
870  sourcetag.text(theElement.fxSourceType.fxTagFile);
871  sourcefirst.val(theElement.fxSourceType.fuStartEvent);
872  sourcelast.val(theElement.fxSourceType.fuStopEvent);
873  sourceskip.val(theElement.fxSourceType.fuEventInterval);
874  break;
875  case GO4.EvIOType.GO4EV_MBS_TRANSPORT:
876  sourcesel.val(3);
877  sourceport.val(theElement.fxSourceType.fiPort);
878  sourcetmout.val(theElement.fxSourceType.fiTimeout);
879  sourceretry.val(theElement.fxSourceType.fiRetryCnt);
880  sourcetag.text(theElement.fxSourceType.fxTagFile);
881  sourcefirst.val(theElement.fxSourceType.fuStartEvent);
882  sourcelast.val(theElement.fxSourceType.fuStopEvent);
883  sourceskip.val(theElement.fxSourceType.fuEventInterval);
884  break;
885  case GO4.EvIOType.GO4EV_MBS_EVENTSERVER:
886  sourcesel.val(4);
887  sourceport.val(theElement.fxSourceType.fiPort);
888  sourcetmout.val(theElement.fxSourceType.fiTimeout);
889  sourceretry.val(theElement.fxSourceType.fiRetryCnt);
890  sourcetag.text(theElement.fxSourceType.fxTagFile);
891  sourcefirst.val(theElement.fxSourceType.fuStartEvent);
892  sourcelast.val(theElement.fxSourceType.fuStopEvent);
893  sourceskip.val(theElement.fxSourceType.fuEventInterval);
894  break;
895  case GO4.EvIOType.GO4EV_MBS_REVSERV:
896  sourcesel.val(5);
897  sourceport.val(theElement.fxSourceType.fiPort);
898  sourcetmout.val(theElement.fxSourceType.fiTimeout);
899  sourceretry.val(theElement.fxSourceType.fiRetryCnt);
900  sourcetag.text(theElement.fxSourceType.fxTagFile);
901  sourcefirst.val(theElement.fxSourceType.fuStartEvent);
902  sourcelast.val(theElement.fxSourceType.fuStopEvent);
903  sourceskip.val(theElement.fxSourceType.fuEventInterval);
904  break;
905  case GO4.EvIOType.GO4EV_MBS_RANDOM:
906  sourcesel.val(6);
907  break;
908  case GO4.EvIOType.GO4EV_USER:
909  sourcesel.val(7);
910  sourceport.val(theElement.fxSourceType.fiPort);
911  sourcetmout.val(theElement.fxSourceType.fiTimeout);
912  sourceargs.text(theElement.fxSourceType.fxExpression);
913  break;
914  default:
915  console.log("WARNING: unknown event source id: "+theElement.fiID);
916  case GO4.EvIOType.GO4EV_MBS_FILE:
917  sourcesel.val(1);
918  sourcetag.text(theElement.fxSourceType.fxTagFile);
919  sourcefirst.val(theElement.fxSourceType.fuStartEvent);
920  sourcelast.val(theElement.fxSourceType.fuStopEvent);
921  sourceskip.val(theElement.fxSourceType.fuEventInterval);
922  break;
923  };
924 
925  sourcesel.selectmenu('refresh', true);
926 
927 
928  // event store properties:
929  storesplit.val(theElement.fxStoreType.fiSplit);
930  storebuf.val(theElement.fxStoreType.fiBufsize / 1000);
931  storecomp.val(theElement.fxStoreType.fiCompression);
932  storetreeasf.val(theElement.fxStoreType.fiAutosavesize);
933 
934  // set event store selector and special fields:
935  //console.log("load tab "+theIndex+" sees store id:"+theElement.fxStoreType.fiID);
936  switch(theElement.fxStoreType.fiID)
937  {
938 
939  case GO4.EvIOType.GO4EV_BACK:
940  storesel.val(1);
941  break;
942  case GO4.EvIOType.GO4EV_FILE:
943  storeover.prop('checked', theElement.fxStoreType.fbOverwrite);
944  default:
945  storesel.val(0);
946  break;
947  };
948 
949  storesel.selectmenu('refresh', true);
950 
951  editor.showStepEditor(pthis, theElement, theIndex); // handle all visibility issues here, also refresh tabs
952 
953 
954 
955  }// load
956 
957  }); // tabs init
958 
959 
961 
962 
963  $(id+" .buttonGetAnalysis")
964  .button({text: false, icons: { primary: "ui-icon-blank MyButtonStyle"}})
965  .click(function() {
966  if (JSROOT.hpainter) JSROOT.hpainter.display(editor.GetItemName());
967  else console.log("dabc object not found!");
968  })
969  .children(":first") // select first button element, used for images
970  .css('background-image', "url(" + GO4.source_dir + "icons/right.png)");
971 
972 
973 
974  $(id+" .buttonSetAnalysis")
975  .button({text: true, icons: { primary: "ui-icon-blank MyButtonStyle"}})
976  .click(function() {
977  var options=""; // do not need to use name here
978  options=editor.EvaluateChanges(options); // complete option string from all changed elements
979  console.log("submit analysis "+ editor.GetItemName()+ ", options="+options);
980  editor.DabcCommand("UpdateFromUrl",options,function(result) {
981  console.log(result ? "setting analyis configuration done. " : "set analysis FAILED.");
982  if(result) {
983  editor.ClearChanges();
984  if ((JSROOT.hpainter != null) && ('reload' in JSROOT.hpainter)) JSROOT.hpainter.reload();
985  }
986  });
987  })
988  .children(":first") // select first button element, used for images
989  .css('background-image', "url(" + GO4.source_dir + "icons/left.png)");
990 
991 
992  $(id+" .buttonAnaChangeLabel")
993  .button({text: false, icons: { primary: "ui-icon-blank MyButtonStyle"}})
994  .children(":first") // select first button element, used for images
995  .css('background-image', "url(" + GO4.source_dir + "icons/info1.png)");
996 
997 
998  $(id+" .buttonSetStartAnalysis")
999  .button({text: true, icons: { primary: "ui-icon-blank MyButtonStyle"}})
1000  .click(function() {
1001  var options=""; // do not need to use name here
1002  options=editor.EvaluateChanges(options); // complete option string from all changed elements
1003  options +="&start";
1004  console.log("submit and start analysis "+ editor.GetItemName()+ ", options="+options);
1005  editor.DabcCommand("UpdateFromUrl",options,function(result) {
1006  console.log(result ? "submit and start analyis configuration done. " : "set analysis FAILED.");
1007  if(result) {
1008  editor.ClearChanges();
1009  if ((JSROOT.hpainter != null) && ('reload' in JSROOT.hpainter)) JSROOT.hpainter.reload();
1010  }
1011  // todo: start analysis only after submission was successful?
1012  // for the moment, try to handle everythingin UpdateFromUrl
1013  });
1014  })
1015  .children(":first") // select first button element, used for images
1016  .css('background-image', "url(" + GO4.source_dir + "icons/start.png)");
1017 
1018 
1019  $(id+" .buttonCloseAnalysis")
1020  .button({text: true, icons: { primary: "ui-icon-closethick MyButtonStyle"}}).click(function() {
1021  var options="&close";
1022  // options=editor.EvaluateChanges(options); // complete option string from all changed elements
1023  console.log("close analysis "+ editor.GetItemName()+ ", options="+options);
1024  editor.DabcCommand("UpdateFromUrl",options,function(
1025  result) {
1026  console.log(result ? "closing down analyis done. "
1027  : "set analysis FAILED.");
1028  //if(result) editor.ClearChanges();
1029 
1030  });
1031  });
1032 
1033 
1034 
1035  $(id+" .buttonSaveAnaASF")
1036  .button({text: false, icons: { primary: "ui-icon-blank MyButtonStyle"}})
1037  .children(":first") // select first button element, used for images
1038  .css('background-image', "url(" + GO4.source_dir + "icons/filesave.png)");
1039 
1040 
1041  $(id + " .anaASF_form").submit(
1042  function(event) {
1043  //event.preventDefault(); // do not send automatic request to server!
1044  var content= $(id + " .anaASF_name")[0].value;
1045  content=content.trim();
1046  // before we write immediately, mark name as changed in setup:
1047  editor.MarkChanged("asfname",0);
1048  editor.stat.fxAutoFileName=content;
1049  var requestmsg = "Really Write autosave file : "+ content;
1050  var response = confirm(requestmsg);
1051  if (!response){
1052  event.preventDefault(); // do not send automatic request to server!
1053  return;
1054  }
1055 
1056  console.log("Writing autosave file: "+content);
1057  var options="&saveasf="+content;
1058  editor.DabcCommand("UpdateFromUrl",options,function(
1059  result) {
1060  console.log(result ? "Writing autosave file done. "
1061  : "Writing autosave file FAILED.");
1062  });
1063  event.preventDefault(); // do not send automatic request to server!
1064  });
1065 
1066 
1067 
1068  $(id +" .anaASF_time").spinner({
1069  min: 0,
1070  max: 100000,
1071  step: 10,
1072  stop: function( event, ui ) {
1073 
1074  editor.MarkChanged("asftime",0);
1075  editor.stat.fiAutoSaveInterval=this.value;
1076  //console.log("asftime stop.")
1077  }
1078  });
1079 
1080  $(id +" .anaASF_compression").spinner({
1081  min: 0,
1082  max: 9,
1083  step: 1,
1084  stop: function( event, ui ) {
1085  editor.MarkChanged("asfcomp",0);
1086  editor.stat.fiAutoSaveCompression=this.value;
1087  //console.log("asfcomp stop.")
1088  }
1089  });
1090 
1091 
1092  $(id+" .buttonSaveAnaConf")
1093  .button({text: false, icons: { primary: "ui-icon-blank MyButtonStyle"}})
1094  .children(":first") // select first button element, used for images
1095  .css('background-image', "url(" + GO4.source_dir + "icons/filesave.png)");
1096 
1097  $(id+" .buttonLoadAnaConf")
1098  .button({text: false, icons: { primary: "ui-icon-blank MyButtonStyle"}})
1099  .click(function() {
1100  var content= $(id + " .anaprefs_name")[0].value;
1101  content=content.trim();
1102  var requestmsg = "Really load analysis preferences: "+ content;
1103  var response = confirm(requestmsg);
1104  if (!response) return;
1105  console.log("Loading analysis Prefs from "+content);
1106  var options="&loadprefs="+content;
1107  editor.DabcCommand("UpdateFromUrl",options,function(result) {
1108  if(result){
1109  if (JSROOT.hpainter) JSROOT.hpainter.display(editor.GetItemName());
1110  else console.log("dabc object not found!");
1111  }
1112  console.log("Loading preferences " + (result ? "done" : "FAILED."));
1113  });
1114  })
1115  .children(":first") // select first button element, used for images
1116  .css('background-image', "url(" + GO4.source_dir + "icons/fileopen.png)");
1117 
1118 
1119  $(id + " .anaprefs_form").submit(
1120  function(event) {
1121  event.preventDefault(); // do not send automatic request to server!
1122  var content= $(id + " .anaprefs_name")[0].value;
1123  content=content.trim();
1124 
1125  // before we write immediately, mark name as changed in setup:
1126  editor.MarkChanged("anaprefsname",0);
1127  editor.stat.fxConfigFileName=content;
1128  var requestmsg = "Really save analysis preferences: "+ content;
1129  var response = confirm(requestmsg);
1130  if (!response) return;
1131  console.log("Saving analysis Prefs to "+content);
1132 
1133  var options="&saveprefs="+content;
1134  editor.DabcCommand("UpdateFromUrl",options,function(result) {
1135  console.log(result ? "Saving preferences done. " : "Saving preferences FAILED.");
1136  });
1137  });
1138 
1139  this.refreshEditor();
1140  }
1141 
1142  GO4.AnalysisStatusEditor.prototype.drawEditor = function(divid) {
1143  var pthis = this;
1144 
1145  $("#"+divid).empty();
1146  $("#"+divid).load(GO4.source_dir + "html/analysiseditor.htm", "", function() {
1147  var html = "<ul>";
1148  for (var i=0;i<8;i++)
1149  html+='<li><a href="'+ GO4.source_dir + 'html/stepeditor.htm">Step ' + i + '</a></li>';
1150  html+="</ul>";
1151  $("#"+divid+" .steptabs").html(html);
1152  pthis.SetDivId(divid);
1153  pthis.fillEditor();
1154  pthis.DrawingReady()
1155  });
1156  return pthis;
1157  //console.log("analysis editor: drawEditor");
1158  }
1159 
1160  GO4.AnalysisStatusEditor.prototype.RedrawPad = function(resize) {
1161  //console.log("analysis editor: RedrawPad");
1162  this.refreshEditor();
1163  }
1164 
1165  GO4.AnalysisStatusEditor.prototype.UpdateObject = function(obj) {
1166  if (obj._typename != this.stat._typename) return false;
1167  this.stat = JSROOT.clone(obj);
1168  return true;
1169  }
1170 
1171  GO4.drawGo4AnalysisStatus = function(divid, stat, option, painter) {
1172  //console.log("Draw analysis status");
1173  var h = $("#"+divid).height(), w = $("#"+divid).width();
1174  if ((h<10) && (w>10)) $("#"+divid).height(w*0.7);
1175  var status = new GO4.AnalysisStatusEditor(stat);
1176  if (painter) status = JSROOT.extend(painter, status);
1177  return status.drawEditor(divid);
1178  }
1179 
1180 })(); // function