kirr has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmocom-bb/+/40069?usp=email )
Change subject: trx_toolkit/_fake_trx: Move constants out of FakeTRX class ......................................................................
trx_toolkit/_fake_trx: Move constants out of FakeTRX class
Accessing those constants via either self.CONSTANT, or FakeTRX.CONSTANT always do dict lookup on FakeTRX.__dict__ and there is no way to change that even with switching to cdef class. Dict lookups are slow.
-> Fix that with moving constants to be module-level cdef globals which are now accessed statically and quickly.
Change-Id: I0f1fa68f69438a75a69aa3cbe1e316375b58b8cc --- M src/target/trx_toolkit/_fake_trx.pyx 1 file changed, 21 insertions(+), 21 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/69/40069/1
diff --git a/src/target/trx_toolkit/_fake_trx.pyx b/src/target/trx_toolkit/_fake_trx.pyx index 7c0fd35..c14895b 100644 --- a/src/target/trx_toolkit/_fake_trx.pyx +++ b/src/target/trx_toolkit/_fake_trx.pyx @@ -29,6 +29,18 @@ from gsm_shared import *
+cdef int NOMINAL_TX_POWER_DEFAULT = 50 # dBm +cdef int TX_ATT_DEFAULT = 0 # dB +cdef int PATH_LOSS_DEFAULT = 110 # dB + +cdef int TOA256_BASE_DEFAULT = 0 +cdef int CI_BASE_DEFAULT = 90 + +# Default values for NOPE / IDLE indications +cdef int TOA256_NOISE_DEFAULT = 0 +cdef int RSSI_NOISE_DEFAULT = -110 +cdef int CI_NOISE_DEFAULT = -30 + class FakeTRX(Transceiver): """ Fake transceiver with RF path (burst loss, RSSI, TA, ToA) simulation.
@@ -94,18 +106,6 @@
"""
- NOMINAL_TX_POWER_DEFAULT = 50 # dBm - TX_ATT_DEFAULT = 0 # dB - PATH_LOSS_DEFAULT = 110 # dB - - TOA256_BASE_DEFAULT = 0 - CI_BASE_DEFAULT = 90 - - # Default values for NOPE / IDLE indications - TOA256_NOISE_DEFAULT = 0 - RSSI_NOISE_DEFAULT = -110 - CI_NOISE_DEFAULT = -30 - def __init__(self, *trx_args, **trx_kwargs): Transceiver.__init__(self, *trx_args, **trx_kwargs)
@@ -114,11 +114,11 @@ self.fake_rssi_enabled = False
# Actual ToA, RSSI, C/I, TA values - self.tx_power_base = self.NOMINAL_TX_POWER_DEFAULT - self.tx_att_base = self.TX_ATT_DEFAULT - self.toa256_base = self.TOA256_BASE_DEFAULT - self.rssi_base = self.NOMINAL_TX_POWER_DEFAULT - self.TX_ATT_DEFAULT - self.PATH_LOSS_DEFAULT - self.ci_base = self.CI_BASE_DEFAULT + self.tx_power_base = NOMINAL_TX_POWER_DEFAULT + self.tx_att_base = TX_ATT_DEFAULT + self.toa256_base = TOA256_BASE_DEFAULT + self.rssi_base = NOMINAL_TX_POWER_DEFAULT - TX_ATT_DEFAULT - PATH_LOSS_DEFAULT + self.ci_base = CI_BASE_DEFAULT self.ta = 0
# ToA, RSSI, C/I randomization thresholds @@ -218,9 +218,9 @@ msg.burst = None # burst bits are omited
# TODO: shoud we make these values configurable? - msg.toa256 = self.TOA256_NOISE_DEFAULT - msg.rssi = self.RSSI_NOISE_DEFAULT - msg.ci = self.CI_NOISE_DEFAULT + msg.toa256 = TOA256_NOISE_DEFAULT + msg.rssi = RSSI_NOISE_DEFAULT + msg.ci = CI_NOISE_DEFAULT
self.data_if.send_msg(msg) return @@ -230,7 +230,7 @@
# Apply RSSI based on transmitter: if not self.fake_rssi_enabled: - msg.rssi = src_trx.tx_power - src_msg.pwr - self.PATH_LOSS_DEFAULT + msg.rssi = src_trx.tx_power - src_msg.pwr - PATH_LOSS_DEFAULT else: # Apply fake RSSI msg.rssi = self.rssi