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
4 years ago
|
/**
|
||
5 years ago
|
*
|
||
4 years ago
|
* \section COPYRIGHT
|
||
5 years ago
|
*
|
||
4 years ago
|
* Copyright 2013-2021 Software Radio Systems Limited
|
||
5 years ago
|
*
|
||
4 years ago
|
* 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.
|
||
5 years ago
|
*
|
||
|
*/
|
||
|
|
||
4 years ago
|
#ifndef SRSRAN_RF_TIMESTAMP_H
|
||
|
#define SRSRAN_RF_TIMESTAMP_H
|
||
5 years ago
|
|
||
4 years ago
|
#include "srsran/interfaces/radio_interfaces.h"
|
||
5 years ago
|
|
||
4 years ago
|
namespace srsran {
|
||
5 years ago
|
|
||
|
/**
|
||
|
* 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
|
||
|
*/
|
||
4 years ago
|
const srsran_timestamp_t& get(uint32_t idx) const override
|
||
5 years ago
|
{
|
||
4 years ago
|
if (idx >= SRSRAN_MAX_CHANNELS) {
|
||
5 years ago
|
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
|
||
|
*/
|
||
4 years ago
|
srsran_timestamp_t* get_ptr(uint32_t idx) override
|
||
5 years ago
|
{
|
||
4 years ago
|
if (idx >= SRSRAN_MAX_CHANNELS) {
|
||
5 years ago
|
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
|
||
|
{
|
||
4 years ago
|
for (srsran_timestamp_t& ts : timestamps) {
|
||
|
srsran_timestamp_add(&ts, 0, secs);
|
||
5 years ago
|
}
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Subtract a given amount of seconds to all the timestamps
|
||
|
* @param secs number of seconds
|
||
|
*/
|
||
|
void sub(double secs) override
|
||
|
{
|
||
4 years ago
|
for (srsran_timestamp_t& ts : timestamps) {
|
||
|
srsran_timestamp_sub(&ts, 0, secs);
|
||
5 years ago
|
}
|
||
|
}
|
||
|
|
||
|
private:
|
||
4 years ago
|
const srsran_timestamp_t default_ts = {};
|
||
|
std::array<srsran_timestamp_t, SRSRAN_MAX_CHANNELS> timestamps = {};
|
||
5 years ago
|
};
|
||
4 years ago
|
} // namespace srsran
|
||
5 years ago
|
|
||
4 years ago
|
#endif // SRSRAN_RF_TIMESTAMP_H
|