Minor aesthetic changes in intra measure class and changed scell_search test arguments

This commit is contained in:
Xavier Arteaga 2020-02-13 10:50:41 +01:00 committed by Xavier Arteaga
parent 344016ef0a
commit 6672f6df0f
3 changed files with 91 additions and 61 deletions

View File

@ -170,7 +170,18 @@ private:
internal_state state;
void run_thread() override;
/**
* Measurement process helper method. Encapusulates the neighbour cell measurement functionality
*/
void measure_proc();
/**
* Internal asynchronous low priority thread, waits for measure internal state to execute the measurement process. It
* stops when the internal state transitions to quit.
*/
void run_thread() override;
///< Internal Thread priority, low by default
const static int INTRA_FREQ_MEAS_PRIO = DEFAULT_PRIORITY + 5;
scell_recv scell = {};

View File

@ -140,79 +140,98 @@ void intra_measure::write(uint32_t tti, cf_t* data, uint32_t nsamples)
}
}
void intra_measure::run_thread()
void intra_measure::measure_proc()
{
std::set<uint32_t> cells_to_measure = {};
while (state.get_state() != internal_state::quit) {
if (state.get_state() == internal_state::measure) {
// Start measuring
active_pci_mutex.lock();
cells_to_measure = active_pci;
active_pci_mutex.unlock();
// Load cell list to measure
active_pci_mutex.lock();
cells_to_measure = active_pci;
active_pci_mutex.unlock();
// Read data from buffer and find cells in it
srslte_ringbuffer_read(&ring_buffer, search_buffer, intra_freq_meas_len_ms * current_sflen * sizeof(cf_t));
// Read data from buffer and find cells in it
srslte_ringbuffer_read(&ring_buffer, search_buffer, intra_freq_meas_len_ms * current_sflen * sizeof(cf_t));
// Go to receive before finishing, so new samples can be enqueued before the thread finishes
if (state.get_state() == internal_state::measure) {
// Prevents transition to wait if state has changed while reading the ring-buffer
state.set_state(internal_state::wait);
}
// Go to receive before finishing, so new samples can be enqueued before the thread finishes
if (state.get_state() == internal_state::measure) {
// Prevents transition to wait if state has changed while reading the ring-buffer
state.set_state(internal_state::wait);
}
// Detect new cells using PSS/SSS
std::set<uint32_t> detected_cells = scell.find_cells(search_buffer, serving_cell, intra_freq_meas_len_ms);
// Detect new cells using PSS/SSS
std::set<uint32_t> detected_cells = scell.find_cells(search_buffer, serving_cell, intra_freq_meas_len_ms);
// Add detected cells to the list of cells to measure
for (auto& c : detected_cells) {
cells_to_measure.insert(c);
}
// Add detected cells to the list of cells to measure
for (auto& c : detected_cells) {
cells_to_measure.insert(c);
}
// Initialise empty neighbour cell list
std::vector<rrc_interface_phy_lte::phy_meas_t> neighbour_cells = {};
// Initialise empty neighbour cell list
std::vector<rrc_interface_phy_lte::phy_meas_t> neighbour_cells = {};
// Use Cell Reference signal to measure cells in the time domain for all known active PCI
for (auto id : cells_to_measure) {
// Do not measure serving cell here since it's measured by workers
if (id == serving_cell.id) {
continue;
}
srslte_cell_t cell = serving_cell;
cell.id = id;
// Use Cell Reference signal to measure cells in the time domain for all known active PCI
for (auto id : cells_to_measure) {
// Do not measure serving cell here since it's measured by workers
if (id == serving_cell.id) {
continue;
}
srslte_cell_t cell = serving_cell;
cell.id = id;
srslte_refsignal_dl_sync_set_cell(&refsignal_dl_sync, cell);
srslte_refsignal_dl_sync_run(&refsignal_dl_sync, search_buffer, intra_freq_meas_len_ms * current_sflen);
srslte_refsignal_dl_sync_set_cell(&refsignal_dl_sync, cell);
srslte_refsignal_dl_sync_run(&refsignal_dl_sync, search_buffer, intra_freq_meas_len_ms * current_sflen);
if (refsignal_dl_sync.found) {
rrc_interface_phy_lte::phy_meas_t m = {};
m.pci = cell.id;
m.earfcn = current_earfcn;
m.rsrp = refsignal_dl_sync.rsrp_dBfs - rx_gain_offset_db;
m.rsrq = refsignal_dl_sync.rsrq_dB;
neighbour_cells.push_back(m);
if (refsignal_dl_sync.found) {
rrc_interface_phy_lte::phy_meas_t m = {};
m.pci = cell.id;
m.earfcn = current_earfcn;
m.rsrp = refsignal_dl_sync.rsrp_dBfs - rx_gain_offset_db;
m.rsrq = refsignal_dl_sync.rsrq_dB;
neighbour_cells.push_back(m);
Info("INTRA: Found neighbour cell: EARFCN=%d, PCI=%03d, RSRP=%5.1f dBm, RSRQ=%5.1f, peak_idx=%5d, "
"CFO=%+.1fHz\n",
m.earfcn,
m.pci,
m.rsrp,
m.rsrq,
refsignal_dl_sync.peak_index,
refsignal_dl_sync.cfo_Hz);
}
}
// Send measurements to RRC
if (not neighbour_cells.empty()) {
rrc->new_cell_meas(neighbour_cells);
}
meas_sync.increase();
} else if (state.get_state() != internal_state::quit) {
// Wait for changing state
state.wait_change();
Info("INTRA: Found neighbour cell: EARFCN=%d, PCI=%03d, RSRP=%5.1f dBm, RSRQ=%5.1f, peak_idx=%5d, "
"CFO=%+.1fHz\n",
m.earfcn,
m.pci,
m.rsrp,
m.rsrq,
refsignal_dl_sync.peak_index,
refsignal_dl_sync.cfo_Hz);
}
}
// Send measurements to RRC if any cell found
if (not neighbour_cells.empty()) {
rrc->new_cell_meas(neighbour_cells);
}
// Inform that measurement has finished
meas_sync.increase();
}
void intra_measure::run_thread()
{
bool quit = false;
do {
switch (state.get_state()) {
case internal_state::idle:
case internal_state::wait:
case internal_state::receive:
// Wait for a state change
state.wait_change();
break;
case internal_state::measure:
// Run the measurement process
measure_proc();
break;
case internal_state::quit:
// Quit loop
quit = true;
break;
}
} while (not quit);
}
} // namespace scell

View File

@ -59,4 +59,4 @@ target_link_libraries(scell_search_test
rrc_asn1
${CMAKE_THREAD_LIBS_INIT}
${Boost_LIBRARIES})
add_test(scell_search_test scell_search_test --duration=1 --phy_lib_log_level=0 --intra_meas_log_level=none --nof_enb=2 --cell.nof_prb=25)
add_test(scell_search_test scell_search_test --duration=5 --cell.nof_prb=6 --active_cell_list=2,3,4,5,6 --simulation_cell_list=1,2,3,4,5,6 --channel_period_s=30 --channel.hst.fd=750 --channel.delay_max=10000)