## Read setup xml file
###############################
my @commands;
-my $boardsini;
+my $JtagCommands = {};
+my @CbCommands;
+
+my $boardsini = {};
+my $chainsini = {};
my $setupFile = $ARGV[0];
my $systemFile = $ARGV[1];
my $parser = XML::LibXML->new(line_numbers => 1);
my $name = $db->getDocumentElement->getAttribute('name');
print STDERR "Loading setup $name from file $setupFile\n" if $verbose;
-my @CbCommands;
foreach my $curctrl ($db->getDocumentElement->findnodes('controller')) {
my $ctrlname = $curctrl->getAttribute('name');
my $ctrlid = $curctrl->getAttribute('id');
my $ctrladdr = $curctrl->getAttribute('address');
print STDERR "Found controller $ctrlname id $ctrlid\n" if $verbose;
- $boardsini .= proto_boardsini($ctrlname,$ctrlid, $ctrladdr);
+
+ unless( defined( $JtagCommands->{$ctrladdr} ) ){
+ $JtagCommands->{$ctrladdr} = [];
+ }
+
+ $boardsini->{$ctrladdr}.= proto_boardsini($ctrlname,$ctrlid, $ctrladdr);
+
foreach my $curchain ($curctrl->findnodes('chain')) {
my $chainid = $curchain->getAttribute('id');
print STDERR " Found chain $chainname id $chainid \n" if $verbose;
my (@sname, @sfile, @senable);
- push(@commands,"./ui_writeram.pl -c $chainname");
+ push(@{$JtagCommands->{$ctrladdr}},"./ui_writeram.pl -c $chainname");
foreach my $cursensor ($curchain->findnodes('sensor')) {
my $sensid = $cursensor->getAttribute('id');
foreach my $cfg ($cursensor->findnodes('config')) {
print STDERR " Found config\n" if $verbose;
- push(@commands,"./ui.pl -b $ctrlname -o ".$cfg->textContent());
+ push(@{$JtagCommands->{$ctrladdr}},"./ui.pl -b $ctrlname -o ".$cfg->textContent());
}
}
foreach my $cfg ($curchain->findnodes('config')) {
print STDERR " Found config\n" if $verbose;
- push(@commands,"./ui.pl -b $ctrlname -c $chainname -o ".$cfg->textContent());
+ push(@{$JtagCommands->{$ctrladdr}},"./ui.pl -b $ctrlname -c $chainname -o ".$cfg->textContent());
}
- $chainsini .= proto_chainsini($chainname,$chainid,$ctrladdr,\@sname,\@sfile,\@senable);
+ $chainsini->{$ctrladdr} .= proto_chainsini($chainname,$chainid,$ctrladdr,\@sname,\@sfile,\@senable);
sensorini(\@sfile);
}
foreach my $cfg ($curctrl->findnodes('config')) {
print STDERR " Found config\n" if $verbose;
- push(@commands,"./ui.pl -b $ctrlname -o ".$cfg->textContent());
+ push(@{$JtagCommands->{$ctrladdr}},"./ui.pl -b $ctrlname -o ".$cfg->textContent());
}
- }
+ } # end of curctl loop
-###############################
-## Write ini files
-###############################
-my $boardsinifile = FileHandle->new($defaultIniPath."/boards.ini", 'w');
-print $boardsinifile $boardsini;
-$boardsinifile->close();
-
-my $chainsinifile = FileHandle->new($defaultIniPath."/chains.ini", 'w');
-print $chainsinifile $chainsini;
-$chainsinifile->close();
-###############################
-## Do whatever has to be done
-###############################
-
# configure Converter Boards
local $CWD = XMLDBPATH;
delete $ENV{'QUERY_STRING'}; # make sure put.pl is used in a command line and not in a web context
my $fieldname = $cmd->{name};
execute("./put.pl $entity $addr $fieldname $value");
}
+
+foreach my $ctrladdr (keys %$JtagCommands) {
-local $CWD = $ENV{'JTAGPATH'};
-foreach my $cmd (@commands) {
- execute($cmd);
- }
+ ###############################
+ ## Write ini files
+ ###############################
+ my $boardsinifile = FileHandle->new($defaultIniPath."/boards.ini", 'w');
+ print $boardsinifile $boardsini->{$ctrladdr};
+ $boardsinifile->close();
+
+ my $chainsinifile = FileHandle->new($defaultIniPath."/chains.ini", 'w');
+ print $chainsinifile $chainsini->{$ctrladdr};
+ $chainsinifile->close();
+
+
+ ###############################
+ ## execute programming commands
+ ###############################
+
+ local $CWD = $ENV{'JTAGPATH'};
+ foreach my $cmd (@{$JtagCommands->{$ctrladdr}}) {
+ execute($cmd);
+ }
+}