trx_toolkit: use **kwargs in Transceiver.__init__()
Change-Id: I65e85a2dc99e81e96d1b31b6bda5010b044b041d
This commit is contained in:
parent
8144470129
commit
f6aada5f5f
|
@ -406,34 +406,31 @@ class Application(ApplicationBase):
|
|||
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, name = "BTS")
|
||||
self.append_trx(self.argv.bts_addr, self.argv.bts_base_port, name = "BTS")
|
||||
|
||||
# Init TRX instance for BB
|
||||
self.append_trx(self.argv.bb_addr,
|
||||
self.argv.bb_base_port, name = "MS")
|
||||
self.append_trx(self.argv.bb_addr, self.argv.bb_base_port, name = "MS")
|
||||
|
||||
# Additional transceivers (optional)
|
||||
if self.argv.trx_list is not None:
|
||||
for trx_def in self.argv.trx_list:
|
||||
(name, addr, port, idx) = trx_def
|
||||
self.append_child_trx(addr, port, idx, name)
|
||||
self.append_child_trx(addr, port, name = name, child_idx = idx)
|
||||
|
||||
# Burst forwarding between transceivers
|
||||
self.burst_fwd = BurstForwarder(self.trx_list.trx_list)
|
||||
|
||||
log.info("Init complete")
|
||||
|
||||
def append_trx(self, remote_addr, base_port, name = None):
|
||||
def append_trx(self, remote_addr, base_port, **kwargs):
|
||||
trx = FakeTRX(self.argv.trx_bind_addr, remote_addr, base_port,
|
||||
clck_gen = self.clck_gen, pwr_meas = self.fake_pm,
|
||||
name = name)
|
||||
clck_gen = self.clck_gen, pwr_meas = self.fake_pm, **kwargs)
|
||||
self.trx_list.add_trx(trx)
|
||||
|
||||
def append_child_trx(self, remote_addr, base_port, child_idx, name = None):
|
||||
# Index 0 corresponds to the first transceiver
|
||||
if child_idx == 0:
|
||||
self.append_trx(remote_addr, base_port, name)
|
||||
def append_child_trx(self, remote_addr, base_port, **kwargs):
|
||||
child_idx = kwargs.get("child_idx", 0)
|
||||
if child_idx == 0: # Index 0 indicates parent transceiver
|
||||
self.append_trx(remote_addr, base_port, **kwargs)
|
||||
return
|
||||
|
||||
# Find 'parent' transceiver for a new child
|
||||
|
@ -444,7 +441,7 @@ class Application(ApplicationBase):
|
|||
|
||||
# Allocate a new child
|
||||
trx_child = FakeTRX(self.argv.trx_bind_addr, remote_addr, base_port,
|
||||
child_idx = child_idx, pwr_meas = self.fake_pm, name = name)
|
||||
pwr_meas = self.fake_pm, **kwargs)
|
||||
self.trx_list.add_trx(trx_child)
|
||||
|
||||
# Link a new 'child' with its 'parent'
|
||||
|
|
|
@ -120,42 +120,41 @@ class Transceiver:
|
|||
|
||||
"""
|
||||
|
||||
def __init__(self, bind_addr, remote_addr, base_port, name = None,
|
||||
child_idx = 0, clck_gen = None, pwr_meas = None):
|
||||
def __init__(self, bind_addr, remote_addr, base_port, **kwargs):
|
||||
# Connection info
|
||||
self.remote_addr = remote_addr
|
||||
self.bind_addr = bind_addr
|
||||
self.base_port = base_port
|
||||
self.child_idx = child_idx
|
||||
self.child_idx = kwargs.get("child_idx", 0)
|
||||
|
||||
# Meta info
|
||||
self.name = name
|
||||
self.name = kwargs.get("name", None)
|
||||
|
||||
log.info("Init transceiver '%s'" % self)
|
||||
|
||||
# Child transceiver cannot have its own clock
|
||||
if clck_gen is not None and child_idx > 0:
|
||||
self.clck_gen = kwargs.get("clck_gen", None)
|
||||
if self.clck_gen is not None and self.child_idx > 0:
|
||||
raise TypeError("Child transceiver cannot have its own clock")
|
||||
|
||||
# Init DATA interface
|
||||
self.data_if = DATAInterface(
|
||||
remote_addr, base_port + child_idx * 2 + 102,
|
||||
bind_addr, base_port + child_idx * 2 + 2)
|
||||
remote_addr, base_port + self.child_idx * 2 + 102,
|
||||
bind_addr, base_port + self.child_idx * 2 + 2)
|
||||
|
||||
# Init CTRL interface
|
||||
self.ctrl_if = CTRLInterfaceTRX(self,
|
||||
remote_addr, base_port + child_idx * 2 + 101,
|
||||
bind_addr, base_port + child_idx * 2 + 1)
|
||||
remote_addr, base_port + self.child_idx * 2 + 101,
|
||||
bind_addr, base_port + self.child_idx * 2 + 1)
|
||||
|
||||
# Init optional CLCK interface
|
||||
self.clck_gen = clck_gen
|
||||
if clck_gen is not None:
|
||||
if self.clck_gen is not None:
|
||||
self.clck_if = UDPLink(
|
||||
remote_addr, base_port + 100,
|
||||
bind_addr, base_port)
|
||||
|
||||
# Optional Power Measurement interface
|
||||
self.pwr_meas = pwr_meas
|
||||
self.pwr_meas = kwargs.get("pwr_meas", None)
|
||||
|
||||
# Internal state
|
||||
self.running = False
|
||||
|
|
Loading…
Reference in New Issue