mirror of https://github.com/pvnis/srsRAN_4G.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
99 lines
2.2 KiB
C++
99 lines
2.2 KiB
C++
/**
|
|
*
|
|
* \section COPYRIGHT
|
|
*
|
|
* Copyright 2013-2021 Software Radio Systems Limited
|
|
*
|
|
* By using this file, you agree to the terms and conditions set
|
|
* forth in the LICENSE file which can be found at the top level of
|
|
* the distribution.
|
|
*
|
|
*/
|
|
|
|
#ifndef SRSRAN_RF_TIMESTAMP_H
|
|
#define SRSRAN_RF_TIMESTAMP_H
|
|
|
|
#include "srsran/interfaces/radio_interfaces.h"
|
|
|
|
namespace srsran {
|
|
|
|
/**
|
|
* Implemenation of the rf_buffer_interface for the current radio implementation which uses flat arrays.
|
|
* @see rf_buffer_interface
|
|
* @see radio
|
|
*
|
|
*/
|
|
class rf_timestamp_t : public rf_timestamp_interface
|
|
{
|
|
public:
|
|
/**
|
|
* Default constructor, all timestamps are zero by default
|
|
*/
|
|
rf_timestamp_t() = default;
|
|
|
|
/**
|
|
* Copy constructor
|
|
* @param other the other object to copy
|
|
*/
|
|
rf_timestamp_t(const rf_timestamp_t& other) { copy(other); }
|
|
|
|
/**
|
|
* Default destructor
|
|
*/
|
|
~rf_timestamp_t() = default;
|
|
|
|
/**
|
|
* Gets a timestamp by reference
|
|
* @return Given timestamp of the indicated device if the index is bounded, otherwise it returns the default timestamp
|
|
*/
|
|
const srsran_timestamp_t& get(uint32_t idx) const override
|
|
{
|
|
if (idx >= SRSRAN_MAX_CHANNELS) {
|
|
return default_ts;
|
|
}
|
|
|
|
return timestamps[idx];
|
|
}
|
|
|
|
/**
|
|
* Get the timestamp array pointer
|
|
* @return timestamp pointer with the value if the channel index is bounded. Otherwise, returns nullptr
|
|
*/
|
|
srsran_timestamp_t* get_ptr(uint32_t idx) override
|
|
{
|
|
if (idx >= SRSRAN_MAX_CHANNELS) {
|
|
return nullptr;
|
|
}
|
|
return ×tamps[idx];
|
|
}
|
|
|
|
/**
|
|
* Add a given amount of seconds to all the timestamps
|
|
* @param secs number of seconds
|
|
*/
|
|
void add(double secs) override
|
|
{
|
|
for (srsran_timestamp_t& ts : timestamps) {
|
|
srsran_timestamp_add(&ts, 0, secs);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Subtract a given amount of seconds to all the timestamps
|
|
* @param secs number of seconds
|
|
*/
|
|
void sub(double secs) override
|
|
{
|
|
for (srsran_timestamp_t& ts : timestamps) {
|
|
srsran_timestamp_sub(&ts, 0, secs);
|
|
}
|
|
}
|
|
|
|
private:
|
|
const srsran_timestamp_t default_ts = {};
|
|
std::array<srsran_timestamp_t, SRSRAN_MAX_CHANNELS> timestamps = {};
|
|
};
|
|
} // namespace srsran
|
|
|
|
#endif // SRSRAN_RF_TIMESTAMP_H
|