use lib "$FindBin::Bin/..";
my $shm = "/dev/null";
-my $timeout = 10;
+my $timeout = 5;
my $suicideTimer = time();
my $updateInterval = 1; #s
my $updateTS = time();
PlotJob::initXmlDb("../../daqtools/xml-db/cache/CbController.entity");
+PlotJob::initTrbNet();
}
sub samplingTasks {
- print "sampling\n" if $verbose;
+# print "sampling\n" if $verbose;
for my $requestString ( keys %{$ps->{requests}} ) {
$jobs->{$requestString}->sample();
package PlotJob;
use HPlot;
-# use HADES::TrbNet;
+use HADES::TrbNet;
use AccessXmlDb;
+require Common;
my $xmldb;
$xmldb = AccessXmlDb->new( entityFile => $entityFile );
}
-
+
+sub initTrbNet {
+ trb_init_ports() or die trb_strerror();
+}
sub new {
my $class = shift;
$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};
$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);
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 {
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