Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@ serde_json = "1.0.116"
serde_libconfig = "0.0.2"
serde_yaml = "0.9.34"
strum_macros = "0.26.2"
tempfile = "3.14.0"
tokio = { version = "1.37.0", features = ["full", "sync"] }
2 changes: 1 addition & 1 deletion src/logger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ impl Logger {
return sender;
}
}
return self.tx_vec.last().unwrap();
self.tx_vec.last().unwrap()
}

pub fn set_base_dir(new_base_dir: String) {
Expand Down
2 changes: 1 addition & 1 deletion src/logic/model_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ fn calculate_pbe_cc_capacity(
/*
* Determine the fair share badnwidth c_p (physical layer) and c_t (transport layer)
* */
let p_alloc_rnti_suggested: u64 = p_alloc_rnti + ((p_idle + nof_rnti_shared - 1) / nof_rnti_shared);
let p_alloc_rnti_suggested: u64 = p_alloc_rnti + p_idle.div_ceil(nof_rnti_shared);
let c_p: u64 = (((r_w * p_alloc_rnti_suggested) as f64) / (nof_dci as f64)) as u64;
let c_t = translate_physcial_to_transport_simple(c_p);

Expand Down
64 changes: 53 additions & 11 deletions src/logic/ngscope_controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ use crate::logic::{
CHANNEL_SYNC_SIZE, DEFAULT_WORKER_SLEEP_MS, DEFAULT_WORKER_SLEEP_US,
};
use crate::ngscope;
use crate::ngscope::config::NgScopeConfig;
use crate::ngscope::config::{NgScopeConfig, NgScopeConfigRfDev};
use crate::ngscope::types::{Message, NgScopeCellDci};
use crate::ngscope::{
ngscope_validate_server_check, ngscope_validate_server_send_initial, start_ngscope,
stop_ngscope,
};
use crate::parse::{Arguments, FlattenedNgScopeArgs};
use crate::parse::{Arguments, FlattenedNgScopeArgs, FlattenedNgScopeSdrConfigArgs};
use crate::util::{determine_process_id, is_debug, print_debug, print_info};

const WAIT_FOR_TRIGGER_NGSCOPE_RESPONE_MS: u64 = 500;
Expand Down Expand Up @@ -94,9 +94,6 @@ fn run(run_args: &mut RunArgs, run_args_mov: RunArgsMovables) -> Result<()> {

let ng_args = FlattenedNgScopeArgs::from_unflattened(app_args.clone().ngscope.unwrap())?;
let mut ng_process_option: Option<Child> = None;
let ngscope_config = NgScopeConfig {
..Default::default()
};

let (tx_dci_thread, rx_main_thread) = sync_channel::<LocalDciState>(CHANNEL_SYNC_SIZE);
let (tx_main_thread, rx_dci_thread) = sync_channel::<LocalDciState>(CHANNEL_SYNC_SIZE);
Expand All @@ -123,7 +120,7 @@ fn run(run_args: &mut RunArgs, run_args_mov: RunArgsMovables) -> Result<()> {

match ngcontrol_state {
NgControlState::CheckingCellInfo => {
ngcontrol_state = handle_cell_update(rx_cell_info, &ngscope_config)?;
ngcontrol_state = handle_cell_update(rx_cell_info, &ng_args.ng_sdr_config)?;
}
NgControlState::TriggerListenDci => {
tx_dci_thread.send(LocalDciState::SendInitial)?;
Expand Down Expand Up @@ -233,18 +230,15 @@ fn handle_start_ngscope(

fn handle_cell_update(
rx_cell_info: &mut BusReader<MessageCellInfo>,
ng_conf: &NgScopeConfig,
ng_sdr_config: &FlattenedNgScopeSdrConfigArgs,
) -> Result<NgControlState> {
match check_cell_update(rx_cell_info)? {
Some(cell_info) => {
print_info(&format!("[ngcontrol] cell_info: {:#?}", cell_info));
if cell_info.cells.is_empty() {
return Ok(NgControlState::StopNgScope);
}
// TODO: Handle multi cell
let mut new_conf = ng_conf.clone();
new_conf.rf_config0.as_mut().unwrap().rf_freq =
cell_info.cells.first().unwrap().frequency as i64;
let new_conf = NgScopeConfig::from_cell(ng_sdr_config, &cell_info)?;
Ok(NgControlState::StartNgScope(Box::new(new_conf)))
}
_ => Ok(NgControlState::CheckingCellInfo),
Expand Down Expand Up @@ -476,3 +470,51 @@ fn check_cell_update(rx_cell_info: &mut BusReader<MessageCellInfo>) -> Result<Op
Err(TryRecvError::Empty) => Ok(None),
}
}

impl NgScopeConfig {
pub fn from_cell(ng_sdr_config: &FlattenedNgScopeSdrConfigArgs, cell_info: &CellInfo) -> Result<NgScopeConfig> {
let mut ng_conf: NgScopeConfig = NgScopeConfig {
rf_config0: Some(NgScopeConfigRfDev {
rf_freq: cell_info.cells.first().ok_or_else(|| anyhow!("[ngcontrol] CellInfo.cells are empty while building NgScopeConfig"))?
.frequency as i64,
N_id_2: ng_sdr_config.ng_sdr_a.ng_sdr_a_n_id,
rf_args: format!("serial={}", ng_sdr_config.ng_sdr_a.ng_sdr_a_serial),
..Default::default()
}),
nof_rf_dev: 1,
..Default::default()
};

if cell_info.cells.len() >= 2 {
if let Some(ng_sdr_b) = &ng_sdr_config.ng_sdr_b {
ng_conf.rf_config1 = Some(NgScopeConfigRfDev {
rf_freq: cell_info.cells[1].frequency as i64,
N_id_2: ng_sdr_b.ng_sdr_b_n_id,
rf_args: format!("serial={}", ng_sdr_b.ng_sdr_b_serial),
..Default::default()
});
ng_conf.nof_rf_dev = 2;
}
else {
print_info("[ngcontrol] two cells identified, but second SDR not configured! (continuing with one)");
return Ok(ng_conf)
}
}

if cell_info.cells.len() >= 3 {
if let Some(ng_sdr_c) = &ng_sdr_config.ng_sdr_c {
ng_conf.rf_config2 = Some(NgScopeConfigRfDev {
rf_freq: cell_info.cells[2].frequency as i64,
N_id_2: ng_sdr_c.ng_sdr_c_n_id,
rf_args: format!("serial={}", ng_sdr_c.ng_sdr_c_serial),
..Default::default()
});
ng_conf.nof_rf_dev = 3;
} else {
print_info("[ngcontrol] three cells identified, but third SDR not configured! (continuing with two)");
return Ok(ng_conf)
}
}
Ok(ng_conf)
}
}
1 change: 0 additions & 1 deletion src/ngscope/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ pub fn write_config(config: &NgScopeConfig, file_path: &str) -> Result<()> {
// https://crates.io/crates/libconfig-rs

#[cfg(test)]

mod tests {
use super::*;

Expand Down
Loading
Loading