Ignoring 'abstract' RMs upon ResourceFactory discover
[nepi.git] / src / nepi / resources / ns3 / ns3wifiphy.py
similarity index 58%
rename from src/nepi/resources/ns3/ns3device.py
rename to src/nepi/resources/ns3/ns3wifiphy.py
index 98d7202..a1f01b7 100644 (file)
 
 from nepi.execution.resource import clsinit_copy
 from nepi.resources.ns3.ns3base import NS3Base
-from nepi.resources.ns3.ns3channel import NS3Channel
 
 @clsinit_copy
-class NS3BaseNetDevice(NS3Base):
-    _rtype = "ns3::NetDevice"
+class NS3BaseWifiPhy(NS3Base):
+    _rtype = "abstract::ns3::WifiPhy"
 
     @property
-    def channel(self):
-        channels = self.get_connected(NS3BaseChannel.get_rtype())
-        if channels: return channels[0]
+    def device(self):
+        from nepi.resources.ns3.ns3device import NS3BaseNetDevice
+        devices = self.get_connected(NS3BaseNetDevice.get_rtype())
+        if devices: return devices[0]
         return None
 
     @property
     def others_to_wait(self):
         others = set()
-        node = self.node
-        if node: others.add(node)
-        
-        channel = self.channel
-        if channel: others.add(channel)
+        device = self.device
+        if device: others.add(device)
         return others
 
     def _connect_object(self):
-        node = self.node
-        if node and node.uuid not in self.connected:
-            self.simulator.invoke(node.uuid, "AddDevice", self.uuid)
-            self._connected.add(node.uuid)
+        device = self.device
+        if device and device.uuid not in self.connected:
+            self.simulator.invoke(device.uuid, "SetPhy", self.uuid)
+            self.simulator.invoke(self.uuid, "SetDevice", device.uuid)
+            self._connected.add(device.uuid)
 
-        channel = self.channel
-        if channel and channel.uuid not in self.connected:
-            self.simulator.invoke(self.uuid, "Attach", channel.uuid)
-            self._connected.add(channel.uuid)
+            node = device.node
+            if node:
+                self.simulator.invoke(self.uuid, "SetMobility", node.uuid)