mirror of
https://gitlab.com/manzerbredes/esds.git
synced 2025-04-07 02:26:28 +02:00
Improve platform format
This commit is contained in:
parent
11966e96ee
commit
c73fc04ddb
2 changed files with 19 additions and 18 deletions
|
@ -70,6 +70,8 @@ class YAMLPlatformFile:
|
||||||
else:
|
else:
|
||||||
self.parsing_error("platform file has no interfaces section")
|
self.parsing_error("platform file has no interfaces section")
|
||||||
|
|
||||||
|
print(self.default)
|
||||||
|
|
||||||
def parsing_error(self,msg):
|
def parsing_error(self,msg):
|
||||||
raise Exception("Fail to parse platform file \""+self.file_path+"\": "+msg)
|
raise Exception("Fail to parse platform file \""+self.file_path+"\": "+msg)
|
||||||
|
|
||||||
|
@ -81,17 +83,11 @@ class YAMLPlatformFile:
|
||||||
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.range(words[3],self.default["node_count"])))
|
||||||
elif len(words) == 2:
|
self.parsing_error("Invalide link \""+link+"\"")
|
||||||
return((
|
|
||||||
range(0,self.default["node_count"]),
|
|
||||||
UnitsParser.bandwidth(words[0]),
|
|
||||||
UnitsParser.latency(words[1]),
|
|
||||||
range(0,self.default["node_count"])))
|
|
||||||
return(None)
|
|
||||||
|
|
||||||
def parse_txperf(self,txperf):
|
def parse_txperf(self,txperf):
|
||||||
elts=txperf.split()
|
elts=txperf.split()
|
||||||
return((UnitsParser.bandwidth(elts[0]),UnitsParser.latency(elts[1])))
|
return((UnitsParser.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"]
|
||||||
|
@ -116,11 +112,11 @@ class YAMLPlatformFile:
|
||||||
##### Set txperfs for wireless interfaces
|
##### Set txperfs for wireless interfaces
|
||||||
if not is_wired:
|
if not is_wired:
|
||||||
txperfs=interfaces[i]["txperfs"]
|
txperfs=interfaces[i]["txperfs"]
|
||||||
for node in range(0,node_count):
|
for txperf in txperfs:
|
||||||
txperf=txperfs[0] if len(txperfs) == 1 else txperfs[node]
|
p=self.parse_txperf(txperf)
|
||||||
bw,lat=self.parse_txperf(txperf)
|
for node in p[0]:
|
||||||
BW[node][node]=bw
|
BW[node][node]=p[1]
|
||||||
LAT[node][node]=lat
|
LAT[node][node]=p[2]
|
||||||
|
|
||||||
self.default["interfaces"][i]={
|
self.default["interfaces"][i]={
|
||||||
"is_wired": is_wired,
|
"is_wired": is_wired,
|
||||||
|
@ -137,13 +133,18 @@ class YAMLPlatformFile:
|
||||||
if "implementations" in nodes:
|
if "implementations" in nodes:
|
||||||
if type(nodes["implementations"]) != list:
|
if type(nodes["implementations"]) != list:
|
||||||
self.parsing_error("nodes implementations should be a list of file path")
|
self.parsing_error("nodes implementations should be a list of file path")
|
||||||
for file in nodes["implementations"]:
|
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"])
|
||||||
|
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")
|
||||||
path, extension = os.path.splitext(file)
|
path, extension = os.path.splitext(file)
|
||||||
if extension != ".py":
|
if extension != ".py":
|
||||||
self.parsing_error("File "+file+" must be a python file")
|
self.parsing_error("File "+file+" must be a python file")
|
||||||
self.default["implementations"].append(path)
|
for node in r:
|
||||||
|
self.default["implementations"][node]=file
|
||||||
count = len(nodes["implementations"])
|
count = len(nodes["implementations"])
|
||||||
if count > 1 and count != self.default["node_count"]:
|
if count > 1 and count != self.default["node_count"]:
|
||||||
self.parsing_error("If more than one implementation is specified, each node implementation should be provided ("+str(self.default["node_count"])+" in total)")
|
self.parsing_error("If more than one implementation is specified, each node implementation should be provided ("+str(self.default["node_count"])+" in total)")
|
||||||
|
|
|
@ -7,7 +7,7 @@ general:
|
||||||
nodes:
|
nodes:
|
||||||
count: 5
|
count: 5
|
||||||
implementations:
|
implementations:
|
||||||
- sender.py
|
- all sender.py
|
||||||
|
|
||||||
interfaces:
|
interfaces:
|
||||||
wlan0:
|
wlan0:
|
||||||
|
@ -15,7 +15,7 @@ interfaces:
|
||||||
links:
|
links:
|
||||||
- 0 1Bps 10s 0
|
- 0 1Bps 10s 0
|
||||||
txperfs:
|
txperfs:
|
||||||
- 1Bps 10s
|
- all 1Bps 10s
|
||||||
eth0:
|
eth0:
|
||||||
wireless: no
|
wireless: no
|
||||||
links: 5Mbps 10s
|
links: all 5Mbps 10s all
|
Loading…
Add table
Reference in a new issue