Andre Puschmann | f14ff81 | 2020-06-19 15:47:32 +0200 | [diff] [blame] | 1 | # osmo_gsm_tester: common methods shared among srsLTE components |
| 2 | # |
| 3 | # Copyright (C) 2020 by Software Radio Systems Ltd |
| 4 | # |
| 5 | # Author: Andre Puschmann <andre@softwareradiosystems.com> |
| 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 | |
| 20 | from ..core import log |
| 21 | |
| 22 | class srslte_common(): # don't inherit from log.Origin here but instead use .name() from whoever inherits from us |
| 23 | |
| 24 | def __init__(self): |
| 25 | self.log_file = None |
| 26 | self.process = None |
| 27 | self.metrics_file = None |
| 28 | |
| 29 | def get_kpis(self): |
| 30 | ''' Use the srsLTE KPI analyzer module (part of srsLTE.git) if available to collect KPIs ''' |
| 31 | kpis = {} |
| 32 | try: |
| 33 | # Please make sure the srsLTE scripts folder is included in your PYTHONPATH env variable |
| 34 | from kpi_analyzer import kpi_analyzer |
| 35 | analyzer = kpi_analyzer(self.name()) |
| 36 | if self.log_file is not None: |
| 37 | kpis["log_" + self.name()] = analyzer.get_kpi_from_logfile(self.log_file) |
| 38 | if self.process.get_output_file('stdout') is not None: |
| 39 | kpis["stdout_" + self.name()] = analyzer.get_kpi_from_stdout(self.process.get_output_file('stdout')) |
| 40 | if self.metrics_file is not None: |
| 41 | kpis["csv_" + self.name()] = analyzer.get_kpi_from_csv(self.metrics_file) |
| 42 | except ImportError: |
| 43 | self.log("Can't load KPI analyzer module.") |
| 44 | |
| 45 | return kpis |