Skip to content

Commit

Permalink
Fixed a bug with incorrect labeling in Castalia results file when com…
Browse files Browse the repository at this point in the history
…mand line configuration is used.
  • Loading branch information
yuritse committed Feb 22, 2011
1 parent 9698dfa commit c9ad61c
Showing 1 changed file with 36 additions and 2 deletions.
38 changes: 36 additions & 2 deletions Castalia/bin/Castalia
Original file line number Diff line number Diff line change
Expand Up @@ -166,22 +166,36 @@ tmpconfig = config
config = ""

while (tmpconfig != ""):
m = re.match(r"^([^=]*=)(\"[^\"]*\")(.*)$",tmpconfig)

# try to match a custom config of the form 'setParam="text"'
m = re.match(r"^([^=]*=)(\"[^\"]*\")(.*)$",tmpconfig)
if (m):
config += m.group(1)
config += str(len(customConfigList))
customConfigList.append(m.group(2))
tmpconfig = m.group(3)
continue

m = re.match(r"^([^=]*=)(\$\{[^\}]*\})(.*)$",tmpconfig)
# try to match a custom config of the form 'setParam=${name=val1,val2,val3}'
m = re.match(r"^([^=]*=)(\$\{[^=\}]+=[^\}]+\})(.*)$",tmpconfig)
if (m):
config += m.group(1)
config += str(len(customConfigList))
customConfigList.append(m.group(2))
tmpconfig = m.group(3)
continue

# try to match a custom config of the form 'setParam=${val1,val2,val3}'
m = re.match(r"^([^=]+=)\$\{([^=\}]+)\}(.*)$",tmpconfig)
if (m):
config += m.group(1)
config += str(len(customConfigList))
# transform ${val1,val2,val3} into ${name=val1,val2,val3}
customConfigList.append("${" + m.group(1).strip(',') + m.group(2) + "}")
tmpconfig = m.group(3)
continue

# try to match a custom config of the form 'setParam=val'
m = re.match(r"^([^=]*=)([^,\[]*)(.*)$",tmpconfig)
if (m):
config += m.group(1)
Expand All @@ -194,6 +208,8 @@ while (tmpconfig != ""):
if (m):
config += m.group(1)
tmpconfig = ""
else:
quit("\nERROR: Unexpected configuration syntax:\n" + tmpconfig)

while (config != ""):
m = re.match(r"^([^\[]*[^,\[]),?(.*)$",config)
Expand Down Expand Up @@ -249,6 +265,24 @@ else:
if c not in configIterations: tmpList2.append(c)
labelList.append(",".join(tmpList2))

for i in range(0,len(labelList)):
labels = labelList[i].split(",")
j = 0;
while j < len(labels):
if ('=' in labels[j]):
name,value = labels[j].split("=")
value = customConfigList[int(value)]
m = re.match("^\$\{(.+)\}$",value)
if (m): # this is a parameter study
# delete it from labels - omnet will make a label for it
del labels[j]
continue
else: # this is not a parameter study
# just substitute the right value
labels[j] = name + "=" + value
j += 1;
labelList[i] = ",".join(labels)

ini_num = 0
if options.output: fr = open(options.output,"w")
else: fr = open(datetime.now().strftime("%y%m%d-%H%M%S")+".txt","w")
Expand Down

0 comments on commit c9ad61c

Please sign in to comment.