<?xml version="1.0" encoding="utf-8" ?>
<TrbNetEntity xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:noNamespaceSchemaLocation="TrbNetEntity.xsd"
+ xsi:noNamespaceSchemaLocation="../schema/TrbNetEntity.xsd"
name="CTS"
address="a000"
>
<?xml version="1.0" encoding="utf-8" ?>
<TrbNetEntity xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:noNamespaceSchemaLocation="TrbNetEntity.xsd"
+ xsi:noNamespaceSchemaLocation="../schema/TrbNetEntity.xsd"
name="Hub"
address="0000"
>
<?xml version="1.0" encoding="utf-8" ?>
<TrbNetEntity xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:noNamespaceSchemaLocation="TrbNetEntity.xsd"
+ xsi:noNamespaceSchemaLocation="../schema/TrbNetEntity.xsd"
name="JtagController"
address="a000"
>
<?xml version="1.0" encoding="utf-8" ?>
<TrbNetEntity xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:noNamespaceSchemaLocation="TrbNetEntity.xsd"
+ xsi:noNamespaceSchemaLocation="../schema/TrbNetEntity.xsd"
name="TrgRdo"
address="7000"
>
<?xml version="1.0" encoding="utf-8" ?>
<TrbNetEntity xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:noNamespaceSchemaLocation="TrbNetEntity.xsd"
+ xsi:noNamespaceSchemaLocation="../schema/TrbNetEntity.xsd"
name="TDC"
address="c000"
>
<?xml version="1.0" encoding="utf-8" ?>
<TrbNetEntity xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:noNamespaceSchemaLocation="TrbNetEntity.xsd"
+ xsi:noNamespaceSchemaLocation="../schema/TrbNetEntity.xsd"
name="TrbNet"
- address="7000"
+ address="0000"
>
<description>Common Registers on allmost all endpoints</description>
<!-- this is just a very minimal version -->
- <register name="IPUHandlerStatus" address="0202" purpose="status">
- <description>IPU handler status register</description>
- <field name="IPUHandlerStatusState" start="0" size="4" format="enum">
- <description>FSM state bits</description>
- <enumItem value="0">IDLE</enumItem>
- <enumItem value="1">WaitForLength</enumItem>
- <enumItem value="2">GotLength</enumItem>
- <enumItem value="3">SendDHDR</enumItem>
- <enumItem value="4">ReadData</enumItem>
- <enumItem value="5">EndReadout</enumItem>
+ <register name="CommonStatus0" address="0000" purpose="status">
+ <description>Common Status Register 0</description>
+ <field name="Temperature" start="20" size="12" format="integer" unit="°C" scale=".0625" >
+ <description>Board temperature</description>
</field>
</register>
--- /dev/null
+<?xml version="1.0" encoding="utf-8" ?>
+<TrbNetSetup xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:noNamespaceSchemaLocation="../schema/TrbNetSetup.xsd"
+ creator="Andreas Neiser"
+ date="2013-06-30T16:11:56"
+ version="0.1"
+ >
+ <!-- The order of the trb elements is respected and their content is
+ evaluated after each one (if they specify a value). This is important if the resulting
+ changes to the TrbNet must happen in a certain way. -->
+
+ <!-- also note the different uses of the address attribute:
+ sometimes it's a register address, sometimes a trbnet endpoint
+ address, or sometimes it specifies the chain number of the
+ external PaDiWa frontend -->
+
+
+ <!-- this specifies the trbaddress from uid's, it can be omitted if
+ the TrbNet is already set-up -->
+ <uidMap>
+ <uid address="0200" endpoint="0">5900000337e29728</uid>
+ <uid address="0201" endpoint="1">cf00000337e29e28</uid>
+ <uid address="0202" endpoint="2">ad00000338175028</uid>
+ <uid address="0203" endpoint="3">0e00000338174b28</uid>
+ <uid address="8000" endpoint="5">4400000338174628</uid>
+ </uidMap>
+
+ <!-- we configure the trb endpoint with address 0x8000 -->
+ <trb address="8000">
+ <broadcast address="fffe" />
+ <broadcast address="ff7f" />
+ <broadcast address="ff7e" />
+ <broadcast address="fe35" />
+
+ <entity ref="TrbNet" />
+
+ <!-- it has a TDC (at default register address) -->
+ <entity ref="TDC">
+ <!-- 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" to get a consistent entity model, but
+ how does one know that programmitcally??? -->
+ <register name="Channel" repeat="5" />
+ </entity>
+
+ <!-- and it has a CTS -->
+ <entity ref="CTS" />
+ </trb>
+
+
+ <trb address="0200">
+ <broadcast address="ff48" />
+
+ <!-- Standard TrbNet enpoint with standard 65ch TDC... -->
+ <entity ref="TrbNet" />
+ <entity ref="TDC" />
+ <!-- ...but also some "external" PaDiWa frontends connected at
+ chain 0 and 2. The fronend has some more registers which can
+ be accessed via SPI. The idea is that there's also a
+ PaDiWa.pm in the database which handles this access, usually
+ via conventional TrbNet registers
+ -->
+ <external ref="PaDiWa" address="0000" />
+ <external ref="PaDiWa" address="0002" />
+ </trb>
+
+
+ <!-- An example how to execute a setting. In general, the entities
+ are identified by their type and address (if specified) -->
+ <trb address="0200">
+ <broadcast address="ff48" />
+
+ <entity ref="TDC">
+ <!-- this field is a bitmask, so there's a converter to easily
+ set single bits -->
+ <field name="ChannelEnable">
+ 0-15 => 1, <!-- enables channels 0-15 -->
+ 34 => 1, <!-- enables channel 34 -->
+ </field>
+ </entity>
+ </trb>
+
+
+ <trb address="0200">
+ <broadcast address="ff48" />
+ <entity ref="TDC">
+ <!-- this field is a bitmask, so there's a converter to easily
+ set single bits -->
+ <field name="ReadoutFSM">
+ <enumItem value="0">Bla</enumItem>
+ 0-15 => 1, <!-- enables channels 0-15 -->
+ 34 => 5, <!-- enables channel 34 -->
+ </field>
+ </entity>
+ </trb>
+
+
+
+
+</TrbNetSetup>
+++ /dev/null
-<?xml version="1.0" encoding="utf-8" ?>
-<TrbNetSetup xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:noNamespaceSchemaLocation="TrbNetSetup.xsd"
- creator="Andreas Neiser"
- date="2013-06-30T16:11:56"
- version="0.1"
- >
- <!-- The order of the trb elements is respected and their content is
- evaluated after each one (if they specify a value). This is important if the resulting
- changes to the TrbNet must happen in a certain way. -->
-
- <!-- also note the different uses of the address attribute:
- sometimes it's a register address, sometimes a trbnet endpoint
- address, or sometimes it specifies the chain number of the
- external PaDiWa frontend -->
-
-
- <!-- this specifies the trbaddress from uid's, it can be omitted if
- the TrbNet is already set-up -->
- <uidMap>
- <uid address="0200" endpoint="0">5900000337e29728</uid>
- <uid address="0201" endpoint="1">cf00000337e29e28</uid>
- <uid address="0202" endpoint="2">ad00000338175028</uid>
- <uid address="0203" endpoint="3">0e00000338174b28</uid>
- <uid address="8000" endpoint="5">4400000338174628</uid>
- </uidMap>
-
- <!-- we configure the trb endpoint with address 0x8000 -->
- <trb address="8000">
- <broadcast address="fffe" />
- <broadcast address="ff7f" />
- <broadcast address="ff7e" />
- <broadcast address="fe35" />
-
- <entity ref="TrbNet" />
-
- <!-- it has a TDC (at default register address) -->
- <entity ref="TDC">
- <!-- 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" to get a consistent entity model, but
- how does one know that programmitcally??? -->
- <register name="Channel" repeat="5" />
- </entity>
-
- <!-- and it has a CTS -->
- <entity ref="CTS" />
- </trb>
-
-
- <trb address="0200">
- <broadcast address="ff48" />
-
- <!-- Standard TrbNet enpoint with standard 65ch TDC... -->
- <entity ref="TrbNet" />
- <entity ref="TDC" />
- <!-- ...but also some "external" PaDiWa frontends connected at
- chain 0 and 2. The fronend has some more registers which can
- be accessed via SPI. The idea is that there's also a
- PaDiWa.pm in the database which handles this access, usually
- via conventional TrbNet registers
- -->
- <external ref="PaDiWa" address="0000" />
- <external ref="PaDiWa" address="0002" />
- </trb>
-
-
- <!-- An example how to execute a setting. In general, the entities
- are identified by their type and address (if specified) -->
- <trb address="0200">
- <broadcast address="ff48" />
-
- <entity ref="TDC">
- <!-- this field is a bitmask, so there's a converter to easily
- set single bits -->
- <field name="ChannelEnable">
- 0-15 => 1, <!-- enables channels 0-15 -->
- 34 => 1, <!-- enables channel 34 -->
- </field>
- </entity>
- </trb>
-
-
- <trb address="0200">
- <broadcast address="ff48" />
- <entity ref="TDC">
- <!-- this field is a bitmask, so there's a converter to easily
- set single bits -->
- <field name="ReadoutFSM">
- <enumItem value="0">Bla</enumItem>
- 0-15 => 1, <!-- enables channels 0-15 -->
- 34 => 5, <!-- enables channel 34 -->
- </field>
- </entity>
- </trb>
-
-
-
-
-</TrbNetSetup>
--- /dev/null
+setup/trb-setup-default.xml
\ No newline at end of file
my $verbose = 0;
my $warnings = 1;
my $db_dir = "$RealBin/database";
+my $schema_dir = "$RealBin/schema";
my $dump_database = 0;
Getopt::Long::Configure(qw(gnu_getopt));
'verbose|v+' => \$verbose,
'warnings|w!' => \$warnings,
'db-dir=s' => \$db_dir,
+ 'schema-dir=s' => \$schema_dir,
'dump' => \$dump_database
) or pod2usage(2);
pod2usage(1) if $help;
# tell something about the configuration
if ($verbose) {
print STDERR "Database directory: $db_dir\n";
+ print STDERR "Schema directory: $schema_dir\n";
# always enable warnings if verbose
$warnings = 1;
}
my $parser = XML::LibXML->new(line_numbers => 1);
{
- # change to the db_dir in the first part
- local $CWD = $db_dir;
+ # change to the schema_dir in the first part
+ local $CWD = $schema_dir;
# we first load the schemas and parse them
}
# load the xml files in the database
+ # change to the db_dir in the first part
+ local $CWD = $db_dir;
while (<*.xml>) {
my $doc = $parser->parse_file($_);
my $schema = ValidateXML($doc, $schemas);
my $doc = shift;
my $schemas = shift;
my $xsd_file = $doc->getDocumentElement->getAttribute('xsi:noNamespaceSchemaLocation');
+ ($xsd_file) = $xsd_file =~ m%.*/([^/]*)$%;
die "Schema $xsd_file not found to validate <$_>" unless defined $schemas->{$xsd_file};
$schemas->{$xsd_file}->validate($doc);
return $schemas->{$xsd_file};