3 if (typeof JSROOT !=
"object") {
4 var e1 =
new Error(
"go4.js requires JSROOT to be already loaded");
11 GO4.version =
"5.1.1";
14 GO4.source_dir =
function() {
15 var scripts = document.getElementsByTagName(
'script');
17 for (var n in scripts) {
18 if (scripts[n][
'type'] !=
'text/javascript')
continue;
20 var src = scripts[n][
'src'];
21 if ((src == null) || (src.length == 0))
continue;
23 var pos = src.indexOf(
"html/go4.js");
25 if (src.indexOf(
"JSRootCore")>=0)
continue;
26 console.log(
'Set GO4.source_dir to ' + src.substr(0, pos));
27 return src.substr(0, pos);
35 GO4.DrawAnalysisRatemeter =
function(divid, itemname) {
37 var html =
"<div style='padding-top:2px'>";
38 html +=
"<img class='go4_logo' style='vertical-align:middle;margin-left:5px;margin-right:5px;' src='go4sys/icons/go4logorun4.gif' alt='logo'></img>";
39 html +=
"<label class='event_source' style='border: 1px solid gray; font-size:large; vertical-align:middle; padding-left:3px; padding-right:3px;'>file.lmd</label> ";
40 html +=
"<label class='event_rate' style='border: 1px solid gray; font-size:large; vertical-align:middle; background-color: grey'; padding-left:3px; padding-right:3px;>---</label> Ev/s ";
41 html +=
"<label class='aver_rate' style='border: 1px solid gray; font-size:large; vertical-align:middle; padding-left:3px; padding-right:3px;'>---</label> Ev/s ";
42 html +=
"<label class='run_time' style='border: 1px solid gray; font-size:large; vertical-align:middle; padding-left:3px; padding-right:3px;'>---</label> s ";
43 html +=
"<label class='total_events' style='border: 1px solid gray; font-size:large; vertical-align:middle; padding-left:3px; padding-right:3px;'>---</label> Events ";
44 html +=
"<label class='analysis_time' style='border: 1px solid gray; font-size:large; vertical-align:middle; padding-left:3px; padding-right:3px;'>time</label>";
47 $(
'#'+divid).css(
'overflow',
'hidden')
48 .css(
'padding-left',
'5px')
49 .css(
'display',
'inline-block')
50 .css(
'white-space',
'nowrap')
54 JSROOT.Painter.AdjustLayout(null, $(
'#'+divid+
' div').height()+4,
false);
57 var was_running = null;
59 function UpdateRatemeter() {
60 if (xreq!=null)
return;
62 xreq = JSROOT.NewHttpRequest(itemname+
"/root.json.gz",
'object',
function(res) {
66 return $(
'#'+divid +
" .event_rate").css(
'background-color',
'grey');
68 $(
'#'+divid +
" .event_rate").css(
'background-color', res.fbRunning ?
'lightgreen' :
'red');
69 if (was_running != res.fbRunning)
70 $(
'#'+divid +
" .go4_logo").attr(
"src", res.fbRunning ?
'go4sys/icons/go4logorun4.gif' :
'go4sys/icons/go4logo_t.png');
71 was_running = res.fbRunning;
73 $(
'#'+divid +
" .event_source").text(res.fxEventSource ==
"" ?
"<source>" : res.fxEventSource);
74 $(
'#'+divid +
" .event_rate").text(res.fdRate.toFixed(1));
75 $(
'#'+divid +
" .aver_rate").text((res.fdTime > 0 ? res.fuCurrentCount / res.fdTime : 0).toFixed(1));
76 $(
'#'+divid +
" .run_time").text(res.fdTime.toFixed(1));
77 $(
'#'+divid +
" .total_events").text(res.fuCurrentCount);
78 $(
'#'+divid +
" .analysis_time").text(res.fxDateString ==
"" ?
"<datime>" : res.fxDateString);
84 setInterval(UpdateRatemeter, 2000);
88 GO4.MakeMsgListRequest =
function(hitem, item) {
89 var arg =
"&max=2000";
90 if (
'last-id' in item) arg+=
"&id="+item[
'last-id'];
91 return 'exe.json.gz?method=Select' + arg;
94 GO4.AfterMsgListRequest =
function(hitem, item, obj) {
98 delete item[
'last-id'];
102 if (obj._typename !=
'TList')
return;
104 obj._typename =
"TGo4MsgList";
106 if (obj.arr.length>0) {
107 var duplicate = ((
'last-id' in item) && (item[
'last-id'] == obj.arr[0].fString));
109 item[
'last-id'] = obj.arr[0].fString;
112 if (duplicate) obj.arr.length = 1;
115 if (!(
'clear' in item))
116 item[
'clear'] =
function() {
delete this[
'last-id']; }
121 GO4.MsgListPainter =
function(lst) {
122 JSROOT.TBasePainter.call(
this);
129 GO4.MsgListPainter.prototype = Object.create( JSROOT.TBasePainter.prototype );
131 GO4.MsgListPainter.prototype.RedrawObject =
function(obj) {
137 GO4.MsgListPainter.prototype.Draw =
function() {
138 if (this.lst==null)
return;
140 var frame = d3.select(
"#" + this.divid);
142 var
main = frame.select(
"div");
144 main = frame.append(
"div")
145 .style(
'max-width',
'100%')
146 .style(
'max-height',
'100%')
147 .style(
'overflow',
'auto');
149 var old = main.selectAll(
"pre");
150 var newsize = old.size() + this.lst.arr.length - 1;
154 old.select(
function(d,i) {
return i < newsize - 2000 ?
this : null; }).
remove();
156 for (var i=this.lst.arr.length-1;i>0;i--)
157 main.append(
"pre").style(
'margin',
'3px').html(this.lst.arr[i].fString);
160 this.SetDivId(this.divid);
164 GO4.DrawMsgList =
function(divid, lst, opt) {
165 var painter =
new GO4.MsgListPainter(lst);
166 painter.SetDivId(divid);
168 return painter.DrawingReady();
171 GO4.drawAnalysisTerminal =
function(hpainter, itemname) {
172 var url = hpainter.GetOnlineItemUrl(itemname);
173 if (url == null)
return null;
174 var frame = hpainter.GetDisplay().FindFrame(itemname,
true);
175 if (frame==null)
return null;
176 var divid = d3.select(frame).attr(
'id');
177 var h = $(
"#"+divid).height(), w = $(
"#"+divid).width();
178 if ((h<10) && (w>10)) $(
"#"+divid).height(w*0.7);
180 var player =
new JSROOT.TBasePainter();
182 player.hpainter = hpainter;
183 player.itemname = itemname;
184 player.draw_ready =
true;
185 player.needscroll =
false;
188 player.DrawReady =
function() {
189 if(this.needscroll) {
191 this.needscroll=
false;
193 this.draw_ready =
true;
197 player.ProcessTimer =
function() {
199 var subid =
"anaterm_output_container";
200 if ($(
"#" + subid).length==0) {
202 clearInterval(this.interval);
203 this.interval = null;
206 if (!this.draw_ready)
return;
208 var msgitem = this.itemname.replace(
"Control/Terminal",
"Status/Log");
210 this.draw_ready =
false;
212 this.hpainter.display(msgitem,
"divid:" + subid, this.DrawReady.bind(
this));
215 player.ClickCommand =
function(kind) {
217 this.hpainter.ExecuteCommand(this.itemname.replace(
"Terminal",
"CmdExecute"),
function(){pthis.needscroll=
true}, kind);
222 player.ClickClear =
function() {
224 document.getElementById(
"anaterm_output_container").firstChild.innerHTML=
"";
227 player.ClickScroll =
function() {
229 var disp = $(
"#anaterm_output_container").children(
":first");
230 disp.scrollTop(disp[0].scrollHeight - disp.height());
234 player.fillDisplay =
function() {
236 var
id =
"#"+this.divid;
239 this.interval = setInterval(this.ProcessTimer.bind(
this), 2000);
241 $(
id +
" .go4_clearterm")
242 .button({text:
false, icons: { primary:
"ui-icon-blank MyTermButtonStyle"}})
243 .click(this.ClickClear.bind(
this))
245 .css(
'background-image',
"url(" + GO4.source_dir +
"icons/clear.png)");
248 $(
id +
" .go4_endterm")
249 .button({text:
false, icons: { primary:
"ui-icon-blank MyTermButtonStyle"}})
250 .click(this.ClickScroll.bind(
this))
252 .css(
'background-image',
"url(" + GO4.source_dir +
"icons/shiftdown.png)");
256 $(
id +
" .go4_printhistos")
257 .button({text:
false, icons: { primary:
"ui-icon-blank MyTermButtonStyle"}})
258 .click(this.ClickCommand.bind(
this,
"@PrintHistograms()"))
260 .css(
'background-image',
"url(" + GO4.source_dir +
"icons/hislist.png)");
262 $(
id +
" .go4_printcond").button()
263 .button({text:
false, icons: { primary:
"ui-icon-blank MyTermButtonStyle"}})
264 .click(this.ClickCommand.bind(
this,
"@PrintConditions()"))
266 .css(
'background-image',
"url(" + GO4.source_dir +
"icons/condlist.png)");
269 $(
"#go4_anaterm_cmd_form").submit(
271 var command= pthis.itemname.replace(
"Terminal",
"CmdExecute");
272 var cmdpar=document.getElementById(
"go4_anaterm_command").value;
273 console.log(
"submit command - " + cmdpar);
274 pthis.hpainter.ExecuteCommand(command,
function(){pthis.needscroll=
true}, cmdpar);
275 event.preventDefault();
279 $(
id +
" .go4_executescript").button()
280 .button({text:
false, icons: { primary:
"ui-icon-blank MyTermButtonStyle"}})
282 .css(
'background-image',
"url(" + GO4.source_dir +
"icons/macro_t.png)");
286 player.Show =
function(divid) {
288 $(
"#"+divid).load(GO4.source_dir +
"html/terminal.htm",
"",
289 function() { pthis.SetDivId(divid); pthis.fillDisplay();}
295 player.CheckResize =
function(force) {
299 return player.Show(divid);
305 JSROOT.addDrawFunc(
"TGo4WinCond", { script: GO4.source_dir +
'html/condition.js', func:
'GO4.drawGo4Cond' },
";editor");
306 JSROOT.addDrawFunc(
"TGo4PolyCond", { script: GO4.source_dir +
'html/condition.js', func:
'GO4.drawGo4Cond' },
";editor");
307 JSROOT.addDrawFunc(
"TGo4ShapedCond", { script: GO4.source_dir +
'html/condition.js', func:
'GO4.drawGo4Cond' },
";editor");
309 JSROOT.addDrawFunc(
"TGo4AnalysisWebStatus", { script: GO4.source_dir +
'html/analysiseditor.js', func:
'GO4.drawGo4AnalysisStatus' },
"editor");
311 JSROOT.addDrawFunc(
"TGo4MsgList", GO4.DrawMsgList,
"");
313 JSROOT.addDrawFunc({ name:
"TGo4MbsEvent", noinspect:
true });
314 JSROOT.addDrawFunc({ name:
"TGo4EventElement", noinspect:
true });
int main(int argc, char **argv)