]> jspc29.x-matter.uni-frankfurt.de Git - daqtools.git/commitdiff
Intermediate work
authorAndreas Neiser <neiser@kph.uni-mainz.de>
Mon, 1 Jul 2013 09:13:51 +0000 (11:13 +0200)
committerAndreas Neiser <neiser@kph.uni-mainz.de>
Mon, 1 Jul 2013 09:13:51 +0000 (11:13 +0200)
xml-db/trb-setup.xml
xml-db/xml-db.pl

index 27f3d749e717fafc4effd661cd808e38ab5771ca..9c7b477c299f9c3e49754bff21fa583af836a718 100644 (file)
@@ -34,7 +34,8 @@
       <!-- this way we modify the number of channels to 5. This works
            since group/register/memory/fifo have unique names. It
            might be that there are several places where one should
-           change the "repeat", but how does one know?  -->
+           change the "repeat" to get a consistent entity model, but
+           how does one know that programmitcally??? -->
       <register name="Channel" repeat="5" />
     </entity>
 
index 2b635ad698d6aa44ae481f931fbdbf6b66d1ba3d..11f8934ee448ad58acb8be3be87addb576630529 100755 (executable)
@@ -46,11 +46,13 @@ sub Main {
   my $merged = {};
   foreach my $item (@$files) {
     my $file = $item->[0];
-    my $doc = $item->[1]; print "Working on $file...\n" if $verbose;
-    
+    my $doc = $item->[1];
+    #print "Working on $file...\n" if $verbose;
+
     foreach my $trbnode ($doc->getDocumentElement->findnodes('trb')) {
       my $trbaddress = $trbnode->getAttribute('address');
-      print $trbaddress,"\n";
+      printf("%s:%d: Evaluating trb node for 0x$trbaddress\n", $file,
+             $trbnode->line_number) if $verbose;
       foreach my $entitynode ($trbnode->findnodes('entity')) {
         my $ref = $entitynode->getAttribute('ref');
 
@@ -58,9 +60,27 @@ sub Main {
         FatalError($entitynode, "Entity reference $ref not found in database")
           unless defined $db->{$ref};
 
-        # check if there's 
-        
-        print $ref,"\n";
+        my $db_entitynode = $db->{$ref}->getDocumentElement;
+
+        # use the provided base address or the default one from the db
+        my $base_address = $entitynode->getAttribute('address') ||
+          $db_entitynode->getAttribute('address');
+        # check if we know already something about that entity at this
+        # trbaddress and base_address...then use this, otherwise use the
+        # a cloned entity from the database as a starting point
+        unless (defined $merged->{$trbaddress} and
+                defined $merged->{$trbaddress}->{$base_address}) {
+          # clone deeply
+          $merged->{$trbaddress}->{$base_address} = $db_entitynode->cloneNode(1);
+        }
+        my $e = $merged->{$trbaddress}->{$base_address};
+
+        # now we apply the changes $entitynode (provided by elements
+        # like field, register, group, ...) to the "full" TrbNetEntity
+        # in $e
+        foreach my $elem ($entitynode->findnodes('*')) {
+          print $elem->nodeName,"\n";
+        }
       }
     }
   }