From 62dabce0140d3211c63ae382aa4768078a89b5ec Mon Sep 17 00:00:00 2001 From: Hades DAQ Date: Mon, 8 Oct 2018 13:59:23 +0200 Subject: [PATCH] add RICH spoke temperature to QA --- hmon/QA.pm | 13 +++++++++++++ hmon/hmon_richMagnet.pl | 24 +++++++++++++++++++++++- hmon/hmon_rich_temp.pl | 9 +-------- hmon/hmon_rich_temp_backplane.pl | 26 ++++++++++++++++---------- hmon/hmon_richrate.pl | 11 ++--------- 5 files changed, 55 insertions(+), 28 deletions(-) diff --git a/hmon/QA.pm b/hmon/QA.pm index 634274d..094b555 100644 --- a/hmon/QA.pm +++ b/hmon/QA.pm @@ -286,5 +286,18 @@ sub SciNotation { } } +############################################ +# A simple date string +sub getTimeString { + my $timeStamp = localtime(); + + my @months = qw( Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec ); + my @days = qw(Sun Mon Tue Wed Thu Fri Sat Sun); + my ($sec,$minute,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(); + my $updatetime = sprintf("%03s, %02d %s %04d - %02d:%02d:%02d",$days[$wday], $mday, $months[$mon], 1900 + $year, $hour, $minute, $sec); + return $updatetime; + } + + 1; __END__ diff --git a/hmon/hmon_richMagnet.pl b/hmon/hmon_richMagnet.pl index e09b32f..48e6612 100755 --- a/hmon/hmon_richMagnet.pl +++ b/hmon/hmon_richMagnet.pl @@ -11,6 +11,8 @@ use HPlot; use Time::HiRes qw(usleep time); use List::Util qw[min max]; +use Encode qw(encode from_to); +use JSON::XS; #my $flog = Hmon::OpenLogfile(); #my $fqa = QA::OpenQAFile(); @@ -89,7 +91,7 @@ xlabel => "RICH Arm number", ylabel => "Sensor Number on Board", ymin => -0.5, ymax => 3.5, -cbmax => "",#"40<*<1E5", +cbmax => "15<*<35", cbmin => 0.0, cblabel => "Temperature [°C]", noinit => 1, @@ -110,6 +112,7 @@ my $cnt=0; while(1){ my $count = 0; my $data; + my $mintemp = 100; my $maxtemp = 0; my $magActive = trb_register_read_mem(0x0110, 0xe001,0,0x6) or sleep 5 and next; my $rich = trb_register_read_mem(0x0110, 0xe010,0,0x60) or sleep 5 and next; #print Dumper $magActive->{0x0110}[2]; @@ -126,6 +129,9 @@ while(1){ if (($magActive->{0x0110}[$boardT] >> 8) == 0 ) { #print "$boardT $sensT $t\n"; HPlot::PlotFill('RichInnerTemp',$t,$boardT,$sensT);# + $data->{$boardT}{$sensT} = $t; + $mintemp = $t if $t < $mintemp; + $maxtemp = $t if $t > $maxtemp; my $reg = 4*$boardT+$sensT; #print "$reg $t\n"; if ($cnt > 7) {$cnt =0;} else {$cnt++;} @@ -154,5 +160,21 @@ while(1){ HPlot::PlotDraw('RichMagnet'); HPlot::PlotDraw('RichInnerTemp'); HPlot::PlotDraw('RichInnerTempHist'); + + + $data->{max} = $maxtemp; + $data->{min} = $mintemp; + $data->{symbol} = " °C"; + $data->{title} = "RICH spoke temperature"; + + + $data->{updatetime} = QA::getTimeString(); + + my $fh; + open($fh, ">", Hmon::HMONDIR."/files/richSpokeTemperature.json"); + print $fh encode_json($data); + close $fh; + + sleep 10; } diff --git a/hmon/hmon_rich_temp.pl b/hmon/hmon_rich_temp.pl index 7bf6ec8..d7cfd44 100755 --- a/hmon/hmon_rich_temp.pl +++ b/hmon/hmon_rich_temp.pl @@ -57,14 +57,7 @@ while (1) { $data->{symbol} = " °C"; $data->{title} = "RICH Temperature"; - my $timeStamp = localtime(); - - my @months = qw( Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec ); - my @days = qw(Sun Mon Tue Wed Thu Fri Sat Sun); - my ($sec,$minute,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(); - my $updatetime = sprintf("%03s, %02d %s %04d - %02d:%02d:%02d",$days[$wday], $mday, $months[$mon], 1900 + $year, $hour, $minute, $sec); - - $data->{updatetime} = $updatetime; + $data->{updatetime} = QA::getTimeString(); diff --git a/hmon/hmon_rich_temp_backplane.pl b/hmon/hmon_rich_temp_backplane.pl index 6837d88..2687a26 100755 --- a/hmon/hmon_rich_temp_backplane.pl +++ b/hmon/hmon_rich_temp_backplane.pl @@ -78,14 +78,8 @@ while (1) { $data->{min} = $min; $data->{symbol} = " °C"; $data->{title} = "RICH Temperature on Backplane"; - my $timeStamp = localtime(); - - my @months = qw( Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec ); - my @days = qw(Sun Mon Tue Wed Thu Fri Sat Sun); - my ($sec,$minute,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(); - my $updatetime = sprintf("%03s, %02d %s %04d - %02d:%02d:%02d",$days[$wday], $mday, $months[$mon], 1900 + $year, $hour, $minute, $sec); - - $data->{updatetime} = $updatetime; + + $data->{updatetime} = QA::getTimeString(); #-------Software Interlock-------# my $InterlockValHW = (($Interlock_value->{0x0110} || 0) & 0xfff)/16; @@ -111,12 +105,24 @@ while (1) { my $qastate = QA::GetQAState('below', $max, @QA::RichInnerTempLimits); + my $fh; + open($fh, "<", Hmon::HMONDIR."/files/richSpokeTemperature.json"); + chomp(my @lines = <$fh>); + close $fh; + + eval { + $data = decode_json(join " ",@lines); + 1; + } + or sleep 5 and next; + my $strspokes = sprintf("%i - %i", $data->{min}, $data->{max}); + my $qastate_interlock = QA::GetQAState('below', $max, @QA::RichInnerTempLimits); my $str = sprintf("%i - %i", $min, $max); QA::WriteQALog($fqa,"rich","bkpl", 40, $qastate, "Temperature", $str, - "Min/Max temperature in RICH " . $str . " °C
Software Interlock Temperature: " . $interlockTemperature . " °C | " .$InterlockActive ."
". $strHWInterlock); + "Min/Max temperature in RICH BKPL " . $str . " °C
Min/Max temperature on RICH spokes " . $strspokes . " °C
Software Interlock Temperature: " . $interlockTemperature . " °C | " .$InterlockActive ."
". $strHWInterlock); - my $fh; + open($fh, ">", Hmon::HMONDIR."/files/richTemperatureBackplane.json"); print $fh encode_json($data); close $fh; diff --git a/hmon/hmon_richrate.pl b/hmon/hmon_richrate.pl index 8706539..af18fde 100755 --- a/hmon/hmon_richrate.pl +++ b/hmon/hmon_richrate.pl @@ -172,16 +172,9 @@ while(1) { # $data->{symbol} = " Hits/s"; # $data->{title} = "Mean DiRICH TDC Rate"; - # my $timeStamp = localtime(); + + # $data->{updatetime} = getTimeString; - # my @months = qw( Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec ); - # my @days = qw(Sun Mon Tue Wed Thu Fri Sat Sun); - # my ($sec,$minute,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(); - # my $updatetime = sprintf("%03s, %02d %s %04d - %02d:%02d:%02d",$days[$wday], $mday, $months[$mon], 1900 + $year, $hour, $minute, $sec); - - # $data->{updatetime} = $updatetime; - - #print Dumper $data; # my $fh; # open($fh, ">", Hmon::HMONDIR."/files/richMeanRateDiRICH.json"); # print $fh encode_json($data); -- 2.43.0