From: www@jspc55 Date: Thu, 23 Jan 2014 16:20:23 +0000 (+0100) Subject: plotting system now works with TRBNet data X-Git-Url: https://jspc29.x-matter.uni-frankfurt.de/git/?a=commitdiff_plain;h=03fb69c9e845fc42316adeb72db2fd8aa6465fc4;p=mvdsensorcontrol.git plotting system now works with TRBNet data --- diff --git a/tools/adcmon.pl b/tools/adcmon.pl index f750445..0c9f7fa 100755 --- a/tools/adcmon.pl +++ b/tools/adcmon.pl @@ -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; diff --git a/tools/plotService.pl b/tools/plotService.pl index 2ec9292..0dd13ea 100755 --- a/tools/plotService.pl +++ b/tools/plotService.pl @@ -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