From 2044e1f6b690d4226384e583659e35cd259d865d Mon Sep 17 00:00:00 2001 From: Jan Michel Date: Wed, 5 Nov 2014 18:30:02 +0100 Subject: [PATCH] plot for padiwa temp --- dmon/scripts/dmon_heatmaprich.pl | 2 +- dmon/scripts/dmon_padiwatemp.pl | 37 +++++++++++++++++++++++++++----- 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/dmon/scripts/dmon_heatmaprich.pl b/dmon/scripts/dmon_heatmaprich.pl index 988c49d..b50974e 100755 --- a/dmon/scripts/dmon_heatmaprich.pl +++ b/dmon/scripts/dmon_heatmaprich.pl @@ -79,7 +79,7 @@ while (1) { my $title = "Heatmap"; my $value = ""; my $longtext = "See plot"; - Dmon::WriteQALog($config{flog},"heatmaprich",5,$status,$title,$value,$longtext,'2-HeatmapRich'); + Dmon::WriteQALog($config{flog},"heatmaprich",5,$status,$title,$value,$longtext,'1-HeatmapRich'); $old = $o; $oldtime = time(); sleep(1); diff --git a/dmon/scripts/dmon_padiwatemp.pl b/dmon/scripts/dmon_padiwatemp.pl index e6ff64f..3077926 100755 --- a/dmon/scripts/dmon_padiwatemp.pl +++ b/dmon/scripts/dmon_padiwatemp.pl @@ -7,21 +7,46 @@ use HADES::TrbNet; use Dmon; use HPlot; use Data::Dumper; +use Time::HiRes qq|usleep|; my %config = Dmon::StartUp(); +HPlot::PlotInit({ + name => "PadiwaTemp", + file => Dmon::DMONDIR."PadiwaTemperature", + entries => scalar @{$config{PadiwaTrbAdresses}}, + type => HPlot::TYPE_HISTORY, + output => HPlot::OUT_PNG, + xlabel => "Board", + ylabel => "Temperature", + sizex => 300, + sizey => 200, + ymin => 10, + ymax => 90, + xscale => 1, + nokey => 1, + buffer => 1 + }); +my $str = Dmon::MakeTitle(9,14,"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") { - sleep 1; + usleep 1E5; if($errcnt >= 12) { - die "SPI still blocked\n"; + return "SPI still blocked\n"; } elsif($errcnt++ >= 10) { trb_register_read($board,0xd412); @@ -39,8 +64,9 @@ while(1) { my $max = 1; my $min = 100; my ($maxboard, $minboard); + my $i = 0; - foreach my $b ($config{PadiwaTrbAdresses}) { + foreach my $b (@{$config{PadiwaTrbAdresses}}) { my $r = sendcmd(0x10040000,$b,0); next unless defined $r; my $temp = (($r->{$b} & 0xFFF))/16; @@ -53,15 +79,16 @@ while(1) { $min = $temp; $minboard = $b; } + HPlot::PlotFill('PadiwaTemp',$temp,$i++); } my $title = "Temperature"; 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,(60,75,80)); + my $status = Dmon::GetQAState('below',$max,(50,60,70)); - Dmon::WriteQALog($config{flog},"padiwatemp",30,$status,$title,$value,$longtext); + Dmon::WriteQALog($config{flog},"padiwatemp",30,$status,$title,$value,$longtext,"10-PadiwaTemp"); sleep(15); } -- 2.43.0