From: hadaq Date: Sun, 21 Oct 2012 23:54:59 +0000 (+0000) Subject: first version for threshold settings for PADIWA, mt X-Git-Url: https://jspc29.x-matter.uni-frankfurt.de/git/?a=commitdiff_plain;h=6931f6879f8eaf5f4de52304873a8caf1c92824a;p=daqtools.git first version for threshold settings for PADIWA, mt --- diff --git a/thres/Window.pm b/thres/Window.pm index 0c82dbc..d47fa41 100644 --- a/thres/Window.pm +++ b/thres/Window.pm @@ -4,7 +4,7 @@ use strict; use warnings; use Data::Dumper; -my $endpoint = 0x201; +my $endpoint = 0xc001; use HADES::TrbNet; @@ -89,7 +89,7 @@ sub scrollBar() { my $rough_value=0; my $fine_value=0; #my $mode = $main::mode; -my $mode = "padiwa"; +my $mode = "cbm"; sub NEW { @@ -135,7 +135,12 @@ sub NEW { this->slider->setMinimum(0x0); - this->slider->setMaximum(0xffff); + if ($mode eq "padiwa") { + this->slider->setMaximum(0xffff); + } + else { + this->slider->setMaximum(0xfff); + } this->scrollBar->setMinimum(0x0); this->scrollBar->setMaximum(0xff); @@ -164,7 +169,9 @@ sub NEW { this->valueSpinBox->setValue(3150); - this->setWindowTitle(this->tr('Thresholds')); + my $titleofwindow="Thresholds of channel $main::channel"; + this->setWindowTitle(this->tr($titleofwindow)); +# this->setWindowTitle(this->tr('Thresholds $channel')); } @@ -175,7 +182,7 @@ sub setValue { $rough_value = $value; write_to_hardware(); - print "set value called: $value\n"; + #print "set value called: $value\n"; } sub setValueFine { @@ -183,15 +190,20 @@ sub setValueFine { this->scrollBar->setValue($value); $fine_value = $value; write_to_hardware(); - print "set fine value called: $value\n"; + #print "set fine value called: $value\n"; } sub write_to_hardware { my $sum = $rough_value + $fine_value; + #print "channels: ". $main::channel_str . "\n"; + if ($mode eq "cbm") { + my $rh_res; + $rh_res = trb_register_write($endpoint,0xd410, 0x1); + if($sum > 4095) { $sum=4095; } @@ -200,16 +212,18 @@ sub write_to_hardware { foreach my $dacch (0..7) { my $rh_res; my $command; - $command= 0x00300000+($dacch<<16) + ($sum<<4); + $command= 0x00300000 | ($dacch<<16) | ($sum<<4); $rh_res = trb_register_write($endpoint,0xd400, $command); - + printf "trbcmd w 0x%x 0xd400 0x%x\n", $endpoint, $command; + if(!defined $rh_res) { my $res = trb_strerror(); print "error output: $res\n"; exit(); } $rh_res = trb_register_write($endpoint,0xd411, 0x1); + printf "trbcmd w 0x%x 0xd411 0x%x\n", $endpoint, 1; } } @@ -221,20 +235,21 @@ sub write_to_hardware { my $rh_res; $rh_res = trb_register_write($endpoint,0xd410, 0x1); - foreach my $dacch (0..15) { - - my $command; - $command= 0x00800000 + ($dacch<<16) + ($sum); - - $rh_res = trb_register_write($endpoint,0xd400, $command); - - if(!defined $rh_res) { - my $res = trb_strerror(); - print "error output: $res\n"; - exit(); - } - $rh_res = trb_register_write($endpoint,0xd411, 0x1); + + #foreach my $dacch (0..15) { + my $dacch = $main::channel; + #print "chosen channel:$dacch\n"; + my $command; + $command= 0x00800000 + ($dacch<<16) + ($sum); + $rh_res = trb_register_write($endpoint,0xd400, $command); + + if(!defined $rh_res) { + my $res = trb_strerror(); + print "error output: $res\n"; + exit(); } + $rh_res = trb_register_write($endpoint,0xd411, 0x1); + } diff --git a/thres/logger_threshold.conf b/thres/logger_threshold.conf new file mode 100644 index 0000000..c62b45e --- /dev/null +++ b/thres/logger_threshold.conf @@ -0,0 +1,33 @@ +log4perl.logger.padiwa_threshold=DEBUG, A1 +log4perl.appender.A1=Log::Dispatch::File +log4perl.appender.A1.filename=padiwa_threshold.log +log4perl.appender.A1.mode=append +log4perl.appender.A1.layout=Log::Log4perl::Layout::PatternLayout +#log4perl.appender.A1.layout.ConversionPattern=%d %p> %F{1}:%L %M %P - %m%n +log4perl.appender.A1.layout.ConversionPattern=%d %p> %M %P - %m%n + +# results of threshold scan +log4perl.logger.padiwa_threshold_data=DEBUG, D1 +log4perl.appender.D1=Log::Dispatch::File +log4perl.appender.D1.filename=padiwa_threshold_results +log4perl.appender.D1.mode=append +log4perl.appender.D1.layout=Log::Log4perl::Layout::PatternLayout +log4perl.appender.D1.layout.ConversionPattern=%d %m%n + + +# for thresholds for the DAQ +#log4perl.logger.mdc_threshold_analyze=DEBUG, A2 +#log4perl.appender.A2=Log::Dispatch::File +#log4perl.appender.A2.filename=data/mdc_threshold_daq.db +#log4perl.appender.A2.mode=append +#log4perl.appender.A2.layout=Log::Log4perl::Layout::PatternLayout +#log4perl.appender.A2.layout.ConversionPattern=%m%n + + +# only for test +log4perl.logger.test=DEBUG, T1 +log4perl.appender.T1=Log::Dispatch::File +log4perl.appender.T1.filename=test.log +log4perl.appender.T1.mode=append +log4perl.appender.T1.layout=Log::Log4perl::Layout::PatternLayout +log4perl.appender.T1.layout.ConversionPattern=%d %m%n diff --git a/thres/thres.pl b/thres/thres.pl index 0721ebc..78a8c27 100755 --- a/thres/thres.pl +++ b/thres/thres.pl @@ -7,7 +7,30 @@ use QtCore4; use QtGui4; use Window; -my $mode = $ARGV[0]; +use Getopt::Long; + + +my $help; +my @channels; +our $channel_str; + +my $result = GetOptions ( + "help" => \$help, + "channel=s" => \$channel_str + ); + +if($help || $channel_str eq "") { + usage(); + exit; +} + +our $channel = int($channel_str); + +if (!defined $channel) { + usage(); + exit; +} + sub main { my $app = Qt::Application( \@ARGV ); @@ -18,3 +41,20 @@ sub main { exit main(); + +sub usage { + + print " +usage: thres.pl --channel= + +example: + +thres.pl --channel=2 +or in short +thres.pl -c 2 +"; + + +} + +