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