]> jspc29.x-matter.uni-frankfurt.de Git - mvdsensorcontrol.git/commitdiff
plotting system now works with TRBNet data
authorwww@jspc55 <www@jspc55>
Thu, 23 Jan 2014 16:20:23 +0000 (17:20 +0100)
committerwww@jspc55 <www@jspc55>
Thu, 23 Jan 2014 16:20:23 +0000 (17:20 +0100)
tools/adcmon.pl
tools/plotService.pl

index f75044576360b189cc38bc3c90799b6cd15784cc..0c9f7fa672a8f4aeee2bfdf1cee7dc759b01efba 100755 (executable)
@@ -37,7 +37,7 @@ $ps->startPlotService() unless $ps->plotServiceRunning();
 
 while(1){
   $ps->retrieveRequests();
-  $ps->addRequest( FPGA => "0xd882", CB => "0", chip => "1", channel => "CurrentDigital");
+  $ps->addRequest( FPGA => "0xd882", CB => "0", chip => "0", channel => "CurrentDigital");
   $ps->listRequests();
   $ps->storeRequests();
   sleep 1;
index 2ec9292ff48e1579ba143ff613b91c715e10d683..0dd13eabc869f8b309018f03a8d4008efedd1b2b 100755 (executable)
@@ -28,7 +28,7 @@ use FindBin;
 use lib "$FindBin::Bin/..";
 
 my $shm = "/dev/null";
-my $timeout = 10;
+my $timeout = 5;
 my $suicideTimer = time();
 my $updateInterval = 1; #s
 my $updateTS = time();
@@ -43,6 +43,7 @@ GetOptions(
           
           
 PlotJob::initXmlDb("../../daqtools/xml-db/cache/CbController.entity");
+PlotJob::initTrbNet();
 
 
 
@@ -73,7 +74,7 @@ while(1) {
 }
 
 sub samplingTasks {
-  print "sampling\n" if $verbose;
+  print "sampling\n" if $verbose;
   
   for my $requestString ( keys %{$ps->{requests}} ) {
     $jobs->{$requestString}->sample();
@@ -138,8 +139,9 @@ sub keepAlive {
 package PlotJob;
 
 use HPlot;
-use HADES::TrbNet;
+use HADES::TrbNet;
 use AccessXmlDb;
+require Common;
 
 my $xmldb;
 
@@ -149,7 +151,10 @@ sub initXmlDb {
   $xmldb = AccessXmlDb->new( entityFile => $entityFile );
   
 }
-  
+
+sub initTrbNet {
+  trb_init_ports() or die trb_strerror();
+}
 
 sub new {
   my $class = shift;
@@ -165,6 +170,8 @@ sub new {
   $self = { %$self, %{$xmldb->channelParm($self->{chip},$self->{channel}) } };
   # combine both into this object hash
   
+  $self->{FPGA} = any2dec($self->{FPGA}); ## convert hex to decimal
+  
   my $plot = ();
   $plot->{name}    = $self->{requestString};
   $plot->{file}    = $self->{plotDir}."/".$self->{requestString};
@@ -172,6 +179,9 @@ sub new {
   $plot->{type}    = HPlot::TYPE_HISTORY;
   $plot->{output}  = HPlot::OUT_PNG;
   $plot->{titles}->[0] = $self->{requestString};
+  $plot->{ylabel}  = $self->{unit};
+  $plot->{ymin}    = 0;
+  $plot->{ymax}    = $self->{scale} * 65536;
   
   HPlot::PlotInit($plot);
   bless($self, $class);
@@ -179,7 +189,13 @@ sub new {
 
 sub sample {
   my $self = shift;
-  HPlot::PlotAdd($self->{requestString},rand());
+  my $myverbose=0;
+  # sample random number for debug
+#   HPlot::PlotAdd($self->{requestString},rand());
+  my $read = trb_register_read($self->{FPGA},$self->{address});
+  my $value = ($read->{$self->{FPGA}} & 0xFFFF ) * $self->{scale};
+  print $value."\n" if $myverbose;
+  HPlot::PlotAdd($self->{requestString},$value);
 
 }
 sub draw {
@@ -187,5 +203,18 @@ sub draw {
   HPlot::PlotDraw($self->{requestString});
 }
 
+sub any2dec { # converts numeric expressions 0x, 0b or decimal to decimal
+  
+  my $argument = $_[0];
+  #print "any2dec input argument $argument\n";  
+
+  if ( $argument =~ m/0[bxBX]/) { 
+    return oct $argument;
+  } else {
+    return $argument;
+  }
+}
+
+
 
 1;
\ No newline at end of file