<p>Vadim Yanitskiy has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/12394">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">trx/txtime_setter: reduce code nesting in process_txtime_of_burst()<br><br>Change-Id: I5c334e16d6b28a5e32cd62a177ad56bfc8e748ee<br>---<br>M lib/transmitter/txtime_setter_impl.cc<br>1 file changed, 39 insertions(+), 39 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/gr-gsm refs/changes/94/12394/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/lib/transmitter/txtime_setter_impl.cc b/lib/transmitter/txtime_setter_impl.cc</span><br><span>index 3c07cc6..50092f4 100644</span><br><span>--- a/lib/transmitter/txtime_setter_impl.cc</span><br><span>+++ b/lib/transmitter/txtime_setter_impl.cc</span><br><span>@@ -116,52 +116,52 @@</span><br><span> </span><br><span>     void txtime_setter_impl::process_txtime_of_burst(pmt::pmt_t msg_in)</span><br><span>     {</span><br><span style="color: hsl(0, 100%, 40%);">-      if (d_fn_ref != UNKNOWN_FN)</span><br><span style="color: hsl(0, 100%, 40%);">-      {</span><br><span style="color: hsl(0, 100%, 40%);">-        pmt::pmt_t blob = pmt::cdr(msg_in);</span><br><span style="color: hsl(120, 100%, 40%);">+      if (d_fn_ref == UNKNOWN_FN)</span><br><span style="color: hsl(120, 100%, 40%);">+        return;</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-        // Extract GSMTAP header from message</span><br><span style="color: hsl(0, 100%, 40%);">-        gsmtap_hdr *header = (gsmtap_hdr *) pmt::blob_data(blob);</span><br><span style="color: hsl(0, 100%, 40%);">-        uint32_t frame_nr = be32toh(header->frame_number);</span><br><span style="color: hsl(0, 100%, 40%);">-        uint32_t ts_num = header->timeslot;</span><br><span style="color: hsl(120, 100%, 40%);">+      pmt::pmt_t blob = pmt::cdr(msg_in);</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-        time_format txtime = fn_time_delta_cpp(d_fn_ref, d_time_ref,</span><br><span style="color: hsl(0, 100%, 40%);">-          frame_nr, d_time_hint, ts_num, d_ts_ref);</span><br><span style="color: hsl(120, 100%, 40%);">+      // Extract GSMTAP header from message</span><br><span style="color: hsl(120, 100%, 40%);">+      gsmtap_hdr *header = (gsmtap_hdr *) pmt::blob_data(blob);</span><br><span style="color: hsl(120, 100%, 40%);">+      uint32_t frame_nr = be32toh(header->frame_number);</span><br><span style="color: hsl(120, 100%, 40%);">+      uint32_t ts_num = header->timeslot;</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-        time_spec_t txtime_spec = time_spec_t(txtime.first, txtime.second);</span><br><span style="color: hsl(0, 100%, 40%);">-        txtime_spec -= d_delay_correction;</span><br><span style="color: hsl(0, 100%, 40%);">-        txtime_spec -= d_timing_advance;</span><br><span style="color: hsl(120, 100%, 40%);">+      time_format txtime = fn_time_delta_cpp(d_fn_ref, d_time_ref,</span><br><span style="color: hsl(120, 100%, 40%);">+        frame_nr, d_time_hint, ts_num, d_ts_ref);</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-        time_spec_t current_time_estimate = time_spec_t(d_time_hint.first, d_time_hint.second);</span><br><span style="color: hsl(120, 100%, 40%);">+      time_spec_t txtime_spec = time_spec_t(txtime.first, txtime.second);</span><br><span style="color: hsl(120, 100%, 40%);">+      txtime_spec -= d_delay_correction;</span><br><span style="color: hsl(120, 100%, 40%);">+      txtime_spec -= d_timing_advance;</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-        if (txtime_spec <= current_time_estimate) { // Drop too late bursts</span><br><span style="color: hsl(0, 100%, 40%);">-          std::cout << "lB" << std::flush;</span><br><span style="color: hsl(0, 100%, 40%);">-        } else if (txtime_spec > current_time_estimate + MAX_EARLY_TIME_DIFF) { // Drop too early bursts</span><br><span style="color: hsl(0, 100%, 40%);">-          std::cout << "eB" << std::flush;      //TODO: too early condition might happen when changing BTSes.</span><br><span style="color: hsl(0, 100%, 40%);">-                                                //Wrong fn_time is applied to new or old bursts in such situation.</span><br><span style="color: hsl(0, 100%, 40%);">-                                                //This solution is not perfect as MS might be blocked upto </span><br><span style="color: hsl(0, 100%, 40%);">-                                                //MAX_EARLY_TIME_DIFF seconds.</span><br><span style="color: hsl(0, 100%, 40%);">-                                                //Better solution would be to indentify fn_time and burst coming</span><br><span style="color: hsl(0, 100%, 40%);">-                                                //from given BTS (i.e. based on ARFCN) and dropping bursts for which</span><br><span style="color: hsl(0, 100%, 40%);">-                                                //the bts_id doesn't match with bts_id of fn_time.</span><br><span style="color: hsl(0, 100%, 40%);">-        } else { //process bursts that are in the right time-frame</span><br><span style="color: hsl(0, 100%, 40%);">-          pmt::pmt_t tags_dict = pmt::dict_add(</span><br><span style="color: hsl(0, 100%, 40%);">-            pmt::make_dict(),</span><br><span style="color: hsl(0, 100%, 40%);">-            pmt::intern("tx_time"),</span><br><span style="color: hsl(0, 100%, 40%);">-            pmt::make_tuple(</span><br><span style="color: hsl(0, 100%, 40%);">-              pmt::from_uint64(txtime_spec.get_full_secs()),</span><br><span style="color: hsl(0, 100%, 40%);">-              pmt::from_double(txtime_spec.get_frac_secs()))</span><br><span style="color: hsl(0, 100%, 40%);">-          );</span><br><span style="color: hsl(120, 100%, 40%);">+      time_spec_t current_time_estimate = time_spec_t(d_time_hint.first, d_time_hint.second);</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-          tags_dict = pmt::dict_add(tags_dict,</span><br><span style="color: hsl(0, 100%, 40%);">-            pmt::intern("fn"), pmt::from_uint64(frame_nr));</span><br><span style="color: hsl(0, 100%, 40%);">-          tags_dict = pmt::dict_add(tags_dict,</span><br><span style="color: hsl(0, 100%, 40%);">-            pmt::intern("ts"), pmt::from_uint64(ts_num));</span><br><span style="color: hsl(120, 100%, 40%);">+      if (txtime_spec <= current_time_estimate) { // Drop too late bursts</span><br><span style="color: hsl(120, 100%, 40%);">+        std::cout << "lB" << std::flush;</span><br><span style="color: hsl(120, 100%, 40%);">+      } else if (txtime_spec > current_time_estimate + MAX_EARLY_TIME_DIFF) { // Drop too early bursts</span><br><span style="color: hsl(120, 100%, 40%);">+        std::cout << "eB" << std::flush;      //TODO: too early condition might happen when changing BTSes.</span><br><span style="color: hsl(120, 100%, 40%);">+                                              //Wrong fn_time is applied to new or old bursts in such situation.</span><br><span style="color: hsl(120, 100%, 40%);">+                                              //This solution is not perfect as MS might be blocked upto</span><br><span style="color: hsl(120, 100%, 40%);">+                                              //MAX_EARLY_TIME_DIFF seconds.</span><br><span style="color: hsl(120, 100%, 40%);">+                                              //Better solution would be to indentify fn_time and burst coming</span><br><span style="color: hsl(120, 100%, 40%);">+                                              //from given BTS (i.e. based on ARFCN) and dropping bursts for which</span><br><span style="color: hsl(120, 100%, 40%);">+                                              //the bts_id doesn't match with bts_id of fn_time.</span><br><span style="color: hsl(120, 100%, 40%);">+      } else { //process bursts that are in the right time-frame</span><br><span style="color: hsl(120, 100%, 40%);">+        pmt::pmt_t tags_dict = pmt::dict_add(</span><br><span style="color: hsl(120, 100%, 40%);">+          pmt::make_dict(),</span><br><span style="color: hsl(120, 100%, 40%);">+          pmt::intern("tx_time"),</span><br><span style="color: hsl(120, 100%, 40%);">+          pmt::make_tuple(</span><br><span style="color: hsl(120, 100%, 40%);">+            pmt::from_uint64(txtime_spec.get_full_secs()),</span><br><span style="color: hsl(120, 100%, 40%);">+            pmt::from_double(txtime_spec.get_frac_secs()))</span><br><span style="color: hsl(120, 100%, 40%);">+        );</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-          // Send a message to the output</span><br><span style="color: hsl(0, 100%, 40%);">-          pmt::pmt_t msg_out = pmt::cons(tags_dict, pmt::cdr(msg_in));</span><br><span style="color: hsl(0, 100%, 40%);">-          message_port_pub(pmt::mp("bursts_out"), msg_out);</span><br><span style="color: hsl(0, 100%, 40%);">-        }</span><br><span style="color: hsl(120, 100%, 40%);">+        tags_dict = pmt::dict_add(tags_dict,</span><br><span style="color: hsl(120, 100%, 40%);">+          pmt::intern("fn"), pmt::from_uint64(frame_nr));</span><br><span style="color: hsl(120, 100%, 40%);">+        tags_dict = pmt::dict_add(tags_dict,</span><br><span style="color: hsl(120, 100%, 40%);">+          pmt::intern("ts"), pmt::from_uint64(ts_num));</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+        // Send a message to the output</span><br><span style="color: hsl(120, 100%, 40%);">+        pmt::pmt_t msg_out = pmt::cons(tags_dict, pmt::cdr(msg_in));</span><br><span style="color: hsl(120, 100%, 40%);">+        message_port_pub(pmt::mp("bursts_out"), msg_out);</span><br><span>       }</span><br><span>     }</span><br><span> </span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/12394">change 12394</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/12394"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: gr-gsm </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: I5c334e16d6b28a5e32cd62a177ad56bfc8e748ee </div>
<div style="display:none"> Gerrit-Change-Number: 12394 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Vadim Yanitskiy <axilirator@gmail.com> </div>