]> jspc29.x-matter.uni-frankfurt.de Git - daqtools.git/commitdiff
first version for threshold settings for PADIWA, mt
authorhadaq <hadaq>
Sun, 21 Oct 2012 23:54:59 +0000 (23:54 +0000)
committerhadaq <hadaq>
Sun, 21 Oct 2012 23:54:59 +0000 (23:54 +0000)
thres/Window.pm
thres/logger_threshold.conf [new file with mode: 0644]
thres/thres.pl

index 0c82dbc7cda329e2d7fb6db31689624df456e382..d47fa411ae969853a26254578448ecf92ea90128 100644 (file)
@@ -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 (file)
index 0000000..c62b45e
--- /dev/null
@@ -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
index 0721ebc528a4f94234dea1d2df033bcc9a74f1b3..78a8c2712499818bbe3fa723cb363a04c6e9586c 100755 (executable)
@@ -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=<channel_number>
+
+example:
+
+thres.pl --channel=2
+or in short
+thres.pl -c 2
+";
+
+
+}
+
+