]> jspc29.x-matter.uni-frankfurt.de Git - daqtools.git/commitdiff
Simple but documented xml-db.pl added, some file renaming and indenting
authorAndreas Neiser <neiser@kph.uni-mainz.de>
Thu, 27 Jun 2013 14:48:37 +0000 (16:48 +0200)
committerAndreas Neiser <neiser@kph.uni-mainz.de>
Thu, 27 Jun 2013 14:48:37 +0000 (16:48 +0200)
xml-db/database/TrbNet.xsd [moved from xml-db/database/TrbNetspec.xsd with 100% similarity]
xml-db/database/first-idea.xml [deleted file]
xml-db/database/jtag_registers_SPEC.xml [deleted file]
xml-db/database/testing.xml [new file with mode: 0644]
xml-db/xml-db.pl [new file with mode: 0755]

diff --git a/xml-db/database/first-idea.xml b/xml-db/database/first-idea.xml
deleted file mode 100644 (file)
index 71d0eab..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-<?xml version="1.0"?>
-<TrbNet 
-  type="JtagController"
-  offset="1000"
-  >
-<group 
-  name
-  addr
-  width
-  continuous="yes"
-  >  
-<register
-  name="TriggerAllchainsInitSeq"
-  address="0003"
-  mode="w"
-  type =""
-  >
-  <description>
-Start initialization sequence for all connected sensor chains    
-  </description>
-<field
-  type="configuration"
-  name="NU"
-  start="16"
-  size="4"
-  defaultValue="0" >
-  <description>Reserved, Not Used </description>
-</field>
-</register>
-</group>
-</TrbNet>
\ No newline at end of file
diff --git a/xml-db/database/jtag_registers_SPEC.xml b/xml-db/database/jtag_registers_SPEC.xml
deleted file mode 100644 (file)
index 7e55c93..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-<?xml version="1.0"  encoding="utf-8" ?>
-<TrbNet xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-xsi:noNamespaceSchemaLocation="TrbNetspec.xsd"
-  name="JtagController"
-  offset="1000"
-  >
-<group
-  name="JtagCommonControl"
-  address="0000"
-  size="21"
-  function="config"
-  continuous="true"
-  >
-
-  <register
-    name="WaitBeforeStart"
-    address="0007"
-    mode="rw"
-    function ="config"
-    >
-    <description>Wait time between write sequence and start signal.</description>
-    <field
-      type="config"
-      name="WaitBeforeStart"
-      start="0"
-      size="20"
-      defaultValue="0" >
-      <description>The number of MAPS clock cycles to wait after last write before sending the start signal. </description>
-    </field>
-  </register>
-</group>
-
-</TrbNet>
\ No newline at end of file
diff --git a/xml-db/database/testing.xml b/xml-db/database/testing.xml
new file mode 100644 (file)
index 0000000..2619fb8
--- /dev/null
@@ -0,0 +1,32 @@
+<?xml version="1.0"  encoding="utf-8" ?>
+<TrbNet xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+        xsi:noNamespaceSchemaLocation="TrbNet.xsd"
+        name="JtagController"
+        offset="1000"
+        >
+  <group
+      name="JtagCommonControl"
+      address="0000"
+      size="21"
+      function="config"
+      continuous="true"
+      >
+
+    <register
+        name="WaitBeforeStart"
+        address="0007"
+        mode="rw"
+        function ="config"
+        >
+      <description>Wait time between write sequence and start signal.</description>
+      <field
+          type="config"
+          name="WaitBeforeStart"
+          start="0"
+          size="20"
+          defaultValue="0" >
+        <description>The number of MAPS clock cycles to wait after last write before sending the start signal. </description>
+      </field>
+    </register>
+  </group>
+</TrbNet>
diff --git a/xml-db/xml-db.pl b/xml-db/xml-db.pl
new file mode 100755 (executable)
index 0000000..abc6cb3
--- /dev/null
@@ -0,0 +1,67 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+
+use XML::LibXML;
+use Getopt::Long;
+use Pod::Usage;
+use FindBin qw($RealBin);
+use Data::Dumper;
+
+# some default config options
+# and provide nice help documentation
+
+my $man = 0;
+my $help = 0;
+my $verbose = 0;
+my $db_dir = "$RealBin/database";
+
+GetOptions(
+           'help|h' => \$help,
+           'man' => \$man,
+           'verbose|v+' => \$verbose
+          ) or pod2usage(2);
+pod2usage(1) if $help;
+pod2usage(-exitval => 0, -verbose => 2) if $man;
+
+print "Database: $db_dir\n" if $verbose;
+
+my $doc = XML::LibXML->new->parse_file("$db_dir/testing.xml");
+my $xmlschema = XML::LibXML::Schema->new( location => "$db_dir/TrbNet.xsd" );
+
+$xmlschema->validate($doc);
+
+__END__
+
+=head1 NAME
+
+xml-db.pl - Access the TRB XML Database
+
+=head1 SYNOPSIS
+
+xml-db.pl [options] [config file]
+
+ Options:
+   -h, --help     brief help message
+   --xml-db_dir  database directory
+
+=head1 OPTIONS
+
+=over 8
+
+=item B<--help>
+
+Print a brief help message and exits.
+
+=item B<--db-dir>
+
+Set the database directory where the default XML files can be found.
+
+=back
+
+=head1 DESCRIPTION
+
+B<This program> provides basic access to the XML database describing
+the TRB registers.
+
+=cut