From 03877802afc7676af9b4daccd233eaa12612f2e8 Mon Sep 17 00:00:00 2001 From: Jan Michel Date: Tue, 9 Jul 2013 14:41:27 +0200 Subject: [PATCH] startup.pl creates commands for ui.pl --- setup/testsetup.xml | 14 ++++- tools/startup.pl | 130 +++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 132 insertions(+), 12 deletions(-) diff --git a/setup/testsetup.xml b/setup/testsetup.xml index 0121bd0..3040bd0 100644 --- a/setup/testsetup.xml +++ b/setup/testsetup.xml @@ -4,9 +4,10 @@ name="Prototype" > The main MVD prototype system setup file - - + + Dat einzige Ding dat mir habbe @@ -18,8 +19,15 @@ flippedy="false" phi="0" /> - + delay1 + prog_ram + set_timing_10mhz + set_inout + maps_reset_before_off + maps_reset_after_on + waitbeforestart_6us + trigger_init_sequence diff --git a/tools/startup.pl b/tools/startup.pl index 02792e0..d8451f4 100755 --- a/tools/startup.pl +++ b/tools/startup.pl @@ -2,20 +2,132 @@ use warnings; use File::chdir; +use XML::LibXML; +use Getopt::Long; +use Data::Dumper; +$Data::Dumper::Terse = 1; +$Data::Dumper::Useqq = 0; + +my ($help, $man, $verbose, $setup, $dryrun); +my $defaultIniPath = "/tmp/inifiles"; + + +############################### +## Get options +############################### +Getopt::Long::Configure(qw(gnu_getopt)); +GetOptions( + 'help|h' => \$help, + 'man' => \$man, + 'dryrun' => \$dryrun, + 'verbose|v+' => \$verbose, + ) or pod2usage(2); +pod2usage(1) if $help; +pod2usage(-exitval => 0, -verbose => 2) if $man; die "DAQOPSERVER not set in environment. Points to trbnetd that provides access to TRB.\n" unless (defined $ENV{'DAQOPSERVER'}); die "JTAGPATH not set in environment. Points to JTAG tools (e.g. ui.pl).\n" unless (defined $ENV{'JTAGPATH'}); -die "JTAGCONFIGPATH not set in environment. Points to JTAG config files (e.g. chains.ini).\n" unless (defined $ENV{'JTAGCONFIGPATH'}); +unless (defined $ENV{'JTAGCONFIGPATH'}) { + printf "JTAGCONFIGPATH not set in environment. Points to JTAG config files (e.g. chains.ini). Using default.\n" if $verbose; + $ENV{'JTAGCONFIGPATH'} = $defaultIniPath; + mkdir($defaultIniPath) unless (-e $defaultIniPath); + } + + +############################### +## Read setup xml file +############################### +my @commands; +my $parser = XML::LibXML->new(line_numbers => 1); +my $filename = $ARGV[0]; +my $db = $parser->parse_file($filename); +my $name = $db->getDocumentElement->getAttribute('name'); +print STDERR "Loading setup $name from file $filename\n" if $verbose; + +foreach my $curctrl ($db->getDocumentElement->findnodes('controller')) { + print STDERR "Found controller id ".$curctrl->getAttribute('id')."\n" if $verbose; + foreach my $curchain ($curctrl->findnodes('chain')) { + print STDERR " Found chain id ".$curchain->getAttribute('id')."\n" if $verbose; + foreach my $cursensor ($curchain->findnodes('sensor')) { + print STDERR " Found sensor id ".$cursensor->getAttribute('id')."\n" if $verbose; + foreach my $cfg ($cursensor->findnodes('config')) { + print STDERR " Found config\n"; + push(@commands,"./ui.pl -b ".$curctrl->getAttribute('name')." -o ".$cfg->textContent()); + } + } + foreach my $cfg ($curchain->findnodes('config')) { + print STDERR " Found config\n"; + push(@commands,"./ui.pl -b ".$curctrl->getAttribute('name')." -c ".$curchain->getAttribute("name")." -o ".$cfg->textContent()); + } + } + foreach my $cfg ($curctrl->findnodes('config')) { + print STDERR " Found config\n"; + push(@commands,"./ui.pl -b ".$curctrl->getAttribute('name')." -o ".$cfg->textContent()); + } + } + + +############################### +## Do whatever has to be done +############################### local $CWD = $ENV{'JTAGPATH'}; -qx(./ui.pl -b board01 -o waitbeforestart_6us); -qx(./ui.pl -b board01 -c newchain1 -o "delay1"); -qx(./ui.pl -b board01 -c newchain1 -o "prog_ram"); -qx(./ui.pl -b board01 -c newchain1 -o "set_timing_10mhz"); -qx(./ui.pl -b board01 -c newchain1 -o "set_inout"); -qx(./ui.pl -b board01 -c newchain1 -o "maps_reset_before_off"); -qx(./ui.pl -b board01 -c newchain1 -o "maps_reset_after_on"); -qx(./ui.pl -b board01 -o trigger_init_sequence); +foreach my $cmd (@commands) { + execute($cmd); + } + + + + +############################### +## Just another execute sub +############################### +sub execute { + my @o; + $o = qx($_[0]) unless $dryrun; + print "Not running> $_[0]\n" if $dryrun; + print Dumper @o if $verbose; + } + + + +print "\n"; + +=head1 NAME + +startup.pl - Run the necessary steps to configure and start MAPS sensors. + +=head1 SYNOPSIS + +startup.pl filename + + Options: + -h, --help brief help message + -v, --verbose be verbose to STDERR + -w, --warnings print warnings to STDERR + +=head1 OPTIONS + +=over 8 + +=item B<--help> + +Print a brief help message and exits. + +=item B<--verbose> + +Print some information what is going on. + +=item B<--dryrun> + +Do everything despite actually executing configuration scripts. + +=back + +=head1 DESCRIPTION + +B runs the necessary steps to configure and start MAPS sensors +=cut -- 2.43.0