From 7bea9740ac1b8d1f811b19ddec60e2f52b796f1f Mon Sep 17 00:00:00 2001 From: hadaq Date: Thu, 15 Dec 2022 12:09:40 +0100 Subject: [PATCH] added padiwa files --- users/eic_crt/dmon_config.pl | 115 ++++++++++++++ users/eic_crt/dmon_restart.pl | 7 + users/eic_crt/padiwa_led_off.pl | 53 +++++++ users/eic_crt/prepare_padiwas_invert_leds.pl | 158 +++++++++++++++++++ users/eic_crt/startup.sh | 10 +- 5 files changed, 341 insertions(+), 2 deletions(-) create mode 100755 users/eic_crt/dmon_config.pl create mode 100755 users/eic_crt/dmon_restart.pl create mode 100755 users/eic_crt/padiwa_led_off.pl create mode 100755 users/eic_crt/prepare_padiwas_invert_leds.pl diff --git a/users/eic_crt/dmon_config.pl b/users/eic_crt/dmon_config.pl new file mode 100755 index 0000000..304f98a --- /dev/null +++ b/users/eic_crt/dmon_config.pl @@ -0,0 +1,115 @@ +#This a an example configuration file. Copy this file to your user directory and give +#start.pl a link to this file as first argument. + +#Scripts to start & order of icons in the Overview +activeScripts => [['time','ping','-','-','daqop'], + ['numfee','temperature','reftime','trgerrors','-'], + ['beamintensity','beammonitors','-','-','-'], + ['trgrate','datarate','deadtime','-','-'], + ['padiwatemp','padiwaonline','-','-','-'], + ['heatmapdirc','-','-','-','-'], +# ['heatmapdirc','heatmapdirc_zoom','-','-','-'], + ['evtbnetmem','eb2','eb3','-','-'], + ], + +#Names to be shown in left column of Overview (max 4 letters!) +qaNames => ['sys','main','beam','rate','Pdwa','Heat','EB'], + +NumberOfFpga => 39, +NumberOfPadiwa => 11, + +#The address of the individual boards +CtsAddress => 0xc000, +PadiwaBroadcastAddress => 0xfe4c, + +PadiwaTrbAddresses => [0x2001,0x2002,0x2003,0x2004,0x2005,0x2006,0x2007, + 0x2008,0x2009,0x200a,0x200b], +PadiwaChainMask => [0x0007,0x0001,0x0004,0x0001,0x0007,0x0001,0x0004,0x0007, + 0x0004,0x0001,0x0004,0x0007,0x0007,0x0001,0x0000,0x0007, + 0x0001,0x0001,0x0001,0x0001, + 0x0001,0x0001,0x0001,0x0001,0x003,0x0001], + ## 0x0001,0x0003,0x0003,0x0001, +# 0x0007,0x0001, +# 0x0001,0x0003], +# 0x0003,0x0003,0x0001,0x0003], + +#0x2020,0x2023, no padiwa +#,0x201d,0x201e,0x201f off +#0x2029,0x202a,0x202b,0x202c,0x202d,0x202e,0x202f +#old OtherTrbAddresses => [0xc00,0x202c,0x202d], +OtherTrbAddresses => [0xc000], + + + + +##HubTrbAddresses => [0x8100,0x8101,0x8102,0x8103,0x8000,0X8001,0x8002,0x8003,0x8004,0x8005,0x8006,0x8007,0x8008], +HubTrbAddresses => [0x8000,0X8001,0x8002], + + +#Addresses of all TDCs. Either single or broadcast addresses +TdcAddress => [0xfe4c,0xfe48,0xfe4a], + +#IPs of all devices which should react on a ping +TrbIP => [ + "192.168.0.99", + "192.168.0.73", + "192.168.0.72", + "192.168.0.104", +], + +#Channel to read spill intensity from. Give limit for off-spill detection +#BeamTRB => 0x2011, +#BeamChan => 0xc001, +#SpillThreshold => 50, + +#Name detectors +#BeamDetectorsTrb => [0x2011,0x2011,0x2011,0x201c,0x201c], +#BeamDetectorsChan => [0xc001,0xc002,0xc003,0xc001,0xc003], +#BeamDetectorsName => ['Trig1','Trig2','Trig3','MCP1','MCP2'], +#BeamDetectorsTrb => [0x0110, 0x0110, 0x0111,0x0110,0x0111,0x0110,0x0113,0x0111,0x0110], +#BeamDetectorsChan => [0xc001, 0xc003, 0xc001,0xc009,0xc005,0xc00b,0xc009,0xc009,0xc005], +#BeamDetectorsName => ['Fngr_d', 'Lead_d', 'C1', 'C1_d', 'C2', 'C2_d', 'Lead1', 'Lead2', 'Hodo'], + +#User directory +UserDirectory => '/home/hadaq/trbsoft/daqtools/users/eic_crt/', +#PowerSupScript => 'measure_powers.sh' # relative to user dir + +#BarrelDirc Heatmap settings +HeatmapDirc => { + # upper limit for high end of color scale + max_count_uclamp => 100000000, +# max_count_uclamp => 100000, +# max_count_uclamp => 20000, +# max_count_uclamp => 4000, + # lower limit for high end of color scale + max_count_lclamp => 10, + + # when set to 1 normalization of color scale is instantaneous, + # when set to 0, normalization has "inertia" + instant_normalization => 1, + + # the inertia of the adaption of the color scale in the unit of 1/(gliding average weight) + normalization_inertia => 3 +}, + +HeatmapDircZoom => { + # upper limit for high end of color scale +# max_count_uclamp => 100000000, +# max_count_uclamp =>500, + max_count_uclamp =>20000, + # lower limit for high end of color scale + max_count_lclamp => 10, + + # when set to 1 normalization of color scale is instantaneous, + # when set to 0, normalization has "inertia" + instant_normalization => 1, + + # the inertia of the adaption of the color scale in the unit of 1/(gliding average weight) + normalization_inertia => 3 +}, + +EvtbNetmem => { + shm_string => "test" +}, + +qalog_persistDirectory => '/d/logs/' diff --git a/users/eic_crt/dmon_restart.pl b/users/eic_crt/dmon_restart.pl new file mode 100755 index 0000000..271a2fc --- /dev/null +++ b/users/eic_crt/dmon_restart.pl @@ -0,0 +1,7 @@ +#!/bin/bash + +cd ../../dmon +./stop.pl +./start.pl ../users/eic_crt/dmon_config.pl + + diff --git a/users/eic_crt/padiwa_led_off.pl b/users/eic_crt/padiwa_led_off.pl new file mode 100755 index 0000000..5ef6f3c --- /dev/null +++ b/users/eic_crt/padiwa_led_off.pl @@ -0,0 +1,53 @@ +#!/usr/bin/perl + +use strict; +use warnings; +use Parallel::ForkManager; + +my $MAX_PROCESSES=50; +my $pm = Parallel::ForkManager->new($MAX_PROCESSES); + +#my @pad0 =(0x2000 .. 0x200b); +#my @pad1 =(0x2000 .. 0x200b); +#my @pad2 =(0x2000 .. 0x200b); + +my @pad0 =(0x2000 .. 0x200f); +my @pad1 =(0x2000 .. 0x200f); +my @pad2 =(0x2000 .. 0x200f); + +#my @pad0 =(0x2000,0x2001,0x2004,0x2007,0x2009,0x200a,0x200c,0x200f,0x2011,0x2012,0x2013); +#my @pad1 =(0x2000,0x2004,0x2005,0x2006,0x2007,0x2008,0x2009,0x200e); +#my @pad2 =(0x2004,0x2006,0x2008,0x2009,0x200a,0x200e,0x2010); + + + + +foreach my $b (@pad0) { + my $pid = $pm->start and next; + my $c = sprintf("../../tools/padiwa.pl 0x%04x 0 ledoff >/dev/null",$b); + #print "$c\n"; + system($c); + #my $r = qx($c); + #print $r; + $pm->finish; + } +$pm->wait_all_children; +#print "next\n"; +foreach my $b (@pad1) { + my $pid = $pm->start and next; + my $c = sprintf("../../tools/padiwa.pl 0x%04x 1 ledoff >/dev/null",$b); + #print $c; + system($c); + $pm->finish; + } +$pm->wait_all_children; + +foreach my $b (@pad2) { + my $pid = $pm->start and next; + my $c = sprintf("../../tools/padiwa.pl 0x%04x 2 ledoff >/dev/null",$b); + system($c); + $pm->finish; +} +$pm->wait_all_children; + +print "finished switching off all led for new Padiwa-Firmware (>= 2014.11.21)\n"; diff --git a/users/eic_crt/prepare_padiwas_invert_leds.pl b/users/eic_crt/prepare_padiwas_invert_leds.pl new file mode 100755 index 0000000..d351a24 --- /dev/null +++ b/users/eic_crt/prepare_padiwas_invert_leds.pl @@ -0,0 +1,158 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +use Parallel::ForkManager; +use Getopt::Long; +use Data::Dumper; + +my $help; +my $opt_invert; +my $opt_stretch; +my @opt_endpoints; +my @opt_chains; + +my $result = GetOptions ( + "h|help" => \$help, + "i|invert=s" => \$opt_invert, + "e|endpoints=s" => \@opt_endpoints, + "s|stretch=s" => \$opt_stretch, + "c|chains=s" => \@opt_chains, + ); + +if($help) { + usage(); + exit; +} + +usage() unless ($opt_invert && @opt_endpoints && @opt_chains); + +#my $arg=$ARGV[0]; +#my @padiwas = split /\s+/, $arg; + +my $endpoints = get_ranges(\@opt_endpoints); +my $chains = get_ranges(\@opt_chains); + + +my $MAX_PROCESSES = 40; +my $pm = Parallel::ForkManager->new($MAX_PROCESSES); + +#my $padiwa_invert_setting = "0xffff"; + +my $str_endpoints= join " ", @opt_endpoints; + +print "current padiwa range: $str_endpoints\n"; + +print "\tsetting padiwa invert-setting to $opt_invert: "; + +execute_command("invert $opt_invert"); +$pm->wait_all_children; +print "\n"; + + +#print "result of invert\n"; +#execute_command("invert", "verbose"); +#exit + +# print "\tturn off all leds depending on the firmware version"; +# execute_command("ledoff"); +# $pm->wait_all_children; +# print "\n"; + + +print "\tset temp compensation to 0x02c0 "; +execute_command("comp 0x02c0"); +#print "\tset temp compensation to 0x0"; +#execute_command("comp 0x0"); +$pm->wait_all_children; +print "\n"; + + +if($opt_stretch) { + print "\tset stretching to $opt_stretch"; + execute_command("stretch $opt_stretch"); + $pm->wait_all_children; + print "\n"; +} + +#sleep 2; +exit; + +sub execute_command { + + (my $padiwa_command, my $verbosity) = @_; + + #print Dumper $endpoints; + if(!@$endpoints) { + print "\nattention: no enpoints selected. Not doing anything!\n"; + die; + } + foreach my $cur_endpoint (@$endpoints) { + my $pid = $pm->start and next; + $cur_endpoint = sprintf "0x%4x", $cur_endpoint; + #print "$cur_endpoint "; + + for my $chain (0..2) { + my $c="/home/hadaq/trbsoft/daqtools/padiwa.pl $cur_endpoint $chain $padiwa_command"; + if (!$verbosity) { $c.= " >/dev/null" }; + #print $c . "\n"; + #$c="/home/hadaq/trbsoft/daqtools/padiwa.pl $cur_endpoint $chain temp"; + #print "$c\n"; + my $res = qx($c); die "could not execute command $c" if $?; + if($verbosity) { print "$res"; } + } + + $pm->finish; # Terminates the child process + }; + + +} + + +sub get_ranges { + (my $ra_data) = @_; + + my @array; + foreach my $str (@$ra_data) { + $str=~s/-/\.\./g; + $str=~s/\.\.\./\.\./g; + my @val = split(/\,/, $str); + #print Dumper \@val; + foreach my $c_val (@val) { + if($c_val =~ /\.\./) { + #print "range: $c_val\n"; + (my $start, my $stop) = $c_val =~ /(\w+)\.\.(\w+)/; + $start = hex($start) if($start=~/0x/); + $stop = hex($stop) if($stop=~/0x/); + #print "start $start, stop $stop\n"; + foreach ($start .. $stop) { + push @array, $_; + } + #print Dumper \@array; + } + else { + $c_val = hex($c_val) if($c_val=~/0x/); + push @array, int($c_val); + } + + } + + } + + return \@array; + +} + + +sub usage { + + + print "usage: +./prepare_padiwas_invert_leds.pl <--invert \"0xffff\" of --invert \"0x0000\"> <--endpoints=> <--chains=> [--help] +"; + + exit; + + +} diff --git a/users/eic_crt/startup.sh b/users/eic_crt/startup.sh index af021e3..a0407d7 100755 --- a/users/eic_crt/startup.sh +++ b/users/eic_crt/startup.sh @@ -1,6 +1,6 @@ #!/bin/bash -export PATH=$PATH:~/trbsoft/daqtools/users/cua_crt +export PATH=$PATH:~/trbsoft/daqtools/users/eic_crt export TRB3_SERVER=trb104:26000 export TRBNETDPID=$(pgrep trbnetd) @@ -20,7 +20,7 @@ rc=$?; if [[ $rc != 0 ]]; then echo "exit from startup as not all boards are up" echo "set addresses" -~/trbsoft/daqtools/merge_serial_address.pl ~/trbsoft/daqtools/base/serials_trb3.db ~/trbsoft/daqtools/users/cua_crt/addresses_trb3.db > /dev/null +~/trbsoft/daqtools/merge_serial_address.pl ~/trbsoft/daqtools/base/serials_trb3.db ~/trbsoft/daqtools/users/eic_crt/addresses_trb3.db > /dev/null @@ -69,3 +69,9 @@ trbcmd w 0xfe4a 0xc804 0x0000007c ## data transfer limit echo -n "- number of trb endpoints in the system after turning off unused tdcs: " trbcmd i 0xffff | wc -l +prepare_padiwas_invert_leds.pl --endpoints=0x2001-0x200b --chains=0..2 --invert=0xffff + +padiwa_led_off.pl + + + -- 2.43.0