updated wlan/mobility configs to be directly associated with a node and allow them to be copied
This commit is contained in:
parent
bd30d0d9ff
commit
85b4a81f8a
7 changed files with 52 additions and 52 deletions
|
@ -90,8 +90,6 @@ class CoreClient:
|
|||
self.location = None
|
||||
self.links = {}
|
||||
self.hooks = {}
|
||||
self.wlan_configs = {}
|
||||
self.mobility_configs = {}
|
||||
self.emane_config = None
|
||||
self.service_configs = {}
|
||||
self.config_service_configs = {}
|
||||
|
@ -127,8 +125,6 @@ class CoreClient:
|
|||
self.canvas_nodes.clear()
|
||||
self.links.clear()
|
||||
self.hooks.clear()
|
||||
self.wlan_configs.clear()
|
||||
self.mobility_configs.clear()
|
||||
self.emane_config = None
|
||||
self.service_configs.clear()
|
||||
self.file_configs.clear()
|
||||
|
@ -311,8 +307,9 @@ class CoreClient:
|
|||
# get mobility configs
|
||||
response = self.client.get_mobility_configs(self.session_id)
|
||||
for node_id in response.configs:
|
||||
node_config = response.configs[node_id].config
|
||||
self.mobility_configs[node_id] = node_config
|
||||
config = response.configs[node_id].config
|
||||
canvas_node = self.canvas_nodes[node_id]
|
||||
canvas_node.mobility_config = dict(config)
|
||||
|
||||
# get emane model config
|
||||
response = self.client.get_emane_model_configs(self.session_id)
|
||||
|
@ -321,15 +318,16 @@ class CoreClient:
|
|||
if config.interface != -1:
|
||||
interface = config.interface
|
||||
canvas_node = self.canvas_nodes[config.node_id]
|
||||
canvas_node.emane_model_configs[
|
||||
(config.model, interface)
|
||||
] = config.config
|
||||
canvas_node.emane_model_configs[(config.model, interface)] = dict(
|
||||
config.config
|
||||
)
|
||||
|
||||
# get wlan configurations
|
||||
response = self.client.get_wlan_configs(self.session_id)
|
||||
for _id in response.configs:
|
||||
mapped_config = response.configs[_id]
|
||||
self.wlan_configs[_id] = mapped_config.config
|
||||
canvas_node = self.canvas_nodes[_id]
|
||||
canvas_node.wlan_config = dict(mapped_config.config)
|
||||
|
||||
# get service configurations
|
||||
response = self.client.get_node_service_configs(self.session_id)
|
||||
|
@ -554,11 +552,16 @@ class CoreClient:
|
|||
return response
|
||||
|
||||
def show_mobility_players(self):
|
||||
for node_id, config in self.mobility_configs.items():
|
||||
canvas_node = self.canvas_nodes[node_id]
|
||||
mobility_player = MobilityPlayer(self.app, self.app, canvas_node, config)
|
||||
mobility_player.show()
|
||||
self.mobility_players[node_id] = mobility_player
|
||||
for canvas_node in self.canvas_nodes.values():
|
||||
if canvas_node.core_node.type != core_pb2.NodeType.WIRELESS_LAN:
|
||||
continue
|
||||
if canvas_node.mobility_config:
|
||||
mobility_player = MobilityPlayer(
|
||||
self.app, self.app, canvas_node, canvas_node.mobility_config
|
||||
)
|
||||
node_id = canvas_node.core_node.id
|
||||
self.mobility_players[node_id] = mobility_player
|
||||
mobility_player.show()
|
||||
|
||||
def set_metadata(self):
|
||||
# create canvas data
|
||||
|
@ -839,14 +842,7 @@ class CoreClient:
|
|||
logging.error("unknown node: %s", node_id)
|
||||
continue
|
||||
del self.canvas_nodes[node_id]
|
||||
|
||||
self.modified_service_nodes.discard(node_id)
|
||||
|
||||
if node_id in self.mobility_configs:
|
||||
del self.mobility_configs[node_id]
|
||||
if node_id in self.wlan_configs:
|
||||
del self.wlan_configs[node_id]
|
||||
|
||||
for edge in canvas_node.edges:
|
||||
if edge in edges:
|
||||
continue
|
||||
|
@ -916,16 +912,24 @@ class CoreClient:
|
|||
|
||||
def get_wlan_configs_proto(self) -> List[WlanConfig]:
|
||||
configs = []
|
||||
for node_id, config in self.wlan_configs.items():
|
||||
for canvas_node in self.canvas_nodes.values():
|
||||
if canvas_node.core_node.type != core_pb2.NodeType.WIRELESS_LAN:
|
||||
continue
|
||||
config = canvas_node.wlan_config
|
||||
config = {x: config[x].value for x in config}
|
||||
node_id = canvas_node.core_node.id
|
||||
wlan_config = WlanConfig(node_id=node_id, config=config)
|
||||
configs.append(wlan_config)
|
||||
return configs
|
||||
|
||||
def get_mobility_configs_proto(self) -> List[MobilityConfig]:
|
||||
configs = []
|
||||
for node_id, config in self.mobility_configs.items():
|
||||
for canvas_node in self.canvas_nodes.values():
|
||||
if canvas_node.core_node.type != core_pb2.NodeType.WIRELESS_LAN:
|
||||
continue
|
||||
config = canvas_node.mobility_config
|
||||
config = {x: config[x].value for x in config}
|
||||
node_id = canvas_node.core_node.id
|
||||
mobility_config = MobilityConfig(node_id=node_id, config=config)
|
||||
configs.append(mobility_config)
|
||||
return configs
|
||||
|
@ -995,28 +999,24 @@ class CoreClient:
|
|||
return self.client.node_command(self.session_id, node_id, self.observer).output
|
||||
|
||||
def get_wlan_config(self, node_id: int) -> Dict[str, common_pb2.ConfigOption]:
|
||||
config = self.wlan_configs.get(node_id)
|
||||
if not config:
|
||||
response = self.client.get_wlan_config(self.session_id, node_id)
|
||||
config = response.config
|
||||
response = self.client.get_wlan_config(self.session_id, node_id)
|
||||
config = response.config
|
||||
logging.debug(
|
||||
"get wlan configuration from node %s, result configuration: %s",
|
||||
node_id,
|
||||
config,
|
||||
)
|
||||
return config
|
||||
return dict(config)
|
||||
|
||||
def get_mobility_config(self, node_id: int) -> Dict[str, common_pb2.ConfigOption]:
|
||||
config = self.mobility_configs.get(node_id)
|
||||
if not config:
|
||||
response = self.client.get_mobility_config(self.session_id, node_id)
|
||||
config = response.config
|
||||
response = self.client.get_mobility_config(self.session_id, node_id)
|
||||
config = response.config
|
||||
logging.debug(
|
||||
"get mobility config from node %s, result configuration: %s",
|
||||
node_id,
|
||||
config,
|
||||
)
|
||||
return config
|
||||
return dict(config)
|
||||
|
||||
def get_emane_model_config(
|
||||
self, node_id: int, model: str, interface: int = None
|
||||
|
@ -1056,13 +1056,6 @@ class CoreClient:
|
|||
if dst_id not in self.file_configs:
|
||||
self.file_configs[dst_id] = {}
|
||||
self.file_configs[dst_id][key] = value
|
||||
elif node_type == core_pb2.NodeType.WIRELESS_LAN:
|
||||
config = self.wlan_configs.get(src_node.id)
|
||||
if config:
|
||||
self.wlan_configs[dst_id] = config
|
||||
config = self.mobility_configs.get(src_node.id)
|
||||
if config:
|
||||
self.mobility_configs[dst_id] = config
|
||||
|
||||
def service_been_modified(self, node_id: int) -> bool:
|
||||
return node_id in self.modified_service_nodes
|
||||
|
|
|
@ -108,7 +108,7 @@ class EmaneModelDialog(Dialog):
|
|||
def click_apply(self):
|
||||
self.config_frame.parse_config()
|
||||
key = (self.model, self.interface)
|
||||
self.canvas_node.emane_model_configs[key] = dict(self.config)
|
||||
self.canvas_node.emane_model_configs[key] = self.config
|
||||
self.destroy()
|
||||
|
||||
|
||||
|
|
|
@ -31,7 +31,9 @@ class MobilityConfigDialog(Dialog):
|
|||
self.config_frame = None
|
||||
self.has_error = False
|
||||
try:
|
||||
self.config = self.app.core.get_mobility_config(self.node.id)
|
||||
self.config = self.canvas_node.mobility_config
|
||||
if not self.config:
|
||||
self.config = self.app.core.get_mobility_config(self.node.id)
|
||||
self.draw()
|
||||
except grpc.RpcError as e:
|
||||
self.has_error = True
|
||||
|
@ -60,5 +62,5 @@ class MobilityConfigDialog(Dialog):
|
|||
|
||||
def click_apply(self):
|
||||
self.config_frame.parse_config()
|
||||
self.app.core.mobility_configs[self.node.id] = self.config
|
||||
self.canvas_node.mobility_config = self.config
|
||||
self.destroy()
|
||||
|
|
|
@ -48,8 +48,9 @@ class MobilityPlayer:
|
|||
self.dialog.show()
|
||||
|
||||
def handle_close(self):
|
||||
self.dialog.destroy()
|
||||
self.dialog = None
|
||||
if self.dialog:
|
||||
self.dialog.destroy()
|
||||
self.dialog = None
|
||||
|
||||
def set_play(self):
|
||||
self.state = MobilityAction.START
|
||||
|
|
|
@ -32,7 +32,9 @@ class WlanConfigDialog(Dialog):
|
|||
self.ranges = {}
|
||||
self.positive_int = self.app.master.register(self.validate_and_update)
|
||||
try:
|
||||
self.config = self.app.core.get_wlan_config(self.node.id)
|
||||
self.config = self.canvas_node.wlan_config
|
||||
if not self.config:
|
||||
self.config = self.app.core.get_wlan_config(self.node.id)
|
||||
self.init_draw_range()
|
||||
self.draw()
|
||||
except grpc.RpcError as e:
|
||||
|
@ -83,7 +85,7 @@ class WlanConfigDialog(Dialog):
|
|||
retrieve user's wlan configuration and store the new configuration values
|
||||
"""
|
||||
config = self.config_frame.parse_config()
|
||||
self.app.core.wlan_configs[self.node.id] = self.config
|
||||
self.canvas_node.wlan_config = self.config
|
||||
if self.app.core.is_runtime():
|
||||
session_id = self.app.core.session_id
|
||||
self.app.core.client.set_wlan_config(session_id, self.node.id, config)
|
||||
|
|
|
@ -305,7 +305,7 @@ class CanvasGraph(tk.Canvas):
|
|||
token = create_edge_token(canvas_node_one.id, canvas_node_two.id)
|
||||
|
||||
if link.type == core_pb2.LinkType.WIRELESS:
|
||||
self.add_wireless_edge(canvas_node_one, canvas_node_two)
|
||||
self.add_wireless_edge(canvas_node_one, canvas_node_two, link)
|
||||
else:
|
||||
if token not in self.edges:
|
||||
src_pos = (node_one.position.x, node_one.position.y)
|
||||
|
@ -352,6 +352,7 @@ class CanvasGraph(tk.Canvas):
|
|||
"""
|
||||
Convert window coordinate to canvas coordinate
|
||||
"""
|
||||
logging.info("event type: %s", type(event))
|
||||
x = self.canvasx(event.x)
|
||||
y = self.canvasy(event.y)
|
||||
return x, y
|
||||
|
@ -421,7 +422,7 @@ class CanvasGraph(tk.Canvas):
|
|||
self.mode = GraphMode.NODE
|
||||
self.selected = None
|
||||
|
||||
def handle_edge_release(self, event: tk.Event):
|
||||
def handle_edge_release(self, _event: tk.Event):
|
||||
edge = self.drawing_edge
|
||||
self.drawing_edge = None
|
||||
|
||||
|
@ -702,7 +703,7 @@ class CanvasGraph(tk.Canvas):
|
|||
else:
|
||||
self.hide_context()
|
||||
|
||||
def press_delete(self, event: tk.Event):
|
||||
def press_delete(self, _event: tk.Event):
|
||||
"""
|
||||
delete selected nodes and any data that relates to it
|
||||
"""
|
||||
|
@ -925,6 +926,8 @@ class CanvasGraph(tk.Canvas):
|
|||
|
||||
# copy configurations
|
||||
node.emane_model_configs = deepcopy(canvas_node.emane_model_configs)
|
||||
node.wlan_config = deepcopy(canvas_node.wlan_config)
|
||||
node.mobility_config = deepcopy(canvas_node.mobility_config)
|
||||
|
||||
# add new node to modified_service_nodes set if that set contains the
|
||||
# to_copy node
|
||||
|
|
|
@ -181,7 +181,6 @@ class ConfigFrame(ttk.Notebook):
|
|||
option.value = "0"
|
||||
else:
|
||||
option.value = config_value
|
||||
|
||||
return {x: self.config[x].value for x in self.config}
|
||||
|
||||
def set_values(self, config: Dict[str, str]) -> None:
|
||||
|
|
Loading…
Reference in a new issue