2 var onmonStarted =
false;
6 function openCanvasWindow( pad,width,height ) {
7 var thisWindow = window.open(
"/artdaq-runcontrol/viewer.html?pad=" + pad +
"&partition=" + partition,
"ROOT Pad Inspector",
"width=" + width +
", height=" + height );
10 function openConfigWindow( config ) {
11 var thisWindow = window.open(
"/artdaq-configuration/ConfigurationEditor.html?configs=" + config );
14 function updateGUI() {
15 if ( hpainter == null ) hpainter =
new JSROOT.HierarchyPainter(
'root',
'wd1div' );
16 hpainter.SetDisplay(
"grid2x1",
'wd0div' );
18 hpainter.OpenRootFile(
"/artdaq-runcontrol/P" + partition +
"/artdaqdemo_onmon.root",
function () {
19 hpainter.displayAll( [
"wf0",
"wf1"] );
21 $(
"#wd0div_grid_0" ).click(
function () {
22 openCanvasWindow(
"wf0",$(
this ).width( ),$(
this ).height( ) );
24 $(
"#wd0div_grid_1" ).click(
function () {
25 openCanvasWindow(
"wf1",$(
this ).width( ),$(
this ).height( ) );
30 function manageButtons( state,running,systemRunning ) {
31 var shutdownActive = $(
"#shutdown" ).hasClass(
"active" ) ?
" active " :
"";
32 var startedActive = $(
"#started" ).hasClass(
"active" ) ?
" active" :
"";
33 var initializedActive = $(
"#initialized" ).hasClass(
"active" ) ?
" active" :
"";
34 var runStartedActive = $(
"#runStarted" ).hasClass(
"active" ) ?
" active" :
"";
35 var runPausedActive = $(
"#runPaused" ).hasClass(
"active" ) ?
" active" :
"";
37 var color = running ?
"yellow" :
"green";
39 if ( !systemRunning ) { color =
"red"; }
43 color = systemRunning ?
"yellow" :
"green";
44 $(
"#shutdown" ).html(
"<span>System Shutdown</span>" ).attr(
"class",
"animated blue visible" );
45 $(
"#started" ).html(
"<span>Boot System</span>" ).attr(
"class",
"animated visible " + color + startedActive );
46 $(
"#initialized" ).html(
"<span></span>" ).attr(
"class",
"animated red hidden" );
47 $(
"#runStarted" ).html(
"<span></span>" ).attr(
"class",
"animated red hidden" );
48 $(
"#runPaused" ).html(
"<span></span>" ).attr(
"class",
"animated red hidden" );
51 $(
"#shutdown" ).html(
"<span>Shutdown System</span>" ).attr(
"class",
"animated visible " + sdColor + shutdownActive );
52 $(
"#started" ).html(
"<span>System Booted</span>" ).attr(
"class",
"animated blue visible" );
53 $(
"#initialized" ).html(
"<span>Initialize System</span>" ).attr(
"class",
"animated visible " + color + initializedActive );
54 $(
"#runStarted" ).html(
"<span></span>" ).attr(
"class",
"animated red hidden" );
55 $(
"#runPaused" ).html(
"<span></span>" ).attr(
"class",
"animated red hidden" );
58 $(
"#shutdown" ).html(
"<span>Shutdown System</span>" ).attr(
"class",
"animated visible " + sdColor + shutdownActive );
59 $(
"#started" ).html(
"<span></span>" ).attr(
"class",
"animated red hidden" );
60 $(
"#initialized" ).html(
"<span>System Initialized</span>" ).attr(
"class",
"animated blue visible" );
61 $(
"#runStarted" ).html(
"<span>Start Run</span>" ).attr(
"class",
"animated visible " + color + runStartedActive );
62 $(
"#runPaused" ).html(
"<span></span>" ).attr(
"class",
"animated red hidden" );
65 $(
"#shutdown" ).html(
"<span></span>" ).attr(
"class",
"animated red hidden" );
66 $(
"#started" ).html(
"<span></span>" ).attr(
"class",
"animated red hidden" );
67 $(
"#initialized" ).html(
"<span>End Run</span>" ).attr(
"class",
"animated visible " + color + initializedActive );
68 $(
"#runStarted" ).html(
"<span>Running</span>" ).attr(
"class",
"animated blue visible" );
69 $(
"#runPaused" ).html(
"<span>Pause Run</span>" ).attr(
"class",
"animated visible " + color + runPausedActive );
72 $(
"#shutdown" ).html(
"<span>Shutdown System</span>" ).attr(
"class",
"animated visible " + sdColor + shutdownActive );
73 $(
"#started" ).html(
"<span></span>" ).attr(
"class",
"animated red hidden" );
74 $(
"#initialized" ).html(
"<span>Reinitialize System</span>" ).attr(
"class",
"animated visible " + color + initializedActive );
75 $(
"#runStarted" ).html(
"<span>Resume Run</span>" ).attr(
"class",
"animated visible " + color + runStartedActive );
76 $(
"#runPaused" ).html(
"<span>Run Paused</span>" ).attr(
"class",
"animated blue visible" );
80 $(
".green.animated" ).hover(
function () {
81 $( this ).addClass(
"active" );
82 },
function () { $( this ).removeClass(
"active" ); } );
86 function update( dataJSON ) {
87 var data = $.parseJSON( dataJSON );
88 partition = data.partition;
89 $(
"#partition" ).val( data.partition );
90 manageButtons( data.state,data.commandRunning,data.systemRunning );
92 $(
"#configs" ).val( data.config );
94 var out = $(
"#systemOut")[0];
95 var err = $(
"#systemErr")[0];
96 var outAtBottom = out.scrollTop + out.clientHeight >= out.scrollHeight - 10;
97 var errAtBottom = err.scrollTop + err.clientHeight >= err.scrollHeight - 10;
98 $(
"#systemOut" ).val( data.systemOutputBuffer );
99 $(
"#systemErr" ).val( data.systemErrorBuffer );
100 if(outAtBottom) { out.scrollTop = out.scrollHeight };
101 if(errAtBottom) { err.scrollTop = err.scrollHeight };
103 out = $(
"#commOut")[0];
104 err = $(
"#commErr")[0];
105 outAtBottom = out.scrollTop + out.clientHeight >= out.scrollHeight - 10;
106 errAtBottom = err.scrollTop + err.clientHeight >= err.scrollHeight - 10;
107 $(
"#commOut" ).val( data.commandOutputBuffer );
108 $(
"#commErr" ).val( data.commandErrorBuffer );
109 if(outAtBottom) { out.scrollTop = out.scrollHeight };
110 if(errAtBottom) { err.scrollTop = err.scrollHeight };
112 if ( data.WFPlotsUpdated && $(
"#monitoringEnabled" ).is(
":checked" ) ) {
113 var updateDate = data.WFPlotsUpdated;
114 if ( updateDate > lastUpdate ) {
116 lastUpdate = updateDate;
120 $(
"#wd0div" ).html(
"" );
123 if((!onmonStarted) && data.okToStartOnMon)
125 Onmon(
"#onmonDiv", partition,
"artdaq-runcontrol");
131 function shutdownSystem() {
132 if ( $(
"#shutdown" ).is(
".green" ) ) {
133 AjaxPost(
"/artdaq-runcontrol/Shutdown",{ partition: $(
"#partition" ).val( ), config: $(
"#config" ).find(
":selected" ).val( ) },update );
137 function startSystem() {
138 if ( $(
"#started" ).is(
".green" ) ) {
139 AjaxPost(
"/artdaq-runcontrol/Start",{ partition: $(
"#partition" ).val( ), config: $(
"#config" ).find(
":selected" ).val( ) },update );
143 function initSystem() {
144 if ( $(
"#initialized" ).is(
".green" ) ) {
145 if ( $(
"#started" ).is(
".blue" ) ) {
146 var verbosity = $(
"#verbosity" ).is(
":checked" );
147 AjaxPost(
"/artdaq-runcontrol/Init",{ partition: $(
"#partition" ).val( ), config: $(
"#config" ).find(
":selected" ).val( ) },update );
150 AjaxPost(
"/artdaq-runcontrol/End",{ partition: $(
"#partition" ).val( ), config: $(
"#config" ).find(
":selected" ).val( ) },update );
151 var number = parseInt( $(
"#runNumber" ).val( ) );
152 $(
"#runNumber" ).val( number + 1 );
157 function startRun() {
158 if ( $(
"#runStarted" ).is(
".green" ) ) {
159 if ( $(
"#runPaused" ).is(
".blue" ) ) {
160 AjaxPost(
"/artdaq-runcontrol/Resume",{ partition: $(
"#partition" ).val( ), config: $(
"#config" ).find(
":selected" ).val( ) },update );
162 AjaxPost(
"/artdaq-runcontrol/Run",{ partition: $(
"#partition" ).val( ), runNumber: $(
"#runNumber" ).val( ), config: $(
"#config" ).find(
":selected" ).val( ) },update );
167 function pauseRun() {
168 if ( $(
"#runPaused" ).is(
".green" ) ) {
169 AjaxPost(
"/artdaq-runcontrol/Pause",{ partition: $(
"#partition" ).val( ), config: $(
"#config" ).find(
":selected" ).val( ) },update );
173 function getConfigs() {
174 $.get(
"/artdaq-configuration/NamedConfigs",
function ( result ) {
175 $(
"#config" ).html( result );
179 $( document ).ready(
function () {
180 $(
"#shutdown" ).click(
function () {
183 $(
"#started" ).click(
function () {
186 $(
"#initialized" ).click(
function () {
189 $(
"#runStarted" ).click(
function () {
192 $(
"#runPaused" ).click(
function () {
195 $(
"#monitoringEnabled" ).change(
function () {
196 if ( $(
"#monitoringEnabled" ).is(
":checked" ) ) {
202 $(
"#editConfig" ).click(
function () {
203 var config = $(
"#config" ).find(
":selected" ).val( );
204 openConfigWindow( config );
207 $(
"#reloadConfigs" ).click(
function () {
211 setInterval(
function () { AjaxGet(
"/artdaq-runcontrol/P" + $(
"#partition" ).val( ),update ); },1000 );
212 JSROOT.AssertPrerequisites(
'2d;io;',updateGUI );