4 from gi.repository
import GooCanvas
5 from visualizer.base import Link, transform_distance_canvas_to_simulation
21 def __init__(self, parent_canvas_item, sta, dev):
22 """! Initialize function. 23 @param self The object pointer. 24 @param parent_canvas_item: parent canvas 25 @param sta The STA node 32 self.
canvas_item = GooCanvas.CanvasGroup(parent=parent_canvas_item)
35 visibility=GooCanvas.CanvasItemVisibility.HIDDEN)
38 stroke_color_rgba=0xC00000FF,
39 line_dash=GooCanvas.CanvasLineDash.newv([2.0, 2.0 ]))
49 @param self The object pointer. 55 if self.
node2 is not None:
56 self.
node2.remove_link(self)
58 if self.
node2 is None:
59 self.
canvas_item.set_property(
"visibility", GooCanvas.CanvasItemVisibility.HIDDEN)
61 self.
node2.add_link(self)
62 self.
canvas_item.set_property(
"visibility", GooCanvas.CanvasItemVisibility.VISIBLE)
66 """! Update points function. 67 @param self The object pointer. 70 if self.
node2 is None:
72 pos1_x, pos1_y = self.
node1.get_position()
73 pos2_x, pos2_y = self.
node2.get_position()
74 points = GooCanvas.CanvasPoints.new(2)
75 points.set_point(0, pos1_x, pos1_y)
76 points.set_point(1, pos2_x, pos2_y)
81 """! Destroy function. 82 @param self The object pointer. 90 """! Destroy function. 91 @param self The object pointer. 92 @param tooltip The tooltip. 95 pos1_x, pos1_y = self.
node1.get_position()
96 pos2_x, pos2_y = self.
node2.get_position()
100 mac = self.
dev.GetMac()
101 tooltip.set_text((
"WiFi link between STA Node %i and AP Node %i; distance=%.2f m.\n" 104 % (self.
node1.node_index, self.
node2.node_index, d,
105 mac.GetSsid(), mac.GetBssid()))
114 """! Initialize function. 115 @param self The object pointer. 116 @param dummy_viz A dummy visualizer 123 """! Scan nodes function. 124 @param self The object pointer. 125 @param viz The visualizer object 128 for (sta_netdevice, viz_node, wifi_link)
in self.
stations:
134 for node
in viz.nodes.itervalues():
135 ns3_node = ns.network.NodeList.GetNode(node.node_index)
136 for devI
in range(ns3_node.GetNDevices()):
137 dev = ns3_node.GetDevice(devI)
138 if not isinstance(dev, ns.wifi.WifiNetDevice):
140 wifi_mac = dev.GetMac()
141 if isinstance(wifi_mac, ns.wifi.StaWifiMac):
142 wifi_link =
WifiLink(viz.links_group, node, dev)
143 self.
stations.append((dev, node, wifi_link))
144 elif isinstance(wifi_mac, ns.wifi.ApWifiMac):
145 bssid = ns.network.Mac48Address.ConvertFrom(dev.GetAddress())
151 """! Simulation Periodic Update function. 152 @param self The object pointer. 153 @param viz The visualizer object 156 for (sta_netdevice, viz_node, wifi_link)
in self.
stations:
157 if not sta_netdevice.IsLinkUp():
158 wifi_link.set_ap(
None)
160 bssid = str(sta_netdevice.GetMac().GetBssid())
161 if bssid ==
'00:00:00:00:00:00':
162 wifi_link.set_ap(
None)
168 """! Update View function. 169 @param self The object pointer. 170 @param viz The visualizer object 173 for (dummy_sta_netdevice, dummy_viz_node, wifi_link)
in self.
stations:
174 if wifi_link
is not None:
175 wifi_link.update_points()
180 viz.connect(
"simulation-periodic-update", link_monitor.simulation_periodic_update)
181 viz.connect(
"update-view", link_monitor.update_view)
182 viz.connect(
"topology-scanned", link_monitor.scan_nodes)
def tooltip_query(self, tooltip)
Destroy function.
def simulation_periodic_update(self, viz)
Simulation Periodic Update function.
def __init__(self, dummy_viz)
Initialize function.
def update_points(self)
Update points function.
invisible_line
invisible line
def update_view(self, viz)
Update View function.
canvas_item
parent_canvas_item
def set_ap(self, ap)
Set AP.
access_points
bssid -> node
def scan_nodes(self, viz)
Scan nodes function.
def __init__(self, parent_canvas_item, sta, dev)
Initialize function.
def destroy(self)
Destroy function.
stations
list of (sta_netdevice, viz_node, wifi_link)
def transform_distance_canvas_to_simulation(d)