updates to remove restriction for emane in general and emane 1.2.1, should support at leat 1.0.1 possibly further back and can run without emane again, updated gui to ask users to install emane when not preset on the emane models panel

This commit is contained in:
Blake J. Harnden 2018-04-20 21:22:08 -07:00
parent 8ed7f7c0ef
commit ac2b64aaaf
5 changed files with 49 additions and 26 deletions

View file

@ -9,7 +9,10 @@ from core.emane import emanemodel
try:
from emane.events.commeffectevent import CommEffectEvent
except ImportError:
logger.info("emane 1.2.1 not found")
try:
from emanesh.events.commeffectevent import CommEffectEvent
except ImportError:
logger.warn("compatible emane python bindings not installed")
def convert_none(x):

View file

@ -34,7 +34,12 @@ try:
from emane.events import LocationEvent
from emane.events.eventserviceexception import EventServiceException
except ImportError:
logger.info("emane 1.2.1 not found")
try:
from emanesh.events import EventService
from emanesh.events import LocationEvent
from emanesh.events.eventserviceexception import EventServiceException
except ImportError:
logger.warn("compatible emane python bindings not installed")
EMANE_MODELS = [
EmaneRfPipeModel,
@ -76,7 +81,7 @@ class EmaneManager(ConfigurableManager):
self.transformport = self.session.get_config_item_int("emane_transform_port", 8200)
self.doeventloop = False
self.eventmonthread = None
self.logversion()
# model for global EMANE configuration options
self.emane_config = EmaneGlobalModel(session, None)
session.broker.handlers.add(self.handledistributed)
@ -86,24 +91,28 @@ class EmaneManager(ConfigurableManager):
self.emane_config.name: self.emane_config
}
# load provided models
self.load_models(EMANE_MODELS)
# load custom models
custom_models_path = session.config.get("emane_models_dir")
if custom_models_path:
emane_models = utils.load_classes(custom_models_path, EmaneModel)
self.load_models(emane_models)
self.service = None
self.emane_check()
def logversion(self):
def emane_check(self):
"""
Log the installed EMANE version.
Check if emane is installed and load models.
:return: nothing
"""
try:
# check for emane
emane_version = utils.check_cmd(["emane", "--version"])
logger.info("using EMANE: %s", emane_version)
# load default emane models
self.load_models(EMANE_MODELS)
# load custom models
custom_models_path = self.session.config.get("emane_models_dir")
if custom_models_path:
emane_models = utils.load_classes(custom_models_path, EmaneModel)
self.load_models(emane_models)
except CoreCommandError:
logger.info("emane is not installed")

View file

@ -1,10 +1,14 @@
from core import logger
from core.enumerations import ConfigDataTypes
manifest = None
try:
from emane.shell import manifest
except ImportError:
logger.info("emane 1.2.1 not found")
try:
from emanesh import manifest
except ImportError:
logger.warn("compatible emane python bindings not installed")
def _type_value(config_type):
@ -77,6 +81,10 @@ def parse(manifest_path, defaults):
:rtype: list
"""
# no results when emane bindings are not present
if not manifest:
return []
# load configuration file
manifest_file = manifest.Manifest(manifest_path)
manifest_configurations = manifest_file.getAllConfiguration()

View file

@ -15,7 +15,10 @@ from core.enumerations import RegisterTlvs
try:
from emane.events import LocationEvent
except ImportError:
logger.info("emane 1.2.1 not found")
try:
from emanesh.events import LocationEvent
except ImportError:
logger.warn("compatible emane python bindings not installed")
class EmaneNet(PyCoreNet):

View file

@ -68,7 +68,7 @@ proc findWlanNodes { peer } {
#
# Returns 1 if the given interface is wireless
proc isIfcWireless { node ifc } {
if { $ifc == "wireless" } {
if { $ifc == "wireless" } {
# wireless peudo-interface
return false
}
@ -102,7 +102,7 @@ proc clearWlanLinks { wlan } {
proc updateRangeCircles { wlan range } {
global .c zoom g_selected_model
set c .c
set radius [expr {$zoom * $range/2}]
$c delete -withtag rangecircles
if { $radius == 0 } {
@ -171,7 +171,7 @@ proc getWlanColor { wlan } {
if {[nodeType $node] != "wlan"} {
continue
}
if {$node == $wlan} {
if {$node == $wlan} {
return [lindex $wlanLinkColors $colornum]
}
incr colornum
@ -180,7 +180,7 @@ proc getWlanColor { wlan } {
# default color
return [lindex $wlanLinkColors 0]
}
# move a node given incremental coordinates
# dx dy should be adjusted for zoom
proc moveNodeIncr { c node dx dy } {
@ -389,7 +389,7 @@ proc wlanConfigDialogHelper { wi target apply } {
# use default model/values when none configured for this node
if { $mobmodel == "" } {
set mobmodel $DEFAULT_WLAN_MODEL
set mobmodel $DEFAULT_WLAN_MODEL
set vals $DEFAULT_WLAN_MODEL_VALS
# look for customized range/bw/jitter/delay/per
} else {
@ -473,7 +473,7 @@ proc wlanConfigDialogHelper { wi target apply } {
-side left -padx 4 -pady 4
pack $de -side top -anchor w -padx 4 -pady 4
# jitter frame
# jitter frame
set jt $wi.wl.note.basic.jt
ttk::frame $jt
ttk::label $jt.label1 -anchor w -text "Jitter (us):"
@ -528,7 +528,7 @@ proc wlanConfigDialogHelper { wi target apply } {
}
if { ! $have_emane_models } {
# show connection dialog box to indicate why there are no EMANE models
$mod.none configure -text "none - connection to CORE daemon required!" \
$mod.none configure -text "Please install EMANE" \
-width "45"
after 500 {
update ;# allow dialog layout, otherwise strange results
@ -608,16 +608,16 @@ proc wlanConfigDialogHelper { wi target apply } {
set cmd "linkSelectedNodes $target"
button $wi.bottom.memb -text "Choose WLAN members" \
-command "popupSelectNodes \"$msg\" \"\" {$cmd}"
# layout items
pack $wi.bottom.ipv4.addrl $wi.bottom.ipv4.addrv -side left
pack $wi.bottom.ipv4 -side top -anchor w
pack $wi.bottom.ipv6.addrl $wi.bottom.ipv6.addrv -side left
pack $wi.bottom.ipv6 -side top -anchor w
pack $wi.bottom.script $wi.bottom.linkall $wi.bottom.memb \
-side left -anchor center
pack $wi.bottom -side top -anchor w
}