From f5ef320d562685da08a94d58bcaa91cdc0066a20 Mon Sep 17 00:00:00 2001 From: Jan Michel Date: Fri, 11 Jul 2014 18:23:53 +0200 Subject: [PATCH] update to dmon tools --- dmon/code/Dmon.pm | 1 + dmon/code/styles.css | 6 +-- dmon/example_config.pl | 17 +++++--- dmon/scripts/dmon_reftime.pl | 41 ++++++++++++++++++ dmon/scripts/dmon_trgrate.pl | 82 ++++++++++++++++++------------------ 5 files changed, 98 insertions(+), 49 deletions(-) create mode 100755 dmon/scripts/dmon_reftime.pl diff --git a/dmon/code/Dmon.pm b/dmon/code/Dmon.pm index 1b69ba7..8bfd4ce 100644 --- a/dmon/code/Dmon.pm +++ b/dmon/code/Dmon.pm @@ -171,6 +171,7 @@ sub OpenQAFile { # $longtext Long description text (PopUp) sub WriteQALog { my ($fh, $entry, $ttl, $status, $title, $value, $longtext,$link) = @_; + $link = "" unless defined $link; my $tmp = time()."\t$entry\t$ttl\t$status\t$title\t$value\t$longtext\t$link\n"; if ($fh == 0) { diff --git a/dmon/code/styles.css b/dmon/code/styles.css index b44708b..cd0a8ff 100644 --- a/dmon/code/styles.css +++ b/dmon/code/styles.css @@ -387,11 +387,11 @@ svg { .byg {background:#ac0;} .bye {background:#ff2;} .bor {background:#fa0;} -.brd {background:#f00; } +.brd {background:#f00;} .bgr {background:#000;color:#aaa !important;} .bwh {background:#eee;} -.bmg {background:#f0a ;} -.bbl {background:#9bf}; +.bmg {background:#f0a;} +.bbl {background:#9bf;} .blinkon .brdb { background:#f00; diff --git a/dmon/example_config.pl b/dmon/example_config.pl index 45b53f7..aaf85ae 100644 --- a/dmon/example_config.pl +++ b/dmon/example_config.pl @@ -1,13 +1,20 @@ #This a an example configuration file. Copy this file to your user directory and give #start.pl a link to this file as first argument. - +#Scripts to start & order of icons in the Overview activeScripts => [['time','-','-','-','daqop'], - ['numfee','temperature','-','-','-'], + ['numfee','temperature','reftime','-','-'], ['trgrate','-','-','-','-'], ['-','-','-','-','-'],], - + +#Names to be shown in left column of Overview qaNames => ['system','main','trigger','-','-','-'], -NumberOfFpga => 11, #Expected number of FPGAs in system -CtsAddress => 0x8000, #The address of the CTS \ No newline at end of file +#Expected number of FPGAs in system +NumberOfFpga => 11, + +#The address of the CTS +CtsAddress => 0x8000, + +#Addresses of all TDCs. Either single or broadcast addresses +TdcAddress => [0xfe48,0xfe4e,0x8000], \ No newline at end of file diff --git a/dmon/scripts/dmon_reftime.pl b/dmon/scripts/dmon_reftime.pl new file mode 100755 index 0000000..db61483 --- /dev/null +++ b/dmon/scripts/dmon_reftime.pl @@ -0,0 +1,41 @@ +#!/usr/bin/perl -w + +use warnings; +use POSIX qw(strftime); +use FileHandle; +use lib "./code"; +use lib "../tools"; +use HADES::TrbNet; +use Time::HiRes qw(usleep); +use Dmon; +use Data::Dumper; + + +my %config = do $ARGV[0]; +my $flog = Dmon::OpenQAFile(); +trb_init_ports() or die trb_strerror(); + + +my $value, my $longtext, my $status; + +my $lasterrors = 0; +while(1) { + my $errors = 0; + foreach my $b (@{$config{TdcAddress}}) { + my $r = trb_register_read($b,0xc100); + foreach my $c (%{$r}) { + if ($c & 0x10000) {$errors++;} + } + } + my $title = "Ref Polarity"; + + if ($errors) { $value = $errors." errors"; } + else { $value = "OK";} + + my $longtext = "Polarity of the reference time signals on TDCs seems to be: ".$value; + if($errors && $lasterrors) { $status = Dmon::GetQAState('below',$errors,(0,1,4));} + else { $status = Dmon::OK;} + Dmon::WriteQALog($flog,"reftime",10,$status,$title,$value,$longtext); + $lasterrors = $errors; + sleep 10; + } diff --git a/dmon/scripts/dmon_trgrate.pl b/dmon/scripts/dmon_trgrate.pl index f02d3eb..e01e007 100755 --- a/dmon/scripts/dmon_trgrate.pl +++ b/dmon/scripts/dmon_trgrate.pl @@ -12,59 +12,59 @@ use HPlot; my %config = do $ARGV[0]; my $flog = Dmon::OpenQAFile(); -trb_init_ports() or die trb_strerror(); + my $old; my $summing = 0; my $cnt = 0; - -my $plot = (); -$plot->{name} = "TriggerRate"; -$plot->{file} = Dmon::DMONDIR."TriggerRate"; -$plot->{entries} = 600; -$plot->{type} = HPlot::TYPE_HISTORY; -$plot->{output} = HPlot::OUT_PNG; -$plot->{titles}->[0] = ""; -$plot->{xlabel} = "Time [s]"; -$plot->{ylabel} = "Rate [Hz]"; -$plot->{sizex} = 750; -$plot->{sizey} = 270; -$plot->{xscale} = 5; -$plot->{nokey} = 1; -$plot->{buffer} = 1; -HPlot::PlotInit($plot); +HPlot::PlotInit({ + name => "TriggerRate", + file => Dmon::DMONDIR."TriggerRate", + entries => 600, + type => HPlot::TYPE_HISTORY, + output => HPlot::OUT_PNG, + titles => ["Trigger Rate"], + xlabel => "Time [s]", + ylabel => "Rate [Hz]", + sizex => 750, + sizey => 270, + xscale => 5, + nokey => 1, + buffer => 1 + }); my $str = Dmon::MakeTitle(10,6,"TriggerRate",0); $str .= qq@@; $str .= Dmon::MakeFooter(); Dmon::WriteFile("TriggerRate",$str); - - - while(1) { - my $r = trb_register_read($config{CtsAddress},0xa000); - my $value = $r->{$config{CtsAddress}}; - my $rate = ($value||0) - ($old||0); - $rate += 2**32 if $rate < 0; - - if( defined $old) { - $summing += $rate; - HPlot::PlotAdd('TriggerRate',$rate*5,0); - print $rate; + trb_init_ports() or die trb_strerror(); + + while(1) { + my $r = trb_register_read($config{CtsAddress},0xa000); + my $value = $r->{$config{CtsAddress}}; + my $rate = ($value||0) - ($old||0); + $rate += 2**32 if $rate < 0; - unless($cnt++ % 10) { - my $title = "Rate"; - my $value = $summing/2; - my $longtext = $value." triggers pre second"; - my $status = Dmon::GetQAState('above',$value,(15,2,1)); - Dmon::WriteQALog($flog,"trgrate",5,$status,$title,$value,$longtext,'2-TriggerRate'); - - HPlot::PlotDraw('TriggerRate'); - $summing = 0; + if( defined $old) { + $summing += $rate; + HPlot::PlotAdd('TriggerRate',$rate*5,0); + + unless($cnt++ % 10) { + my $title = "Rate"; + my $value = $summing/2; + my $longtext = $value." triggers pre second"; + my $status = Dmon::GetQAState('above',$value,(15,2,1)); + Dmon::WriteQALog($flog,"trgrate",5,$status,$title,$value,$longtext,'2-TriggerRate'); + + HPlot::PlotDraw('TriggerRate'); + $summing = 0; + } } + $old = $value; + usleep(200000); } - $old = $value; - usleep(200000); -} + sleep 10; + } -- 2.43.0