applied the except and raise fixers to the master branch to close the gap with py3
[nepi.git] / src / nepi / resources / ns3 / ns3fdnetdevice.py
1 #
2 #    NEPI, a framework to manage network experiments
3 #    Copyright (C) 2014 INRIA
4 #
5 #    This program is free software: you can redistribute it and/or modify
6 #    it under the terms of the GNU General Public License version 2 as
7 #    published by the Free Software Foundation;
8 #
9 #    This program is distributed in the hope that it will be useful,
10 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
11 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 #    GNU General Public License for more details.
13 #
14 #    You should have received a copy of the GNU General Public License
15 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 #
17 # Author: Alina Quereilhac <alina.quereilhac@inria.fr>
18
19 from nepi.execution.resource import clsinit_copy
20 from nepi.resources.ns3.ns3netdevice import NS3BaseNetDevice
21
22 @clsinit_copy
23 class NS3BaseFdNetDevice(NS3BaseNetDevice):
24     _rtype = "abstract::ns3::FdNetDevice"
25
26     @property
27     def _rms_to_wait(self):
28         rms = set([self.node])
29         return rms
30
31     def _configure_mac_address(self):
32         # The wifimac is the one responsible for
33         # configuring the MAC address
34         pass
35
36     def _connect_object(self):
37         node = self.node
38         if node and node.uuid not in self.connected:
39             self.simulation.invoke(node.uuid, "AddDevice", self.uuid)
40             self._connected.add(node.uuid)
41
42     def _instantiate_object(self):
43         """ just validate that the simulator is in real time
44         mode, otherwise it is not going to work
45         """
46
47         mode = self.simulation.get("simulatorImplementationType")
48         if mode != "ns3::RealtimeSimulatorImpl":
49             msg = "The simulation must run in real time!!"
50             self.error(msg)
51             raise RuntimeError(msg)
52         
53         super(NS3BaseFdNetDevice, self)._instantiate_object()
54
55     def recv_fd(self):
56         address = self.simulation.invoke(self.uuid, "recvFD")
57         return address
58