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

View file

@ -15,7 +15,7 @@ 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.utils import maketuplefromstr from core.misc.utils import maketuplefromstr, cmdresult
from core.misc.xmlutils import addtextelementsfromtuples, addparamlisttoparent 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
@ -45,7 +45,7 @@ class Emane(ConfigurableManager):
(SUCCESS, NOT_NEEDED, NOT_READY) = (0, 1, 2) (SUCCESS, NOT_NEEDED, NOT_READY) = (0, 1, 2)
EVENTCFGVAR = 'LIBEMANEEVENTSERVICECONFIG' EVENTCFGVAR = 'LIBEMANEEVENTSERVICECONFIG'
# possible self.version values # possible self.version values
(EMANE074, EMANE081, EMANE091) = (7, 8, 9) (EMANEUNK, EMANE074, EMANE081, EMANE091, EMANE092) = (0, 7, 8, 91, 92)
def __init__(self, session): def __init__(self, session):
ConfigurableManager.__init__(self, session) ConfigurableManager.__init__(self, session)
@ -62,27 +62,41 @@ class Emane(ConfigurableManager):
8200) 8200)
self.doeventloop = False self.doeventloop = False
self.eventmonthread = None self.eventmonthread = None
# detect between EMANE versions 0.7.4, 0.8.1, and 0.9.1+ self.detectversion()
# 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
# model for global EMANE configuration options # model for global EMANE configuration options
self.emane_config = EmaneGlobalModel(session, None, self.verbose) self.emane_config = EmaneGlobalModel(session, None, self.verbose)
session.broker.handlers += (self.handledistributed, ) session.broker.handlers += (self.handledistributed, )
self.loadmodels() self.loadmodels()
self.initeventservice() 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): def initeventservice(self, filename=None):
''' (Re-)initialize the EMANE Event service. The multicast group and/or ''' (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 port may be configured, and can be changed via XML config file and an
@ -92,7 +106,7 @@ class Emane(ConfigurableManager):
del self.service del self.service
self.service = None self.service = None
# EMANE 0.9.1+ does not require event service XML config # 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", values = self.getconfig(None, "emane",
self.emane_config.getdefaultvalues())[1] self.emane_config.getdefaultvalues())[1]
group, port = self.emane_config.valueof('eventservicegroup', group, port = self.emane_config.valueof('eventservicegroup',
@ -460,7 +474,7 @@ class Emane(ConfigurableManager):
doc = self.xmldoc("platform") doc = self.xmldoc("platform")
plat = doc.getElementsByTagName("platform").pop() plat = doc.getElementsByTagName("platform").pop()
platformid = self.emane_config.valueof("platform_id_start", values) 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("name", "Platform %s" % platformid)
plat.setAttribute("id", platformid) plat.setAttribute("id", platformid)
@ -481,6 +495,7 @@ class Emane(ConfigurableManager):
# set ID, endpoints here # set ID, endpoints here
nementry = nems[netif] nementry = nems[netif]
nementry.setAttribute("id", "%d" % nemid) nementry.setAttribute("id", "%d" % nemid)
if self.version < self.EMANE092:
# insert nem options (except nem id) to doc # insert nem options (except nem id) to doc
trans_addr = self.emane_config.valueof("transportendpoint", \ trans_addr = self.emane_config.valueof("transportendpoint", \
values) values)
@ -693,7 +708,7 @@ class Emane(ConfigurableManager):
# reset the service, otherwise nextEvent won't work # reset the service, otherwise nextEvent won't work
self.initeventservice() self.initeventservice()
if self.eventmonthread is not None: if self.eventmonthread is not None:
if self.version == self.EMANE091: if self.version >= self.EMANE091:
self.eventmonthread._Thread__stop() self.eventmonthread._Thread__stop()
self.eventmonthread.join() self.eventmonthread.join()
self.eventmonthread = None self.eventmonthread = None
@ -706,7 +721,7 @@ class Emane(ConfigurableManager):
self.info("Subscribing to EMANE location events (not generating them). " \ self.info("Subscribing to EMANE location events (not generating them). " \
"(%s) " % threading.currentThread().getName()) "(%s) " % threading.currentThread().getName())
while self.doeventloop is True: while self.doeventloop is True:
if self.version == self.EMANE091: if self.version >= self.EMANE091:
(uuid, seq, events) = self.service.nextEvent() (uuid, seq, events) = self.service.nextEvent()
if not self.doeventloop: if not self.doeventloop:
break # this occurs with 0.9.1 event service 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)" self.info("setnemposition %s (%s) x,y,z=(%d,%d,%s)"
"(%.6f,%.6f,%.6f)" % \ "(%.6f,%.6f,%.6f)" % \
(ifname, nemid, x, y, z, lat, long, alt)) (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() event = LocationEvent()
else: else:
event = emaneeventlocation.EventLocation(1) event = emaneeventlocation.EventLocation(1)
# altitude must be an integer or warning is printed # altitude must be an integer or warning is printed
# unused: yaw, pitch, roll, azimuth, elevation, velocity # unused: yaw, pitch, roll, azimuth, elevation, velocity
alt = int(round(alt)) 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) event.append(nemid, latitude=lat, longitude=long, altitude=alt)
self.session.emane.service.publish(0, event) self.session.emane.service.publish(0, event)
else: else:
@ -279,7 +279,7 @@ class EmaneNode(EmaneNet):
self.info("position service not available") self.info("position service not available")
return return
if self.session.emane.version == self.session.emane.EMANE091: if self.session.emane.version >= self.session.emane.EMANE091:
event = LocationEvent() event = LocationEvent()
else: else:
event = emaneeventlocation.EventLocation(len(moved_netifs)) event = emaneeventlocation.EventLocation(len(moved_netifs))
@ -298,13 +298,13 @@ class EmaneNode(EmaneNet):
(i, ifname, nemid, x, y, z, lat, long, alt)) (i, ifname, nemid, x, y, z, lat, long, alt))
# altitude must be an integer or warning is printed # altitude must be an integer or warning is printed
alt = int(round(alt)) 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) event.append(nemid, latitude=lat, longitude=long, altitude=alt)
else: else:
event.set(i, nemid, lat, long, alt) event.set(i, nemid, lat, long, alt)
i += 1 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) self.session.emane.service.publish(0, event)
else: else:
self.session.emane.service.publish(emaneeventlocation.EVENT_ID, self.session.emane.service.publish(emaneeventlocation.EVENT_ID,

View file

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

View file

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