summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVadim Yanitskiy <axilirator@gmail.com>2019-01-14 07:18:39 +0700
committerVadim Yanitskiy <axilirator@gmail.com>2019-01-14 23:52:31 +0000
commit71fee8639179beb6bce58f39cc98e014021c8340 (patch)
tree34e240da9c0186b8badd70754f457c1a3d511db4 /src
parent2986a318b12c26904f87f6da40c3dce852de7952 (diff)
trx_toolkit/fake_trx.py: move init code to __init__()
There should be no code in run() that does initialization, __init__() is the best place for this. This change allows to import the Application class from fake_trx.py, and run it from script (e.g. for testing). Change-Id: I84969630348a189d237cc98354e568421839a37b
Diffstat (limited to 'src')
-rwxr-xr-xsrc/target/trx_toolkit/fake_trx.py60
1 files changed, 30 insertions, 30 deletions
diff --git a/src/target/trx_toolkit/fake_trx.py b/src/target/trx_toolkit/fake_trx.py
index 0bf9266..0bed29d 100755
--- a/src/target/trx_toolkit/fake_trx.py
+++ b/src/target/trx_toolkit/fake_trx.py
@@ -275,6 +275,32 @@ class Application(ApplicationBase):
# List of all transceivers
self.trx_list = TRXList()
+ # Init shared clock generator
+ self.clck_gen = CLCKGen([])
+
+ # Power measurement emulation
+ # Noise: -120 .. -105
+ # BTS: -75 .. -50
+ self.fake_pm = FakePM(-120, -105, -75, -50)
+ self.fake_pm.trx_list = self.trx_list
+
+ # Init TRX instance for BTS
+ self.append_trx(self.argv.bts_addr, self.argv.bts_base_port)
+
+ # Init TRX instance for BB
+ self.append_trx(self.argv.bb_addr, self.argv.bb_base_port)
+
+ # Additional transceivers (optional)
+ if self.argv.trx_list is not None:
+ for trx_def in self.argv.trx_list:
+ (addr, port, idx) = trx_def
+ self.append_child_trx(addr, port, idx)
+
+ # Burst forwarding between transceivers
+ self.burst_fwd = BurstForwarder(self.trx_list)
+
+ log.info("Init complete")
+
def append_trx(self, remote_addr, base_port):
trx = FakeTRX(self.argv.trx_bind_addr, remote_addr, base_port,
clck_gen = self.clck_gen, pwr_meas = self.fake_pm)
@@ -301,42 +327,16 @@ class Application(ApplicationBase):
trx_parent.child_trx_list.add_trx(trx_child)
def run(self):
- # Init shared clock generator
- self.clck_gen = CLCKGen([])
-
- # Power measurement emulation
- # Noise: -120 .. -105
- # BTS: -75 .. -50
- self.fake_pm = FakePM(-120, -105, -75, -50)
- self.fake_pm.trx_list = self.trx_list
-
- # Init TRX instance for BTS
- self.append_trx(self.argv.bts_addr, self.argv.bts_base_port)
-
- # Init TRX instance for BB
- self.append_trx(self.argv.bb_addr, self.argv.bb_base_port)
-
- # Additional transceivers (optional)
- if self.argv.trx_list is not None:
- for trx_def in self.argv.trx_list:
- (addr, port, idx) = trx_def
- self.append_child_trx(addr, port, idx)
-
- # Burst forwarding between transceivers
- self.burst_fwd = BurstForwarder(self.trx_list)
-
# Compose list of to be monitored sockets
- self.sock_list = []
+ sock_list = []
for trx in self.trx_list:
- self.sock_list.append(trx.ctrl_if.sock)
- self.sock_list.append(trx.data_if.sock)
-
- log.info("Init complete")
+ sock_list.append(trx.ctrl_if.sock)
+ sock_list.append(trx.data_if.sock)
# Enter main loop
while True:
# Wait until we get any data on any socket
- r_event, _, _ = select.select(self.sock_list, [], [])
+ r_event, _, _ = select.select(sock_list, [], [])
# Iterate over all transceivers
for trx in self.trx_list: