use warnings;
use POSIX qw(strftime);
use FileHandle;
-use lib "./code";
-use lib "../tools";
use HADES::TrbNet;
use Time::HiRes qw(usleep);
use Dmon;
--- /dev/null
+#!/usr/bin/perl -w
+
+use warnings;
+use POSIX qw(strftime);
+use FileHandle;
+use HADES::TrbNet;
+use Time::HiRes qw(usleep);
+use Dmon;
+use HPlot;
+use Data::Dumper;
+
+my %config = Dmon::StartUp();
+
+HPlot::PlotInit({
+ name => "Beam",
+ file => Dmon::DMONDIR."BeamMonitors",
+ entries => scalar @{$config{BeamDetectorsName}},
+ type => HPlot::TYPE_BARGRAPH,
+ output => HPlot::OUT_PNG,
+ bartitle => $config{BeamDetectorsName},
+ xlabel => "",
+ ylabel => "Counts/s",
+ sizex => 430,
+ sizey => 360,
+ curvewidth => 1.5,
+# ymin => -1,
+ ymax => "1000<*",
+# xscale => 5,
+ nokey => 1,
+ buffer => 1
+ });
+
+my $str = Dmon::MakeTitle(6,8,"BeamMonitors",0);
+ $str .= qq@<img src="%ADDPNG BeamMonitors.png%" type="image/png">@;
+ $str .= Dmon::MakeFooter();
+Dmon::WriteFile("BeamMonitors",$str);
+
+my @old;
+
+while(1) {
+ my @regs;
+ for (my $c = 0; $c < scalar @{$config{BeamDetectorsTrb}}; $c++) {
+ my $t = trb_registertime_read($config{BeamDetectorsTrb}->[$c],$config{BeamDetectorsChan}->[$c]);
+ $regs[$c] = $t->{$config{BeamDetectorsTrb}->[$c]};
+ }
+
+ for (my $c = 0; $c < scalar @{$config{BeamDetectorsTrb}}; $c++) {
+ my $value = $regs[$c]->{value}[0];
+
+ $value -= $old[$c]->{value}[0] || 0;
+
+ HPlot::PlotFill('Beam',$value,$c,0);
+ }
+
+
+ HPlot::PlotDraw('Beam');
+ Dmon::WriteQALog($config{flog},"beammonitors",60,Dmon::OK,"Beam Monitors","","Just plotting","1-BeamMonitors");
+
+# my $curr = $sig->{$config{BeamTRB}} & 0xffffff;
+#
+# if($curr - $old > $config{SpillThreshold}) {
+# $value += $curr - $old||0;
+# }
+# else {
+# if ($value > 0) {
+# my $longtext = "Number of signals in last spill: ".$value;
+# my $status = Dmon::OK;
+# Dmon::WriteQALog($config{flog},"beamintensity",60,$status,$title,$value,$longtext);
+# $value = 0;
+# }
+# }
+
+
+ @old = @regs;
+ sleep 1;
+ }
my %config = Dmon::StartUp();
my $t0;
-for(my $i = 1; $i<=20; $i++) {
- my $name = sprintf('CBM:PWRSWITCH:GetCurrent%02x',$i);
- Perl2Epics::Connect("C".$i,$name);
+for(my $i = 0; $i< 16 ; $i++) {
+ Perl2Epics::Connect("PC".$i, sprintf('CBM:PWRSWITCH:GetCurrent%02x',$i));
+
+ Perl2Epics::Connect("HV_U".$i, sprintf('OUTPUT_TERMINAL_VOLTAGE_U%d',$i));
+ Perl2Epics::Connect("HV_I".$i, sprintf('MEASUREMENT_CURRENT_U%d',$i));
}
+Perl2Epics::Connect("Pres","CBM:BMP180:GetPressure");
+Perl2Epics::Connect("Temp","CBM:BMP180:GetTemp");
+
while(1) {
# update billboard
my @billboardValues = ();
my $epicsData = Perl2Epics::GetAll();
# temp & pressure
- $billboardValues[0] = 0xdeadc0de;
+ push @billboardValues,
+ (($billboardVersion & 0x3) << 30) | # version 2 bit
+ (($epicsData{"Pres"} & 0x1fffff) << 9) | # pressure 21 bit
+ (($epicsData{"Temp"} & 0x1ff ) << 0); # temp 9 bit
- # currents
- for(my $i = 1; $i<=20; $i++) {
- my $milAmp = $epicsData->{"C".$i}->{"val"} * 1000;
+ # padiwa currents
+ for(my $i = 0; $i < 16; $i++) {
+ my $milAmp = $epicsData->{"PC".$i}->{"val"} * 1000;
$reg = 0 unless $i & 1;
$reg |= ($milAmp & 0xffff) << (16 * ($i&1));
- $billboardValues[$i / 2 + 1] = $reg;
+ push @billboardValues, $reg if $i & 1;
}
+ # threshold timestamp
+ my $threshTime = do($config{UserDirectory} . '/thresh/billboard_info') || 0;
+ push @billboardValues, $threshTime & 0xffffffff;
+
+ # hv values
+ for(my $i=0; $i < 16; $i++) {
+ push @billboardValues,
+ ((("HV_I".$i) * 1e6) & 0xffff) << 16) |
+ ((("HV_U".$i) * 1e2) & 0xffff) << 0);
+ }
+
trb_register_write_mem($config{BillboardAddress}, 0xb100, 0, \@billboardValues, scalar @billboardValues); # copy data
trb_register_write($config{BillboardAddress}, 0xb000, scalar @billboardValues); # commit
-
+
# build statistics
my $title = "Billboard";
my $longtext='';
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 strict;
use POSIX qw(strftime);
use FileHandle;
-use lib "./code";
-use lib "../tools";
use lib "../users/cern_cbmrich";
use HADES::TrbNet;
use Time::HiRes qw(usleep);
$plot2->{ymin} = 0.5;
$plot2->{ymax} = 32.5;
$plot2->{cbmin} = "0";
-$plot2->{cbmax} = "100<*<1000000";
+$plot2->{cbmax} = "100<*";
$plot2->{showvalues} = 0;
$plot2->{xlabel} = "column";
$plot2->{ylabel} = "row";
-$plot2->{addCmd} = "set lmargin at screen 0.07\nset rmargin at screen 0.80\nset bmargin at screen 0.07\nset tmargin at screen 0.95";
+$plot2->{addCmd} = "set lmargin at screen 0.07\nset rmargin at screen 0.85\nset bmargin at screen 0.07\nset tmargin at screen 0.95";
HPlot::PlotInit($plot2);
my $str = Dmon::MakeTitle(9,14,"HeatmapRich",0);
- $str .= qq@<div style="padding:0"><img src="%ADDPNG HeatmapRich.png%" type="image/png" id="heatmap-img"></div><div id="heatmap-caption" style="margin-top: -5px;"></div>@;
+ $str .= qq@<img src="%ADDPNG HeatmapRich.png%" type="image/png">@;
$str .= Dmon::MakeFooter();
Dmon::WriteFile("HeatmapRich",$str);
-sub generateDef {
- my $x = 56; my $y = 51; my $w = (564-$x) / 32.0; my $h = (619-$y) / 32.0;
-
- $str = qq@
- var HeatmapDef = {
- 'x': $x, 'y': $y, 'w': $w, 'h': $h,
- 'labels': [
- @;
-
- for my $ix (1..32) {
- $str .= '[';
- for my $iy (1..32) {
- my $fpga = $ChannelMapping::chanmap->{fpga}->[$ix]->[$iy];
- my $channel = ($ChannelMapping::chanmap->{chan}->[$ix]->[$iy]-1) / 2;
-
- $str .= sprintf("'0x%04x CH: %d'", $fpga, $channel) . ($iy == 32 ? '' : ',');
- }
- $str .= ']' . ($ix == 32 ? '' : ',') . "\n";
- }
-
- $str .= ']};';
- return $str;
-}
-
-open FH, ">", Dmon::DMONDIR . '/HeatmapRichDefs.js';
-print FH generateDef;
-close FH;
my $old;
my $oldtime = time();
my $time = time();
my $diff;
-
while (1) {
+ my $sum = 0;
my $o = trb_register_read_mem($config{PadiwaBroadcastAddress},0xc000,0,33);
if (defined $old) {
my $fpga = $ChannelMapping::chanmap->{fpga}->[$x]->[$y];
my $channel = $ChannelMapping::chanmap->{chan}->[$x]->[$y];
HPlot::PlotFill('HeatmapRich',$diff->{$fpga}->[$channel],$x,$y);
+ $sum += $diff->{$fpga}->[$channel];
}
}
HPlot::PlotDraw('HeatmapRich');
}
my $status = Dmon::OK;
my $title = "Heatmap";
- my $value = "";
- my $longtext = "See plot";
+ my $value = Dmon::SciNotation($sum);
+ my $longtext = "Total: ".$value;
Dmon::WriteQALog($config{flog},"heatmaprich",5,$status,$title,$value,$longtext,'1-HeatmapRich');
$old = $o;
$oldtime = time();
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 warnings;
use POSIX qw(strftime);
use FileHandle;
-use lib "./code";
use HADES::TrbNet;
use Dmon;
#!/usr/bin/perl -w
use warnings;
-use lib "./code";
-use lib "../tools";
use HADES::TrbNet;
use Dmon;
use HPlot;
use warnings;
use POSIX qw(strftime);
use FileHandle;
-use lib "./code";
-use lib "./tools";
use HADES::TrbNet;
use Time::HiRes qw(usleep);
use Dmon;
my $total = scalar @{$config{TrbIP}};
foreach my $p (@{$config{TrbIP}}) {
my $r = $ping->ping($p,1);
-# print $p."\t$r\n";
$found += $r || 0;
$notavail += 1-($r||0);
$list .= " $p" unless $r;
#Generate output file at most once per second
if(1 || $oldtime < time) {
$oldtime = scalar time();
- $str = Dmon::MakeTitle($width,7,"Tactical Overview",1);
+ $str = Dmon::MakeTitle($width,8,"Tactical Overview",1);
$str .= "<div class=\"QA\">";
foreach my $row (@{$config{activeScripts}}) {
$str .= "<div class=\"header\" style=\"clear:both\">".($config{qaNames}->[$i++])."</div>\n";
--- /dev/null
+#!/usr/bin/perl -w
+
+use warnings;
+use POSIX qw(strftime);
+use FileHandle;
+use HADES::TrbNet;
+# use List::Util qw(min max);
+# use Time::HiRes qw(usleep);
+use Dmon;
+use HPlot;
+use Perl2Epics;
+# use Data::Dumper;
+
+my %config = Dmon::StartUp();
+
+HPlot::PlotInit({
+ name => "temperature",
+ file => Dmon::DMONDIR."RichEnvironmentTemperature",
+ curves => 1,
+ entries => 3000,
+ type => HPlot::TYPE_HISTORY,
+ output => HPlot::OUT_PNG,
+ xlabel => "Time [m]",
+ ylabel => "Temperature",
+ sizex => 750,
+ sizey => 270,
+ ymin => 10,
+ ymax => "30<*",
+ nokey => 1,
+ storable=> 1,
+ buffer => 1
+ });
+HPlot::PlotInit({
+ name => "pressure",
+ file => Dmon::DMONDIR."RichEnvironmentPressure",
+ curves => 1,
+ entries => 3000,
+ type => HPlot::TYPE_HISTORY,
+ output => HPlot::OUT_PNG,
+ xlabel => "Time [m]",
+ ylabel => "Pressure",
+ sizex => 750,
+ sizey => 270,
+ ymin => 900,
+ ymax => 1000,
+ nokey => 1,
+ storable=> 1,
+ buffer => 1
+ });
+
+my $str = Dmon::MakeTitle(10,12,"RichEnvironment",0);
+ $str .= qq@<img src="%ADDPNG RichEnvironmentTemperature.png%" type="image/png">@."\n";
+ $str .= qq@<img src="%ADDPNG RichEnvironmentPressure.png%" type="image/png">\n@;
+ $str .= Dmon::MakeFooter();
+Dmon::WriteFile("RichEnvironment",$str);
+
+Perl2Epics::Connect("T","CBM:BMP180:GetTemp");
+Perl2Epics::Connect("P","CBM:BMP180:GetPressure");
+
+my $iter = 0;
+
+while (1) {
+
+ # get data from epics
+ my $data = Perl2Epics::GetAll();
+ my $temperature = $data->{"T"}->{"val"} / 10.;
+ my $pressure = $data->{"P"}->{"val"} / 100.;
+
+ my $title = "Environment";
+ my $value = sprintf("%.1f / %.1f", $pressure, $temperature);
+ my $longtext = "Pressue (mbar) / Temperatur (°C): ". $value;
+ my $status = Dmon::OK;
+# print time."\t".$data->{"P"}->{"tme"}."\t".$data->{"T"}->{"tme"}."\n";
+ if (time - $data->{"P"}->{"tme"} > 240 || time - $data->{"T"}->{"tme"} > 240) {
+ $status = Dmon::WARN;
+ $longtext .="<br>Updates missing";
+ }
+
+ Dmon::WriteQALog($config{flog},"richenvironment",15,$status,$title,$value,$longtext,'30-RichEnvironment');
+
+ if($iter++ % 12 == 0) {
+ HPlot::PlotAdd('temperature',$temperature);
+ HPlot::PlotAdd('pressure',$pressure);
+ HPlot::PlotDraw('temperature');
+ HPlot::PlotDraw('pressure');
+ }
+ sleep 5;
+ }
+
+
+
+
+
use warnings;
use POSIX qw(strftime);
use FileHandle;
-use lib "./code";
-use lib "../tools";
use HADES::TrbNet;
use Time::HiRes qw(usleep);
use Dmon;
--- /dev/null
+../users/cern_cbmrich/ChannelMapping.pm
\ No newline at end of file
my $filename = $p->{$name}->{file};
$filename =~ s%/%%;
- $storefile->{$name} = "/dev/shm/".$name.'-'.$p->{$name}->{curves}.'-'.$p->{$name}->{entries}.'-'.$filename.'.store';
-
-
+ $storefile->{$name} = $name.'-'.$p->{$name}->{curves}.'-'.$p->{$name}->{entries}.'-'.$filename.'.store';
+ $storefile->{$name} =~ s%/%%g;
+ $storefile->{$name} = "/dev/shm/".$storefile->{$name};
+
foreach my $i (0..($c->{entries}-1)) {
for my $j (0..($c->{curves}-1)) {
push(@{$p->{$name}->{value}->[$j]},0) ;
#Scripts to start & order of icons in the Overview
activeScripts => [['time','ping','-','-','daqop'],
['numfee','temperature','reftime','billboard','mbs'],
- ['beamintensity','-','-','-','-'],
+ ['beamintensity','beammonitors','-','-','richenvironment'],
['trgrate','datarate','deadtime','-','-'],
['heatmaprich','padiwatemp','padiwaonline','currents','pscurrents'],
['cbmnetlink','cbmnetdata','cbmnetsync','-','-']],
qaNames => ['sys','main','beam','rate','Pdwa','CNet','-'],
#Expected number of FPGAs in system
-NumberOfFpga => 90,
+NumberOfFpga => 90,
#The address of the individual boards
CtsAddress => 0x7005,
SpillThreshold => 30,
#Name detectors
-BeamDetectorsTrb => [0x0111,0x0111,0x0111,0x0110],
-BeamDetectorsChan => [0xc001,0xc005,0xc009,0xc005],
+BeamDetectorsTrb => [0x0111,0x0110,0x0111,0x0110,0x0113,0x0110],
+BeamDetectorsChan => [0xc001,0xc009,0xc005,0xc00b,0xc009,0xc005],
+BeamDetectorsName => ['C1', 'C1d', 'C2', 'C2d', 'Lead', 'Hodo'],
#User directory
UserDirectory => '/home/hadaq/trbsoft/daqtools/users/cern_cbmrich/',
#!/bin/bash
rm padiwa_threshold_results.log
./write_thresholds.pl thresh/dummythresholds.thr -o 0
-
+trbcmd setbit 0x7005 0xa00c 0x80000000
# ./run_thresh_on_system.pl \
# --endpoints=0x0013,0x0021,0x0033,0x0041,0x0053,0x0061,0x0073,0x0081,0x0093,0x00a1,0x00b3,0x00c1,0x00d3,0x00e1,0x00f3,0x0101 \
./run_thresh_on_system.pl --endpoints=0x0010-0x0013,0x0020-0x0023,0x0030-0x0033,0x0040-0x0043,0x0050-0x0053,0x0060-0x0063,0x0070-0x0073,0x0080-0x0083,0x0090-0x0093,0x00a0-0x00a3,0x00b0-0x00b3,0x00c0-0x00c3,0x00d0-0x00d3,0x00e0-0x00e3,0x00f0-0x00f3,0x0100-0x0103\
--32channel --chains=0 --offset=0 --polarity 1 --tool ./thresholds_new.pl
-./write_thresholds.pl padiwa_threshold_results.log -o 0
\ No newline at end of file
+./write_thresholds.pl padiwa_threshold_results.log -o 0
+trbcmd clearbit 0x7005 0xa00c 0x80000000