use constant TEMPDIR => JTAGROOTPATH."temp/";
use constant SETUPDIR => JTAGROOTPATH."../mvdconfig/setup/";
+use constant SYSTEMDIR => JTAGROOTPATH."../mvdconfig/system/";
use constant CONFDIR => JTAGROOTPATH."../mvdconfig/config/";
use constant SPECDIR => JTAGROOTPATH."specs/";
use constant PICTUREPATH => TEMPDIR."prevImgs/"; #path for images on webserver (absolute path)
my $opt_time;
my $opt_path="./";
my $time;
-
+my $opt_system = "null";
+my $opt_ports;
GetOptions ('h|help' => \$opt_help,
't|time=f' => \$opt_time,
- 'p|path=s' => \$opt_path
+ 'p|path=s' => \$opt_path,
+ 's|system=s' => \$opt_system,
+ 'd|ports=s' => \$opt_ports
);
if($opt_help) {
[-h|--help] : Show this help.
[-p|--path /path/to/dump/data/ ] : Specify the path where the data is to be written to.
default: ./
+ -s|system <id> : Name of the system data is read from.
+ -d|ports <portlist> : dash separated list of ports to listen on.
"
}
$time = 3;
}
+my $c;
+my $portoption = "";
+if (defined($opt_ports)) {
+ $portoption = $opt_ports;
+ $c = ($portoption =~ tr/-//) + 1;
+ $opt_ports =~ s/-/ -i /g;
+ $portoption = "-i ".$opt_ports;
+ }
+else {
+ die "No ports specified";
+ }
+
chdir($opt_path);
-$thr1 = threads->new(\&execute, "timeout -s SIGINT ".($time+1.5)." daq_evtbuild -m 1 -q 32 -d file -x te -Se -S mvdtest");
+$thr1 = threads->new(\&execute, "timeout -s SIGINT ".($time+1.5)." daq_evtbuild -m $c -q 32 -d file -x te -Se -S $opt_system");
sleep 1;
-$thr2 = threads->new(\&execute, "timeout -s SIGINT ".$time." daq_netmem -m 1 -q 32 -i 50000 -S mvdtest");
+$thr2 = threads->new(\&execute, "timeout -s SIGINT ".$time." daq_netmem -m $c -q 32 $portoption -S $opt_system");
$thr1->join();
$thr2->join();
my $s = shift;
system($s);
}
+
my $totalevents = 1E9;
my $opt_movie = 0;
my $mode = "";
+my $system = "null";
GetOptions ('h|help' => \$opt_help,
'f|file=s' => \$file,
'd|debug' => \$opt_debug,
'p|picpath=s' => \$opt_picpath,
'm|movie=i' => \$opt_movie,
+ 's|system=s' => \$system,
'e|events=i' => \$totalevents);
printf("[-i|--info] Show frame information\n");
printf("[-d|--debug] More debugging output\n");
printf("[-m|--movie] Make a slideshow of frames\n");
+ printf("[-s|--system] <name>Name of the system\n");
printf("[-p|--picpath] Set where to write plots\n");
printf("\n");
exit;
print $fg strftime("set label 100 \"%H:%M:%S\" at screen 0.98,0.02 right tc rgb \"#000044\" font \"monospace,8\"\n", localtime());
print $fg "set label 101 \"".$hitcount->{$id}." States, ".($Statistics->{$id}->{Valid}||0)." good, ".($Statistics->{$id}->{Broken}||0)." broken, ".($Statistics->{$id}->{RealBroken}||0)." invalid\" at screen 0.02,0.02 left tc rgb \"#000044\" font \"monospace,8\"\n" ;
- print $fg "set output '$opt_picpath/image_recalibrated_$s$num.png';\n";
+ print $fg "set output '$opt_picpath/".$system."_$s$num.png';\n";
print $fg "plot '-' matrix with image\n";
}
else {
my $s = sprintf("%04x",$id);
print $fg strftime("set label 100 \"%H:%M:%S\" at screen 0.98,0.02 right tc rgb \"#000044\" font \"monospace,8\"\n", localtime());
print $fg "set label 101 \"".$hitcount->{$id}." States, ".($Statistics->{$id}->{Valid}||0)." good, ".($Statistics->{$id}->{Broken}||0)." broken, ".($Statistics->{$id}->{RealBroken}||0)." invalid\" at screen 0.02,0.02 left tc rgb \"#000044\" font \"monospace,8\"\n" ;
- print $fg "set output '$opt_picpath/image_recalibrated_$s$num.png';\n";
+ print $fg "set output '$opt_picpath/".$system."_$s$num.png';\n";
print $fg "replot\n";
}
use strict;
use warnings;
use POSIX;
+use XML::LibXML;
use CGI ':standard';
# use Cwd;
use CGI::Carp qw(fatalsToBrowser);
my $here = getcwd();
+my $q = CGI->new;
my $runtime = 0.2;
-
-my $dumpPath = DUMPPATH;
+my $setupFile = $q->param('setupFile'); #$ENV{'QUERY_STRING'}; #
+if( $q->param('runtime') ) {
+ $runtime = $q->param('runtime');
+ }
+
+#print "Loading detector setup from $setupFile\n";
+my $parser = XML::LibXML->new(line_numbers => 1);
+my $db = $parser->parse_file($setupFile);
+my $systemName = $db->findvalue("/DetectorSetup/readoutsystem/\@name");
+#print "Loading system description from $systemName\n";
+my $systemFile = SYSTEMDIR."/".$systemName.".xml";
+$db = $parser->parse_file($systemFile);
+my @portlist;
+for my $gbe ($db->findnodes("//gbe")) {
+ push(@portlist,$gbe->findvalue("./\@port"));
+ }
+my $ports = join("-",@portlist);
+my $daqopserver = $db->getDocumentElement->findvalue('daqopserver');
+$ENV{'DAQOPSERVER'} = $daqopserver if defined($daqopserver);
+
+
+my $dumpPath = DUMPPATH."/".$systemName;
my $picPath = PICTUREPATH;
-my $q = CGI->new;
+
+
print header;
print start_html(
-style=>{'src'=>'../layout/styles.css'}
);
-if( $q->param('runtime') ) {
- $runtime = $q->param('runtime');
-}
-my $setupFile = $q->param('setupFile');
+
+
# print escapeHTML("hallo<<<>>>&&&!!"),br;
# print escapeHTML($here);
# $ENV{'PATH'}=$ENV{'PATH'}.":/home/hadaq/bin";
$dummy =qx"./startup.pl $setupFile";
$dummy.=qx"rm $dumpPath/te1*.hld 2>&1";
-$dummy.=qx"./preview/exec_evtbuild_t.pl -t $runtime -p $dumpPath 2>&1";
+$dummy.=qx"./preview/exec_evtbuild_t.pl -t $runtime -p $dumpPath -s $systemName -d $ports 2>&1";
$dummy.=qx"rm $dumpPath/temp.hld 2>&1";
$dummy.=qx"mv $dumpPath/te1* $dumpPath/temp.hld 2>&1";
-$dummy.=qx"rm $picPath/*.png 2>&1"; # delete old pictures
-$dummy.=qx"./preview/unpack_hld.pl -f $dumpPath/temp.hld -p $picPath 2>&1";
+$dummy.=qx"rm $picPath/$systemName*.png 2>&1"; # delete old pictures
+$dummy.=qx"./preview/unpack_hld.pl -f $dumpPath/temp.hld -p $picPath -s $systemName 2>&1";
my $escapedDummy = escapeHTML($dummy);
$escapedDummy =~ s/\n/<br>/g;
print $escapedDummy;
}
-#trb_register_write(0x8000,0xa002,0xab);
-#print Dumper trb_register_read(0x8000,0xa002);
-
-#exit;
-
+my $system = $ARGV[0];
+unless (defined $system) {die "No system name given\n";}
+my $systemFile = SYSTEMDIR."/".$system.".xml";
+unless(-e $systemFile) {die "System file $systemFile not found\n";}
+my $parser = XML::LibXML->new(line_numbers => 1);
+my $db = $parser->parse_file($systemFile);
+
+my $ccu = hex($db->findvalue("/DaqSetup/ccu/\@address"));
+my(@hub,@gbe,@roc);
+for my $n ($db->findnodes("//hub")) {
+ push(@hub,hex($n->findvalue("./\@address")));
+ }
+for my $n ($db->findnodes("//gbe")) {
+ push(@gbe,hex($n->findvalue("./\@address")));
+ }
+for my $n ($db->findnodes("//roc")) {
+ push(@roc,hex($n->findvalue("./\@address")));
+ }
+printf("CCU:\t%04x\n",$ccu);
+print("ROC:\t".join(", ", map {sprintf("%04x",$_)} @roc)."\n");
+print("HUB:\t".join(", ", map {sprintf("%04x",$_)} @hub)."\n");
+print("GBE:\t".join(", ", map {sprintf("%04x",$_)} @gbe)."\n");
+
run("trbcmd reset");
#Set addresses
run(DAQTOOLSPATH."/tools/merge_serial_address.pl ".DAQTOOLSPATH."/base/serials_trb3.db ".CONFIGPATH."/network/addresses_trb3.db");
-
-
-#Set GbE Configuration
+#Set GbE Configuration (common for all boards)
run(DAQTOOLSPATH."/tools/loadregisterdb.pl ".CONFIGPATH."/network/register_configgbe_mvd.db");
run(DAQTOOLSPATH."/tools/loadregisterdb.pl ".CONFIGPATH."/network/register_configgbe_ip_mvd.db");
-#trb_write(0x8c00,0x8000,0x8000);
-#trb_write(0x8c00,0x8000,0x0000);
-
-
trb_write(0xfffe,0x00c5,0x20ff); #Timeouts
-
-#trb_write(0x8c00,0x00c0,0xffff); #Enable ports of Hub2
-#trb_write(0x8c00,0x00c1,0xffff);
-#trb_write(0x8c00,0x00c3,0xffff);
-#trb_write(0x8c01,0x00c0,0xffff);
-#trb_write(0x8c01,0x00c1,0xffff);
-#trb_write(0x8c01,0x00c3,0xffff);
-
-trb_write(0x8000,0x00c0,0x00e1);
-trb_write(0x8000,0x00c1,0x00e1);
-trb_write(0x8000,0x00c3,0x00ff); #only slowcontrol for unused FPGA
-
-
-#Set Sensor IDs
-#trb_write(0xfe4d,0x00c0,0xccc1ccc0);
-
-#Set JTAG switches
-trb_write(0xfe4d,0xb000,0x00000000);
+if($system eq 'Vacuum') {
+ trb_write($ccu,0x00c0,0x00e1);
+ trb_write($ccu,0x00c1,0x00e1);
+ trb_write($ccu,0x00c3,0x00ff); #only slowcontrol for unused FPGA
+ }
+if($system eq 'ELab') {
+ trb_write($ccu,0x00c0,0x00e4);
+ trb_write($ccu,0x00c1,0x00e4);
+ trb_write($ccu,0x00c3,0x00fc); #only slowcontrol for unused FPGA
+ }
#Send arbiter start signal
-trb_write(0x8000,0xa000,0x00000001);
+trb_write($ccu,0xa000,0x00000001);
###############################
my @commands;
my $boardsini;
+my $setupFile = $ARGV[0];
+my $systemFile = $ARGV[1];
my $parser = XML::LibXML->new(line_numbers => 1);
-my $filename = $ARGV[0];
-my $db = $parser->parse_file($filename);
+my $db = $parser->parse_file($setupFile);
my $name = $db->getDocumentElement->getAttribute('name');
-print STDERR "Loading setup $name from file $filename\n" if $verbose;
-
-my $daqopserver = $db->getDocumentElement->findvalue('daqopserver');
-$ENV{'DAQOPSERVER'} = $daqopserver if defined($daqopserver);
-print "DAQOPSERVER = ".$ENV{'DAQOPSERVER'}."\n" if $verbose;
-
+print STDERR "Loading setup $name from file $setupFile\n" if $verbose;
foreach my $curctrl ($db->getDocumentElement->findnodes('controller')) {
# my $setupFile = SETUPFILE;
my $setupFile;
my $setupFileName;
+my $systemName;
# the file that tells me what fields should be printed in the quick edit area
# for each sensor
if ($q->param('busy') and ($q->param('busy') ne "false") ) {
print img{src=>"../share/hourglass.png",title=>$sensorId};
} else {
- my $imgSrc = $picPath.'/image_recalibrated_'.$sensorId.'.png';
+ my $imgSrc = $picPath.'/'.$sensorId.'.png';
if (-e $imgSrc) {
print img{src=>$imgSrc."?".rand(),title=>$sensorId};
} else {
unless(defined($setup)) { die "did not find DetectorSetup node in setup file!\n";}
my $setupDesc = $setup->findvalue("./description");
my $setupName = $setup->findvalue("./\@name");
+ $systemName = $setup->findvalue("/DetectorSetup/readoutsystem/\@name");
print h2("Setup: $setupName");
print "<p>description: $setupDesc</p>";
unless(scalar(@sensors)>0) { die "no sensors attached to chain $chainName\n";}
for my $sensor (@sensors) {
- my $sensorId = $sensor->findvalue("./\@id");
- my $sensorName = $sensor->findvalue("./\@name");
- my $sensorConfig = $sensor->findvalue("./\@config");
- my $sensorEnabled = $sensor->findvalue("./\@enabled");
- my $sensorSerial = $sensor->findvalue("./\@serial");
- my $sensorPosition = $sensor->findnodes("./position")->shift();
- my $sensorDescription = $sensor->findvalue("./description");
+# my $sensorId = $systemName.'_'.$sensor->findvalue("./\@id");
+# my $sensorName = $sensor->findvalue("./\@name");
+# my $sensorConfig = $sensor->findvalue("./\@config");
+# my $sensorEnabled = $sensor->findvalue("./\@enabled");
+# my $sensorSerial = $sensor->findvalue("./\@serial");
+# my $sensorPosition = $sensor->findnodes("./position")->shift();
+# my $sensorDescription = $sensor->findvalue("./description");
# print h5("Sensor name:$sensorName id:$sensorId");
# print "<p>description: $sensorDescription</p>";
my $sensor = $_[0];
# this is an xml object that contains the sensor node
# from the setup file
- my $sensorId = $sensor->findvalue("./\@id");
+ my $sensorId = $systemName.'_'.$sensor->findvalue("./\@id");
my $sensorName = $sensor->findvalue("./\@name");
my $sensorConfig = $sensor->findvalue("./\@config");
my $sensorEnabled = $sensor->findvalue("./\@enabled");