From: hadeshyp Date: Sun, 4 Nov 2012 21:36:42 +0000 (+0000) Subject: Support for cached enums and new parameter passing from monitoring process to CGI... X-Git-Url: https://jspc29.x-matter.uni-frankfurt.de/git/?a=commitdiff_plain;h=7a0abfbedd32e751e92b076bc1b49430e9abf805;p=daqtools.git Support for cached enums and new parameter passing from monitoring process to CGI script --- diff --git a/cts/include/Cts.pm b/cts/include/Cts.pm index 83e4df6..978b325 100644 --- a/cts/include/Cts.pm +++ b/cts/include/Cts.pm @@ -7,8 +7,9 @@ use warnings::register; use CtsPlugins::CtsModStatic; sub new { - my $type = $_[0]; - my $trb = $_[1]; + my $type = shift; + my $trb = shift; + my $enumCache = shift; my $self = { '_trb' => $trb, @@ -23,11 +24,15 @@ sub new { unconnected unconnected unconnected unconnected)] }, # hash of properties (e.g. "number of inputs" ...) + '_enumCache' => {}, # can be used to speed up the enumeration if already connected to CTS with + # other process. Has to be implemented by the user interface layer ... '_exportRegs' => [] # list of registers, that need to be stored, when saving configuration }; bless($self, $type); + $self->{'_enumCache'} = $enumCache if ref $enumCache; + my $static = $self->_loadModule("Static") or die("Error while loading mandantory module >CtsModStatic<"); $static->register(); @@ -40,6 +45,7 @@ sub _enumerateTriggerLogic { # Starts my $self = shift; my $address = shift; + $address = 0xa100 if not defined $address; my $last = 0; @@ -56,10 +62,18 @@ sub _enumerateTriggerLogic { 'last' => {'lower' => 31, 'len' => 1, 'type' => 'bool'} }, { 'accessmode' => 'ro', - 'constant' => 1 + 'const' => 1 }); - $regv = $reg->read(); + + if (exists $self->{'_enumCache'}->{sprintf("addr_%04x", $address)}) { + $regv = $self->{'_enumCache'}->{sprintf("addr_%04x", $address)}; + $reg->setConstantValue($regv); + $regv = $reg->read(); + } else { + $regv = $reg->read(); + $self->{'_enumCache'}->{sprintf("addr_%04x", $address)} = $regv->{'_raw'}; + } $offsetToNextHeader = $regv->{'len'} + 1; @@ -87,7 +101,6 @@ sub _enumerateTriggerLogic { $address += $offsetToNextHeader; } - } sub _loadModule { @@ -107,6 +120,8 @@ sub _loadModule { return $ret; }; + print("Error when loading module >$modKey<: $@ \n") unless ($mod); + #print "return of eval module -> new (self, address: $address: $@\n"; $self->{'_modules'}{$modKey} = $mod if $mod; return $mod;