From: HADES DAQ Date: Fri, 11 May 2018 11:24:40 +0000 (+0200) Subject: update hmon scripts, add voltage monitor for RICH X-Git-Url: https://jspc29.x-matter.uni-frankfurt.de/git/?a=commitdiff_plain;h=a976d9b87e7277c17d948d4676a2dbb795f745ad;p=hadesdaq.git update hmon scripts, add voltage monitor for RICH --- diff --git a/hmon/QA.pm b/hmon/QA.pm index f1957e4..3d93a53 100644 --- a/hmon/QA.pm +++ b/hmon/QA.pm @@ -48,7 +48,7 @@ $entries->{'endp'} = ['mdc','rich', 'tof', 'rpc', 'other']; $entries->{'feeerr'} = ['mdcinvalid', 'trb', 'feeerr','trginp','trgqual']; $entries->{'pion'} = ['nxstatus', 'HV', 'HVcurr', 'cooling','seu']; $entries->{'other'} = ['magnet','goofy','','','sequencer']; -$entries->{'rich'} = ['','','','','']; +$entries->{'rich'} = ['temp','volt','curr','','']; $entries->{'ecal'} = ['','','','','']; @@ -110,7 +110,7 @@ our @mdc_boards_removed =(); #(0x2257, 0x2029); # 2233 added 2014-08-28 , 2203 a our @mdc_chambers_removed =(); our @rich_boards_removed =(); our @tof_boards_removed =(); -our @rpc_boards_removed =(0x8a00); +our @rpc_boards_removed =(); our @other_boards_removed =(); diff --git a/hmon/hmon_adcvolt.pl b/hmon/hmon_adcvolt.pl new file mode 100755 index 0000000..e2bf2b4 --- /dev/null +++ b/hmon/hmon_adcvolt.pl @@ -0,0 +1,325 @@ +#!/usr/bin/perl -w + +use warnings; +use POSIX qw(strftime); +use FileHandle; +use lib "./code"; +use lib "../daqtools/tools"; +use HADES::TrbNet; +use Time::HiRes qw(usleep); +use Dmon; +use Hmon; +use HPlot; +use QA; +use Data::Dumper; +use List::Util qw(min max); +trb_init_ports() or die trb_strerror(); + +# my %config = Dmon::StartUp(); + +my $fqa = QA::OpenQAFile(); + + +#0 for TRB3sc, 1 for DiRich, 2 for Concentrator, 3 for PowerVoltages, 4 for PowerCurrents +my $t = [['mV (3.3)','mV (2.5)','mV (1.2)','mV (6)'], + ['mV (3.3)','mV (2.5)','mV (1.1)',''], + ['mV (3.3)','mV (2.5)','mV (1.2)','mA (@1.2)'], + ['mV (3.3)','mV (2.5)','mV (1.2)','mV (1.1)'], + ['mA (@1.1)','mA (@1.2)','mA (@2.5)','mA (@3.3)']]; +my $channel = [7,7,7,6,5]; #SPI interface number + +#1:4V, 2:2V, 3:1V +my $resolution = [[2,1,2,1], [2,2,2,1], [2,2,2,4], [2,2,2,2], [3,3,2,2]]; +my $multiplier= [[1,1,0.5,2],[1,1,0.5,0],[1,1,0.5,3.125],[1,1,0.5,0.5], [2.5,1.25,1,0.5]]; +my $modedesc = [ 'Trb3sc', 'DiRich', 'Concentrator', 'Power-Voltages','Power-Currents']; + + + +HPlot::PlotInit({ + name => "DiRichVolt", + file => 'files/DiRichVolt', + curves => 3, + entries => 1000, + titles => ['3.3V','2.56V','1.16V/1.26V'], + type => HPlot::TYPE_BARGRAPH, + output => HPlot::OUT_PNG, + xlabel => "DiRich/Combiner Board #", + ylabel => "Voltage (mV diff to nom)", + sizex => 1600, + sizey => 200, + xmin => 0, + ymin => '*<-50', + ymax => '200<*', + countup => 1, + xscale => 1, + nokey => 0, + buffer => 0, + bargap => 0.4, + curvewidth => 1, + additional => " + set obj 1 rect from -1, -500 to 2000, 0 fc rgb '#ffbbbb' behind lc rgb '#01000000'\n + set obj 2 rect from -1, 0 to 2000, 100 fc rgb '#ddffdd' behind \n + set obj 3 rect from -1, 100 to 2000, 1000 fc rgb '#ffffbb' behind \n" + }); +# set object 2 rect from 1,3 to 2,4 lw 5 fs empty border lc rgb '#880088' +HPlot::PlotInit({ + name => "PowerVolt", + file => 'files/PowerVolt', + curves => 4, + entries => 1000, + titles => ['3.36V','2.56V','1.26V','1.16V'], + type => HPlot::TYPE_BARGRAPH, + output => HPlot::OUT_PNG, + xlabel => "PowerBoard #", + ylabel => "Voltage (mV diff to nom)", + sizex => 800, + sizey => 200, + xmin => 0, + ymin => '*<-50', + ymax => '200<*', + countup => 1, + xscale => 1, + nokey => 0, + buffer => 0, + bargap => 0.4, + curvewidth => 1, + additional => " + set obj 1 rect from -1, -500 to 2000, 0 fc rgb '#ffbbbb' behind \n + set obj 2 rect from -1, 0 to 2000, 100 fc rgb '#ddffdd' behind \n + set obj 3 rect from -1, 100 to 2000, 1000 fc rgb '#ffffbb' behind\n" + }); + +HPlot::PlotInit({ + name => "PowerCurr", + file => 'files/PowerCurr', + curves => 4, + entries => 100, + titles => ['3.3V','2.5V','1.2V','1.1V'], + type => HPlot::TYPE_BARGRAPH, + output => HPlot::OUT_PNG, + xlabel => "PowerBoard #", + ylabel => "Current (mA)", + sizex => 800, + sizey => 200, + xmin => 0, + ymin => '0', +# ymax => '200<*', + countup => 1, + xscale => 1, + nokey => 0, + buffer => 0, + bargap => 0.4, + curvewidth => 1, + }); + +HPlot::PlotInit({ + name => "PowerPower", + file => 'files/PowerPower', + curves => 4, + entries => 100, + titles => ['3.3V','2.5V','1.2V','1.1V'], + type => HPlot::TYPE_BARGRAPH, + output => HPlot::OUT_PNG, + xlabel => "PowerBoard #", + ylabel => "Power (W)", + sizex => 800, + sizey => 200, + xmin => 0, + ymin => '0', +# ymax => '200<*', + countup => 1, + xscale => 1, + nokey => 0, + buffer => 0, + bargap => 0.4, + curvewidth => 1, + stacked => 1, + }); + +my $str = Hmon::MakeTitle(22,13,"DiRich Power",0); + $str .= qq@
\n@; + $str .= qq@\n@; + $str .= qq@
\n@; + $str .= qq@\n@; + $str .= Hmon::MakeFooter(); +Hmon::WriteFile("richvolt",$str); + + + +sub measure { + my ($board,$mode) = @_; + #2 MHz SPI + trb_register_write($board,0xd41a,25); + + my $cmd; my $s; + my $return; + for(my $i = 0; $i <= 4; $i++) { + $cmd = 0xc1830000 + ($resolution->[$mode][0] << 25) + (($i % 4) << 28); + $s = Dmon::PadiwaSendCmd($cmd,$board,$channel->[$mode]); + if($i) { + foreach my $t (keys %$s) { + $return->[$i-1]{$t} = ($s->{$t}>>19&0xfff)*$multiplier->[$mode][$i-1]; + } + } + usleep(5000); + } + return $return; + } + +# my $dirich = trb_register_read(0xfe51,0); +# my $combiner = trb_register_read(0xfe52,0); +# print Dumper $dirich; +while(1) { + + my $ret; + +# foreach my $a (@{$config{AdcTrb3sc}}) { +# $ret->[0] = measure($a,0); +# } +# foreach my $a (keys %{$dirich}) { + $ret->[1] = measure(0xfe51,1); +# } +# foreach my $a (keys %{$combiner}) { + $ret->[2] = measure(0xfe52,2); + $ret->[3] = measure(0xfe52,3); + $ret->[4] = measure(0xfe52,4); +# } + + +# print Dumper $ret; + my $longtext = ''; + + foreach my $m (sort keys %{$ret->[1][0]}) { + HPlot::PlotAdd('DiRichVolt',$ret->[1][0]{$m}-3300,0); + HPlot::PlotAdd('DiRichVolt',$ret->[1][1]{$m}-2560,1); + HPlot::PlotAdd('DiRichVolt',$ret->[1][2]{$m}-1160,2); + } + foreach my $m (sort keys %{$ret->[2][0]}) { + HPlot::PlotAdd('DiRichVolt',$ret->[2][0]{$m}-3300,0); + HPlot::PlotAdd('DiRichVolt',$ret->[2][1]{$m}-2560,1); + HPlot::PlotAdd('DiRichVolt',$ret->[2][2]{$m}-1260,2); + } + HPlot::PlotLimitEntries('DiRichVolt',(scalar keys %{$ret->[1][0]}) + (scalar keys %{$ret->[2][0]})); + HPlot::PlotDraw('DiRichVolt'); + + foreach my $m (sort keys %{$ret->[3][0]}) { + HPlot::PlotAdd('PowerVolt',$ret->[3][0]{$m}-3360,0); + HPlot::PlotAdd('PowerVolt',$ret->[3][1]{$m}-2560,1); + HPlot::PlotAdd('PowerVolt',$ret->[3][2]{$m}-1260,2); + HPlot::PlotAdd('PowerVolt',$ret->[3][3]{$m}-1160,3); + } + HPlot::PlotLimitEntries('PowerVolt',(scalar keys %{$ret->[3][0]})); + HPlot::PlotDraw('PowerVolt'); + + foreach my $m (sort keys %{$ret->[4][0]}) { + HPlot::PlotAdd('PowerCurr',$ret->[4][3]{$m},0); + HPlot::PlotAdd('PowerCurr',$ret->[4][2]{$m},1); + HPlot::PlotAdd('PowerCurr',$ret->[4][1]{$m},2); + HPlot::PlotAdd('PowerCurr',$ret->[4][0]{$m},3); + } + HPlot::PlotLimitEntries('PowerCurr',(scalar keys %{$ret->[4][0]})); + HPlot::PlotDraw('PowerCurr'); + + foreach my $m (sort keys %{$ret->[4][0]}) { + HPlot::PlotAdd('PowerPower',$ret->[4][3]{$m} * $ret->[3][0]{$m}/1e6,0); + HPlot::PlotAdd('PowerPower',$ret->[4][2]{$m} * $ret->[3][1]{$m}/1e6,1); + HPlot::PlotAdd('PowerPower',$ret->[4][1]{$m} * $ret->[3][2]{$m}/1e6,2); + HPlot::PlotAdd('PowerPower',$ret->[4][0]{$m} * $ret->[3][3]{$m}/1e6,3); + } + HPlot::PlotLimitEntries('PowerPower',(scalar keys %{$ret->[4][0]})); + HPlot::PlotDraw('PowerPower'); + + + + my @min; my @max; + $min[0] = min(values %{$ret->[1][0]}, values %{$ret->[2][0]}); + $min[1] = min(values %{$ret->[1][1]}, values %{$ret->[2][1]}); + $min[2] = min(values %{$ret->[2][2]}); + $min[3] = min(values %{$ret->[1][2]}); + $max[0] = max(values %{$ret->[1][0]}, values %{$ret->[2][0]}); + $max[1] = max(values %{$ret->[1][1]}, values %{$ret->[2][1]}); + $max[2] = max(values %{$ret->[2][2]}); + $max[3] = max(values %{$ret->[1][2]}); + + $min[10] = min(values %{$ret->[3][0]}); + $min[11] = min(values %{$ret->[3][1]}); + $min[12] = min(values %{$ret->[3][2]}); + $min[13] = min(values %{$ret->[3][3]}); + $max[10] = max(values %{$ret->[3][0]}); + $max[11] = max(values %{$ret->[3][1]}); + $max[12] = max(values %{$ret->[3][2]}); + $max[13] = max(values %{$ret->[3][3]}); + + $min[20] = min(values %{$ret->[4][0]}); + $min[21] = min(values %{$ret->[4][1]}); + $min[22] = min(values %{$ret->[4][2]}); + $min[23] = min(values %{$ret->[4][3]}); + $max[20] = max(values %{$ret->[4][0]}); + $max[21] = max(values %{$ret->[4][1]}); + $max[22] = max(values %{$ret->[4][2]}); + $max[23] = max(values %{$ret->[4][3]}); + + + $longtext = "Voltage Rail: FPGA / Powerboard
" + ."3.3V: $min[0]-$max[0] / $min[10]-$max[10] --- " + ."2.5V: $min[1]-$max[1] / $min[11]-$max[11]
" + ."1.2V: $min[2]-$max[2] / $min[12]-$max[12] --- " + ."1.1V: $min[3]-$max[3] / $min[13]-$max[13]
"; + + my $value = ''; + my $status = QA::OK; + if($min[0]<3290 || $min[1]<2260 || $min[2]<1260 || $min[3]<1160) {$status = QA::WARN} + if($min[10]<3360 || $min[11]<2260 || $min[12]<1260 || $min[13]<1160) {$status = QA::WARN} + + QA::WriteQALog($fqa,"rich","volt",30,$status,'Voltages',$value,$longtext); + + $longtext = "Voltage Rail: Current
" + ."1.1V: $min[20]-$max[20] --- " + ."1.2V: $min[21]-$max[21]
" + ."2.5V: $min[22]-$max[22] --- " + ."3.3V: $min[23]-$max[23]
"; + + $value = ''; + $status = QA::NOSTATE; + $status = QA::OK; + QA::WriteQALog($fqa,"rich","curr",30,$status,'Currents',$value,$longtext); + + +# +# my $cmd; my $s; +# +# $cmd = 0xc1830000 + ($resolution->[$mode][0] << 25); +# $s = Dmon::PadiwaSendCmd($cmd,$board,$channel->[$mode]); +# +# usleep(5000); +# $cmd = 0xd1830000 + ($resolution->[$mode][1] << 25); +# $s = Dmon::PadiwaSendCmd($cmd,$board,$channel->[$mode]); +# printf("0x%08x\t%i %s\n",$s->{$board},($s->{$board}>>19&0xfff)*$multiplier->[$mode][0],$t->[$mode][0]); +# +# usleep(5000); +# $cmd = 0xe1830000 + ($resolution->[$mode][2] << 25); +# $s = Dmon::PadiwaSendCmd($cmd,$board,$channel->[$mode]); +# printf("0x%08x\t%i %s\n",$s->{$board},($s->{$board}>>19&0xfff)*$multiplier->[$mode][1],$t->[$mode][1]); +# +# usleep(1000); +# $cmd = 0xf1830000 + ($resolution->[$mode][3] << 25); +# $s = Dmon::PadiwaSendCmd($cmd,$board,$channel->[$mode]); +# printf("0x%08x\t%i %s\n",$s->{$board},($s->{$board}>>19&0xfff)*$multiplier->[$mode][2],$t->[$mode][2]); +# +# usleep(5000); +# $cmd = 0xf3930000; +# $s = Dmon::PadiwaSendCmd($cmd,$board,$channel->[$mode]); +# printf("0x%08x\t%i %s\n",$s->{$board},($s->{$board}>>19&0xfff)*$multiplier->[$mode][3],$t->[$mode][3]); +# +# usleep(5000); +# $s = Dmon::PadiwaSendCmd(0,$board,$channel->[$mode]); +# printf("0x%08x\t%.2f °C\n",$s->{$board},(($s->{$board}>>19)&0xfff)/16.); +# +# #back to normal SPI speed +# system("trbcmd w $board 0xd41a 7"); +# print "\n"; + + + sleep 10; +} + diff --git a/hmon/hmon_endpoints.pl b/hmon/hmon_endpoints.pl index 567f18a..5a06833 100755 --- a/hmon/hmon_endpoints.pl +++ b/hmon/hmon_endpoints.pl @@ -53,10 +53,10 @@ while(1) { 0x235a,0x235b,0x235c,0x235d,0x235e,0x235f, # ###MDC Concentrator 0x1000,0x1001,0x1002,0x1003,0x1004,0x1010,0x1011,0x1012,0x1013,0x1014,0x1020, - 0x1021,0x1022,0x1023,0x1024,0x1030,0x1031,0x1032,0x1033,0x1034,0x1040,0x1041,0x1042,0x1043,0x1044,0x1050, - 0x1051,0x1052,0x1053,0x1054,0x1100,0x1101,0x1102,0x1103,0x1104,0x1120,0x1121, - 0x1122,0x1123,0x1124,0x1140,0x1131,0x1132,0x1133,0x1134,0x1140,0x1141,0x1142,0x1143,0x1144,0x1150,0x1151,0x1152, - 0x1153,0x1154, + 0x1021,0x1022,0x1023,0x1024,0x1030,0x1031,0x1032,0x1033,0x1034,0x1040,0x1041, + 0x1042,0x1043,0x1044,0x1050,0x1051,0x1052,0x1053,0x1054,0x1100,0x1101,0x1102, + 0x1103,0x1104,0x1120,0x1121,0x1122,0x1123,0x1124,0x1140,0x1131,0x1132,0x1133, + 0x1134,0x1140,0x1141,0x1142,0x1143,0x1144,0x1150,0x1151,0x1152,0x1153,0x1154, ### # 0x8100,0x8101,0x8110,0x8111 ); @@ -142,8 +142,7 @@ while(1) { my @rpc_boards = (0x8013, 0x8a00,0x8a01,0x8a02,0x8a03,0x8a04,0x8a05, #0x6000,0x6001,0x6002,0x6003,0x6004,0x6005,0x6006, - #0x6010,0x6011,0x6012, - 0x6013,0x6014,0x6015,0x6016, + 0x6010,0x6011,0x6012,0x6013,0x6014,0x6015,0x6016, 0x6020,0x6021,0x6022,0x6023,0x6024,0x6025,0x6026, #0x6030,0x6031,0x6032,0x6033,0x6034,0x6035,0x6036, 0x6040,0x6041,0x6042,0x6043,0x6044,0x6045,0x6046, @@ -164,6 +163,7 @@ while(1) { 0x8880,0x5000,0x5002,0x5003, #Hodo TRB3 # 0x8890,0x5010,0x5011,0x5012,0x5013 + 0x0100,0x0110, #trigger etc. ); ###strip the register value diff --git a/hmon/hmon_mdc_temp.pl b/hmon/hmon_mdc_temp.pl index 3b3559c..ea8814a 100755 --- a/hmon/hmon_mdc_temp.pl +++ b/hmon/hmon_mdc_temp.pl @@ -85,7 +85,7 @@ while (1) { if($qastate >= QA::ERROR || ( $data->{'TempAlarmEPICS'}->{'val'} > 0 ) ) { if($mailerrstatecnt++ >= 60) { Hmon::SendEmail('j.michel@gsi.de,c.wendisch@gsi.de',"Error: MDC Temperature too high","MDC temperatures are too high: -\n$str"); +\n$str\n".$data->{'TempAlarmEPICS'}->{'val'}); $mailerrstatecnt = 0; } } diff --git a/hmon/hmon_rich_temp.pl b/hmon/hmon_rich_temp.pl new file mode 100755 index 0000000..13488f2 --- /dev/null +++ b/hmon/hmon_rich_temp.pl @@ -0,0 +1,91 @@ +#!/usr/bin/perl -w + +use warnings; +use strict; +use Time::HiRes qw( gettimeofday usleep time ); +use FileHandle; +use Data::Dumper; +use POSIX qw/floor ceil/; +use List::Util qw'max min'; +# use Perl2Epics; +use QA; + +use Hmon; +my $flog = Hmon::OpenLogfile(); +my $fqa = QA::OpenQAFile(); + +use HADES::TrbNet; + +my @str; + +my $store = {}; +my $laststore = {}; +my $values = {}; +my $color = {}; +my $raw = {}; +my $val; +my $mailerrstatecnt = 0; +my ($max,$min,$avg,$sum,$count); + +trb_init_ports() or die trb_strerror(); + + +while (1) { + my $rich_temp; + $rich_temp = trb_register_read(0xfe51, 0x0) or sleep 5 and next; + print Dumper $rich_temp; + $min = 1000; + $max = 0; + $sum = 0; + $count = 0; + foreach my $b (keys %{$rich_temp}) { + $count ++; + my $t = ($rich_temp->{$b}>>20)/16; + $min = $t if $t < $min; + $max = $t if $t > $max; + $sum += $t; + } + $avg = $sum / $count; + +# +# ($min,$max) = Hmon::MakeMinMax3($store, 4, 6, 16); +# $str[0][4] = Hmon::MakeTitle(9, 10, "MDC Temperatures"); +# for (my $l = 0; $l < 4;$l++) { +# $str[0][$l] = Hmon::MakeTitle(9, 3, "MDC $l Temperatures"); +# $str[1][$l] = ""; +# for (my $s = 0; $s < 6;$s++) { +# for (my $b = 0; $b < 16; $b++) { +# $color->{$b} = sprintf("style=\"background:%4s;\"",Hmon::findcolor($store->{$l}->{$s}->{$b},$min,$max,0)); +# $raw->{$b} = sprintf("%.1f",$store->{$l}->{$s}->{$b}); +# } +# $str[1][$l] .= Hmon::DrawMDC($l,$s,$color,$raw); +# } +# $str[2][$l] = Hmon::DrawScale($min,$max,42); +# $str[2][$l] .= Hmon::MakeFooter(); +# # Hmon::WriteFile("MDC".$l."Temperature",$str[0][$l].$str[1][$l].$str[2][$l]); +# } +# Hmon::WriteFile("MDCTemperature",$str[0][4]."

".$str[1][0].$str[1][1]."

".$str[1][2]."

".$str[1][3].$str[2][0]); +# +# my @mint; my @maxt; +# for (my $i = 0; $i<4; $i++) { +# ($mint[$i],$maxt[$i],$avg,$mean) = Hmon::MakeMinMax2(\%{$store->{$i}},6,16,1); +# Hmon::WriteLog($flog, "MDC $i Temp","Temperatures, Sector %i: min. %.1f°C - max. %.1f°C - Ø %.1f°C",$i,$min,$max,$avg); +# } + + my $qastate = QA::GetQAState('below', $max, @QA::MdcTempLimits); + my $str = sprintf("%i - %i", $min, $max); + QA::WriteQALog($fqa,"rich","temp", 40, $qastate, "Temperature", $str, + "Min/Max temperature on DiRich " . $str); +# $store = {}; + + +# if($qastate >= QA::ERROR || ( $data->{'TempAlarmEPICS'}->{'val'} > 0 ) ) { +# if($mailerrstatecnt++ >= 60) { +# Hmon::SendEmail('j.michel@gsi.de,c.wendisch@gsi.de',"Error: MDC Temperature too high","MDC temperatures are too high: +# \n$str\n".$data->{'TempAlarmEPICS'}->{'val'}); +# $mailerrstatecnt = 0; +# } +# } + + sleep 10; +} diff --git a/hmon/permanent/hmon_mdcpressure.pl b/hmon/permanent/hmon_mdcpressure.pl index 4489266..ad9cb25 100755 --- a/hmon/permanent/hmon_mdcpressure.pl +++ b/hmon/permanent/hmon_mdcpressure.pl @@ -171,7 +171,7 @@ my $timer = 0; for(my $i = 1; $i<=3; $i++) { for(my $j = 1; $j<=6; $j++) { my $s = sprintf("HAD:MDC:P%i:S%i:p_delta",$i,$j); - Perl2Epics::Connect("p$i$j",$s);x + Perl2Epics::Connect("p$i$j",$s); } } foreach my $n (@names) { @@ -262,8 +262,7 @@ while(1) { # $presserr++; # } - for my $i (1..3) { # CW 1.4.2016 : only for Plane 1 to 3, as pressure values in plane 4 S5&6 are wrong - readout failure -planes + for my $i (1..3) { # CW 1.4.2016 : only for Plane 1 to 3, as pressure values in plane 4 S5&6 are wrong - readout failure planes for my $j (1..6) { my $pressure_now = $data->{"p$i$j"}->{val}; if( $pressure_now < 1.0 || $pressure_now > 55) { @@ -285,7 +284,7 @@ planes } $presserrtimer = 0; # Hmon::SendEmail('c.wendisch@gsi.de',"Warning: MDC Over-Pressure","Pressures in MDC are too high: \n$valstr"); -< } + } } $timer++; sleep(10);