Pau Espin Pedrol | 4109123 | 2020-10-05 19:23:38 +0200 | [diff] [blame] | 1 | # osmo_gsm_tester: class defining a RF emulation object implemented using SRS ENB stdin interface |
| 2 | # |
| 3 | # Copyright (C) 2020 by sysmocom - s.f.m.c. GmbH |
| 4 | # |
| 5 | # Author: Pau Espin Pedrol <pespin@sysmocom.de> |
| 6 | # |
| 7 | # This program is free software: you can redistribute it and/or modify |
| 8 | # it under the terms of the GNU General Public License as |
| 9 | # published by the Free Software Foundation, either version 3 of the |
| 10 | # License, or (at your option) any later version. |
| 11 | # |
| 12 | # This program is distributed in the hope that it will be useful, |
| 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | # GNU General Public License for more details. |
| 16 | # |
| 17 | # You should have received a copy of the GNU General Public License |
| 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 19 | |
Pau Espin Pedrol | 4109123 | 2020-10-05 19:23:38 +0200 | [diff] [blame] | 20 | from ..core import log |
Pau Espin Pedrol | 4109123 | 2020-10-05 19:23:38 +0200 | [diff] [blame] | 21 | from .rfemu import RFemulation |
Pau Espin Pedrol | fbb8611 | 2020-10-16 16:55:23 +0200 | [diff] [blame] | 22 | from .gnuradio_zmq_broker import GrBroker |
Pau Espin Pedrol | 4109123 | 2020-10-05 19:23:38 +0200 | [diff] [blame] | 23 | |
| 24 | class RFemulationGnuradioZmq(RFemulation): |
| 25 | ############## |
| 26 | # PROTECTED |
| 27 | ############## |
| 28 | def __init__(self, conf): |
| 29 | super().__init__(conf, 'gnuradio_zmq') |
| 30 | self.broker = None |
| 31 | self.ctrl_port = 5005 |
| 32 | self.cell_id = int(conf.get('cell_id')) |
| 33 | if self.cell_id is None: |
| 34 | raise log.Error('No "cell_id" attribute provided in rfemu conf!') |
| 35 | self.enb = conf.get('enb') |
| 36 | if self.enb is None: |
| 37 | raise log.Error('No "srsenb" attribute provided in rfemu conf!') |
| 38 | self.set_name('%s_%s_%d' % (self.name(), self.enb.name(), self.cell_id)) |
| 39 | self.testenv = self.enb.testenv |
| 40 | self.configure() |
| 41 | |
| 42 | def __del__(self): |
| 43 | if self.broker: |
| 44 | self.broker.unref() |
| 45 | self.broker = None |
| 46 | self.enb = None |
| 47 | self.testenv = None |
| 48 | |
| 49 | def configure(self): |
| 50 | self.broker = GrBroker.ref() |
| 51 | |
| 52 | ############################# |
| 53 | # PUBLIC (test API included) |
| 54 | ############################# |
| 55 | def set_attenuation(self, db): |
| 56 | for cell in self.enb.gen_conf['enb']['cell_list']: |
| 57 | if int(cell['cell_id']) == self.cell_id: |
Andre Puschmann | d5579fa | 2020-10-15 16:40:21 +0200 | [diff] [blame] | 58 | # convert negative dB to amplitude |
| 59 | amp = pow(10, -db/20.0) |
| 60 | self.broker.cmd_set_relative_gain_on_local_port(cell['zmq_enb_peer_port'], amp) |
Pau Espin Pedrol | 4109123 | 2020-10-05 19:23:38 +0200 | [diff] [blame] | 61 | break |
| 62 | |
| 63 | def get_max_attenuation(self): |
Andre Puschmann | d5579fa | 2020-10-15 16:40:21 +0200 | [diff] [blame] | 64 | return 200 |
Pau Espin Pedrol | 4109123 | 2020-10-05 19:23:38 +0200 | [diff] [blame] | 65 | |
| 66 | # vim: expandtab tabstop=4 shiftwidth=4 |