2017-04-25 16:45:34 +01:00
|
|
|
"""
|
2013-08-29 15:21:13 +01:00
|
|
|
universal.py: EMANE Universal PHY model for CORE. Enumerates configuration items
|
|
|
|
used for the Universal PHY.
|
2017-04-25 16:45:34 +01:00
|
|
|
"""
|
|
|
|
|
|
|
|
from core import emane
|
|
|
|
from core.emane.emanemodel import EmaneModel
|
|
|
|
from core.enumerations import ConfigDataTypes
|
|
|
|
from core.misc import log
|
|
|
|
|
|
|
|
logger = log.get_logger(__name__)
|
2013-08-29 15:21:13 +01:00
|
|
|
|
2014-05-25 21:08:41 +01:00
|
|
|
try:
|
|
|
|
from emanesh.events import EventService
|
2017-04-25 16:45:34 +01:00
|
|
|
except ImportError:
|
|
|
|
logger.error("error importing emanesh")
|
|
|
|
|
2013-08-29 15:21:13 +01:00
|
|
|
|
|
|
|
class EmaneUniversalModel(EmaneModel):
|
2017-04-25 16:45:34 +01:00
|
|
|
"""
|
|
|
|
This Univeral PHY model is meant to be imported by other models,
|
|
|
|
not instantiated.
|
|
|
|
"""
|
|
|
|
|
|
|
|
def __init__(self, session, object_id=None):
|
|
|
|
raise NotImplemented("Cannot use this class directly")
|
2013-08-29 15:21:13 +01:00
|
|
|
|
2017-04-25 16:45:34 +01:00
|
|
|
name = "emane_universal"
|
2013-08-29 15:21:13 +01:00
|
|
|
_xmlname = "universalphy"
|
|
|
|
_xmllibrary = "universalphylayer"
|
|
|
|
|
|
|
|
# universal PHY parameters
|
2014-05-25 21:08:41 +01:00
|
|
|
_confmatrix_base = [
|
2017-04-25 16:45:34 +01:00
|
|
|
("bandwidth", ConfigDataTypes.UINT64.value, '1M',
|
|
|
|
'', 'rf bandwidth (hz)'),
|
|
|
|
("frequency", ConfigDataTypes.UINT64.value, '2.347G',
|
|
|
|
'', 'frequency (Hz)'),
|
|
|
|
("frequencyofinterest", ConfigDataTypes.UINT64.value, '2.347G',
|
|
|
|
'', 'frequency of interest (Hz)'),
|
|
|
|
("subid", ConfigDataTypes.UINT16.value, '1',
|
|
|
|
'', 'subid'),
|
|
|
|
("systemnoisefigure", ConfigDataTypes.FLOAT.value, '4.0',
|
|
|
|
'', 'system noise figure (dB)'),
|
|
|
|
("txpower", ConfigDataTypes.FLOAT.value, '0.0',
|
|
|
|
'', 'transmit power (dBm)'),
|
2014-05-25 21:08:41 +01:00
|
|
|
]
|
|
|
|
_confmatrix_081 = [
|
2017-04-25 16:45:34 +01:00
|
|
|
("antennagain", ConfigDataTypes.FLOAT.value, '0.0',
|
|
|
|
'', 'antenna gain (dBi)'),
|
|
|
|
("antennaazimuth", ConfigDataTypes.FLOAT.value, '0.0',
|
|
|
|
'', 'antenna azimuth (deg)'),
|
|
|
|
("antennaelevation", ConfigDataTypes.FLOAT.value, '0.0',
|
|
|
|
'', 'antenna elevation (deg)'),
|
|
|
|
("antennaprofileid", ConfigDataTypes.STRING.value, '1',
|
|
|
|
'', 'antenna profile ID'),
|
|
|
|
("antennaprofilemanifesturi", ConfigDataTypes.STRING.value, '',
|
|
|
|
'', 'antenna profile manifest URI'),
|
|
|
|
("antennaprofileenable", ConfigDataTypes.BOOL.value, '0',
|
|
|
|
'On,Off', 'antenna profile mode'),
|
|
|
|
("defaultconnectivitymode", ConfigDataTypes.BOOL.value, '1',
|
|
|
|
'On,Off', 'default connectivity'),
|
|
|
|
("frequencyofinterestfilterenable", ConfigDataTypes.BOOL.value, '1',
|
|
|
|
'On,Off', 'frequency of interest filter enable'),
|
|
|
|
("noiseprocessingmode", ConfigDataTypes.BOOL.value, '0',
|
|
|
|
'On,Off', 'enable noise processing'),
|
|
|
|
("pathlossmode", ConfigDataTypes.STRING.value, '2ray',
|
|
|
|
'pathloss,2ray,freespace', 'path loss mode'),
|
2014-05-25 21:08:41 +01:00
|
|
|
]
|
|
|
|
_confmatrix_091 = [
|
2017-04-25 16:45:34 +01:00
|
|
|
("fixedantennagain", ConfigDataTypes.FLOAT.value, '0.0',
|
|
|
|
'', 'antenna gain (dBi)'),
|
|
|
|
("fixedantennagainenable", ConfigDataTypes.BOOL.value, '1',
|
|
|
|
'On,Off', 'enable fixed antenna gain'),
|
|
|
|
("noisemode", ConfigDataTypes.STRING.value, 'none',
|
|
|
|
'none,all,outofband', 'noise processing mode'),
|
|
|
|
("noisebinsize", ConfigDataTypes.UINT64.value, '20',
|
|
|
|
'', 'noise bin size in microseconds'),
|
|
|
|
("propagationmodel", ConfigDataTypes.STRING.value, '2ray',
|
|
|
|
'precomputed,2ray,freespace', 'path loss mode'),
|
2014-05-25 21:08:41 +01:00
|
|
|
]
|
2017-04-25 16:45:34 +01:00
|
|
|
if emane.VERSION >= emane.EMANE091:
|
|
|
|
config_matrix = _confmatrix_base + _confmatrix_091
|
2014-05-25 21:08:41 +01:00
|
|
|
else:
|
2017-04-25 16:45:34 +01:00
|
|
|
config_matrix = _confmatrix_base + _confmatrix_081
|
2013-08-29 15:21:13 +01:00
|
|
|
|
|
|
|
# old parameters
|
|
|
|
_confmatrix_ver074 = [
|
2017-04-25 16:45:34 +01:00
|
|
|
("antennaazimuthbeamwidth", ConfigDataTypes.FLOAT.value, '360.0',
|
|
|
|
'', 'azimith beam width (deg)'),
|
|
|
|
("antennaelevationbeamwidth", ConfigDataTypes.FLOAT.value, '180.0',
|
|
|
|
'', 'elevation beam width (deg)'),
|
|
|
|
("antennatype", ConfigDataTypes.STRING.value, 'omnidirectional',
|
|
|
|
'omnidirectional,unidirectional', 'antenna type'),
|
|
|
|
]
|
2014-09-17 23:00:11 +01:00
|
|
|
|
2013-08-29 15:21:13 +01:00
|
|
|
# parameters that require unit conversion for 0.7.4
|
|
|
|
_update_ver074 = ("bandwidth", "frequency", "frequencyofinterest")
|
|
|
|
# parameters that should be removed for 0.7.4
|
|
|
|
_remove_ver074 = ("antennaprofileenable", "antennaprofileid",
|
|
|
|
"antennaprofilemanifesturi",
|
|
|
|
"frequencyofinterestfilterenable")
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def getphydoc(cls, e, mac, values, phynames):
|
|
|
|
phydoc = e.xmldoc("phy")
|
|
|
|
phy = phydoc.getElementsByTagName("phy").pop()
|
|
|
|
phy.setAttribute("name", cls._xmlname)
|
2017-04-25 16:45:34 +01:00
|
|
|
if emane.VERSION < emane.EMANE091:
|
2014-05-25 21:08:41 +01:00
|
|
|
phy.setAttribute("library", cls._xmllibrary)
|
2013-08-29 15:21:13 +01:00
|
|
|
# EMANE 0.7.4 suppport - to be removed when 0.7.4 support is deprecated
|
2017-04-25 16:45:34 +01:00
|
|
|
if emane.VERSION == emane.EMANE074:
|
2013-08-29 15:21:13 +01:00
|
|
|
names = mac.getnames()
|
|
|
|
values = list(values)
|
|
|
|
phynames = list(phynames)
|
|
|
|
# update units for some parameters
|
|
|
|
for p in cls._update_ver074:
|
|
|
|
i = names.index(p)
|
|
|
|
# these all happen to be KHz, so 1000 is used
|
|
|
|
values[i] = cls.emane074_fixup(values[i], 1000)
|
|
|
|
# remove new incompatible options
|
|
|
|
for p in cls._remove_ver074:
|
|
|
|
phynames.remove(p)
|
|
|
|
# insert old options with their default values
|
|
|
|
for old in cls._confmatrix_ver074:
|
|
|
|
phy.appendChild(e.xmlparam(phydoc, old[0], old[2]))
|
2014-07-11 18:44:41 +01:00
|
|
|
|
|
|
|
frequencies = None
|
2017-04-25 16:45:34 +01:00
|
|
|
if emane.VERSION >= emane.EMANE091:
|
2014-07-11 18:44:41 +01:00
|
|
|
name = "frequencyofinterest"
|
|
|
|
value = mac.valueof(name, values)
|
|
|
|
frequencies = cls.valuestrtoparamlist(phydoc, name, value)
|
|
|
|
if frequencies:
|
|
|
|
phynames = list(phynames)
|
|
|
|
phynames.remove("frequencyofinterest")
|
2014-09-18 16:50:09 +01:00
|
|
|
|
2013-08-29 15:21:13 +01:00
|
|
|
# append all PHY options to phydoc
|
2017-04-25 16:45:34 +01:00
|
|
|
map(lambda n: phy.appendChild(e.xmlparam(phydoc, n, mac.valueof(n, values))), phynames)
|
2014-07-11 18:44:41 +01:00
|
|
|
if frequencies:
|
|
|
|
phy.appendChild(frequencies)
|
2013-08-29 15:21:13 +01:00
|
|
|
return phydoc
|