--- /dev/null
+
+
+
+
+
+
+
+
+.plasticBox {
+ border-radius:5px;
+ background:#eef;
+ box-shadow: 0 0 10px 5px #fff, 0 0 4px 1px #78b inset;
+}
+
+.debugFeature {
+ visibility:collapse;
+}
+
+
+#selectors {
+ float:right;
+ position:absolute;
+ position:fixed;
+ top: 0px;
+ left: 640px;
+ width:280px;
+ padding:10px;
+ margin-top:30px;
+ margin-left:30px;
+
+ }
+
+.plotArea {
+/* float:left; */
+ position:absolute;
+/* position:fixed; */
+/* width:320px; */
+ left:0px;
+ top:0px;
+ min-width: 600px;
+ min-height: 400px;
+ padding:10px;
+ margin-top:30px;
+ margin-left:30px;
+
+ }
+
+#plotAreaFg {
+ z-index: +1;
+}
+#plotAreaBg {
+}
\ No newline at end of file
--- /dev/null
+/**
+ * jquery.timer.js
+ *
+ * Copyright (c) 2011 Jason Chavannes <jason.chavannes@gmail.com>
+ *
+ * http://jchavannes.com/jquery-timer
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy,
+ * modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+;(function($) {
+ $.timer = function(func, time, autostart) {
+ this.set = function(func, time, autostart) {
+ this.init = true;
+ if(typeof func == 'object') {
+ var paramList = ['autostart', 'time'];
+ for(var arg in paramList) {if(func[paramList[arg]] != undefined) {eval(paramList[arg] + " = func[paramList[arg]]");}};
+ func = func.action;
+ }
+ if(typeof func == 'function') {this.action = func;}
+ if(!isNaN(time)) {this.intervalTime = time;}
+ if(autostart && !this.isActive) {
+ this.isActive = true;
+ this.setTimer();
+ }
+ return this;
+ };
+ this.once = function(time) {
+ var timer = this;
+ if(isNaN(time)) {time = 0;}
+ window.setTimeout(function() {timer.action();}, time);
+ return this;
+ };
+ this.play = function(reset) {
+ if(!this.isActive) {
+ if(reset) {this.setTimer();}
+ else {this.setTimer(this.remaining);}
+ this.isActive = true;
+ }
+ return this;
+ };
+ this.pause = function() {
+ if(this.isActive) {
+ this.isActive = false;
+ this.remaining -= new Date() - this.last;
+ this.clearTimer();
+ }
+ return this;
+ };
+ this.stop = function() {
+ this.isActive = false;
+ this.remaining = this.intervalTime;
+ this.clearTimer();
+ return this;
+ };
+ this.toggle = function(reset) {
+ if(this.isActive) {this.pause();}
+ else if(reset) {this.play(true);}
+ else {this.play();}
+ return this;
+ };
+ this.reset = function() {
+ this.isActive = false;
+ this.play(true);
+ return this;
+ };
+ this.clearTimer = function() {
+ window.clearTimeout(this.timeoutObject);
+ };
+ this.setTimer = function(time) {
+ var timer = this;
+ if(typeof this.action != 'function') {return;}
+ if(isNaN(time)) {time = this.intervalTime;}
+ this.remaining = time;
+ this.last = new Date();
+ this.clearTimer();
+ this.timeoutObject = window.setTimeout(function() {timer.go();}, time);
+ };
+ this.go = function() {
+ if(this.isActive) {
+ this.action();
+ this.setTimer();
+ }
+ };
+
+ if(this.init) {
+ return new $.timer(func, time, autostart);
+ } else {
+ this.set(func, time, autostart);
+ return this;
+ }
+ };
+})(jQuery);
if (-e $self->{shm}) {
die "service already running!\n";
} else {
- system("./plotService.pl --shm ".$self->{shm}.' >/dev/null & disown');
+ system("./plotService.pl --daemonize --shm ".$self->{shm});
for (my $i = 0; $i< $self->{startTimeout}*100; $i++){
if( -e $self->{shm} ) {
return 1;
+var timer;
-$(document).ready(function(){
+function activateSelectorFunctions() {
+
$("#btn1").click(function(){
$("#test1").text(function(i,origText){
return "Old text: " + origText + " New text: Hello world! (index: " + i + ")";
});
$("#comm_ajax").click(function(){
- var collector = [];
- $(".channelCheckbox:checked").each(function(){
- var cb_id = $(this).attr('id');
- collector.push( cb_id.replace(/checkbox_/,""));
- });
- var requestStrings = collector.join(",");
- var daqopserver = $("#input_DAQOPSERVER").val();
- $.ajax({
+ refreshPlots();
+ });
+ var counter= 0;
+
+ $(".selectorsReloadTrigger").change(function(){
+ var DAQOPSERVER = $("#input_DAQOPSERVER").val();
+ var FPGA = $("#FPGA_selector :selected").val();
+ var CB = $("#CB_selector :selected").val();
+ var chip = $("#chip_selector :selected").val();
+ $.ajax({
url: "adcmon.pl",
cache: false,
+ async: false,
dataType: "text",
- data: { sub: 'plot_request',
- requestStrings: requestStrings,
- DAQOPSERVER: daqopserver},
- success: function(result) {$("#plotArea").html(result);}
- });
-
-
- });
- var counter= 0;
+ data: {
+ sub : "print_selectors",
+ DAQOPSERVER: DAQOPSERVER,
+ FPGA : FPGA,
+ CB : CB,
+ chip : chip
+ },
+ success: function(result) {
+ $("#selectors").html(result);
+ activateSelectorFunctions();
+ }
+ });
+ });
- var timer = $.timer(function() {
-// alert('This message was sent by a timer.');
- $("#refreshInterval").val(counter++);
- });
- timer.set({ time : 2000, autostart : true });
-
+
$("#test_but").click(function(){
var collector = [];
});
alert(collector.join(","));
});
+
+ $("#startStopButton").click(function(){
+ if(timer.isActive){
+ timer.stop();
+ $(this).text("start");
+ } else {
+ $(this).text("stop");
+ timer.set({time:1000,autostart: true});
+ }
+
+ });
+
+}
+
+$(document).ready(function(){
+
+
+ timer = $.timer(function() {
+ refreshPlots();
+ });
+
+ activateSelectorFunctions();
});
+var BgFg = true; // true when bg is being refreshed
+
+function refreshPlots(){
+ var collector = [];
+ var fadeSpeed = 200;
+ $(".channelCheckbox:checked").each(function(){
+ var cb_id = $(this).attr('id');
+ collector.push( cb_id.replace(/checkbox_/,""));
+ });
+ var requestStrings = collector.join(",");
+ var DAQOPSERVER = $("#input_DAQOPSERVER").val();
+ $.ajax({
+ url: "adcmon.pl",
+ cache: false,
+ async: false,
+ dataType: "text",
+ data: { sub: 'plot_request',
+ requestStrings: requestStrings,
+ DAQOPSERVER: DAQOPSERVER},
+ success: function(result) {
+// var tempScrollTop = $(window).scrollTop();
+ if(BgFg) {
+
+ $("#plotAreaBg").html(result);
+ $("#plotAreaFg").fadeOut(fadeSpeed);
+
+ BgFg = false;
+ }else{
+
+ $("#plotAreaFg").html(result);
+ $("#plotAreaFg").fadeIn(fadeSpeed);
+
+ BgFg = true;
+ }
+// $(window).scrollTop(tempScrollTop);
+ }
+ });
+
+
+}
require Common;
-
use FindBin;
use lib "$FindBin::Bin/..";
use Environment;
+
+##############
+## preliminarily hardcoded constants
+##############
+my $CBsPerFpga=2;
+my $ChipsPerCB=2;
+
+
+
+
+
+
+
+
+
# subs that are callable via http request
my $dispatch = {
table_hash => \&table_hash,
- plot_request => \&plot_request
+ plot_request => \&plot_request,
+ print_selectors => \&print_selectors
};
my $q = CGI->new;
my $entityFile = "../../daqtools/xml-db/cache/CbController.entity";
my $xmldb;
-
+my $plotWidth=600;
+my $plotHeight=400;
$ENV{'DAQOPSERVER'} = $q->param('DAQOPSERVER') if defined $q->param('DAQOPSERVER');
-my $FPGA = $q->param('FPGA');
-my $CB = $q->param('CB');
-my $chip = $q->param('chip');
-my $channel = $q->param('channel');
+
my $daqopserver = $ENV{'DAQOPSERVER'};
# }
# system("echo 'blah'>".$ps->{plotDir}."/test.txt");
for my $reqStr (@requestStrings){
- print "<img src='".addpng($ps->{plotDir}."/".$reqStr.".png")."'>";
+ print "<img alt='$reqStr' width='$plotWidth' height='$plotHeight' src='".addpng($ps->{plotDir}."/".$reqStr.".png")."'>";
print br;
}
}
sub print_selectors {
-
+my $FPGA = $q->param('FPGA');
+my $CB = $q->param('CB');
+my $chip = $q->param('chip');
+my $channel = $q->param('channel');
my $q=shift;
print "<table>";
print "<tr>";
print "<td>DAQOPSERVER</td>";
-print "<td><input type='text' id='input_DAQOPSERVER' value='".$daqopserver."'></td>";
+print "<td colspan=2><input type='text' class='selectorsReloadTrigger' id='input_DAQOPSERVER' value='".$daqopserver."'></td>";
print "</tr>";
print "<tr>";
print "<td>FPGA</td>";
my $FPGA_selector = fileSelector->new(
id=>"FPGA_selector",
name=>"FPGA_selectionDropdown",
- selected=>lc($q->param("FPGA"))
+ selected=>lc($q->param("FPGA")),
+ class=>"selectorsReloadTrigger"
);
$FPGA_selector->add_item(value=>'...');
for my $element (activeTRBs()) {
my $CB_selector = fileSelector->new(
id=>"CB_selector",
name=>"CB_selectionDropdown",
- selected=>$q->param("CB")
+ selected=>$q->param("CB"),
+ class=>"selectorsReloadTrigger"
);
$CB_selector->add_item(value=>'...');
-$CB_selector->add_item(value=>$q->param("CB")) if defined $q->param("CB");
+for( my $i = 0; $i < $CBsPerFpga; $i++){
+ $CB_selector->add_item(value=>$i);
+}
+# $CB_selector->add_item(value=>$q->param("CB")) if defined $q->param("CB");
$CB_selector->print_html();
print "</td>";
print "<td>";
my $chip_selector = fileSelector->new(
id=>"chip_selector",
name=>"chip_selectionDropdown",
- selected=>$q->param("chip")
+ selected=>$q->param("chip"),
+ class=>"selectorsReloadTrigger"
);
$chip_selector->add_item(value=>'...');
-$chip_selector->add_item(value=>$q->param("chip")) if defined $q->param("chip");
+for( my $i = 0; $i < $ChipsPerCB; $i++){
+ $chip_selector->add_item(value=>$i);
+}
+# $chip_selector->add_item(value=>$q->param("chip")) if defined $q->param("chip");
$chip_selector->print_html();
print "</td>";
print "</tr>";
print "<table>";
print "<tr>";
+
print "<td>";
+print "<button id='startStopButton'>start</button>";
+print "</td>";
+print "</tr>";
+
+
+print "<tr class='debugFeature'>";
+print "<td class='debugFeature'>";
print "<button id='comm_ajax'>ajax!</button>";
print "</td>";
-print "<td>";
+print "<td class='debugFeature'>";
print "<button id='test_but'>test</button>";
print "</td>";
-print "<td>";
+print "<td class='debugFeature'>";
print "<input type='text' name='refresh(ms)' id='refreshInterval' value='1000'>";
print "</td>";
-print "</tr>";
+print "<tr>";
+
print "</table>";
-trb_init_ports() or die trb_strerror();
-print '<div id="selectors">';
+
+print '<div id="selectors" class="plasticBox">';
print_selectors($q);
print '</div>';
-print '<div id="plotArea">';
-print_plotArea($q);
+print '<div id="plotAreaBg" class="plasticBox plotArea">';
+# print "plotAreaBg";
+print '</div>';
+
+print '<div id="plotAreaFg" class="plotArea">';
+# print "plotAreaFg";
print '</div>';
-print '<div id="debugStuff">';
+print '<div id="debugStuff" class="debugFeature">';
print_debugStuff($q);
print '</div>';
}
-sub print_plotArea{
- my $q=shift;
- print p "plot Area";
-
-}
sub print_debugStuff{
-title=>'ADC Monitor',
-style=>[{'src'=>'../layout/styles.css'},
{'src'=>'../layout/jtageditor_blue.css'},
- {'src'=>'../layout/testgui.css'}
+ {'src'=>'../layout/adcmon.css'}
],
-script=>[
{ -type => 'text/javascript', -src => 'http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js'},
sub activeTRBs {
+
+# trb_init_ports() or die trb_strerror();
+ trb_init_ports() or return ();
+
# read microsecond counters, return list of active addresses
my $read = trb_register_read(0xFFFF,0x50);
return (keys %$read);
my $suicideTimer = time();
my $updateInterval = 1; #s
my $updateTS = time();
+my $daemonize = 0;
Getopt::Long::Configure(qw(gnu_getopt));
GetOptions(
'shm=s' => \$shm,
'timeout=s' => \$timeout,
+ 'daemonize' => \$daemonize
);
-
+daemonize() if $daemonize;
PlotJob::initXmlDb("../../daqtools/xml-db/cache/CbController.entity");
PlotJob::initTrbNet();
}
}
+
+sub daemonize {
+# chdir '/' or die "Can't chdir to /: $!";
+open STDIN, '/dev/null' or die "Can't read /dev/null: $!";
+open STDOUT, '>>/dev/null' or die "Can't write to /dev/null: $!";
+open STDERR, '>>/dev/null' or die "Can't write to /dev/null: $!";
+defined(my $pid = fork) or die "Can't fork: $!";
+exit if $pid;
+POSIX::setsid or die "Can't start a new session: $!";
+umask 0;
+}
+
+
package PlotJob;
use HPlot;
+
+
1;
\ No newline at end of file