add wireless network variable to CanvasGraph that maps a wireless/EMANE node to all MDRs connected to it

This commit is contained in:
Huy Pham 2020-02-18 15:58:18 -08:00
parent 08e652633f
commit d8f586bd2b
3 changed files with 25 additions and 0 deletions

View file

@ -27,6 +27,7 @@ class WlanConfigDialog(Dialog):
self.canvas_node = canvas_node
self.node = canvas_node.core_node
self.config_frame = None
self.range_entry = None
self.has_error = False
try:
self.config = self.app.core.get_wlan_config(self.node.id)
@ -53,6 +54,11 @@ class WlanConfigDialog(Dialog):
for i in range(2):
frame.columnconfigure(i, weight=1)
self.range_entry = self.config_frame.winfo_children()[0].frame.winfo_children()[
-1
]
self.range_entry.bind("<Key>", self.update_range)
button = ttk.Button(frame, text="Apply", command=self.click_apply)
button.grid(row=0, column=0, padx=PADX, sticky="ew")
@ -69,3 +75,7 @@ class WlanConfigDialog(Dialog):
session_id = self.app.core.session_id
self.app.core.client.set_wlan_config(session_id, self.node.id, config)
self.destroy()
def update_range(self, event):
if event.char.isdigit():
print(self.range_entry.get() + event.char)

View file

@ -177,6 +177,17 @@ class CanvasEdge:
dst_node_type = dst_node.core_node.type
is_src_wireless = NodeUtils.is_wireless_node(src_node_type)
is_dst_wireless = NodeUtils.is_wireless_node(dst_node_type)
# update the wlan/EMANE network
wlan_network = self.canvas.wireless_network
if is_src_wireless and not is_dst_wireless:
if self.src not in wlan_network:
wlan_network[self.src] = set()
wlan_network[self.src].add(self.dst)
elif not is_src_wireless and is_dst_wireless:
if self.dst not in wlan_network:
wlan_network[self.dst] = set()
wlan_network[self.dst].add(self.src)
return is_src_wireless or is_dst_wireless
def check_wireless(self):

View file

@ -42,6 +42,10 @@ class CanvasGraph(tk.Canvas):
self.edges = {}
self.shapes = {}
self.wireless_edges = {}
# map wireless/EMANE node to the set of MDRs connected to that node
self.wireless_network = {}
self.drawing_edge = None
self.grid = None
self.shape_drawing = False