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.constants import *
from core.api import coreapi from core.api import coreapi
from core.misc.ipaddr import MacAddr 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.conf import ConfigurableManager, Configurable
from core.mobility import WirelessModel from core.mobility import WirelessModel
from core.emane.nodes import EmaneNode from core.emane.nodes import EmaneNode
@ -941,6 +942,20 @@ class EmaneModel(WirelessModel):
warntxt += "configuration, dropping Link Message" warntxt += "configuration, dropping Link Message"
self.session.warn(warntxt) 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): class EmaneGlobalModel(EmaneModel):
''' Global EMANE configuration options. ''' Global EMANE configuration options.

View file

@ -127,9 +127,20 @@ class EmaneUniversalModel(EmaneModel):
for old in cls._confmatrix_ver074: for old in cls._confmatrix_ver074:
phy.appendChild(e.xmlparam(phydoc, old[0], old[2])) 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 # append all PHY options to phydoc
map( lambda n: phy.appendChild(e.xmlparam(phydoc, n, \ map( lambda n: phy.appendChild(e.xmlparam(phydoc, n, \
mac.valueof(n, values))), phynames) mac.valueof(n, values))), phynames)
if frequencies:
phy.appendChild(frequencies)
return phydoc return phydoc

View file

@ -114,6 +114,26 @@ def addtextparamtoparent(dom, parent, name, value):
p.appendChild(txt) p.appendChild(txt)
return p 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): def getoneelement(dom, name):
e = dom.getElementsByTagName(name) e = dom.getElementsByTagName(name)
if len(e) == 0: if len(e) == 0: