3from gi.repository
import GooCanvas
20 def __init__(self, parent_canvas_item, sta, dev):
21 """! Initialize function.
22 @param self The object pointer.
23 @param parent_canvas_item: parent canvas
24 @param sta The STA node
31 self.
canvas_item = GooCanvas.CanvasGroup(parent=parent_canvas_item)
34 visibility=GooCanvas.CanvasItemVisibility.HIDDEN)
37 stroke_color_rgba=0xC00000FF,
38 line_dash=GooCanvas.CanvasLineDash.newv([2.0, 2.0 ]))
48 @param self The object pointer.
54 if self.
node2 is not None:
55 self.
node2.remove_link(self)
57 if self.
node2 is None:
58 self.
canvas_item.set_property(
"visibility", GooCanvas.CanvasItemVisibility.HIDDEN)
60 self.
node2.add_link(self)
61 self.
canvas_item.set_property(
"visibility", GooCanvas.CanvasItemVisibility.VISIBLE)
65 """! Update points function.
66 @param self The object pointer.
69 if self.
node2 is None:
71 pos1_x, pos1_y = self.
node1.get_position()
72 pos2_x, pos2_y = self.
node2.get_position()
73 points = GooCanvas.CanvasPoints.new(2)
74 points.set_point(0, pos1_x, pos1_y)
75 points.set_point(1, pos2_x, pos2_y)
80 """! Destroy function.
81 @param self The object pointer.
89 """! Destroy function.
90 @param self The object pointer.
91 @param tooltip The tooltip.
94 pos1_x, pos1_y = self.node1.get_position()
95 pos2_x, pos2_y = self.node2.get_position()
98 d = transform_distance_canvas_to_simulation(math.sqrt(dx*dx + dy*dy))
99 mac = self.dev.GetMac()
100 tooltip.set_text(("WiFi link between STA Node %i and AP Node %i; distance=%.2f m.\n"
103 % (self.
node1.node_index, self.
node2.node_index, d,
104 mac.GetSsid(), mac.GetBssid()))
113 """! Initialize function.
114 @param self The object pointer.
115 @param dummy_viz A dummy visualizer
121 """! Scan nodes function.
122 @param self The object pointer.
123 @param viz The visualizer object
126 for (sta_netdevice, viz_node, wifi_link)
in self.
stations:
132 for node
in viz.nodes.values():
133 ns3_node = ns.network.NodeList.GetNode(node.node_index)
134 for devI
in range(ns3_node.GetNDevices()):
135 dev = ns3_node.GetDevice(devI)
136 if not isinstance(dev, ns.wifi.WifiNetDevice):
138 wifi_mac = dev.GetMac()
139 if isinstance(wifi_mac, ns.wifi.StaWifiMac):
140 wifi_link =
WifiLink(viz.links_group, node, dev)
141 self.
stations.append((dev, node, wifi_link))
142 elif isinstance(wifi_mac, ns.wifi.ApWifiMac):
143 bssid = ns.network.Mac48Address.ConvertFrom(dev.GetAddress())
149 """! Simulation Periodic Update function.
150 @param self The object pointer.
151 @param viz The visualizer object
154 for (sta_netdevice, viz_node, wifi_link)
in self.
stations:
155 if not sta_netdevice.IsLinkUp():
156 wifi_link.set_ap(
None)
158 bssid = str(sta_netdevice.GetMac().GetBssid())
159 if bssid ==
'00:00:00:00:00:00':
160 wifi_link.set_ap(
None)
166 """! Update View function.
167 @param self The object pointer.
168 @param viz The visualizer object
171 for (dummy_sta_netdevice, dummy_viz_node, wifi_link)
in self.
stations:
172 if wifi_link
is not None:
173 wifi_link.update_points()
178 viz.connect(
"simulation-periodic-update", link_monitor.simulation_periodic_update)
179 viz.connect(
"update-view", link_monitor.update_view)
180 viz.connect(
"topology-scanned", link_monitor.scan_nodes)
canvas_item
parent_canvas_item
def destroy(self)
Destroy function.
def update_points(self)
Update points function.
def tooltip_query(self, tooltip)
Destroy function.
invisible_line
invisible line
def set_ap(self, ap)
Set AP.
def __init__(self, parent_canvas_item, sta, dev)
Initialize function.
def scan_nodes(self, viz)
Scan nodes function.
def simulation_periodic_update(self, viz)
Simulation Periodic Update function.
def __init__(self, dummy_viz)
Initialize function.
access_points
bssid -> node
def update_view(self, viz)
Update View function.
stations
list of (sta_netdevice, viz_node, wifi_link)