add ue_lte_phy_base and move logger out of UE class

This commit is contained in:
Andre Puschmann 2019-05-22 11:26:24 +02:00
parent 58b09c8677
commit af8564e376
7 changed files with 84 additions and 21 deletions

View File

@ -33,14 +33,14 @@
#include "srslte/interfaces/ue_interfaces.h"
#include "srslte/radio/radio.h"
#include "srslte/srslte.h"
#include "srsue/hdr/phy/ue_phy_base.h"
#include "srsue/hdr/phy/ue_lte_phy_base.h"
#include "sync.h"
namespace srsue {
typedef _Complex float cf_t;
class phy : public ue_phy_base, public phy_interface_stack_lte, public phy_interface_radio, public thread
class phy : public ue_lte_phy_base, public thread
{
public:
phy();

View File

@ -0,0 +1,60 @@
/*
* Copyright 2013-2019 Software Radio Systems Limited
*
* This file is part of srsLTE.
*
* srsLTE is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
* srsLTE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* A copy of the GNU Affero General Public License can be found in
* the LICENSE file in the top-level directory of this distribution
* and at http://www.gnu.org/licenses/.
*
*/
/******************************************************************************
* File: ue_lte_phy_base.h
* Description: Base class for UE LTE PHYs.
*****************************************************************************/
#ifndef SRSUE_UE_LTE_PHY_BASE_H
#define SRSUE_UE_LTE_PHY_BASE_H
#include "srsue/hdr/phy/ue_phy_base.h"
namespace srsue {
class ue_lte_phy_base : public ue_phy_base, public phy_interface_stack_lte, public phy_interface_radio
{
public:
ue_lte_phy_base(){};
virtual ~ue_lte_phy_base(){};
virtual std::string get_type() = 0;
virtual int init(const phy_args_t& args_, srslte::logger* logger_) = 0;
virtual int init(const phy_args_t& args_,
srslte::logger* logger_,
stack_interface_phy_lte* stack_,
radio_interface_phy* radio_) = 0;
virtual void stop() = 0;
virtual void set_earfcn(std::vector<uint32_t> earfcns) = 0;
virtual void force_freq(float dl_freq, float ul_freq) = 0;
virtual void wait_initialize() = 0;
virtual void start_plot() = 0;
virtual void get_metrics(phy_metrics_t* m) = 0;
};
} // namespace srsue
#endif // SRSUE_UE_LTE_PHY_BASE_H

View File

@ -43,7 +43,8 @@ public:
virtual std::string get_type() = 0;
virtual int init(const phy_args_t& args_, srslte::logger* logger_) = 0;
virtual int init(const phy_args_t& args_, srslte::logger* logger_) = 0;
virtual void stop() = 0;
virtual void set_earfcn(std::vector<uint32_t> earfcns) = 0;

View File

@ -94,7 +94,7 @@ public:
ue();
~ue();
int init(const all_args_t& args_);
int init(const all_args_t& args_, srslte::logger* logger_);
void stop();
bool switch_on();
bool switch_off();
@ -113,13 +113,11 @@ private:
std::unique_ptr<ue_stack_base> stack;
// Generic logger members
srslte::logger_stdout logger_stdout;
srslte::logger_file logger_file;
srslte::logger *logger;
srslte::logger* logger = nullptr;
srslte::log_filter log; // Own logger for UE
all_args_t args;
srslte::byte_buffer_pool* pool;
srslte::byte_buffer_pool* pool = nullptr;
// Helper functions
int parse_args(const all_args_t& args); // parse and validate arguments

View File

@ -49,8 +49,6 @@ if (RPATH)
set_target_properties(srsue PROPERTIES INSTALL_RPATH ".")
endif (RPATH)
install(TARGETS srsue DESTINATION ${RUNTIME_DIR})
########################################################################
# Option to run command after build (useful for remote builds)
########################################################################

View File

@ -491,9 +491,21 @@ int main(int argc, char* argv[])
all_args_t args = {};
parse_args(&args, argc, argv);
srslte::logger_stdout logger_stdout;
srslte::logger_file logger_file;
// Setup logging
srslte::logger* logger = nullptr;
if (!args.log.filename.compare("stdout")) {
logger = &logger_stdout;
} else {
logger_file.init(args.log.filename, args.log.file_max_size);
logger = &logger_file;
}
// Create UE instance
srsue::ue ue;
if (ue.init(args)) {
if (ue.init(args, logger)) {
ue.stop();
return SRSLTE_ERROR;
}

View File

@ -55,21 +55,15 @@ ue::~ue()
srslte_dft_exit();
}
int ue::init(const all_args_t& args_)
int ue::init(const all_args_t& args_, srslte::logger* logger_)
{
// Setup logging
if (!args_.log.filename.compare("stdout")) {
logger = &logger_stdout;
} else {
logger_file.init(args_.log.filename, args_.log.file_max_size);
logger_file.log("\n\n");
logger_file.log(get_build_string().c_str());
logger = &logger_file;
}
logger = logger_;
// Init UE log
log.init("UE ", logger);
log.set_level(srslte::LOG_LEVEL_INFO);
log.info("\n\n");
log.info("%s\n", get_build_string().c_str());
// Validate arguments
if (parse_args(args_)) {