artdaq_node_server  v1_00_12
UDPDump.js
1 var artStarted = false;
2 
3 function manageButtons( artRunning ) {
4  if(artRunning) {
5  $("#shutdown").html("<span>Stop UDPDump</span>").attr("class","animated green visible");
6  $("#started").html("<span>UDPDump Running</span>").attr("class","animated blue visible");
7  } else {
8  $("#shutdown").html("<span>UDPDump Not Running</span>").attr("class","animated blue visible");
9  $("#started").html("<span>Start UDPDump</span>").attr("class","animated green visible");
10  }
11 
12  $( ".green.animated" ).hover( function () {
13  $( this ).addClass( "active" );
14  },function () { $( this ).removeClass( "active" ); } );
15 }
16 
17 function update( data ) {
18  //var data = $.parseJSON( dataJSON );
19  manageButtons( data.running );
20 
21 
22  var out = $("#out")[0];
23  var err = $("#err")[0];
24  var outAtBottom = out.scrollTop + out.clientHeight >= out.scrollHeight - 10;
25  var errAtBottom = err.scrollTop + err.clientHeight >= err.scrollHeight - 10;
26  $( "#out" ).val( data.out );
27  $( "#err" ).val( data.err );
28  if(outAtBottom) { out.scrollTop = out.scrollHeight };
29  if(errAtBottom) { err.scrollTop = err.scrollHeight };
30 
31  if(artStarted) {
32  setTimeout(function() {Onmon("#wd0div",0,"udpdump");}, 1000);
33  artStarted = false;
34  }
35 
36  if(data.running) { setTimeout(function() { AjaxGet( "/udpdump/Log", update); }, 1000); }
37 }
38 
39 function getFileNames() {
40  $.get("/udpdump/FileNames", function(result) {
41  $("#fileName").html(result);
42  });
43 }
44 
45 function shutdownSystem() {
46  if ( $( "#shutdown" ).is( ".green" ) ) {
47  AjaxPost( "/udpdump/Kill",{ },update );
48  }
49 }
50 
51 function startSystem() {
52  if ( $( "#started" ).is( ".green" ) ) {
53  artStarted = true;
54  $("#wd0div").empty();
55  AjaxPost( "/udpdump/Start",{ fileIndex: $( "#fileName" )[0].selectedIndex },update );
56  }
57 }
58 
59 $( document ).ready( function() {
60  $("#shutdown").click(function() {
61  shutdownSystem();
62  });
63  $("#started").click(function() {
64  startSystem();
65  });
66 
67  getFileNames();
68  $("#reloadFileNames").click(function() {
69  getFileNames();
70  });
71 
72  AjaxGet("/udpdump/Log", update);
73  });