aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVadim Yanitskiy <axilirator@gmail.com>2018-09-21 13:49:57 +0700
committerPiotr Krysik <ptrkrysik@gmail.com>2019-07-18 10:31:26 +0200
commit06f76fb3a6d58a3486584c1b2c8692a755358dd4 (patch)
tree23fc4588c0578f49e410fee2e36717edd953f42a
parentef93382ed1eec15be053a3f5d07d78db840d5fe7 (diff)
trx/txtime_setter: reduce code nesting in process_txtime_of_burst()
-rw-r--r--lib/transmitter/txtime_setter_impl.cc92
1 files changed, 46 insertions, 46 deletions
diff --git a/lib/transmitter/txtime_setter_impl.cc b/lib/transmitter/txtime_setter_impl.cc
index 3c07cc6..50092f4 100644
--- a/lib/transmitter/txtime_setter_impl.cc
+++ b/lib/transmitter/txtime_setter_impl.cc
@@ -116,52 +116,52 @@ namespace gr {
void txtime_setter_impl::process_txtime_of_burst(pmt::pmt_t msg_in)
{
- if (d_fn_ref != UNKNOWN_FN)
- {
- pmt::pmt_t blob = pmt::cdr(msg_in);
-
- // Extract GSMTAP header from message
- gsmtap_hdr *header = (gsmtap_hdr *) pmt::blob_data(blob);
- uint32_t frame_nr = be32toh(header->frame_number);
- uint32_t ts_num = header->timeslot;
-
- time_format txtime = fn_time_delta_cpp(d_fn_ref, d_time_ref,
- frame_nr, d_time_hint, ts_num, d_ts_ref);
-
- time_spec_t txtime_spec = time_spec_t(txtime.first, txtime.second);
- txtime_spec -= d_delay_correction;
- txtime_spec -= d_timing_advance;
-
- time_spec_t current_time_estimate = time_spec_t(d_time_hint.first, d_time_hint.second);
-
- if (txtime_spec <= current_time_estimate) { // Drop too late bursts
- std::cout << "lB" << std::flush;
- } else if (txtime_spec > current_time_estimate + MAX_EARLY_TIME_DIFF) { // Drop too early bursts
- std::cout << "eB" << std::flush; //TODO: too early condition might happen when changing BTSes.
- //Wrong fn_time is applied to new or old bursts in such situation.
- //This solution is not perfect as MS might be blocked upto
- //MAX_EARLY_TIME_DIFF seconds.
- //Better solution would be to indentify fn_time and burst coming
- //from given BTS (i.e. based on ARFCN) and dropping bursts for which
- //the bts_id doesn't match with bts_id of fn_time.
- } else { //process bursts that are in the right time-frame
- pmt::pmt_t tags_dict = pmt::dict_add(
- pmt::make_dict(),
- pmt::intern("tx_time"),
- pmt::make_tuple(
- pmt::from_uint64(txtime_spec.get_full_secs()),
- pmt::from_double(txtime_spec.get_frac_secs()))
- );
-
- tags_dict = pmt::dict_add(tags_dict,
- pmt::intern("fn"), pmt::from_uint64(frame_nr));
- tags_dict = pmt::dict_add(tags_dict,
- pmt::intern("ts"), pmt::from_uint64(ts_num));
-
- // Send a message to the output
- pmt::pmt_t msg_out = pmt::cons(tags_dict, pmt::cdr(msg_in));
- message_port_pub(pmt::mp("bursts_out"), msg_out);
- }
+ if (d_fn_ref == UNKNOWN_FN)
+ return;
+
+ pmt::pmt_t blob = pmt::cdr(msg_in);
+
+ // Extract GSMTAP header from message
+ gsmtap_hdr *header = (gsmtap_hdr *) pmt::blob_data(blob);
+ uint32_t frame_nr = be32toh(header->frame_number);
+ uint32_t ts_num = header->timeslot;
+
+ time_format txtime = fn_time_delta_cpp(d_fn_ref, d_time_ref,
+ frame_nr, d_time_hint, ts_num, d_ts_ref);
+
+ time_spec_t txtime_spec = time_spec_t(txtime.first, txtime.second);
+ txtime_spec -= d_delay_correction;
+ txtime_spec -= d_timing_advance;
+
+ time_spec_t current_time_estimate = time_spec_t(d_time_hint.first, d_time_hint.second);
+
+ if (txtime_spec <= current_time_estimate) { // Drop too late bursts
+ std::cout << "lB" << std::flush;
+ } else if (txtime_spec > current_time_estimate + MAX_EARLY_TIME_DIFF) { // Drop too early bursts
+ std::cout << "eB" << std::flush; //TODO: too early condition might happen when changing BTSes.
+ //Wrong fn_time is applied to new or old bursts in such situation.
+ //This solution is not perfect as MS might be blocked upto
+ //MAX_EARLY_TIME_DIFF seconds.
+ //Better solution would be to indentify fn_time and burst coming
+ //from given BTS (i.e. based on ARFCN) and dropping bursts for which
+ //the bts_id doesn't match with bts_id of fn_time.
+ } else { //process bursts that are in the right time-frame
+ pmt::pmt_t tags_dict = pmt::dict_add(
+ pmt::make_dict(),
+ pmt::intern("tx_time"),
+ pmt::make_tuple(
+ pmt::from_uint64(txtime_spec.get_full_secs()),
+ pmt::from_double(txtime_spec.get_frac_secs()))
+ );
+
+ tags_dict = pmt::dict_add(tags_dict,
+ pmt::intern("fn"), pmt::from_uint64(frame_nr));
+ tags_dict = pmt::dict_add(tags_dict,
+ pmt::intern("ts"), pmt::from_uint64(ts_num));
+
+ // Send a message to the output
+ pmt::pmt_t msg_out = pmt::cons(tags_dict, pmt::cdr(msg_in));
+ message_port_pub(pmt::mp("bursts_out"), msg_out);
}
}