]> jspc29.x-matter.uni-frankfurt.de Git - daqtools.git/commitdiff
Loading and validating all *.xml files
authorAndreas Neiser <neiser@kph.uni-mainz.de>
Fri, 28 Jun 2013 14:30:56 +0000 (16:30 +0200)
committerAndreas Neiser <neiser@kph.uni-mainz.de>
Fri, 28 Jun 2013 14:30:56 +0000 (16:30 +0200)
xml-db/database/TDC.xml [new file with mode: 0644]
xml-db/database/testing.xml
xml-db/xml-db.pl

diff --git a/xml-db/database/TDC.xml b/xml-db/database/TDC.xml
new file mode 100644 (file)
index 0000000..51fde5c
--- /dev/null
@@ -0,0 +1,207 @@
+<?xml version="1.0"  encoding="utf-8" ?>
+<TrbNet xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+        xsi:noNamespaceSchemaLocation="TrbNet.xsd"
+        name="JtagController"
+        address="a000"
+        >
+  <!--===========================================-->
+  <!-- Common TDC control registers             -->
+  <!--===========================================-->
+  <group name="JtagCommonControl"
+         address="1000"  size="37"  function="config"  mode="rw"  continuous="true">
+    <register name="WaitBeforeStart"
+              address="0007" mode="rw" function ="config" >
+      <description>Wait time between write sequence and start signal.</description>
+      <field name="WaitBeforeStart"
+             start="0"   size="20"  mode="rw"  type="config"  format="integer"  defaultValue="0" >
+        <description>The number of MAPS clock cycles to wait after last write before sending the start signal. </description>
+      </field>
+    </register>
+    <register name="TriggerInitSeq"
+              address="000c" mode="w" function ="trigger" >
+      <description>Trigger the init sequence.</description>
+      <field name="TriggerInitSeq"
+             start="0"   size="5"  mode="w"  type="trigger"  format="bitmask"  defaultValue="0" >
+        <description>A bitmask to trigger the init sequence on individual JTAG chains. </description>
+      </field>
+    </register>
+    <register name="TriggerReset"
+              address="000d" mode="w" function ="trigger" >
+      <description>Trigger the init sequence.</description>
+      <field name="TriggerReset"
+             start="0"   size="5"  mode="w"  type="trigger"  format="bitmask"  defaultValue="0" >
+        <description>A bitmask to trigger sending a reset pulse on individual JTAG chains </description>
+      </field>
+    </register>
+    <register name="TriggerStart"
+              address="000e" mode="w" function ="trigger" >
+      <description>Trigger sending a start pulse.</description>
+      <field name="TriggerStart"
+             start="0"   size="5"  mode="w"  type="trigger"  format="bitmask"  defaultValue="0" >
+        <description>A bitmask to trigger sending a start pulse on individual JTAG chains </description>
+      </field>
+    </register>
+    <register name="TriggerJtagRun"
+              address="000f" mode="w" function ="trigger" >
+      <description>Trigger running JTAG write.</description>
+      <field name="TriggerJtagRun"
+             start="0"   size="5"  mode="w"  type="trigger"  format="bitmask"  defaultValue="0" >
+        <description>A bitmask to trigger writing the JTAG registers three times on individual JTAG chains </description>
+      </field>
+    </register>
+    <register name="ResetBeforeInit"
+              address="0010" mode="rw" function="config" >
+      <description>Generate a reset before doing init sequence</description>
+      <field name="ResetBeforeInit"
+             start="0"   size="1"  mode="rw"  type="config"  format="boolean"  defaultValue="0" >
+        <description>Enable to send a reset pulse before starting init sequence</description>
+      </field>
+    </register>
+    <register name="ResetAfterFirstWrite"
+              address="0011" mode="rw" function="config" >
+      <description>Generate a reset after first register write sequence</description>
+      <field name="ResetAfterFirstWrite"
+             start="0"   size="1"  mode="rw"  type="config"  format="boolean"  defaultValue="0" >
+        <description>Enable to send a reset pulse after the first writing of JTAG registers</description>
+      </field>
+    </register>
+    <register name="TriggerWriteOnce"
+              address="0014" mode="w" function ="trigger" >
+      <description>Trigger writing all JTAG registers once</description>
+      <field name="TriggerWriteOnce"
+             start="0"   size="5"  mode="w"  type="trigger"  format="bitmask"  defaultValue="0" >
+        <description>Trigger writing all JTAG registers once on individual JTAG chains</description>
+      </field>
+    </register>
+    <group name="JtagOverride"
+           address="0020"  size="5"  function="config"  mode="rw"  continuous="true">
+      <description>Sets fixed values for all outputs for JTAG and sensor control and inverts the outputs if needed. One register for each JTAG chain.</description>
+      <register name="JtagOverride"
+                address="0020"  repeat="5" function="config" mode="rw" >
+        <description>Sets fixed values for all outputs for JTAG and sensor control and inverts the outputs if needed. One register for each JTAG chain.</description>
+        <field name="InvertTDO"
+               start="0"   size="1"  mode="rw"  type="config"  format="boolean"  defaultValue="0" >
+          <description>Invert TDO input signal</description>
+        </field>      
+        <field name="InvertTDI"
+               start="2"   size="1"  mode="rw"  type="config"  format="boolean"  defaultValue="0" >
+          <description>Invert TDI output signal</description>
+        </field>
+        <field name="InvertTMS"
+               start="4"   size="1"  mode="rw"  type="config"  format="boolean"  defaultValue="0" >
+          <description>Invert TMS output signal</description>
+        </field>
+        <field name="InvertTCK"
+               start="6"   size="1"  mode="rw"  type="config"  format="boolean"  defaultValue="0" >
+          <description>Invert TCK output signal</description>
+        </field>
+        <field name="InvertStart"
+               start="8"   size="1"  mode="rw"  type="config"  format="boolean"  defaultValue="0" >
+          <description>Invert Start output signal</description>
+        </field>
+        <field name="InvertReset"
+               start="10"   size="1"  mode="rw"  type="config"  format="boolean"  defaultValue="0" >
+          <description>Invert Reset output signal</description>
+        </field>
+        <field name="InvertClock"
+               start="12"   size="1"  mode="rw"  type="config"  format="boolean"  defaultValue="0" >
+          <description>Invert Clock output signal</description>
+        </field>
+        <field name="EnableTDO"
+               start="1"   size="1"  mode="rw"  type="config"  format="boolean"  defaultValue="0" >
+          <description>Enable TDO input signal</description>
+        </field>      
+        <field name="EnableTDI"
+               start="3"   size="1"  mode="rw"  type="config"  format="boolean"  defaultValue="0" >
+          <description>Enable TDI output signal</description>
+        </field>
+        <field name="EnableTMS"
+               start="5"   size="1"  mode="rw"  type="config"  format="boolean"  defaultValue="0" >
+          <description>Enable TMS output signal</description>
+        </field>
+        <field name="EnableTCK"
+               start="7"   size="1"  mode="rw"  type="config"  format="boolean"  defaultValue="0" >
+          <description>Enable TCK output signal</description>
+        </field>
+        <field name="EnableStart"
+               start="9"   size="1"  mode="rw"  type="config"  format="boolean"  defaultValue="0" >
+          <description>Enable Start output signal</description>
+        </field>
+        <field name="EnableReset"
+               start="11"   size="1"  mode="rw"  type="config"  format="boolean"  defaultValue="0" >
+          <description>Enable Reset output signal</description>
+        </field>
+        <field name="EnableClock"
+               start="13"   size="1"  mode="rw"  type="config"  format="boolean"  defaultValue="0" >
+          <description>Enable Clock output signal</description>
+        </field>
+      </register>
+    </group>
+  </group>
+  <!--===========================================-->
+  <!--JTAG Status registers for each chain       -->
+  <!--===========================================-->
+  <group name="JtagStatus"
+         address="1800"  size="40"  function="status"  mode="r"  continuous="true">
+    <group name="JtagStatusChain"
+           address="0000"  size="8"  repeat="5"  function="status"  mode="r"  continuous="true">
+      <register  name="JtagErrorCount1"
+                address="0002" function="status" mode="r" >
+        <field name="ErrorsReadId"
+               start="0"   size="16"  mode="r"  type="status"  format="integer" >
+          <description>Number of read errors during "read id" operation</description>
+        </field>
+        <field name="ErrorsWrite"
+               start="16"   size="16"  mode="r"  type="status"  format="integer" >
+          <description>Number of read errors during write operation</description>
+        </field>
+      </register>
+      <register  name="JtagErrorCount2"
+                address="0003" function="status" mode="r" >
+        <field name="ErrorsDataChanged"
+               start="0"   size="16"  mode="r"  type="status"  format="integer" >
+          <description>Number of times data read back from the sensor was not identical to the data written to the sensor.</description>
+        </field>
+        <field name="ErrorsSampling"
+               start="16"   size="16"  mode="r"  type="status"  format="integer" >
+          <description>Number of sampling errors of TDI signal. The signal from the sensor is sampled three times for each bit, all occurrences must be equal.</description>
+        </field>
+      </register>
+      <register  name="JtagRunCounter"
+                address="0004" function="status" mode="r" >
+        <field name="JtagRunCounter"
+               start="0"   size="32"  mode="r"  type="status"  format="integer" >
+          <description>Number of times the JTAG controller run a full sequence</description>
+        </field>
+      </register>
+      <register  name="JtagStatusFlags"
+                address="0005" function="status" mode="r" >
+        <field name="JtagStarted"
+               start="0"   size="1"  mode="r"  type="status"  format="boolean" >
+          <description>JTAG has been started</description>
+        </field>
+        <field name="JtagLastSuccesful"
+               start="4"   size="1"  mode="r"  type="status"  format="boolean" >
+          <description>Last JTAG run was successful</description>
+        </field>
+        <field name="JtagLastDataChanged"
+               start="8"   size="1"  mode="r"  type="status"  format="boolean" >
+          <description>Data in the sensor was corrupted at last JTAG run</description>
+        </field>
+        <field name="JtagLastWriteError"
+               start="12"   size="1"  mode="r"  type="status"  format="boolean" >
+          <description>Last run had a JTAG write error</description>
+        </field>
+        <field name="JtagLastReadError"
+               start="16"   size="1"  mode="r"  type="status"  format="boolean" >
+          <description>Last run had a JTAG read error</description>
+        </field>
+        <field name="JtagCrcError"
+               start="20"   size="1"  mode="r"  type="status"  format="boolean" >
+          <description>Last run had a JTAG CRC error</description>
+        </field>
+      </register>
+    </group>
+  </group>
+</TrbNet>
+
index 183bf3437d59ef4d852e493e3f6b51a0fcf7afcd..1ab8a24818e55c0519298981839ee58473a9f672 100644 (file)
@@ -15,7 +15,7 @@
     <register
         name="WaitBeforeStart"
         address="0007"
-        mode="rww"
+        mode="rw"
         function ="config"
         >
       <description>Wait time between write sequence and start signal.</description>
index eb10576baf156d491b63e5756b589b464df90e7e..eaf808674b4a11f4d8e5c0bced786182b00bcf1a 100755 (executable)
@@ -5,11 +5,13 @@ use warnings;
 use XML::LibXML;
 use Getopt::Long;
 use Pod::Usage;
+use File::chdir;
 use FindBin qw($RealBin);
 use Data::Dumper;
 
 # some default config options
 # and provide nice help documentation
+# some global variables, needed everywhere
 
 my $man = 0;
 my $help = 0;
@@ -24,13 +26,56 @@ GetOptions(
 pod2usage(1) if $help;
 pod2usage(-exitval => 0, -verbose => 2) if $man;
 
-print "Database: $db_dir\n" if $verbose;
+# tell something about the configuration
+if($verbose) {
+  print "Database directory: $db_dir\n";
+}
+
+# jump to subroutine which handles the job,
+# depending on the options
+&main;
+
+sub main {
+  # load the unmerged database
+  my $db = &LoadDB;
+}
+
+sub LoadDB {
+  # change to he db_dir here in this subroutine
+  local $CWD = $db_dir;
+
+  # we first load the schemas and parse them
+  # so we can validate the XML files
+  my %schemas = ();
+  while(<*.xsd>) {
+    $schemas{$_} = XML::LibXML::Schema->new(location => $_);
+    print "Loaded schema $_\n" if $verbose;
+  }
+
+  # load the xml files
+  my $parser = XML::LibXML->new(line_numbers => 1);
+  my $db = {};
+  while(<*.xml>) {
+    my $doc = $parser->parse_file($_);
+    my $xsd_file = $doc->getDocumentElement->getAttribute('xsi:noNamespaceSchemaLocation');
+    die "Schema $xsd_file not found to validate $_" unless defined $schemas{$xsd_file};
+    $schemas{$xsd_file}->validate($doc);
+    $db->{$_} = $doc;
+    print "Loaded and validated database file $_\n" if $verbose;
+  }
+  # $parser->parse_file("$db_dir/testing.xml");
+
+  # my $xmlschema = XML::LibXML::Schema->new('location' => "$db_dir/".
+  #                                          $doc->getDocumentElement->getAttribute('xsi:noNamespaceSchemaLocation'));
+
+  # 
+  return $db;
+}
+
+
+
 
-my $doc = XML::LibXML->new->parse_file("$db_dir/testing.xml");
-my $xmlschema = XML::LibXML::Schema->new('location' => "$db_dir/".
-                                         $doc->getDocumentElement->getAttribute('xsi:noNamespaceSchemaLocation'));
 
-$xmlschema->validate($doc);
 
 #print $xsd;
 
@@ -46,7 +91,7 @@ xml-db.pl - Access the TRB XML Database
 xml-db.pl [options] [config file]
 
  Options:
-   -h, --help     brief help message
+   -h, --help    brief help message
    --xml-db_dir  database directory
 
 =head1 OPTIONS