#use bignum qw/hex/;
require Common;
+require xmlOperations;
# TODO:
# decimal option?
+# set specDir and configDir as ENV variables?
# done:
# check if setting is identical with default value, if true ommit?
+our $confDir = '../config'; # default, gets overwritten anyway, maybe set them as ENV variables?
+our $specDir = '../specs';
+# separate configFileName and the containing directory path
+my @specFilePath = split("/",$specFile);
+my $specFileName = pop(@specFilePath);
+$specDir = join("/",@specFilePath);
+createConfigFile("dummy",$specFileName);
+# make available some variables from the xmlOperations module
+ my $configFile = getConfigFile(); # ="../conf/dummy" for this application
+ $specFile = getSpecFile(); # already there, but for completeness ...
+ my $configFileName = getConfigFileName(); #="dummy"
+ $specFileName = getSpecFileName(); # already there, but for completeness ...
+ my $configTree = getConfigTree(); # this we need!
+ my $specTree = getSpecTree(); # this we need, too!
+
+
+
+
+ my $configMaps = $configTree->findnodes("/MAPS")->shift();
+# obsolete stuff ... :D
-
-# initialize the xml parser
-my $parser = XML::LibXML->new();
-# read in the JTAG specification file
-print VERBOSE "parsing specifications file...\n";
-my $specTree = $parser->parse_file($specFile);
-
-
-# create a new tree document that will become the decoded config file
-my $configTree = XML::LibXML->createDocument;
-
-# create standard content
-
-$specFile =~ m/([^\/]+\.xml)$/;
-my $specFileName = $1;
-
-my $configMaps = $configTree->createElementNS( "", "MAPS" );
-$configTree->setDocumentElement($configMaps);
-
-my $specMaps = $specTree->findnodes("/MAPS")->shift();
-
-my $mapsType = $specMaps->findvalue("./\@type");
-
-$configMaps->setAttribute( "type", $mapsType );
-$configMaps->setAttribute( "specDbFile", $specFileName );
-
-# done doing standard content
+# # initialize the xml parser
+# my $parser = XML::LibXML->new();
+# # read in the JTAG specification file
+# print VERBOSE "parsing specifications file...\n";
+# my $specTree = $parser->parse_file($specFile);
+#
+#
+# # create a new tree document that will become the decoded config file
+# my $configTree = XML::LibXML->createDocument;
+#
+# # create standard content
+#
+# $specFile =~ m/([^\/]+\.xml)$/;
+# my $specFileName = $1;
+#
+# my $configMaps = $configTree->createElementNS( "", "MAPS" );
+# $configTree->setDocumentElement($configMaps);
+#
+# my $specMaps = $specTree->findnodes("/MAPS")->shift();
+#
+# my $mapsType = $specMaps->findvalue("./\@type");
+#
+# $configMaps->setAttribute( "type", $mapsType );
+# $configMaps->setAttribute( "specDbFile", $specFileName );
+#
+# # done doing standard content
-# sub register2hex {
-# # TODO
-# # try catch blocks?
-# # good work so far
-# my $register = $_[0];
-# my $registerName = $register->findvalue("./\@name");
-# my $registerId = $register->findvalue("./\@id");
-# my $registerSize = $register->findvalue("./\@size");
-# my $stringSize = ceil($registerSize/32)*8;
-#
-#
-# my $result = 0;
-#
-# my @fields = $register->findnodes("./field");
-#
-# for my $field (@fields){
-# my $name = $field->findvalue("./\@name");
-# my $start = $field->findvalue("./\@start");
-# my $end = $field->findvalue("./\@end");
-# my $size = $field->findvalue("./\@size");
-#
-# # check for setting in the settings file
-# my $value = $settree->findvalue("/MAPS/register[\@name='".$registerName."']/field[\@name='".$name."']/\@value");
-# if ($value ne "") {
-# #print "Setting found! $value\n";
-# } else { # if nothing found, then use the default value from the specFile
-# $value = $field->findvalue("./\@defaultValue");
-# #print "Use default setting: $value\n";
-# }
-#
-# $value = any2dec($value); # convert any numeric code to decimal
-# my $calcedsize = $end-$start+1;
-# if ( $calcedsize != $size) {
-# die "start/stop/size mismatch in register $registerName : field $name\n";
-# }
-# #print "$name: $start -> $end = $calcedsize/$size\n";
-# $result = $result | ($value<<$start);
-# #print "value: $value\n";
-# }
-# my $resultstring = sprintf("%0".$stringSize."X",$result);
-# print ";$registerName\n";
-# printf ("%02d=%s,%d,%s\n",$registerCounter,$registerId,$registerSize,$resultstring);
-#
-# }
-
-
-