diff --git a/esds/helpers/platform.py b/esds/helpers/platform.py index b7e5637..e2f780d 100644 --- a/esds/helpers/platform.py +++ b/esds/helpers/platform.py @@ -3,7 +3,7 @@ import yaml, os import numpy as np class UnitsParser: - def range(r,limit): + def node_range(r,limit): if r == "all": return(range(0,limit)) r=r.replace("@",str(limit-1)) @@ -11,9 +11,9 @@ class UnitsParser: if len(elt) == 2: min = int(elt[0]) max = int(elt[1]) - if min < 0 or max > limit: + if min < 0 or max >= limit: raise Exception("Outside of range limit [0-"+str(limit)+"]") - return(range(min,max)) + return(range(min,max+1)) else: return(list(map(int, r.split(",")))) @@ -85,15 +85,15 @@ class YAMLPlatformFile: words=link.split() if len(words) == 4: return(( - UnitsParser.range(words[0],self.default["node_count"]), + UnitsParser.node_range(words[0],self.default["node_count"]), UnitsParser.bandwidth(words[1]), UnitsParser.latency(words[2]), - UnitsParser.range(words[3],self.default["node_count"]))) + UnitsParser.node_range(words[3],self.default["node_count"]))) self.parsing_error("Invalide link \""+link+"\"") def parse_txperf(self,txperf): elts=txperf.split() - return((UnitsParser.range(elts[0],self.default["node_count"]),UnitsParser.bandwidth(elts[1]),UnitsParser.latency(elts[2]))) + return((UnitsParser.node_range(elts[0],self.default["node_count"]),UnitsParser.bandwidth(elts[1]),UnitsParser.latency(elts[2]))) def parse_interfaces(self): interfaces=self.platform["interfaces"] @@ -124,6 +124,8 @@ class YAMLPlatformFile: for node in p[0]: BW[node][node]=p[1] LAT[node][node]=p[2] + if (BW.diagonal()==0).any(): + self.parsing_error("Not all node have a txpref on the wireless interface "+i) self.default["interfaces"][i]={ "is_wired": is_wired, @@ -145,7 +147,7 @@ class YAMLPlatformFile: self.default["implementations"]=[None]*self.default["node_count"] for impl in nodes["implementations"]: words=impl.split() - r=UnitsParser.range(words[0],self.default["node_count"]) + r=UnitsParser.node_range(words[0],self.default["node_count"]) file="".join(words[1:]) if not os.path.exists(file): self.parsing_error("File "+file+ " not found") diff --git a/example/platform.yaml b/example/platform.yaml index cf8c3f8..0e1c820 100644 --- a/example/platform.yaml +++ b/example/platform.yaml @@ -18,7 +18,7 @@ interfaces: links: - 0 1Bps 10s 0 txperfs: - - all 1Bps 10s + - 0-4 1Bps 10s eth0: type: "wired" links: