From: www@jspc55 Date: Wed, 22 Jan 2014 15:19:01 +0000 (+0100) Subject: backup of work on plotting system X-Git-Url: https://jspc29.x-matter.uni-frankfurt.de/git/?a=commitdiff_plain;h=2d2cc6a3f181b46f0888ba3fb9b3ff5c724ce70c;p=mvdsensorcontrol.git backup of work on plotting system --- diff --git a/tools/AccessXmlDb.pm b/tools/AccessXmlDb.pm new file mode 100644 index 0000000..0b385b7 --- /dev/null +++ b/tools/AccessXmlDb.pm @@ -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 diff --git a/tools/adcmon.pl b/tools/adcmon.pl index 811998b..e1a6821 100755 --- a/tools/adcmon.pl +++ b/tools/adcmon.pl @@ -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 diff --git a/tools/plotService.pl b/tools/plotService.pl index d5ba12f..38f52c2 100755 --- a/tools/plotService.pl +++ b/tools/plotService.pl @@ -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