Piotr Krysik | 902f4eb | 2017-09-19 08:04:33 +0200 | [diff] [blame] | 1 | #!/usr/bin/env python2 |
| 2 | # -*- coding: utf-8 -*- |
| 3 | |
| 4 | # Virtual Um-interface (fake transceiver) |
| 5 | # Power measurement emulation for BB |
| 6 | # |
| 7 | # (C) 2017 by Vadim Yanitskiy <axilirator@gmail.com> |
| 8 | # |
| 9 | # All Rights Reserved |
| 10 | # |
| 11 | # This program is free software; you can redistribute it and/or modify |
| 12 | # it under the terms of the GNU General Public License as published by |
| 13 | # the Free Software Foundation; either version 2 of the License, or |
| 14 | # (at your option) any later version. |
| 15 | # |
| 16 | # This program is distributed in the hope that it will be useful, |
| 17 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 18 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 19 | # GNU General Public License for more details. |
| 20 | # |
| 21 | # You should have received a copy of the GNU General Public License along |
| 22 | # with this program; if not, write to the Free Software Foundation, Inc., |
| 23 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 24 | |
| 25 | from random import randint |
| 26 | |
Vadim Yanitskiy | 873e44e | 2017-10-17 06:52:01 +0700 | [diff] [blame] | 27 | class fake_pm: |
Piotr Krysik | 902f4eb | 2017-09-19 08:04:33 +0200 | [diff] [blame] | 28 | # Freq. list for good power level |
| 29 | bts_list = [] |
| 30 | |
| 31 | def __init__(self, noise_min, noise_max, bts_min, bts_max): |
| 32 | # Save power level ranges |
| 33 | self.noise_min = noise_min |
| 34 | self.noise_max = noise_max |
| 35 | self.bts_min = bts_min |
| 36 | self.bts_max = bts_max |
| 37 | |
| 38 | def measure(self, bts): |
| 39 | if bts in self.bts_list: |
| 40 | return randint(self.bts_min, self.bts_max) |
| 41 | else: |
| 42 | return randint(self.noise_min, self.noise_max) |
| 43 | |
| 44 | def update_bts_list(self, new_list): |
| 45 | self.bts_list = new_list |
| 46 | |
| 47 | def add_bts_list(self, add_list): |
| 48 | self.bts_list += add_list |
| 49 | |
| 50 | def del_bts_list(self, del_list): |
| 51 | for item in del_list: |
| 52 | if item in self.bts_list: |
| 53 | self.bts_list.remove(item) |