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