mobility config, start emane config
This commit is contained in:
parent
eabca7dfcf
commit
91ab1b0ee6
13 changed files with 297 additions and 80 deletions
|
@ -15,7 +15,6 @@ class Application(tk.Frame):
|
||||||
def __init__(self, master=None):
|
def __init__(self, master=None):
|
||||||
super().__init__(master)
|
super().__init__(master)
|
||||||
appcache.cache_variable(self)
|
appcache.cache_variable(self)
|
||||||
print(self.is_open_xml)
|
|
||||||
self.load_images()
|
self.load_images()
|
||||||
self.setup_app()
|
self.setup_app()
|
||||||
self.menubar = None
|
self.menubar = None
|
||||||
|
@ -100,6 +99,10 @@ class Application(tk.Frame):
|
||||||
self.canvas.grpc_manager.update_preexisting_ids()
|
self.canvas.grpc_manager.update_preexisting_ids()
|
||||||
self.canvas.draw_existing_component()
|
self.canvas.draw_existing_component()
|
||||||
|
|
||||||
|
self.canvas.grpc_manager.wlanconfig_management.load_wlan_configurations(
|
||||||
|
self.core_grpc
|
||||||
|
)
|
||||||
|
|
||||||
def on_closing(self):
|
def on_closing(self):
|
||||||
menu_action = MenuAction(self, self.master)
|
menu_action = MenuAction(self, self.master)
|
||||||
menu_action.on_quit()
|
menu_action.on_quit()
|
||||||
|
|
|
@ -5,6 +5,7 @@ canvas graph action
|
||||||
# import tkinter as tk
|
# import tkinter as tk
|
||||||
|
|
||||||
from core.api.grpc import core_pb2
|
from core.api.grpc import core_pb2
|
||||||
|
from coretk.dialogs.emaneconfig import EmaneConfiguration
|
||||||
from coretk.nodeconfigtable import NodeConfig
|
from coretk.nodeconfigtable import NodeConfig
|
||||||
from coretk.wlanconfiguration import WlanConfiguration
|
from coretk.wlanconfiguration import WlanConfiguration
|
||||||
|
|
||||||
|
@ -12,6 +13,7 @@ from coretk.wlanconfiguration import WlanConfiguration
|
||||||
NODE_TO_TYPE = {
|
NODE_TO_TYPE = {
|
||||||
"router": core_pb2.NodeType.DEFAULT,
|
"router": core_pb2.NodeType.DEFAULT,
|
||||||
"wlan": core_pb2.NodeType.WIRELESS_LAN,
|
"wlan": core_pb2.NodeType.WIRELESS_LAN,
|
||||||
|
"emane": core_pb2.NodeType.EMANE,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -29,6 +31,8 @@ class CanvasAction:
|
||||||
self.display_node_configuration()
|
self.display_node_configuration()
|
||||||
elif pb_type == core_pb2.NodeType.WIRELESS_LAN:
|
elif pb_type == core_pb2.NodeType.WIRELESS_LAN:
|
||||||
self.display_wlan_configuration(canvas_node)
|
self.display_wlan_configuration(canvas_node)
|
||||||
|
elif pb_type == core_pb2.NodeType.EMANE:
|
||||||
|
self.display_emane_configuration()
|
||||||
|
|
||||||
def display_node_configuration(self):
|
def display_node_configuration(self):
|
||||||
NodeConfig(self.canvas, self.node_to_show_config)
|
NodeConfig(self.canvas, self.node_to_show_config)
|
||||||
|
@ -41,3 +45,9 @@ class CanvasAction:
|
||||||
]
|
]
|
||||||
WlanConfiguration(self.canvas, self.node_to_show_config, wlan_config)
|
WlanConfiguration(self.canvas, self.node_to_show_config, wlan_config)
|
||||||
self.node_to_show_config = None
|
self.node_to_show_config = None
|
||||||
|
|
||||||
|
def display_emane_configuration(self):
|
||||||
|
app = self.canvas.core_grpc.app
|
||||||
|
dialog = EmaneConfiguration(self.master, app, self.node_to_show_config)
|
||||||
|
print(dialog)
|
||||||
|
dialog.show()
|
||||||
|
|
|
@ -3,7 +3,6 @@ Incorporate grpc into python tkinter GUI
|
||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
from collections import OrderedDict
|
|
||||||
|
|
||||||
from core.api.grpc import client, core_pb2
|
from core.api.grpc import client, core_pb2
|
||||||
from coretk.dialogs.sessions import SessionsDialog
|
from coretk.dialogs.sessions import SessionsDialog
|
||||||
|
@ -143,22 +142,22 @@ class CoreGrpc:
|
||||||
|
|
||||||
logging.info("set session state: %s", response)
|
logging.info("set session state: %s", response)
|
||||||
|
|
||||||
def add_node(self, node_type, model, x, y, name, node_id):
|
# def add_node(self, node_type, model, x, y, name, node_id):
|
||||||
position = core_pb2.Position(x=x, y=y)
|
# position = core_pb2.Position(x=x, y=y)
|
||||||
node = core_pb2.Node(id=node_id, type=node_type, position=position, model=model)
|
# node = core_pb2.Node(id=node_id, type=node_type, position=position, model=model)
|
||||||
self.node_ids.append(node_id)
|
# self.node_ids.append(node_id)
|
||||||
response = self.core.add_node(self.session_id, node)
|
# response = self.core.add_node(self.session_id, node)
|
||||||
logging.info("created node: %s", response)
|
# logging.info("created node: %s", response)
|
||||||
if node_type == core_pb2.NodeType.WIRELESS_LAN:
|
# if node_type == core_pb2.NodeType.WIRELESS_LAN:
|
||||||
d = OrderedDict()
|
# d = OrderedDict()
|
||||||
d["basic_range"] = "275"
|
# d["basic_range"] = "275"
|
||||||
d["bandwidth"] = "54000000"
|
# d["bandwidth"] = "54000000"
|
||||||
d["jitter"] = "0"
|
# d["jitter"] = "0"
|
||||||
d["delay"] = "20000"
|
# d["delay"] = "20000"
|
||||||
d["error"] = "0"
|
# d["error"] = "0"
|
||||||
r = self.core.set_wlan_config(self.session_id, node_id, d)
|
# r = self.core.set_wlan_config(self.session_id, node_id, d)
|
||||||
logging.debug("set wlan config %s", r)
|
# logging.debug("set wlan config %s", r)
|
||||||
return response.node_id
|
# return response.node_id
|
||||||
|
|
||||||
def edit_node(self, node_id, x, y):
|
def edit_node(self, node_id, x, y):
|
||||||
position = core_pb2.Position(x=x, y=y)
|
position = core_pb2.Position(x=x, y=y)
|
||||||
|
@ -232,6 +231,7 @@ class CoreGrpc:
|
||||||
nodes=nodes,
|
nodes=nodes,
|
||||||
links=links,
|
links=links,
|
||||||
wlan_configs=wlan_configs,
|
wlan_configs=wlan_configs,
|
||||||
|
mobility_configs=mobility_configs,
|
||||||
)
|
)
|
||||||
logging.debug("Start session %s, result: %s", self.session_id, response.result)
|
logging.debug("Start session %s, result: %s", self.session_id, response.result)
|
||||||
|
|
||||||
|
@ -253,28 +253,6 @@ class CoreGrpc:
|
||||||
"""
|
"""
|
||||||
if1 = self.create_interface(type1, edge.interface_1)
|
if1 = self.create_interface(type1, edge.interface_1)
|
||||||
if2 = self.create_interface(type2, edge.interface_2)
|
if2 = self.create_interface(type2, edge.interface_2)
|
||||||
# if type1 == core_pb2.NodeType.DEFAULT:
|
|
||||||
# interface = edge.interface_1
|
|
||||||
# if1 = core_pb2.Interface(
|
|
||||||
# id=interface.id,
|
|
||||||
# name=interface.name,
|
|
||||||
# mac=interface.mac,
|
|
||||||
# ip4=interface.ipv4,
|
|
||||||
# ip4mask=interface.ip4prefix,
|
|
||||||
# )
|
|
||||||
# logging.debug("create interface 1 %s", if1)
|
|
||||||
# # interface1 = self.interface_helper.create_interface(id1, 0)
|
|
||||||
#
|
|
||||||
# if type2 == core_pb2.NodeType.DEFAULT:
|
|
||||||
# interface = edge.interface_2
|
|
||||||
# if2 = core_pb2.Interface(
|
|
||||||
# id=interface.id,
|
|
||||||
# name=interface.name,
|
|
||||||
# mac=interface.mac,
|
|
||||||
# ip4=interface.ipv4,
|
|
||||||
# ip4mask=interface.ip4prefix,
|
|
||||||
# )
|
|
||||||
# logging.debug("create interface 2: %s", if2)
|
|
||||||
|
|
||||||
response = self.core.add_link(self.session_id, id1, id2, if1, if2)
|
response = self.core.add_link(self.session_id, id1, id2, if1, if2)
|
||||||
logging.info("created link: %s", response)
|
logging.info("created link: %s", response)
|
||||||
|
|
|
@ -368,9 +368,9 @@ class CoreToolbar(object):
|
||||||
|
|
||||||
def pick_emane(self, main_button):
|
def pick_emane(self, main_button):
|
||||||
self.link_layer_option_menu.destroy()
|
self.link_layer_option_menu.destroy()
|
||||||
main_button.configure(image=Images.get(ImageEnum.EMANE.value))
|
main_button.configure(image=Images.get(ImageEnum.EMANE))
|
||||||
self.canvas.mode = GraphMode.PICKNODE
|
self.canvas.mode = GraphMode.PICKNODE
|
||||||
self.canvas.draw_node_image = Images.get(ImageEnum.EMANE.value)
|
self.canvas.draw_node_image = Images.get(ImageEnum.EMANE)
|
||||||
self.canvas.draw_node_name = "emane"
|
self.canvas.draw_node_name = "emane"
|
||||||
|
|
||||||
def draw_link_layer_options(self, link_layer_button):
|
def draw_link_layer_options(self, link_layer_button):
|
||||||
|
|
|
@ -71,6 +71,11 @@ class CoreToolbarHelp:
|
||||||
return links
|
return links
|
||||||
|
|
||||||
def get_wlan_configuration_list(self):
|
def get_wlan_configuration_list(self):
|
||||||
|
"""
|
||||||
|
form a list of wlan configuration to pass to start_session
|
||||||
|
|
||||||
|
:return: nothing
|
||||||
|
"""
|
||||||
configs = []
|
configs = []
|
||||||
grpc_manager = self.application.canvas.grpc_manager
|
grpc_manager = self.application.canvas.grpc_manager
|
||||||
manager_configs = grpc_manager.wlanconfig_management.configurations
|
manager_configs = grpc_manager.wlanconfig_management.configurations
|
||||||
|
@ -79,23 +84,33 @@ class CoreToolbarHelp:
|
||||||
configs.append(cnf)
|
configs.append(cnf)
|
||||||
return configs
|
return configs
|
||||||
|
|
||||||
|
def get_mobility_configuration_list(self):
|
||||||
|
"""
|
||||||
|
form a list of mobility configuration to pass to start_session
|
||||||
|
|
||||||
|
:return: nothing
|
||||||
|
"""
|
||||||
|
configs = []
|
||||||
|
grpc_manager = self.application.canvas.grpc_manager
|
||||||
|
manager_configs = grpc_manager.mobilityconfig_management.configurations
|
||||||
|
for key in manager_configs:
|
||||||
|
cnf = core_pb2.MobilityConfig(node_id=key, config=manager_configs[key])
|
||||||
|
configs.append(cnf)
|
||||||
|
return configs
|
||||||
|
|
||||||
def gui_start_session(self):
|
def gui_start_session(self):
|
||||||
# list(core_pb2.Node)
|
|
||||||
nodes = self.get_node_list()
|
nodes = self.get_node_list()
|
||||||
|
|
||||||
# list(core_bp2.Link)
|
|
||||||
links = self.get_link_list()
|
links = self.get_link_list()
|
||||||
|
|
||||||
# print(links[0])
|
|
||||||
wlan_configs = self.get_wlan_configuration_list()
|
wlan_configs = self.get_wlan_configuration_list()
|
||||||
# print(wlan_configs)
|
mobility_configs = self.get_mobility_configuration_list()
|
||||||
self.core_grpc.start_session(nodes, links, wlan_configs=wlan_configs)
|
|
||||||
|
self.core_grpc.start_session(
|
||||||
|
nodes, links, wlan_configs=wlan_configs, mobility_configs=mobility_configs
|
||||||
|
)
|
||||||
# self.core_grpc.core.add_link(self.core_grpc.session_id, self.id1, self.id2, self.if1, self.if2)
|
# self.core_grpc.core.add_link(self.core_grpc.session_id, self.id1, self.id2, self.if1, self.if2)
|
||||||
# res = self.core_grpc.core.get_wlan_config(self.core_grpc.session_id, 1)
|
# res = self.core_grpc.core.get_wlan_config(self.core_grpc.session_id, 1)
|
||||||
|
|
||||||
# res = self.core_grpc.core.get_session(self.core_grpc.session_id).session
|
# res = self.core_grpc.core.get_wlan_config(self.core_grpc.session_id, 2)
|
||||||
# print(res)
|
|
||||||
# res = self.core_grpc.core.get_wlan_config(self.core_grpc.session_id, 1)
|
|
||||||
|
|
||||||
# print(res)
|
# print(res)
|
||||||
|
|
||||||
|
|
47
coretk/coretk/dialogs/emaneconfig.py
Normal file
47
coretk/coretk/dialogs/emaneconfig.py
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
"""
|
||||||
|
emane configuration
|
||||||
|
"""
|
||||||
|
|
||||||
|
import tkinter as tk
|
||||||
|
|
||||||
|
from coretk.dialogs.dialog import Dialog
|
||||||
|
|
||||||
|
|
||||||
|
class EmaneConfiguration(Dialog):
|
||||||
|
def __init__(self, master, app, canvas_node):
|
||||||
|
super().__init__(master, app, "emane configuration", modal=False)
|
||||||
|
self.canvas_node = canvas_node
|
||||||
|
|
||||||
|
def create_text_variable(self, val):
|
||||||
|
"""
|
||||||
|
create a string variable for convenience
|
||||||
|
|
||||||
|
:param str val: entry text
|
||||||
|
:return: nothing
|
||||||
|
"""
|
||||||
|
var = tk.StringVar()
|
||||||
|
var.set(val)
|
||||||
|
return var
|
||||||
|
|
||||||
|
def choose_core(self):
|
||||||
|
print("not implemented")
|
||||||
|
|
||||||
|
def node_name_and_image(self):
|
||||||
|
f = tk.Frame(self)
|
||||||
|
|
||||||
|
lbl = tk.Label(f, text="Node name:")
|
||||||
|
lbl.grid(row=0, column=0)
|
||||||
|
e = tk.Entry(f, textvariable=self.create_text_variable(""), bg="white")
|
||||||
|
e.grid(row=0, column=1)
|
||||||
|
|
||||||
|
om = tk.OptionMenu(
|
||||||
|
f,
|
||||||
|
self.create_text_variable("None"),
|
||||||
|
"(none)",
|
||||||
|
"core1",
|
||||||
|
"core2",
|
||||||
|
command=self.choose_core,
|
||||||
|
)
|
||||||
|
om.grid(row=0, column=2)
|
||||||
|
|
||||||
|
# b = tk.Button(f,)
|
|
@ -20,6 +20,10 @@ class MobilityConfiguration(Dialog):
|
||||||
"""
|
"""
|
||||||
super().__init__(master, app, "ns2script configuration", modal=True)
|
super().__init__(master, app, "ns2script configuration", modal=True)
|
||||||
self.canvas_node = canvas_node
|
self.canvas_node = canvas_node
|
||||||
|
self.node_config = app.canvas.grpc_manager.mobilityconfig_management.configurations[
|
||||||
|
canvas_node.core_id
|
||||||
|
]
|
||||||
|
|
||||||
self.mobility_script_parameters()
|
self.mobility_script_parameters()
|
||||||
self.ns2script_options()
|
self.ns2script_options()
|
||||||
self.loop = "On"
|
self.loop = "On"
|
||||||
|
@ -51,13 +55,13 @@ class MobilityConfiguration(Dialog):
|
||||||
self.loop = value
|
self.loop = value
|
||||||
|
|
||||||
def create_label_entry_filebrowser(
|
def create_label_entry_filebrowser(
|
||||||
self, parent_frame, text_label, filebrowser=False
|
self, parent_frame, text_label, entry_text, filebrowser=False
|
||||||
):
|
):
|
||||||
f = tk.Frame(parent_frame, bg="#d9d9d9")
|
f = tk.Frame(parent_frame, bg="#d9d9d9")
|
||||||
lbl = tk.Label(f, text=text_label, bg="#d9d9d9")
|
lbl = tk.Label(f, text=text_label, bg="#d9d9d9")
|
||||||
lbl.grid(padx=3, pady=3)
|
lbl.grid(padx=3, pady=3)
|
||||||
# f.grid()
|
# f.grid()
|
||||||
e = tk.Entry(f, textvariable=self.create_string_var(""), bg="#ffffff")
|
e = tk.Entry(f, textvariable=self.create_string_var(entry_text), bg="#ffffff")
|
||||||
e.grid(row=0, column=1, padx=3, pady=3)
|
e.grid(row=0, column=1, padx=3, pady=3)
|
||||||
if filebrowser:
|
if filebrowser:
|
||||||
b = tk.Button(f, text="...", command=lambda: self.open_file(e))
|
b = tk.Button(f, text="...", command=lambda: self.open_file(e))
|
||||||
|
@ -88,9 +92,11 @@ class MobilityConfiguration(Dialog):
|
||||||
bd=0,
|
bd=0,
|
||||||
)
|
)
|
||||||
self.create_label_entry_filebrowser(
|
self.create_label_entry_filebrowser(
|
||||||
f1, "mobility script file", filebrowser=True
|
f1, "mobility script file", self.node_config["file"], filebrowser=True
|
||||||
|
)
|
||||||
|
self.create_label_entry_filebrowser(
|
||||||
|
f1, "Refresh time (ms)", self.node_config["refresh_ms"]
|
||||||
)
|
)
|
||||||
self.create_label_entry_filebrowser(f1, "Refresh time (ms)")
|
|
||||||
|
|
||||||
# f12 = tk.Frame(f1)
|
# f12 = tk.Frame(f1)
|
||||||
#
|
#
|
||||||
|
@ -107,18 +113,15 @@ class MobilityConfiguration(Dialog):
|
||||||
lbl.grid()
|
lbl.grid()
|
||||||
|
|
||||||
om = tk.OptionMenu(
|
om = tk.OptionMenu(
|
||||||
f13,
|
f13, self.create_string_var("On"), "On", "Off", command=self.set_loop_value
|
||||||
self.create_string_var("On"),
|
|
||||||
"On",
|
|
||||||
"Off",
|
|
||||||
command=self.set_loop_value,
|
|
||||||
indicatoron=True,
|
|
||||||
)
|
)
|
||||||
om.grid(row=0, column=1)
|
om.grid(row=0, column=1)
|
||||||
|
|
||||||
f13.grid(sticky=tk.E)
|
f13.grid(sticky=tk.E)
|
||||||
|
|
||||||
self.create_label_entry_filebrowser(f1, "auto-start seconds (0.0 for runtime)")
|
self.create_label_entry_filebrowser(
|
||||||
|
f1, "auto-start seconds (0.0 for runtime)", self.node_config["autostart"]
|
||||||
|
)
|
||||||
# f14 = tk.Frame(f1)
|
# f14 = tk.Frame(f1)
|
||||||
#
|
#
|
||||||
# lbl = tk.Label(f14, text="auto-start seconds (0.0 for runtime)")
|
# lbl = tk.Label(f14, text="auto-start seconds (0.0 for runtime)")
|
||||||
|
@ -129,7 +132,7 @@ class MobilityConfiguration(Dialog):
|
||||||
#
|
#
|
||||||
# f14.grid()
|
# f14.grid()
|
||||||
self.create_label_entry_filebrowser(
|
self.create_label_entry_filebrowser(
|
||||||
f1, "node mapping (optional, e.g. 0:1, 1:2, 2:3)"
|
f1, "node mapping (optional, e.g. 0:1, 1:2, 2:3)", self.node_config["map"]
|
||||||
)
|
)
|
||||||
# f15 = tk.Frame(f1)
|
# f15 = tk.Frame(f1)
|
||||||
#
|
#
|
||||||
|
@ -142,13 +145,22 @@ class MobilityConfiguration(Dialog):
|
||||||
# f15.grid()
|
# f15.grid()
|
||||||
|
|
||||||
self.create_label_entry_filebrowser(
|
self.create_label_entry_filebrowser(
|
||||||
f1, "script file to run upon start", filebrowser=True
|
f1,
|
||||||
|
"script file to run upon start",
|
||||||
|
self.node_config["script_start"],
|
||||||
|
filebrowser=True,
|
||||||
)
|
)
|
||||||
self.create_label_entry_filebrowser(
|
self.create_label_entry_filebrowser(
|
||||||
f1, "script file to run upon pause", filebrowser=True
|
f1,
|
||||||
|
"script file to run upon pause",
|
||||||
|
self.node_config["script_pause"],
|
||||||
|
filebrowser=True,
|
||||||
)
|
)
|
||||||
self.create_label_entry_filebrowser(
|
self.create_label_entry_filebrowser(
|
||||||
f1, "script file to run upon stop", filebrowser=True
|
f1,
|
||||||
|
"script file to run upon stop",
|
||||||
|
self.node_config["script_stop"],
|
||||||
|
filebrowser=True,
|
||||||
)
|
)
|
||||||
f1.grid()
|
f1.grid()
|
||||||
sb.config(command=f1.yview)
|
sb.config(command=f1.yview)
|
||||||
|
@ -186,13 +198,28 @@ class MobilityConfiguration(Dialog):
|
||||||
canvas.grid_slaves(row=7, column=0)[0].grid_slaves(row=0, column=1)[0].get()
|
canvas.grid_slaves(row=7, column=0)[0].grid_slaves(row=0, column=1)[0].get()
|
||||||
)
|
)
|
||||||
|
|
||||||
print("mobility script file: ", file)
|
# print("mobility script file: ", file)
|
||||||
print("refresh time: ", refresh_time)
|
# print("refresh time: ", refresh_time)
|
||||||
print("auto start seconds: ", auto_start_seconds)
|
# print("auto start seconds: ", auto_start_seconds)
|
||||||
print("node mapping: ", node_mapping)
|
# print("node mapping: ", node_mapping)
|
||||||
print("script file to run upon start: ", file_upon_start)
|
# print("script file to run upon start: ", file_upon_start)
|
||||||
print("file upon pause: ", file_upon_pause)
|
# print("file upon pause: ", file_upon_pause)
|
||||||
print("file upon stop: ", file_upon_stop)
|
# print("file upon stop: ", file_upon_stop)
|
||||||
|
if self.loop == "On":
|
||||||
|
loop = "1"
|
||||||
|
else:
|
||||||
|
loop = "0"
|
||||||
|
self.app.canvas.grpc_manager.mobilityconfig_management.set_custom_configuration(
|
||||||
|
node_id=self.canvas_node.core_id,
|
||||||
|
file=file,
|
||||||
|
refresh_ms=refresh_time,
|
||||||
|
loop=loop,
|
||||||
|
autostart=auto_start_seconds,
|
||||||
|
node_mapping=node_mapping,
|
||||||
|
script_start=file_upon_start,
|
||||||
|
script_pause=file_upon_pause,
|
||||||
|
script_stop=file_upon_stop,
|
||||||
|
)
|
||||||
|
|
||||||
self.destroy()
|
self.destroy()
|
||||||
|
|
||||||
|
|
|
@ -90,8 +90,8 @@ class CanvasGraph(tk.Canvas):
|
||||||
self.draw_node_name = None
|
self.draw_node_name = None
|
||||||
self.selected = None
|
self.selected = None
|
||||||
self.node_context = None
|
self.node_context = None
|
||||||
self.nodes = {}
|
self.nodes.clear()
|
||||||
self.edges = {}
|
self.edges.clear()
|
||||||
self.drawing_edge = None
|
self.drawing_edge = None
|
||||||
|
|
||||||
self.grpc_manager = GrpcManager(new_grpc)
|
self.grpc_manager = GrpcManager(new_grpc)
|
||||||
|
@ -100,6 +100,8 @@ class CanvasGraph(tk.Canvas):
|
||||||
self.core_grpc = new_grpc
|
self.core_grpc = new_grpc
|
||||||
self.draw_existing_component()
|
self.draw_existing_component()
|
||||||
|
|
||||||
|
# self.grpc_manager.wlanconfig_management.load_wlan_configurations(self.core_grpc)
|
||||||
|
|
||||||
def setup_bindings(self):
|
def setup_bindings(self):
|
||||||
"""
|
"""
|
||||||
Bind any mouse events or hot keys to the matching action
|
Bind any mouse events or hot keys to the matching action
|
||||||
|
|
|
@ -7,6 +7,7 @@ import logging
|
||||||
from core.api.grpc import core_pb2
|
from core.api.grpc import core_pb2
|
||||||
from coretk.coretocanvas import CoreToCanvasMapping
|
from coretk.coretocanvas import CoreToCanvasMapping
|
||||||
from coretk.interface import Interface, InterfaceManager
|
from coretk.interface import Interface, InterfaceManager
|
||||||
|
from coretk.mobilitynodeconfig import MobilityNodeConfig
|
||||||
from coretk.wlannodeconfig import WlanNodeConfig
|
from coretk.wlannodeconfig import WlanNodeConfig
|
||||||
|
|
||||||
link_layer_nodes = ["switch", "hub", "wlan", "rj45", "tunnel"]
|
link_layer_nodes = ["switch", "hub", "wlan", "rj45", "tunnel"]
|
||||||
|
@ -74,6 +75,7 @@ class GrpcManager:
|
||||||
self.core_mapping = CoreToCanvasMapping()
|
self.core_mapping = CoreToCanvasMapping()
|
||||||
|
|
||||||
self.wlanconfig_management = WlanNodeConfig()
|
self.wlanconfig_management = WlanNodeConfig()
|
||||||
|
self.mobilityconfig_management = MobilityNodeConfig()
|
||||||
|
|
||||||
def update_preexisting_ids(self):
|
def update_preexisting_ids(self):
|
||||||
"""
|
"""
|
||||||
|
@ -152,6 +154,9 @@ class GrpcManager:
|
||||||
# set default configuration for wireless node
|
# set default configuration for wireless node
|
||||||
self.wlanconfig_management.set_default_config(node_type, nid)
|
self.wlanconfig_management.set_default_config(node_type, nid)
|
||||||
|
|
||||||
|
# set default mobility configuration for wireless node
|
||||||
|
self.mobilityconfig_management.set_default_configuration(node_type, nid)
|
||||||
|
|
||||||
self.nodes[canvas_id] = create_node
|
self.nodes[canvas_id] = create_node
|
||||||
self.core_mapping.map_core_id_to_canvas_id(nid, canvas_id)
|
self.core_mapping.map_core_id_to_canvas_id(nid, canvas_id)
|
||||||
# self.core_id_to_canvas_id[nid] = canvas_id
|
# self.core_id_to_canvas_id[nid] = canvas_id
|
||||||
|
|
|
@ -400,6 +400,14 @@ class MenuAction:
|
||||||
# print(grpc.get_session_state())
|
# print(grpc.get_session_state())
|
||||||
self.application.canvas.canvas_reset_and_redraw(core_grpc)
|
self.application.canvas.canvas_reset_and_redraw(core_grpc)
|
||||||
|
|
||||||
|
self.application.canvas.grpc_manager.wlanconfig_management.load_wlan_configurations(
|
||||||
|
core_grpc
|
||||||
|
)
|
||||||
|
|
||||||
|
self.application.canvas.grpc_manager.mobilityconfig_management.load_mobility_configurations(
|
||||||
|
core_grpc
|
||||||
|
)
|
||||||
|
|
||||||
# Todo might not need
|
# Todo might not need
|
||||||
self.application.core_grpc = core_grpc
|
self.application.core_grpc = core_grpc
|
||||||
|
|
||||||
|
|
89
coretk/coretk/mobilitynodeconfig.py
Normal file
89
coretk/coretk/mobilitynodeconfig.py
Normal file
|
@ -0,0 +1,89 @@
|
||||||
|
"""
|
||||||
|
mobility configurations for all the nodes
|
||||||
|
"""
|
||||||
|
|
||||||
|
import logging
|
||||||
|
from collections import OrderedDict
|
||||||
|
|
||||||
|
from core.api.grpc import core_pb2
|
||||||
|
|
||||||
|
|
||||||
|
class MobilityNodeConfig:
|
||||||
|
def __init__(self):
|
||||||
|
self.configurations = {}
|
||||||
|
|
||||||
|
def set_default_configuration(self, node_type, node_id):
|
||||||
|
"""
|
||||||
|
set default mobility configuration for a node
|
||||||
|
|
||||||
|
:param core_pb2.NodeType node_type: protobuf node type
|
||||||
|
:param int node_id: node id
|
||||||
|
:return: nothing
|
||||||
|
"""
|
||||||
|
if node_type == core_pb2.NodeType.WIRELESS_LAN:
|
||||||
|
config = OrderedDict()
|
||||||
|
config["autostart"] = ""
|
||||||
|
config["file"] = ""
|
||||||
|
config["loop"] = "1"
|
||||||
|
config["map"] = ""
|
||||||
|
config["refresh_ms"] = "50"
|
||||||
|
config["script_pause"] = ""
|
||||||
|
config["script_start"] = ""
|
||||||
|
config["script_stop"] = ""
|
||||||
|
self.configurations[node_id] = config
|
||||||
|
|
||||||
|
def set_custom_configuration(
|
||||||
|
self,
|
||||||
|
node_id,
|
||||||
|
file,
|
||||||
|
refresh_ms,
|
||||||
|
loop,
|
||||||
|
autostart,
|
||||||
|
node_mapping,
|
||||||
|
script_start,
|
||||||
|
script_pause,
|
||||||
|
script_stop,
|
||||||
|
):
|
||||||
|
"""
|
||||||
|
set custom mobility configuration for a node
|
||||||
|
|
||||||
|
:param int node_id: node id
|
||||||
|
:param str file: path to mobility script file
|
||||||
|
:param str refresh_ms: refresh time
|
||||||
|
:param str loop: loop option
|
||||||
|
:param str autostart: auto-start seconds value
|
||||||
|
:param str node_mapping: node mapping
|
||||||
|
:param str script_start: path to script to run upon start
|
||||||
|
:param str script_pause: path to script to run upon pause
|
||||||
|
:param str script_stop: path to script to run upon stop
|
||||||
|
:return: nothing
|
||||||
|
"""
|
||||||
|
if node_id in self.configurations:
|
||||||
|
self.configurations[node_id]["autostart"] = autostart
|
||||||
|
self.configurations[node_id]["file"] = file
|
||||||
|
self.configurations[node_id]["loop"] = loop
|
||||||
|
self.configurations[node_id]["map"] = node_mapping
|
||||||
|
self.configurations[node_id]["refresh_ms"] = refresh_ms
|
||||||
|
self.configurations[node_id]["script_pause"] = script_pause
|
||||||
|
self.configurations[node_id]["script_start"] = script_start
|
||||||
|
self.configurations[node_id]["script_stop"] = script_stop
|
||||||
|
else:
|
||||||
|
logging.error("mobilitynodeconfig.py invalid node_id")
|
||||||
|
|
||||||
|
def load_mobility_configurations(self, core_grpc):
|
||||||
|
"""
|
||||||
|
load mobility configuration from the daemon into memory
|
||||||
|
|
||||||
|
:param coretk.coregrpc.CoreGrpc core_grpc: CoreGrpc object
|
||||||
|
:return: nothing
|
||||||
|
"""
|
||||||
|
self.configurations.clear()
|
||||||
|
sid = core_grpc.session_id
|
||||||
|
client = core_grpc.core
|
||||||
|
configs = client.get_mobility_configs(sid).configs
|
||||||
|
for nid in configs:
|
||||||
|
node_config = configs[nid].config
|
||||||
|
cnf = OrderedDict()
|
||||||
|
for key in node_config:
|
||||||
|
cnf[key] = node_config[key].value
|
||||||
|
self.configurations[nid] = cnf
|
|
@ -32,7 +32,8 @@ class WlanConfiguration:
|
||||||
# self.range_var.set(275.0)
|
# self.range_var.set(275.0)
|
||||||
self.config = config
|
self.config = config
|
||||||
self.range_var = tk.StringVar()
|
self.range_var = tk.StringVar()
|
||||||
self.range_var.set(config["basic_range"])
|
# self.range_var.set(config["basic_range"])
|
||||||
|
self.range_var.set(config["range"])
|
||||||
# self.bandwidth_var = tk.IntVar()
|
# self.bandwidth_var = tk.IntVar()
|
||||||
self.bandwidth_var = tk.StringVar()
|
self.bandwidth_var = tk.StringVar()
|
||||||
self.bandwidth_var.set(config["bandwidth"])
|
self.bandwidth_var.set(config["bandwidth"])
|
||||||
|
@ -130,7 +131,8 @@ class WlanConfiguration:
|
||||||
|
|
||||||
e = tk.Entry(
|
e = tk.Entry(
|
||||||
f1,
|
f1,
|
||||||
textvariable=self.create_string_var(self.config["basic_range"]),
|
# textvariable=self.create_string_var(self.config["basic_range"]),
|
||||||
|
textvariable=self.create_string_var(self.config["range"]),
|
||||||
width=5,
|
width=5,
|
||||||
bg="white",
|
bg="white",
|
||||||
)
|
)
|
||||||
|
|
|
@ -14,7 +14,7 @@ class WlanNodeConfig:
|
||||||
def set_default_config(self, node_type, node_id):
|
def set_default_config(self, node_type, node_id):
|
||||||
if node_type == core_pb2.NodeType.WIRELESS_LAN:
|
if node_type == core_pb2.NodeType.WIRELESS_LAN:
|
||||||
config = OrderedDict()
|
config = OrderedDict()
|
||||||
config["basic_range"] = "275"
|
config["range"] = "275"
|
||||||
config["bandwidth"] = "54000000"
|
config["bandwidth"] = "54000000"
|
||||||
config["jitter"] = "0"
|
config["jitter"] = "0"
|
||||||
config["delay"] = "20000"
|
config["delay"] = "20000"
|
||||||
|
@ -22,8 +22,39 @@ class WlanNodeConfig:
|
||||||
self.configurations[node_id] = config
|
self.configurations[node_id] = config
|
||||||
|
|
||||||
def set_custom_config(self, node_id, range, bandwidth, jitter, delay, error):
|
def set_custom_config(self, node_id, range, bandwidth, jitter, delay, error):
|
||||||
self.configurations[node_id]["basic_range"] = range
|
self.configurations[node_id]["range"] = range
|
||||||
self.configurations[node_id]["bandwidth"] = bandwidth
|
self.configurations[node_id]["bandwidth"] = bandwidth
|
||||||
self.configurations[node_id]["jitter"] = jitter
|
self.configurations[node_id]["jitter"] = jitter
|
||||||
self.configurations[node_id]["delay"] = delay
|
self.configurations[node_id]["delay"] = delay
|
||||||
self.configurations[node_id]["error"] = error
|
self.configurations[node_id]["error"] = error
|
||||||
|
|
||||||
|
def delete_node_config(self, node_id):
|
||||||
|
"""
|
||||||
|
not implemented
|
||||||
|
:param node_id:
|
||||||
|
:return:
|
||||||
|
"""
|
||||||
|
return
|
||||||
|
|
||||||
|
def load_wlan_configurations(self, core_grpc):
|
||||||
|
"""
|
||||||
|
load wlan configuration from the daemon
|
||||||
|
|
||||||
|
:param coretk.coregrpc.CoreGrpc core_grpc: CoreGrpc object
|
||||||
|
:return: nothing
|
||||||
|
"""
|
||||||
|
self.configurations.clear()
|
||||||
|
sid = core_grpc.session_id
|
||||||
|
client = core_grpc.core
|
||||||
|
for node in client.get_session(sid).session.nodes:
|
||||||
|
if node.type == core_pb2.NodeType.WIRELESS_LAN:
|
||||||
|
wlan_config = client.get_wlan_config(sid, node.id).config
|
||||||
|
config = OrderedDict()
|
||||||
|
for key in wlan_config:
|
||||||
|
config[key] = wlan_config[key].value
|
||||||
|
|
||||||
|
# config[key] = wlan_config[key]["value"]
|
||||||
|
# print(config)
|
||||||
|
# for k, v in wlan_config.config:
|
||||||
|
|
||||||
|
self.configurations[node.id] = config
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue