mirror of
https://gitlab.com/manzerbredes/esds.git
synced 2025-04-07 02:26:28 +02:00
Improve platform parsing
This commit is contained in:
parent
c3b03417f8
commit
d11a867b3c
2 changed files with 10 additions and 8 deletions
|
@ -3,7 +3,7 @@ import yaml, os
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
class UnitsParser:
|
class UnitsParser:
|
||||||
def range(r,limit):
|
def node_range(r,limit):
|
||||||
if r == "all":
|
if r == "all":
|
||||||
return(range(0,limit))
|
return(range(0,limit))
|
||||||
r=r.replace("@",str(limit-1))
|
r=r.replace("@",str(limit-1))
|
||||||
|
@ -11,9 +11,9 @@ class UnitsParser:
|
||||||
if len(elt) == 2:
|
if len(elt) == 2:
|
||||||
min = int(elt[0])
|
min = int(elt[0])
|
||||||
max = int(elt[1])
|
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)+"]")
|
raise Exception("Outside of range limit [0-"+str(limit)+"]")
|
||||||
return(range(min,max))
|
return(range(min,max+1))
|
||||||
else:
|
else:
|
||||||
return(list(map(int, r.split(","))))
|
return(list(map(int, r.split(","))))
|
||||||
|
|
||||||
|
@ -85,15 +85,15 @@ class YAMLPlatformFile:
|
||||||
words=link.split()
|
words=link.split()
|
||||||
if len(words) == 4:
|
if len(words) == 4:
|
||||||
return((
|
return((
|
||||||
UnitsParser.range(words[0],self.default["node_count"]),
|
UnitsParser.node_range(words[0],self.default["node_count"]),
|
||||||
UnitsParser.bandwidth(words[1]),
|
UnitsParser.bandwidth(words[1]),
|
||||||
UnitsParser.latency(words[2]),
|
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+"\"")
|
self.parsing_error("Invalide link \""+link+"\"")
|
||||||
|
|
||||||
def parse_txperf(self,txperf):
|
def parse_txperf(self,txperf):
|
||||||
elts=txperf.split()
|
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):
|
def parse_interfaces(self):
|
||||||
interfaces=self.platform["interfaces"]
|
interfaces=self.platform["interfaces"]
|
||||||
|
@ -124,6 +124,8 @@ class YAMLPlatformFile:
|
||||||
for node in p[0]:
|
for node in p[0]:
|
||||||
BW[node][node]=p[1]
|
BW[node][node]=p[1]
|
||||||
LAT[node][node]=p[2]
|
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]={
|
self.default["interfaces"][i]={
|
||||||
"is_wired": is_wired,
|
"is_wired": is_wired,
|
||||||
|
@ -145,7 +147,7 @@ class YAMLPlatformFile:
|
||||||
self.default["implementations"]=[None]*self.default["node_count"]
|
self.default["implementations"]=[None]*self.default["node_count"]
|
||||||
for impl in nodes["implementations"]:
|
for impl in nodes["implementations"]:
|
||||||
words=impl.split()
|
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:])
|
file="".join(words[1:])
|
||||||
if not os.path.exists(file):
|
if not os.path.exists(file):
|
||||||
self.parsing_error("File "+file+ " not found")
|
self.parsing_error("File "+file+ " not found")
|
||||||
|
|
|
@ -18,7 +18,7 @@ interfaces:
|
||||||
links:
|
links:
|
||||||
- 0 1Bps 10s 0
|
- 0 1Bps 10s 0
|
||||||
txperfs:
|
txperfs:
|
||||||
- all 1Bps 10s
|
- 0-4 1Bps 10s
|
||||||
eth0:
|
eth0:
|
||||||
type: "wired"
|
type: "wired"
|
||||||
links:
|
links:
|
||||||
|
|
Loading…
Add table
Reference in a new issue