]> jspc29.x-matter.uni-frankfurt.de Git - mvdsensorcontrol.git/commitdiff
init_setup.pl from now on only uses one input argument, which is the setup file
authorMichael Wiebusch <m.wiebusch@gsi.de>
Fri, 15 May 2015 11:58:26 +0000 (13:58 +0200)
committerMichael Wiebusch <m.wiebusch@gsi.de>
Fri, 15 May 2015 11:58:26 +0000 (13:58 +0200)
tools/init_setup.pl

index 3ee6a7b6867beaa5bff34b1f509733996a6667cb..a5807b6a1d8d93d8b62486c26afca87e696d445b 100755 (executable)
@@ -53,6 +53,7 @@ pod2usage(-exitval => 0, -verbose => 2) if $man;
 my $defaultIniPath = JTAGCONFIGPATH;
 my $defaultXmlPath = CONFDIR;
 mkdir($defaultIniPath) unless (-e $defaultIniPath);
+my $systemDir = SYSTEMDIR;
 
   
 ###############################
@@ -65,12 +66,17 @@ my @CbCommands;
 my $boardsini = {};
 my $chainsini = {};
 my $setupFile = $ARGV[0];
-my $systemFile = $ARGV[1];
+my $systemFile = $ARGV[1];
 my $parser = XML::LibXML->new(line_numbers => 1);
 my $db = $parser->parse_file($setupFile);
+my $systemName = $db->findvalue("/setup/system/\@name");
+my $systemFile = $systemDir.$systemName.".xml";
+my $dbsys = $parser->parse_file($systemFile);
 my $name = $db->getDocumentElement->getAttribute('name');
+my $ccu = $dbsys->getDocumentElement->findnodes('ccu')->[0]->getAttribute('address');
 print STDERR "Loading setup $name from file $setupFile\n" if $verbose;
 
+execute("trbcmd clearbit 0x$ccu 0xa101 0x1");
 
 foreach my $curctrl ($db->getDocumentElement->findnodes('controller')) {
   my $ctrlname = $curctrl->getAttribute('name');
@@ -107,15 +113,15 @@ foreach my $curctrl ($db->getDocumentElement->findnodes('controller')) {
       # parse <CbConf> configuration and set settings in converter board
       my $CbConf = $cursensor->findnodes('CbConf')->shift();
       if (defined($CbConf)){
-       foreach my $attr ($CbConf->findnodes('@*')){
-#        print $ctrladdr." ".$attr->getName()." ".$attr->getValue()."\n";
-         push(@CbCommands,{
-           addr => "0x".$ctrladdr,
-           name => $attr->getName().".".sprintf("%d",$sensid),
-           # sensor id is used to addres the xml-db data slice
-           value => any2hex($attr->getValue())
-         }); 
-       }
+        foreach my $attr ($CbConf->findnodes('@*')){
+#           print $ctrladdr." ".$attr->getName()." ".$attr->getValue()."\n";
+          push(@CbCommands,{
+            addr => "0x".$ctrladdr,
+            name => $attr->getName().".".sprintf("%d",$sensid),
+            # sensor id is used to addres the xml-db data slice
+            value => any2hex($attr->getValue())
+          }); 
+        }
       }
 
       foreach my $cfg ($cursensor->findnodes('JtagConf')) {
@@ -127,15 +133,15 @@ foreach my $curctrl ($db->getDocumentElement->findnodes('controller')) {
       # parse <CbConf> configuration and set settings in converter board
       my $CbConf = $curchain->findnodes('CbConf')->shift();
       if (defined($CbConf)){
-       foreach my $attr ($CbConf->findnodes('@*')){
-#        print $ctrladdr." ".$attr->getName()." ".$attr->getValue()."\n";
-         push(@CbCommands,{
-           addr => "0x".$ctrladdr,
-           name => $attr->getName(),
-           # sensor id is used to addres the xml-db data slice
-           value => any2hex($attr->getValue())
-         }); 
-       }
+        foreach my $attr ($CbConf->findnodes('@*')){
+#           print $ctrladdr." ".$attr->getName()." ".$attr->getValue()."\n";
+          push(@CbCommands,{
+            addr => "0x".$ctrladdr,
+            name => $attr->getName(),
+            # sensor id is used to addres the xml-db data slice
+            value => any2hex($attr->getValue())
+          }); 
+        }
       }
       
       
@@ -191,7 +197,10 @@ foreach my $ctrladdr (keys %$JtagCommands) {
     execute($cmd);
     }
 }
-  
+execute("trbcmd w 0xfe4d 0xb00b 1"); #Enable start sensors on next reference time
+execute("trbcmd setbit 0x$ccu 0xa101 0x1");
+execute("trbcmd w 0xfe4d 0xb00b 1"); #Enable start sensors on next reference time
+