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: try:
from emane.events.commeffectevent import CommEffectEvent from emane.events.commeffectevent import CommEffectEvent
except ImportError: 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): def convert_none(x):

View file

@ -34,7 +34,12 @@ try:
from emane.events import LocationEvent from emane.events import LocationEvent
from emane.events.eventserviceexception import EventServiceException from emane.events.eventserviceexception import EventServiceException
except ImportError: 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 = [ EMANE_MODELS = [
EmaneRfPipeModel, EmaneRfPipeModel,
@ -76,7 +81,7 @@ class EmaneManager(ConfigurableManager):
self.transformport = self.session.get_config_item_int("emane_transform_port", 8200) self.transformport = self.session.get_config_item_int("emane_transform_port", 8200)
self.doeventloop = False self.doeventloop = False
self.eventmonthread = None self.eventmonthread = None
self.logversion()
# model for global EMANE configuration options # model for global EMANE configuration options
self.emane_config = EmaneGlobalModel(session, None) self.emane_config = EmaneGlobalModel(session, None)
session.broker.handlers.add(self.handledistributed) session.broker.handlers.add(self.handledistributed)
@ -86,24 +91,28 @@ class EmaneManager(ConfigurableManager):
self.emane_config.name: self.emane_config 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.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: try:
# check for emane
emane_version = utils.check_cmd(["emane", "--version"]) emane_version = utils.check_cmd(["emane", "--version"])
logger.info("using EMANE: %s", 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: except CoreCommandError:
logger.info("emane is not installed") logger.info("emane is not installed")

View file

@ -1,10 +1,14 @@
from core import logger from core import logger
from core.enumerations import ConfigDataTypes from core.enumerations import ConfigDataTypes
manifest = None
try: try:
from emane.shell import manifest from emane.shell import manifest
except ImportError: 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): def _type_value(config_type):
@ -77,6 +81,10 @@ def parse(manifest_path, defaults):
:rtype: list :rtype: list
""" """
# no results when emane bindings are not present
if not manifest:
return []
# load configuration file # load configuration file
manifest_file = manifest.Manifest(manifest_path) manifest_file = manifest.Manifest(manifest_path)
manifest_configurations = manifest_file.getAllConfiguration() manifest_configurations = manifest_file.getAllConfiguration()

View file

@ -15,7 +15,10 @@ from core.enumerations import RegisterTlvs
try: try:
from emane.events import LocationEvent from emane.events import LocationEvent
except ImportError: 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): class EmaneNet(PyCoreNet):

View file

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