4from gi.repository 
import GooCanvas
 
   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
 
  122        """! Scan nodes function. 
  123        @param self The object pointer.
 
  124        @param viz The visualizer object
 
  127        for (sta_netdevice, viz_node, wifi_link) 
in self.
stations:
 
  133        for node 
in viz.nodes.values():
 
  134            ns3_node = ns.network.NodeList.GetNode(node.node_index)
 
  135            for devI 
in range(ns3_node.GetNDevices()):
 
  136                dev = ns3_node.GetDevice(devI)
 
  137                if not isinstance(dev, ns.wifi.WifiNetDevice):
 
  139                wifi_mac = dev.GetMac()
 
  140                if isinstance(wifi_mac, ns.wifi.StaWifiMac):
 
  141                    wifi_link = 
WifiLink(viz.links_group, node, dev)
 
  142                    self.
stations.append((dev, node, wifi_link))
 
  143                elif isinstance(wifi_mac, ns.wifi.ApWifiMac):
 
  144                    bssid = ns.network.Mac48Address.ConvertFrom(dev.GetAddress())
 
  150        """! Simulation Periodic Update function. 
  151        @param self The object pointer.
 
  152        @param viz The visualizer object
 
  155        for (sta_netdevice, viz_node, wifi_link) 
in self.
stations:
 
  156            if not sta_netdevice.IsLinkUp():
 
  157                wifi_link.set_ap(
None)
 
  159            bssid = str(sta_netdevice.GetMac().GetBssid())
 
  160            if bssid == 
'00:00:00:00:00:00':
 
  161                wifi_link.set_ap(
None)
 
  167        """! Update View function. 
  168        @param self The object pointer.
 
  169        @param viz The visualizer object
 
  172        for (dummy_sta_netdevice, dummy_viz_node, wifi_link) 
in self.
stations:
 
  173            if wifi_link 
is not None:
 
  174                wifi_link.update_points()
 
  179    viz.connect(
"simulation-periodic-update", link_monitor.simulation_periodic_update)
 
  180    viz.connect(
"update-view", link_monitor.update_view)
 
  181    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)
 
def transform_distance_canvas_to_simulation(d)