From 8ed499a805d28ee742201b5be826f9ee70e1dd7a Mon Sep 17 00:00:00 2001 From: Jan Michel Date: Wed, 5 Nov 2014 18:53:41 +0100 Subject: [PATCH] added monitor for missing Padiwa --- dmon/code/Dmon.pm | 30 ++++++++++++++++++- dmon/scripts/dmon_padiwatemp.pl | 49 ++++++++++++------------------- users/cern_cbmrich/dmon_config.pl | 2 +- 3 files changed, 49 insertions(+), 32 deletions(-) diff --git a/dmon/code/Dmon.pm b/dmon/code/Dmon.pm index 6ee69ce..a01fd83 100644 --- a/dmon/code/Dmon.pm +++ b/dmon/code/Dmon.pm @@ -4,7 +4,7 @@ use Data::Dumper; use warnings; use strict; use HADES::TrbNet; - +use Time::HiRes qq|usleep|; print STDERR "Script started at ".strftime("%d.%m.%y %H:%M:%S", localtime()).".\n"; @@ -294,5 +294,33 @@ sub SciNotation { } +############################################ +# Sends a command to a Padiwa +sub PadiwaSendCmd { + my ($cmd,$board,$chain) = @_; + my $c = [$cmd,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1<<$chain,0x10001]; + my $errcnt = 0; + while(1){ + trb_register_write_mem($board,0xd400,0,$c,scalar @{$c}); + + if (trb_strerror() =~ "no endpoint has been reached") {return -1;} + if (trb_strerror() ne "No Error") { + usleep 1E5; + if($errcnt >= 12) { + return "SPI still blocked\n"; + } + elsif($errcnt++ >= 10) { + trb_register_read($board,0xd412); + } + } + else { + last; + } + } + return trb_register_read($board,0xd412); + } + + + 1; __END__ diff --git a/dmon/scripts/dmon_padiwatemp.pl b/dmon/scripts/dmon_padiwatemp.pl index 0e56303..1d8026e 100755 --- a/dmon/scripts/dmon_padiwatemp.pl +++ b/dmon/scripts/dmon_padiwatemp.pl @@ -7,7 +7,7 @@ use HADES::TrbNet; use Dmon; use HPlot; use Data::Dumper; -use Time::HiRes qq|usleep|; + my %config = Dmon::StartUp(); @@ -27,47 +27,28 @@ HPlot::PlotInit({ buffer => 0 }); -my $str = Dmon::MakeTitle(6,7,"PadiwaTemp",0); +my $str = Dmon::MakeTitle(6,6,"PadiwaTemp",0); $str .= qq@@; $str .= Dmon::MakeFooter(); Dmon::WriteFile("PadiwaTemp",$str); - - -sub sendcmd { - my ($cmd,$board,$chain) = @_; - my $c = [$cmd,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1<<$chain,0x10001]; - my $errcnt = 0; - while(1){ - trb_register_write_mem($board,0xd400,0,$c,scalar @{$c}); - if (trb_strerror() =~ "no endpoint has been reached") {return -1;} - if (trb_strerror() ne "No Error") { - usleep 1E5; - if($errcnt >= 12) { - return "SPI still blocked\n"; - } - elsif($errcnt++ >= 10) { - trb_register_read($board,0xd412); - } - } - else { - last; - } - } - return trb_register_read($board,0xd412); - } - while(1) { my $max = 1; my $min = 100; my ($maxboard, $minboard); my $i = -1; + my $notonline = ""; + my $notonlinecnt = 0; foreach my $b (@{$config{PadiwaTrbAdresses}}) { $i++; - my $r = sendcmd(0x10040000,$b,0); - next unless defined $r; + my $r = Dmon::PadiwaSendCmd(0x10040000,$b,0); + unless (defined $r) { + $notonline .= sprintf(" %04x",$b); + $notonlinecnt++; + next; + } my $temp = (($r->{$b} & 0xFFF))/16; unless ($temp < 10 || $temp > 90) { if ($max < $temp) { @@ -82,6 +63,8 @@ while(1) { } else { HPlot::PlotFill('PadiwaTemp',10,$i); + $notonline .= sprintf(" %04x",$b); + $notonlinecnt++; } } @@ -89,9 +72,15 @@ while(1) { my $value = sprintf("%.1f",$max); my $longtext = sprintf("Maximum: %.1f on board 0x%04x
Minimum: %.1f on board 0x%04x",$max,$maxboard,$min,$minboard); my $status = Dmon::GetQAState('below',$max,(50,60,70)); + Dmon::WriteQALog($config{flog},"padiwatemp",30,$status,$title,$value,$longtext,"10-PadiwaTemp"); + + $title = "Online"; + $value = sprintf("%i / %i",(scalar @{$config{PadiwaTrbAdresses}})-$notonline,scalar @{$config{PadiwaTrbAdresses}}); + $longtext = "Boards not reacting:".$notonline; + $status = Dmon::GetQAState('above',$notonline,(0,1,4)); + Dmon::WriteQALog($config{flog},"padiwaonline",30,$status,$title,$value,$longtext,"10-PadiwaOnline"); HPlot::PlotDraw('PadiwaTemp'); - Dmon::WriteQALog($config{flog},"padiwatemp",30,$status,$title,$value,$longtext,"10-PadiwaTemp"); sleep(15); } diff --git a/users/cern_cbmrich/dmon_config.pl b/users/cern_cbmrich/dmon_config.pl index 2088f38..0681c6d 100644 --- a/users/cern_cbmrich/dmon_config.pl +++ b/users/cern_cbmrich/dmon_config.pl @@ -5,7 +5,7 @@ activeScripts => [['time','ping','-','-','daqop'], ['numfee','temperature','reftime','billboard','mbs'], ['trgrate','datarate','deadtime','-','-'], - ['heatmaprich','padiwatemp','-','-','-'], + ['heatmaprich','padiwatemp','padiwaonline','-','-'], ['cbmnetlink','cbmnetdata','cbmnetsync','-','-'],], #Names to be shown in left column of Overview (max 4 letters!) -- 2.43.0