Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of https://github.com/mpoquet/simgrid
[simgrid.git] / examples / platforms / syscoord / generate_peer_platform.pl
index a866f87..9e4c6a3 100755 (executable)
@@ -9,31 +9,30 @@
 use strict;
 use warnings;
 
-my $toversion=4;
-my $nb_peer = $ARGV[0];
-my $i;
-
 print "<?xml version='1.0'?>\n";
 print "<!DOCTYPE platform SYSTEM \"http://simgrid.gforge.inria.fr/simgrid/simgrid.dtd\">\n";
-print "<platform version=\"$toversion\">\n";
+print "<platform version=\"4\">\n\n";
+
+print "<!-- This file was generated with the following command:\n          generate_peer_platform.pl $ARGV[0]\n-->\n\n";
 
-print "\n<config id=\"General\">\n";
-print "\t<prop id=\"coordinates\" value=\"yes\"></prop>\n";
-print "</config>\n\n";
+print "\t<config id=\"General\">\n";
+print "\t\t<prop id=\"coordinates\" value=\"yes\"></prop>\n";
+print "\t</config>\n\n";
 
 print "\t<AS id=\"AS0\" routing=\"Vivaldi\">\n";
 
 my $line;
 
-open SITES_LIGNE, $ARGV[0] or die "Unable to open $ARGV[1]\n";
-while(defined($line=<SITES_LIGNE>))
+open INPUT, $ARGV[0] or die "Unable to open $ARGV[1]: $!\n";
+while(defined($line=<INPUT>))
 {
-    #278 7.2 -9.4 h 2.3 
-    if($line =~ /^(.*) (.*) (.*) h (.*)$/)
-    {
-       print "\t\t<peer id=\"peer-$1\" coordinates=\"$2 $3 $4\" speed=\"730Mf\" ";
-       print "bw_in=\"13.38MBps\" bw_out=\"1.024MBps\" lat=\"500us\"/>\n";
+    next if ($line =~ /^#/);
+    # 278 7.2 -9.4 h 2.3 
+    if($line =~ /^(.*) (.*) (.*) h (.*)$/) {
+       print "\t\t<peer id=\"peer-$1\" coordinates=\"$2 $3 $4\" speed=\"730Mf\" bw_in=\"13.38MBps\" bw_out=\"1.024MBps\" lat=\"500us\"/>\n";
+       next;
     }
+    die "Parse error: $line\n";
 }                      
 print "\t</AS>\n";
 print "</platform>\n";