initial XML changes for EMANE 0.9.2

for version detection, use 'emane --version' output instead of other tricks
(Boeing r1880)
This commit is contained in:
ahrenholz 2014-09-18 15:50:09 +00:00
parent 3ca4cecd0b
commit 24263d77bd
5 changed files with 62 additions and 47 deletions

View file

@ -103,7 +103,7 @@ class EmaneCommEffectModel(EmaneModel):
''' Generate CommEffect events when a Link Message is received having
link parameters.
'''
if self.session.emane.version == self.session.emane.EMANE091:
if self.session.emane.version >= self.session.emane.EMANE091:
raise NotImplementedError, \
"CommEffect linkconfig() not implemented for EMANE 0.9.1+"
def z(x):

View file

@ -15,7 +15,7 @@ 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.utils import maketuplefromstr
from core.misc.utils import maketuplefromstr, cmdresult
from core.misc.xmlutils import addtextelementsfromtuples, addparamlisttoparent
from core.conf import ConfigurableManager, Configurable
from core.mobility import WirelessModel
@ -45,7 +45,7 @@ class Emane(ConfigurableManager):
(SUCCESS, NOT_NEEDED, NOT_READY) = (0, 1, 2)
EVENTCFGVAR = 'LIBEMANEEVENTSERVICECONFIG'
# possible self.version values
(EMANE074, EMANE081, EMANE091) = (7, 8, 9)
(EMANEUNK, EMANE074, EMANE081, EMANE091, EMANE092) = (0, 7, 8, 91, 92)
def __init__(self, session):
ConfigurableManager.__init__(self, session)
@ -62,27 +62,41 @@ class Emane(ConfigurableManager):
8200)
self.doeventloop = False
self.eventmonthread = None
# detect between EMANE versions 0.7.4, 0.8.1, and 0.9.1+
# to be removed as support for older EMANEs is deprecated
self.version = self.EMANE081
try:
tmp = emaneeventlocation.EventLocation(1)
# check if yaw parameter is supported by Location Events
# if so, we have EMANE 0.8.1; if not, we have EMANE 0.7.4/earlier
tmp.set(0, 1, 2, 2, 2, 3)
except TypeError:
self.version = self.EMANE074
except Exception:
# e.g. no Python bindings installed
pass
if 'EventService' in globals():
self.version = self.EMANE091
self.detectversion()
# model for global EMANE configuration options
self.emane_config = EmaneGlobalModel(session, None, self.verbose)
session.broker.handlers += (self.handledistributed, )
self.loadmodels()
self.initeventservice()
def detectversion(self):
''' Detects the installed EMANE version and sets self.version.
'''
self.version, self.versionstr = self.detectversionfromcmd()
if self.verbose:
self.info("detected EMANE version: %s" % self.versionstr)
def detectversionfromcmd(self):
''' Runs 'emane --version' locally to determine version number.
'''
# for further study: different EMANE versions on distributed machines
try:
status, result = cmdresult(['emane', '--version'])
except OSError:
status = -1
result = ""
v = self.EMANEUNK
if status == 0:
if result[:5] == "0.7.4":
v = self.EMANE074
elif result[:5] == "0.8.1":
v = self.EMANE081
elif result[:5] == "0.9.1":
v = self.EMANE091
elif result[:5] == "0.9.2":
v = self.EMANE092
return v, result.strip()
def initeventservice(self, filename=None):
''' (Re-)initialize the EMANE Event service. The multicast group and/or
port may be configured, and can be changed via XML config file and an
@ -92,7 +106,7 @@ class Emane(ConfigurableManager):
del self.service
self.service = None
# EMANE 0.9.1+ does not require event service XML config
if self.version == self.EMANE091:
if self.version >= self.EMANE091:
values = self.getconfig(None, "emane",
self.emane_config.getdefaultvalues())[1]
group, port = self.emane_config.valueof('eventservicegroup',
@ -460,7 +474,7 @@ class Emane(ConfigurableManager):
doc = self.xmldoc("platform")
plat = doc.getElementsByTagName("platform").pop()
platformid = self.emane_config.valueof("platform_id_start", values)
if self.version != self.EMANE091:
if self.version < self.EMANE091:
plat.setAttribute("name", "Platform %s" % platformid)
plat.setAttribute("id", platformid)
@ -481,17 +495,18 @@ class Emane(ConfigurableManager):
# set ID, endpoints here
nementry = nems[netif]
nementry.setAttribute("id", "%d" % nemid)
# insert nem options (except nem id) to doc
trans_addr = self.emane_config.valueof("transportendpoint", \
values)
nementry.insertBefore(self.xmlparam(doc, "transportendpoint", \
"%s:%d" % (trans_addr, self.transformport)),
nementry.firstChild)
platform_addr = self.emane_config.valueof("platformendpoint", \
values)
nementry.insertBefore(self.xmlparam(doc, "platformendpoint", \
"%s:%d" % (platform_addr, self.platformport)),
nementry.firstChild)
if self.version < self.EMANE092:
# insert nem options (except nem id) to doc
trans_addr = self.emane_config.valueof("transportendpoint", \
values)
nementry.insertBefore(self.xmlparam(doc, "transportendpoint", \
"%s:%d" % (trans_addr, self.transformport)),
nementry.firstChild)
platform_addr = self.emane_config.valueof("platformendpoint", \
values)
nementry.insertBefore(self.xmlparam(doc, "platformendpoint", \
"%s:%d" % (platform_addr, self.platformport)),
nementry.firstChild)
plat.appendChild(nementry)
emanenode.setnemid(netif, nemid)
# NOTE: MAC address set before here is incorrect, including the one
@ -693,7 +708,7 @@ class Emane(ConfigurableManager):
# reset the service, otherwise nextEvent won't work
self.initeventservice()
if self.eventmonthread is not None:
if self.version == self.EMANE091:
if self.version >= self.EMANE091:
self.eventmonthread._Thread__stop()
self.eventmonthread.join()
self.eventmonthread = None
@ -706,7 +721,7 @@ class Emane(ConfigurableManager):
self.info("Subscribing to EMANE location events (not generating them). " \
"(%s) " % threading.currentThread().getName())
while self.doeventloop is True:
if self.version == self.EMANE091:
if self.version >= self.EMANE091:
(uuid, seq, events) = self.service.nextEvent()
if not self.doeventloop:
break # this occurs with 0.9.1 event service

View file

@ -249,14 +249,14 @@ class EmaneNode(EmaneNet):
self.info("setnemposition %s (%s) x,y,z=(%d,%d,%s)"
"(%.6f,%.6f,%.6f)" % \
(ifname, nemid, x, y, z, lat, long, alt))
if self.session.emane.version == self.session.emane.EMANE091:
if self.session.emane.version >= self.session.emane.EMANE091:
event = LocationEvent()
else:
event = emaneeventlocation.EventLocation(1)
# altitude must be an integer or warning is printed
# unused: yaw, pitch, roll, azimuth, elevation, velocity
alt = int(round(alt))
if self.session.emane.version == self.session.emane.EMANE091:
if self.session.emane.version >= self.session.emane.EMANE091:
event.append(nemid, latitude=lat, longitude=long, altitude=alt)
self.session.emane.service.publish(0, event)
else:
@ -279,7 +279,7 @@ class EmaneNode(EmaneNet):
self.info("position service not available")
return
if self.session.emane.version == self.session.emane.EMANE091:
if self.session.emane.version >= self.session.emane.EMANE091:
event = LocationEvent()
else:
event = emaneeventlocation.EventLocation(len(moved_netifs))
@ -298,13 +298,13 @@ class EmaneNode(EmaneNet):
(i, ifname, nemid, x, y, z, lat, long, alt))
# altitude must be an integer or warning is printed
alt = int(round(alt))
if self.session.emane.version == self.session.emane.EMANE091:
if self.session.emane.version >= self.session.emane.EMANE091:
event.append(nemid, latitude=lat, longitude=long, altitude=alt)
else:
event.set(i, nemid, lat, long, alt)
i += 1
if self.session.emane.version == self.session.emane.EMANE091:
if self.session.emane.version >= self.session.emane.EMANE091:
self.session.emane.service.publish(0, event)
else:
self.session.emane.service.publish(emaneeventlocation.EVENT_ID,

View file

@ -102,7 +102,7 @@ class EmaneRfPipeModel(EmaneModel):
mac = macdoc.getElementsByTagName("mac").pop()
mac.setAttribute("name", "RF-PIPE MAC")
mac.setAttribute("library", "rfpipemaclayer")
if e.version != e.EMANE091 and \
if e.version < e.EMANE091 and \
self.valueof("transmissioncontrolmap", values) is "":
macnames.remove("transmissioncontrolmap")
# EMANE 0.7.4 support

View file

@ -108,7 +108,7 @@ class EmaneUniversalModel(EmaneModel):
phydoc = e.xmldoc("phy")
phy = phydoc.getElementsByTagName("phy").pop()
phy.setAttribute("name", cls._xmlname)
if e.version != e.EMANE091:
if e.version < e.EMANE091:
phy.setAttribute("library", cls._xmllibrary)
# EMANE 0.7.4 suppport - to be removed when 0.7.4 support is deprecated
if e.version == e.EMANE074:
@ -128,7 +128,7 @@ class EmaneUniversalModel(EmaneModel):
phy.appendChild(e.xmlparam(phydoc, old[0], old[2]))
frequencies = None
if e.version == e.EMANE091:
if e.version >= e.EMANE091:
name = "frequencyofinterest"
value = mac.valueof(name, values)
frequencies = cls.valuestrtoparamlist(phydoc, name, value)