From: hadeshyp Date: Sat, 29 Sep 2012 13:03:50 +0000 (+0000) Subject: Bugfixes. Throttle support. Edge/Level selection on ITC. Addresses in title X-Git-Url: https://jspc29.x-matter.uni-frankfurt.de/git/?a=commitdiff_plain;h=fa3c54545577ee98e86b3a6c92cee460fd80663d;p=daqtools.git Bugfixes. Throttle support. Edge/Level selection on ITC. Addresses in title --- diff --git a/cts/CtsConfig.pm b/cts/CtsConfig.pm new file mode 100644 index 0000000..553665c --- /dev/null +++ b/cts/CtsConfig.pm @@ -0,0 +1,8 @@ +package CtsConfig; + +#default cts endpoint. can be overriden by a command line parameter +sub getDefaultEndpoint { + return 0xf3c0; +} + +1; \ No newline at end of file diff --git a/cts/CtsPlugins/CtsMod00.pm b/cts/CtsPlugins/CtsMod00.pm index d598cbb..89fbe05 100755 --- a/cts/CtsPlugins/CtsMod00.pm +++ b/cts/CtsPlugins/CtsMod00.pm @@ -1,6 +1,7 @@ -# Module: Channel Masking (Type 0x00) +# Module: Channel Configuration (Type 0x00) # This block contains only one control register that holds -# the bitmask (bits 15:0) for the internal channel selection. +# - the bitmask (bits 15:0) for the internal channel selection (0 = off, 1 = on) +# - the bitmask (bits 31:16) enable rising edge operation (0 = level, 1 = edge). # A trigger event is detected, if any of the masked channels is asserted. package CtsMod00; @@ -11,7 +12,7 @@ use warnings; use strict; use TrbRegister; -sub moduleName {"Channel Masking"} +sub moduleName {"Channel Configuration"} sub init { my $self = $_[0]; @@ -24,7 +25,8 @@ sub init { # registers $regs->{"trg_channel_mask"} = TrbRegister->new($address + 1, $trb, { - 'mask' => {'lower' => 0, 'len' => 16, 'type' => 'mask'} + 'mask' => {'lower' => 0, 'len' => 16, 'type' => 'mask'}, + 'edge' => {'lower' => 16, 'len' => 16, 'type' => 'mask'} }, { 'accessmode' =>"rw", 'monitor' => '1', diff --git a/cts/CtsPlugins/CtsMod50.pm b/cts/CtsPlugins/CtsMod50.pm index f466657..f612440 100755 --- a/cts/CtsPlugins/CtsMod50.pm +++ b/cts/CtsPlugins/CtsMod50.pm @@ -1,8 +1,8 @@ # Module: Random Pulser (Type 0x50) -# The random pulser generates irregular event patterns. As -# the pulser is not configurable, the sole purpose of this block is to inform about the -# presens of the unit and its mapping to the internal channel. The has no payload, -# i.e. a fixed size of 0 words. +# A random pulser generates irregular event patterns. Each instance is configured +# with a single word control registers, which holds its threshold. There is a +# linear depency between the average trigger rate F and the threshold T given by +# F(T) = Freq_Base * T / Max_T = 100 MHz * T / Max_T package CtsMod50; @@ -25,12 +25,25 @@ sub init { my $header = $self->{'_cts'}{'_enum'}{0x50}->read(); + for(my $i = 0; $i < $header->{'len'}; $i++) { + my $key = "trg_random_pulser_config$i"; + + $regs->{$key} = new TrbRegister($address + 1 + $i, $trb, { + 'threshold' => {'lower' => 0, 'len' => 32}, + }, { + 'accessmode' => "rw", + 'label' => "Random Pulser Threshold $i", + 'monitor' => '1', + 'export' => 1 + }); + } + for(my $i = 0; $i < $header->{'itc_len'}; $i++) { - $self->{'_cts'}->getProperties->{'itc_assignments'}[$i + $header->{'itc_base'}] = "Random Pulser"; + $self->{'_cts'}->getProperties->{'itc_assignments'}[$i + $header->{'itc_base'}] = "Random Pulser $i"; } # registers - $prop->{"trg_random_pulser_count"} = 1; + $prop->{"trg_random_pulser_count"} = $header->{'len'}; } 1; \ No newline at end of file diff --git a/cts/CtsPlugins/CtsModStatic.pm b/cts/CtsPlugins/CtsModStatic.pm index 3d0c4b2..45609b4 100755 --- a/cts/CtsPlugins/CtsModStatic.pm +++ b/cts/CtsPlugins/CtsModStatic.pm @@ -143,6 +143,17 @@ sub init { 'monitor' => 1 }); + $regs->{'cts_throttle'} = TrbRegister->new(0x0c + $debug_block, $trb, { + 'threshold' => {'lower' => 0, 'len' => 10}, + 'enable' => {'lower' => 10, 'len' => 1, 'type' => 'bool'}, + 'stop' => {'lower' => 31, 'len' => 1, 'type' => 'bool'} + }, { + 'accessmode' => "rw", + 'label' => "Trigger Throttle", + 'monitor' => 1, + 'export' => 1 + }); + $prop->{'cts_clock_frq'} = 1e8; $prop->{'trb_endpoint'} = $trb->getEndpoint; $prop->{'trb_compiletime'} = $trb->read(0x40); diff --git a/cts/cts b/cts/cts index e0f83c3..726dc72 100755 --- a/cts/cts +++ b/cts/cts @@ -11,8 +11,9 @@ use lib "./include"; # Trb/Cts IO # use TrbSim; included in connectToCTS if required - use TrbNet; #included in connectToCTS if required +# use TrbNet; #included in connectToCTS if required use Cts; + use CtsConfig; # Misc use POSIX qw[ceil]; @@ -458,7 +459,9 @@ sub commandMonitor { $rate , $value]; } } - + + printTable $tab; + if ($filename) { # store json my $json = JSON::PP->new->encode({ @@ -470,7 +473,7 @@ sub commandMonitor { 'monitor' => $monData }); - open FH, ">$filename.js"; + open FH, ">$filename/dump.js"; print FH $json; close FH; @@ -485,7 +488,7 @@ sub commandMonitor { if ($#{ $plotData } > 4) { - open FH, ">$filename.gpdata"; + open FH, ">$filename/plot.data"; foreach (@{$plotData}) { my @row = (@{ $_ }); $row[0] -= $plotData->[-1][0]; @@ -494,60 +497,51 @@ sub commandMonitor { close FH; my $fh = new FileHandle ("|gnuplot"); - $fh->autoflush(1); - - print $fh <<"EOF"; -set terminal png font "monospace,8" size 450,170 + if ($fh) { + $fh->autoflush(1); + + print $fh <<"EOF"; +set terminal svg font "monospace,8" size 450,185 set font -set output "$filename.png" +set output "$filename/plot.svg" set grid set key set autoscale xfixmin #set yrange [* : *<1000000] -set xlabel "Time [s]" -set ylabel "Rate [1/s]" +set xlabel "Time since last update [s]" +set ylabel "Rate [Hz]" plot \\ - "$filename.gpdata" using 1:3:(\$3 / 1000) with yerrorlines title "Edges", \\ - "$filename.gpdata" using 1:4:(\$4 / 1000) with yerrorlines title "Accepted" + "$filename/plot.data" using 1:3:(\$3 / 1000) with yerrorlines title "Edges", \\ + "$filename/plot.data" using 1:4:(\$4 / 1000) with yerrorlines title "Accepted" EOF - ; - close $fh; + ; + close $fh; + + print "Plot produced\n"; + } else { + print "error while executing gnuplot\n"; + } } } - printTable $tab; - $lastRead = $read; usleep($interval*1e3); - } } sub connectToCTS { - my $mode = shift; my $endpoint = shift; my $trb; - if ($mode eq 'sim') { - eval {require "TrbSim.pm"}; - $trb = TrbSim->new($endpoint); - my $fp; - open $fp, "loadDump($fp); - close $fp; - - } else{ - eval {require "TrbNet.pm"}; - $trb = TrbNet->new($endpoint); - } + eval {require "TrbNet.pm"}; + $trb = TrbNet->new($endpoint); return Cts->new($trb); } #################################################################################### -my $trbMode = 'net'; -my $endpoint = 0xf3c0; +my $endpoint = CtsConfig->getDefaultEndpoint; my $updateInterval = 1000; my $rateNumber = 30; @@ -560,8 +554,6 @@ for(my $i=0; $i < @ARGV; $i++) { if ($arg eq "-h" or $arg eq "--help") { help(); exit(); - } elsif ($arg eq "-s" or $arg eq "--sim") { - $trbMode = 'sim'; } elsif ($arg eq "-e" or $arg eq "--endpoint") { unless ($i < @ARGV) { @@ -595,11 +587,11 @@ for(my $i=0; $i < @ARGV; $i++) { $rateNumber = $ARGV[++$i]; } elsif ($arg eq "l" or $arg eq "list") { - printTable commandList connectToCTS($trbMode, $endpoint); + printTable commandList connectToCTS($endpoint); exit(); } elsif ($arg eq "d" or $arg eq "dump") { - print commandDump connectToCTS($trbMode, $endpoint); + print commandDump connectToCTS($endpoint); exit(); } elsif ($arg eq "r" or $arg eq "read") { @@ -609,7 +601,7 @@ for(my $i=0; $i < @ARGV; $i++) { } my @list = @ARGV[$i+1 .. $#ARGV]; - printTable commandRead(connectToCTS($trbMode, $endpoint), \@list); + printTable commandRead(connectToCTS($endpoint), \@list); exit(); } elsif ($arg eq "w" or $arg eq "write") { @@ -618,12 +610,12 @@ for(my $i=0; $i < @ARGV; $i++) { exit(); } - my $cts = connectToCTS($trbMode, $endpoint); + my $cts = connectToCTS($endpoint); commandWrite($cts, lc join(" ", @ARGV[$i+1 .. $#ARGV])); exit(); } elsif ($arg eq "m" or $arg eq "monitor") { - my $cts = connectToCTS($trbMode, $endpoint); + my $cts = connectToCTS($endpoint); commandMonitor($cts, $ARGV[++$i], $updateInterval, $rateNumber); } else { diff --git a/cts/cts_gui b/cts/cts_gui new file mode 100755 index 0000000..2cfb686 --- /dev/null +++ b/cts/cts_gui @@ -0,0 +1,29 @@ +#!/bin/bash +if [ $2 > 0 ]; then + host=`hostname` + port="1234" + + echo "Trying to kill processes 'cts' and 'dhttpi'" + pkill "^(cts|dhttpi)$" + + echo "Try to map monitoring files to shared memory (if it failes, no harm is" + echo " done. Only the HDD has to work a little bit more)" + + rm -rf /dev/shm/cts-monitor + mkdir -p /dev/shm/cts-monitor +# chmod 666 /dev/shm/cts-monitor + ln -s /dev/shm/cts-monitor htdocs/monitor + mkdir -p htdocs/monitor + + echo "Start webserver at http://$host:$port" + ./httpi $host $port & + + echo "Start monitoring script" + until ./cts m htdocs/monitor ; do + echo " - Monitor crashed with exit code $?. Respawning.." >&2 + sleep 1 + done +else + xterm -fn "-misc-fixed-medium-r-normal--8-*-*-*-*-*-iso8859-15" \ + +sb -geometry 200x100 +aw +bc -bg LightCoral -j -e ./cts_gui 1 1 +fi; \ No newline at end of file diff --git a/cts/htdocs/cts.pl b/cts/htdocs/cts.pl index 8badb5c..faeea87 100755 --- a/cts/htdocs/cts.pl +++ b/cts/htdocs/cts.pl @@ -4,29 +4,21 @@ use warnings; use lib "./include/"; use Cts; +use CtsConfig; use JSON::PP; sub connectToCTS { - my $mode = shift; my $endpoint = shift; my $trb; - if ($mode eq 'sim') { - eval {require "TrbSim.pm"}; - $trb = TrbSim->new($endpoint); - my $fp; - open $fp, "loadDump($fp); - close $fp; - } else{ - eval {require "TrbNet.pm"}; - $trb = TrbNet->new($endpoint); - } + eval {require "TrbNet.pm"}; + $trb = TrbNet->new($endpoint); return Cts->new($trb); } -my $cts = connectToCTS 'trb', 0xf3c0; + +my $cts = connectToCTS( CtsConfig->getDefaultEndpoint ); my $query = $ENV{'QUERY_STRING'}; @@ -48,12 +40,17 @@ if ($query eq "init") { } print JSON::PP->new->allow_blessed->convert_blessed->encode(\%result); -} elsif ($query =~ /^write,([\w\d_,\.]+)$/) { +} elsif ($query =~ /^write,([\w\d_,\.\[\]]+)$/) { my @values = split /,/, $1; my $regs = {}; + $cts->getTrb->startCachedWrites(); + while (my $key = shift @values) { - if ($key =~ /^(.*)\.(.*)$/) { + if ($key =~ /^(.*)\.(.*)\[(\d+)\]$/) { + my $val = $cts->getRegisters->{$1}->read()->{$2}; + $regs->{$1}{$2} = ($val & (0xFFFFFFFF ^ (1 << $3))) | (((shift @values) & 1) << $3); + } elsif ($key =~ /^(.*)\.(.*)$/) { $regs->{$1} = {} unless ref $regs->{$1}; $regs->{$1}{$2} = shift @values; } else { @@ -63,9 +60,11 @@ if ($query eq "init") { foreach my $key (keys $regs) { my $reg = $cts->getRegisters->{$key}; - next unless defined $reg; + #next unless defined $reg; $reg->write($regs->{$key}); } + + $cts->getTrb->stopCachedWrites(); print "1"; } diff --git a/cts/htdocs/index.html b/cts/htdocs/index.html index 7809436..ba97457 100644 --- a/cts/htdocs/index.html +++ b/cts/htdocs/index.html @@ -12,6 +12,7 @@ @@ -21,7 +22,7 @@
Status overview
- + @@ -29,7 +30,7 @@ - + @@ -41,7 +42,7 @@ - + @@ -51,7 +52,7 @@ - + @@ -62,71 +63,88 @@ -
CounterRate
Trigger asserted n/a n/an/a
Trigger accepted n/a n/a 
Last Idle Time n/a n/a n/a
-
- - - - -