]> jspc29.x-matter.uni-frankfurt.de Git - mvdsensorcontrol.git/commitdiff
backup of work on plotting system
authorwww@jspc55 <www@jspc55>
Wed, 22 Jan 2014 15:19:01 +0000 (16:19 +0100)
committerwww@jspc55 <www@jspc55>
Wed, 22 Jan 2014 15:19:01 +0000 (16:19 +0100)
tools/AccessXmlDb.pm [new file with mode: 0644]
tools/adcmon.pl
tools/plotService.pl

diff --git a/tools/AccessXmlDb.pm b/tools/AccessXmlDb.pm
new file mode 100644 (file)
index 0000000..0b385b7
--- /dev/null
@@ -0,0 +1,49 @@
+package AccessXmlDb;
+
+use Storable qw(lock_store lock_retrieve);
+
+sub new {
+  my $class = shift;
+  my %options = @_;
+  my $self  = {
+    entityFile => '/dev/null',
+    %options
+  };
+  bless($self, $class);
+  $self->{entity} = lock_retrieve($self->{entityFile});
+  die "cannot open xml-db entity file ".$self->{entityFile}."\n" unless defined $self->{entity};
+  return $self;
+}
+
+sub channelParm {
+  my $self = shift;
+  my $chip = shift;
+  my $channel = shift;
+  
+  my $parm;
+  %{$parm}= %{$self->{entity}->{$channel."D"}};
+  
+  die "entry $channel does not exist for chip=".$chip."\n" if ($chip ge $parm->{repeat});
+  
+  $parm->{address} += $chip * $parm->{stepsize};
+  return $parm;
+}
+
+# returns a hash ref to the following contents (example);
+# 
+# $VAR1 = {
+#           'mode' => 'r',
+#           'purpose' => 'status',
+#           'description' => 'Current on the digital power supply.',
+#           'unit' => 'mA',
+#           'format' => 'unsigned',
+#           'scale' => '0.0038147',
+#           'repeat' => '2',
+#           'type' => 'field',
+#           'bits' => '16',
+#           'address' => 49424,
+#           'stepsize' => 16,
+#           'start' => '0'
+#         };
+
+1;
\ No newline at end of file
index 811998bfbda5c792fe54e9c58d56bfcbd97b298d..e1a6821671e7958aacbca165579022ec8b15bcf8 100755 (executable)
@@ -11,8 +11,10 @@ use POSIX;
 # use CGI::Carp qw(fatalsToBrowser);
 # use HTML::Entities;
 # use Widgets;
-
+use Data::Dumper;
 use PlotScheduler;
+use AccessXmlDb;
+use Storable qw(lock_store lock_retrieve);
 
 # use HPlot;
 
@@ -27,15 +29,32 @@ use Environment;
 
 
 
-my $ps = PlotScheduler->new( shm => "/dev/shm/DQ55_88", timeout=> 3 );
+
+my $ps = PlotScheduler->new( shm => "/dev/shm/DQ55_88" );
 # $ps->addRequest( FPGA => "0xd882", CB => "0", chip => "1", channel => "TEMP");
 # $ps->storeRequests();
 $ps->startPlotService() unless $ps->plotServiceRunning();
 
 while(1){
-$ps->retrieveRequests();
-$ps->addRequest( FPGA => "0xd882", CB => "0", chip => "1", channel => "VDDA");
-$ps->listRequests();
-$ps->storeRequests();
-sleep 1;
+  $ps->retrieveRequests();
+  $ps->addRequest( FPGA => "0xd882", CB => "0", chip => "1", channel => "VDDA");
+  $ps->listRequests();
+  $ps->storeRequests();
+  sleep 1;
 }
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+  
+  
\ No newline at end of file
index d5ba12f1f03985d49057c64cf5487dcfb58c932c..38f52c209b0d3ea5adad5dd5c065ea1f140d7adf 100755 (executable)
@@ -6,6 +6,7 @@ my $me = "plotService.pl";
 my $verbose = 1;
 my $suicideTimeout = 5;
 
+
 use strict;
 use warnings;
 use POSIX;
@@ -16,11 +17,13 @@ use Data::Dumper;
 use HADES::TrbNet;
 use HPlot;
 use Getopt::Long;
+use Time::HiRes;
 
 require Common;
 
 use PlotScheduler;
 
+
 use FindBin;
 use lib "$FindBin::Bin/..";
 
@@ -28,12 +31,32 @@ my $shm = "/dev/null";
 my $timeout = 10;
 my $suicideTimer = time();
 
+
 Getopt::Long::Configure(qw(gnu_getopt));
 GetOptions(
            'shm=s' => \$shm,
            'timeout=s' => \$timeout,
           );
 
+          
+          
+PlotJob::initXmlDb("/local.1/htdocs/daqtools/xml-db/cache/CbController.entity");
+
+
+
+
+
+# my $testJob = PlotJob->new(requestString => "0xd882-0-0-CurrentDigital");  
+# 
+# print Dumper $testJob;
+# 
+# exit;
+  
+          
+          
+          
+          
+          
 
 my $ps = PlotScheduler->new( shm => $shm, timeout => $timeout);
 $ps->createShm(); # create empty shm
@@ -63,4 +86,40 @@ sub keepAlive {
       exit;
     }
   }
-}
\ No newline at end of file
+}
+
+package PlotJob;
+
+use HPlot;
+use HADES::TrbNet;
+use AccessXmlDb;
+
+my $xmldb;
+
+sub initXmlDb {
+  my $entityFile = shift;
+  
+  $xmldb = AccessXmlDb->new( entityFile => $entityFile );
+  
+}
+  
+
+sub new {
+  my $class = shift;
+  my %options = @_;
+  my $self  = {
+    requestString => '',
+    %options
+  };
+  bless($self, $class);
+  
+  ($self->{FPGA},$self->{CB},$self->{chip},$self->{channel}) = split("-",$self->{requestString});
+  $self = { %$self, %{$xmldb->channelParm($self->{chip},$self->{channel}) } };
+  
+  
+  
+  return $self;
+}
+
+
+1;
\ No newline at end of file