- cleaned up from debug output

- fixed peak change mechanism

git-svn-id: http://moon:8086/svn/software/trunk/projects/GnuRadio@506 b431acfa-c32f-4a4a-93f1-934dc6c82436
This commit is contained in:
2019-05-29 14:12:42 +00:00
parent 4c255bf3ff
commit 2d656e14fc
5 changed files with 39 additions and 30 deletions
+12 -8
View File
@@ -78,17 +78,21 @@ namespace gr {
void message_debug_impl::set_msg(pmt::pmt_t msg)
{
if (pmt::is_pair(msg))
{
print_pair(msg);
}
else if (pmt::is_dict(msg))
if (pmt::is_dict(msg))
{
pmt::pmt_t items = pmt::dict_items(msg);
for (int i = 0; i < pmt::length(items); i++)
try
{
pmt::pmt_t pair = pmt::nth(i, items);
print_pair(pair);
size_t len_items = pmt::length(items);
for (int i=0; i < len_items; i++)
{
pmt::pmt_t pair = pmt::nth(i, items);
print_pair(pair);
}
}
catch (const std::exception& e)
{
print_pair(msg);
}
}
else
+4 -4
View File
@@ -278,8 +278,8 @@ namespace gr {
if (!intersection)
{
peak.height_rel = m_pXds[peak.pos];
peak.height_abs = m_pXs[peak.pos];
peak.heightUpdate_rel(m_pXds, nitems_per_block);
peak.heightUpdate_abs(m_pXs, nitems_per_block);
m_peakList.push_back(peak);
}
}
@@ -313,14 +313,14 @@ namespace gr {
for (int i = 0; i < m_peakList.size(); i++)
{
Peak &peak = m_peakList[i];
peak.heightUpdate_rel(m_pXds, nitems_per_block);
peak.heightUpdate_abs(m_pXs, nitems_per_block);
bool found = false;
for (int j=0; j < temp.size(); j++)
{
if (temp[j].isInRange(peak))
{
temp[j].update(peak);
temp[j].setState(1);
found = true;
break;
}
+16 -7
View File
@@ -48,7 +48,9 @@ namespace jay {
, pbh(_pbh)
, frequency(_frequency)
, height_rel(_height_rel)
, height_rel_last(_height_rel)
, height_abs(_height_abs)
, height_abs_last(_height_abs)
{
}
@@ -59,6 +61,8 @@ namespace jay {
int pbh;
float height_rel;
float height_abs;
float height_rel_last;
float height_abs_last;
float frequency;
bool isInRange(const Peak &other) const
@@ -92,10 +96,11 @@ namespace jay {
pos = newPos;
}
if (std::fabs(height_rel-newHeight) >= 3.0f)
height_rel = newHeight;
if (std::fabs(height_rel_last-newHeight) >= 1.0f)
{
isModified = true;
height_rel = newHeight;
height_rel_last = height_rel;
}
}
}
@@ -118,14 +123,16 @@ namespace jay {
if (pos != newPos)
{
isModified = true;
height_abs = newHeight;
pos = newPos;
}
if (std::fabs(height_abs-newHeight) >= 3.0f)
height_abs = newHeight;
if (std::fabs(height_abs_last-newHeight) >= 1.0f)
{
isModified = true;
height_rel = newHeight;
height_abs_last = height_abs;
}
}
}
@@ -194,12 +201,14 @@ namespace jay {
bool update(const Peak &other)
{
if (std::fabs(height_rel-other.height_rel) >= 3.0f)
if (std::fabs(height_rel_last-other.height_rel) >= 1.0f)
{
height_rel_last = other.height_rel;
isModified = true;
}
if (std::fabs(height_abs-other.height_abs) >= 3.0f)
if (std::fabs(height_abs-other.height_abs) >= 1.0f)
{
height_abs_last = other.height_abs;
isModified = true;
}
if (pos != other.pos)
+1 -1
View File
@@ -87,7 +87,7 @@ namespace gr {
// Check pair for data
if (pmt::symbol_to_string(key) == std::string("gain"))
{
float gain_dB = pmt::to_float(val) - 40.f;
float gain_dB = pmt::to_float(val) - 50.f;
m_gain_target = std::pow(10.f, gain_dB/10);
}
}
+6 -10
View File
@@ -38,8 +38,6 @@ class peak_manager(gr.basic_block):
self.ports_avail = []
self.ports_used = []
print ("numPeaksMax : ", numPeaksMax)
# Register in / out message ports
self.message_port_register_in(pmt.intern("control"))
@@ -109,30 +107,28 @@ class peak_manager(gr.basic_block):
if peakMsg['state'] == 1:
if peakEntry is not None:
portname = peakEntry['port_name']
print("Update " + peak_key + "(" + portname + ")")
msg_dict = pmt.make_dict()
msg_dict = pmt.dict_add(msg_dict, pmt.intern("freq"), pmt.from_double(peakMsg['freq_Hz']))
msg_dict = pmt.dict_add(msg_dict, pmt.intern("gain"), pmt.from_double(-peakMsg['height']))
portname = peakEntry['port_name']
self.message_port_pub(pmt.intern(portname), msg_dict)
print ("Updated peak #{} at {:0.2f} MHz on port {}".format(id, freq_MHz, portname))
else:
print ("New peak #{} at {:0.2f} MHz".format(id, freq_MHz))
peakEntry = self.peak_add(peak_key, peakMsg)
if peakEntry is not None:
portname = peakEntry['port_name']
print("Added " + peak_key + "(" + portname + ")")
msg_dict = pmt.make_dict()
msg_dict = pmt.dict_add(msg_dict, pmt.intern("freq"), pmt.from_double(peakMsg['freq_Hz']))
msg_dict = pmt.dict_add(msg_dict, pmt.intern("gain"), pmt.from_double(-peakMsg['height']))
portname = peakEntry['port_name']
self.message_port_pub(pmt.intern(portname), msg_dict)
print ("New peak #{} at {:0.2f} MHz on port {}".format(id, freq_MHz, portname))
else:
if peakEntry is not None:
print ("Lost peak #{} at {:0.2f} MHz".format(id, freq_MHz))
portname = peakEntry['port_name']
pair = pmt.cons(pmt.intern("gain"), pmt.from_float(-120.0))
portname = peakEntry['port_name']
self.message_port_pub(pmt.intern(portname), pair)
if self.peak_del(peak_key):
print("Deleted " + peak_key + "(" + portname + ")")
print ("Lost peak #{} at {:0.2f} MHz on port {}".format(id, freq_MHz, portname))
else: