pygui display error and link to emane docs when attempting to use emane node and it is not installed, fix dialog refactoring breaking mobility player, updated emane docs
This commit is contained in:
parent
1d620a0b17
commit
41b46b7e7a
4 changed files with 84 additions and 45 deletions
|
@ -6,7 +6,7 @@ import logging
|
|||
import os
|
||||
from pathlib import Path
|
||||
from tkinter import messagebox
|
||||
from typing import TYPE_CHECKING, Dict, Iterable, List
|
||||
from typing import TYPE_CHECKING, Dict, Iterable, List, Optional
|
||||
|
||||
import grpc
|
||||
|
||||
|
@ -16,6 +16,7 @@ from core.api.grpc.mobility_pb2 import MobilityConfig
|
|||
from core.api.grpc.services_pb2 import NodeServiceData, ServiceConfig, ServiceFileConfig
|
||||
from core.api.grpc.wlan_pb2 import WlanConfig
|
||||
from core.gui import appconfig
|
||||
from core.gui.dialogs.emaneinstall import EmaneInstallDialog
|
||||
from core.gui.dialogs.error import ErrorDialog
|
||||
from core.gui.dialogs.mobilityplayer import MobilityPlayer
|
||||
from core.gui.dialogs.sessions import SessionsDialog
|
||||
|
@ -552,7 +553,7 @@ class CoreClient:
|
|||
continue
|
||||
if canvas_node.mobility_config:
|
||||
mobility_player = MobilityPlayer(
|
||||
self.app, self.app, canvas_node, canvas_node.mobility_config
|
||||
self.app, canvas_node, canvas_node.mobility_config
|
||||
)
|
||||
node_id = canvas_node.core_node.id
|
||||
self.mobility_players[node_id] = mobility_player
|
||||
|
@ -785,7 +786,7 @@ class CoreClient:
|
|||
|
||||
def create_node(
|
||||
self, x: float, y: float, node_type: core_pb2.NodeType, model: str
|
||||
) -> core_pb2.Node:
|
||||
) -> Optional[core_pb2.Node]:
|
||||
"""
|
||||
Add node, with information filled in, to grpc manager
|
||||
"""
|
||||
|
@ -796,6 +797,10 @@ class CoreClient:
|
|||
image = "ubuntu:latest"
|
||||
emane = None
|
||||
if node_type == core_pb2.NodeType.EMANE:
|
||||
if not self.emane_models:
|
||||
dialog = EmaneInstallDialog(self.app)
|
||||
dialog.show()
|
||||
return
|
||||
emane = self.emane_models[0]
|
||||
name = f"EMANE{node_id}"
|
||||
elif node_type == core_pb2.NodeType.WIRELESS_LAN:
|
||||
|
@ -818,7 +823,7 @@ class CoreClient:
|
|||
node.services[:] = services
|
||||
# assign default services to CORE node
|
||||
else:
|
||||
services = self.default_services.get(model, None)
|
||||
services = self.default_services.get(model)
|
||||
if services:
|
||||
node.services[:] = services
|
||||
logging.info(
|
||||
|
|
25
daemon/core/gui/dialogs/emaneinstall.py
Normal file
25
daemon/core/gui/dialogs/emaneinstall.py
Normal file
|
@ -0,0 +1,25 @@
|
|||
import webbrowser
|
||||
from tkinter import ttk
|
||||
|
||||
from core.gui.dialogs.dialog import Dialog
|
||||
from core.gui.themes import PADY
|
||||
|
||||
|
||||
class EmaneInstallDialog(Dialog):
|
||||
def __init__(self, app) -> None:
|
||||
super().__init__(app, "EMANE Error")
|
||||
self.draw()
|
||||
|
||||
def draw(self):
|
||||
self.top.columnconfigure(0, weight=1)
|
||||
label = ttk.Label(self.top, text="EMANE needs to be installed!")
|
||||
label.grid(sticky="ew", pady=PADY)
|
||||
button = ttk.Button(
|
||||
self.top, text="EMANE Documentation", command=self.click_doc
|
||||
)
|
||||
button.grid(sticky="ew", pady=PADY)
|
||||
button = ttk.Button(self.top, text="Close", command=self.destroy)
|
||||
button.grid(sticky="ew")
|
||||
|
||||
def click_doc(self):
|
||||
webbrowser.open_new("https://coreemu.github.io/core/emane.html")
|
|
@ -723,24 +723,26 @@ class CanvasGraph(tk.Canvas):
|
|||
dialog = ShapeDialog(self.app, shape)
|
||||
dialog.show()
|
||||
|
||||
def add_node(self, x: float, y: float) -> CanvasNode:
|
||||
if self.selected is None or self.selected in self.shapes:
|
||||
actual_x, actual_y = self.get_actual_coords(x, y)
|
||||
core_node = self.core.create_node(
|
||||
actual_x, actual_y, self.node_draw.node_type, self.node_draw.model
|
||||
def add_node(self, x: float, y: float) -> None:
|
||||
if self.selected is not None and self.selected not in self.shapes:
|
||||
return
|
||||
actual_x, actual_y = self.get_actual_coords(x, y)
|
||||
core_node = self.core.create_node(
|
||||
actual_x, actual_y, self.node_draw.node_type, self.node_draw.model
|
||||
)
|
||||
if not core_node:
|
||||
return
|
||||
try:
|
||||
self.node_draw.image = Images.get(
|
||||
self.node_draw.image_enum, int(ICON_SIZE * self.app.app_scale)
|
||||
)
|
||||
try:
|
||||
self.node_draw.image = Images.get(
|
||||
self.node_draw.image_enum, int(ICON_SIZE * self.app.app_scale)
|
||||
)
|
||||
except AttributeError:
|
||||
self.node_draw.image = Images.get_custom(
|
||||
self.node_draw.image_file, int(ICON_SIZE * self.app.app_scale)
|
||||
)
|
||||
node = CanvasNode(self.app, x, y, core_node, self.node_draw.image)
|
||||
self.core.canvas_nodes[core_node.id] = node
|
||||
self.nodes[node.id] = node
|
||||
return node
|
||||
except AttributeError:
|
||||
self.node_draw.image = Images.get_custom(
|
||||
self.node_draw.image_file, int(ICON_SIZE * self.app.app_scale)
|
||||
)
|
||||
node = CanvasNode(self.app, x, y, core_node, self.node_draw.image)
|
||||
self.core.canvas_nodes[core_node.id] = node
|
||||
self.nodes[node.id] = node
|
||||
|
||||
def width_and_height(self):
|
||||
"""
|
||||
|
@ -925,6 +927,8 @@ class CanvasGraph(tk.Canvas):
|
|||
copy = self.core.create_node(
|
||||
actual_x, actual_y, core_node.type, core_node.model
|
||||
)
|
||||
if not copy:
|
||||
continue
|
||||
node = CanvasNode(self.app, scaled_x, scaled_y, copy, canvas_node.image)
|
||||
|
||||
# copy configurations and services
|
||||
|
|
|
@ -50,10 +50,27 @@ can also subscribe to EMANE location events and move the nodes on the canvas
|
|||
as they are moved in the EMANE emulation. This would occur when an Emulation
|
||||
Script Generator, for example, is running a mobility script.
|
||||
|
||||
## EMANE Installation
|
||||
|
||||
EMANE can be installed from deb or RPM packages or from source. See the
|
||||
[EMANE GitHub](https://github.com/adjacentlink/emane) for full details.
|
||||
|
||||
Here are quick instructions for installing all EMANE packages for Ubuntu 18.04:
|
||||
```shell
|
||||
# install dependencies
|
||||
sudo apt-get install libssl-dev libxml-libxml-perl libxml-simple-perl
|
||||
wget https://adjacentlink.com/downloads/emane/emane-1.2.5-release-1.ubuntu-18_04.amd64.tar.gz
|
||||
tar xzf emane-1.2.5-release-1.ubuntu-18_04.amd64.tar.gz
|
||||
# install base emane packages
|
||||
sudo dpkg -i emane-1.2.5-release-1/deb/ubuntu-18_04/amd64/emane*.deb
|
||||
# install python3 bindings
|
||||
sudo dpkg -i emane-1.2.5-release-1/deb/ubuntu-18_04/amd64/python3*.deb
|
||||
```
|
||||
|
||||
## EMANE Configuration
|
||||
|
||||
The CORE configuration file */etc/core/core.conf* has options specific to
|
||||
EMANE. An example emane section from the *core.conf* file is shown below:
|
||||
The CORE configuration file **/etc/core/core.conf** has options specific to
|
||||
EMANE. An example emane section from the **core.conf** file is shown below:
|
||||
|
||||
```shell
|
||||
# EMANE configuration
|
||||
|
@ -64,40 +81,28 @@ emane_event_monitor = False
|
|||
# EMANE log level range [0,4] default: 2
|
||||
emane_log_level = 2
|
||||
emane_realtime = True
|
||||
```
|
||||
|
||||
EMANE can be installed from deb or RPM packages or from source. See the
|
||||
[EMANE GitHub](https://github.com/adjacentlink/emane) for full details.
|
||||
|
||||
Here are quick instructions for installing all EMANE packages:
|
||||
|
||||
```shell
|
||||
# install dependencies
|
||||
sudo apt-get install libssl-dev libxml-libxml-perl libxml-simple-perl
|
||||
wget https://adjacentlink.com/downloads/emane/emane-1.2.1-release-1.ubuntu-16_04.amd64.tar.gz
|
||||
tar xzf emane-1.2.1-release-1.ubuntu-16_04.amd64.tar.gz
|
||||
sudo dpkg -i emane-1.2.1-release-1/deb/ubuntu-16_04/amd64/*.deb
|
||||
# prefix used for emane installation
|
||||
# emane_prefix = /usr
|
||||
```
|
||||
|
||||
If you have an EMANE event generator (e.g. mobility or pathloss scripts) and
|
||||
want to have CORE subscribe to EMANE location events, set the following line
|
||||
in the */etc/core/core.conf* configuration file:
|
||||
in the **core.conf** configuration file.
|
||||
|
||||
> **NOTE:** Do not set this option to True if you want to manually drag nodes around
|
||||
on the canvas to update their location in EMANE.
|
||||
|
||||
```shell
|
||||
emane_event_monitor = True
|
||||
```
|
||||
|
||||
Do not set the above option to True if you want to manually drag nodes around
|
||||
on the canvas to update their location in EMANE.
|
||||
|
||||
Another common issue is if installing EMANE from source, the default configure
|
||||
prefix will place the DTD files in */usr/local/share/emane/dtd* while CORE
|
||||
expects them in */usr/share/emane/dtd*.
|
||||
|
||||
A symbolic link will fix this:
|
||||
prefix will place the DTD files in **/usr/local/share/emane/dtd** while CORE
|
||||
expects them in **/usr/share/emane/dtd**.
|
||||
|
||||
Update the EMANE prefix configuration to resolve this problem.
|
||||
```shell
|
||||
sudo ln -s /usr/local/share/emane /usr/share/emane
|
||||
emane_prefix = /usr/local
|
||||
```
|
||||
|
||||
## Custom EMANE Models
|
||||
|
|
Loading…
Reference in a new issue