diff options
| author | Loic Guegan <manzerbredes@mailbox.org> | 2022-09-11 13:12:48 +0200 |
|---|---|---|
| committer | Loic Guegan <manzerbredes@mailbox.org> | 2022-09-11 13:12:48 +0200 |
| commit | d11a867b3ca46287b9b62356fc25836b7f19b757 (patch) | |
| tree | 33b1855e53fbff35990dc66a2b15de9a7f74d724 /esds | |
| parent | c3b03417f8bc659087edc85e68a1da0e937cd9d9 (diff) | |
Improve platform parsing
Diffstat (limited to 'esds')
| -rw-r--r-- | esds/helpers/platform.py | 16 |
1 files changed, 9 insertions, 7 deletions
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") |
