use CtsPlugins::CtsModStatic;
sub new {
- my $type = $_[0];
- my $trb = $_[1];
+ my $type = shift;
+ my $trb = shift;
+ my $enumCache = shift;
my $self = {
'_trb' => $trb,
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();
# Starts
my $self = shift;
my $address = shift;
+
$address = 0xa100 if not defined $address;
my $last = 0;
'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;
$address += $offsetToNextHeader;
}
-
}
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;