support multiple frequencies of interest with the EMANE 0.9.1 Universal Phy

(Boeing r1850)
This commit is contained in:
ahrenholz 2014-07-11 17:44:41 +00:00
parent 7905a26e4d
commit e6ff3b4cce
3 changed files with 47 additions and 1 deletions

View file

@ -15,7 +15,8 @@ from xml.dom.minidom import parseString, Document
from core.constants import *
from core.api import coreapi
from core.misc.ipaddr import MacAddr
from core.misc.xmlutils import addtextelementsfromtuples
from core.misc.utils import maketuplefromstr
from core.misc.xmlutils import addtextelementsfromtuples, addparamlisttoparent
from core.conf import ConfigurableManager, Configurable
from core.mobility import WirelessModel
from core.emane.nodes import EmaneNode
@ -940,6 +941,20 @@ class EmaneModel(WirelessModel):
warntxt = "EMANE model %s does not support link " % self._name
warntxt += "configuration, dropping Link Message"
self.session.warn(warntxt)
@staticmethod
def valuestrtoparamlist(dom, name, value):
''' Helper to convert a parameter to a paramlist.
Returns a an XML paramlist, or None if the value does not expand to
multiple values.
'''
try:
values = maketuplefromstr(value, str)
except SyntaxError:
return None
if len(values) < 2:
return None
return addparamlisttoparent(dom, parent=None, name=name, values=values)
class EmaneGlobalModel(EmaneModel):

View file

@ -126,10 +126,21 @@ class EmaneUniversalModel(EmaneModel):
# insert old options with their default values
for old in cls._confmatrix_ver074:
phy.appendChild(e.xmlparam(phydoc, old[0], old[2]))
frequencies = None
if e.version == e.EMANE091:
name = "frequencyofinterest"
value = mac.valueof(name, values)
frequencies = cls.valuestrtoparamlist(phydoc, name, value)
if frequencies:
phynames = list(phynames)
phynames.remove("frequencyofinterest")
# append all PHY options to phydoc
map( lambda n: phy.appendChild(e.xmlparam(phydoc, n, \
mac.valueof(n, values))), phynames)
if frequencies:
phy.appendChild(frequencies)
return phydoc

View file

@ -113,6 +113,26 @@ def addtextparamtoparent(dom, parent, name, value):
txt = dom.createTextNode(value)
p.appendChild(txt)
return p
def addparamlisttoparent(dom, parent, name, values):
''' XML helper to return a parameter list and optionally add it to the
parent element:
<paramlist name="name">
<item value="123">
<item value="456">
</paramlist>
'''
if values is None:
return None
p = dom.createElement("paramlist")
if parent:
parent.appendChild(p)
p.setAttribute("name", name)
for v in values:
item = dom.createElement("item")
item.setAttribute("value", str(v))
p.appendChild(item)
return p
def getoneelement(dom, name):
e = dom.getElementsByTagName(name)