Peak Manager

- renamed ports to status[0..N]
- emiut gain messages 

PekaDetect
- emit peak messages also on peak height changes

git-svn-id: http://moon:8086/svn/software/trunk/projects/GnuRadio@499 b431acfa-c32f-4a4a-93f1-934dc6c82436
This commit is contained in:
2019-05-29 09:58:23 +00:00
parent b665890f9e
commit a50f613991
4 changed files with 123 additions and 60 deletions
+74 -18
View File
@@ -42,6 +42,8 @@ namespace jay {
}
Peak(uint64_t _id, int _pos, int _pbh, float _frequency, float _height_rel, float _height_abs)
: id(_id)
, isModified(false)
, state(0)
, pos(_pos)
, pbh(_pbh)
, frequency(_frequency)
@@ -51,6 +53,8 @@ namespace jay {
}
uint64_t id;
bool isModified;
int state;
int pos;
int pbh;
float height_rel;
@@ -69,22 +73,60 @@ namespace jay {
void heightUpdate_rel(float const *pData, int length)
{
float newHeight = -100.f;
for (int i=left(); i <= right(); i++)
if (pbh)
{
newHeight = std::max(newHeight, pData[i]);
int newPos = -1;
float newHeight = -100.f;
for (int i=left(); i <= right(); i++)
{
if (newHeight < pData[i])
{
newPos = i;
newHeight = pData[i];
}
}
if (pos != newPos)
{
isModified = true;
pos = newPos;
}
if (std::fabs(height_rel-newHeight) >= 3.0f)
{
isModified = true;
height_rel = newHeight;
}
}
height_rel = newHeight;
}
void heightUpdate_abs(float const *pData, int length)
{
float newHeight = -100.f;
for (int i=left(); i <= right(); i++)
if (pbh)
{
newHeight = std::max(newHeight, pData[i]);
int newPos = -1;
float newHeight = -100.f;
for (int i=left(); i <= right(); i++)
{
if (newHeight < pData[i])
{
newPos = i;
newHeight = pData[i];
}
}
if (pos != newPos)
{
isModified = true;
height_abs = newHeight;
}
if (std::fabs(height_abs-newHeight) >= 3.0f)
{
isModified = true;
height_rel = newHeight;
}
}
height_abs = newHeight;
}
bool makeBox(int pbh_min, int pbh_max, float const *pData, int length)
@@ -146,26 +188,30 @@ namespace jay {
break;
}
}
// isModified = true;
return pbh > 0;
}
bool update(const Peak &other)
{
bool changed = false;
if (std::fabs(height_rel-other.height_rel) >= 3.0f)
{
isModified = true;
}
if (std::fabs(height_abs-other.height_abs) >= 3.0f)
{
isModified = true;
}
if (pos != other.pos)
{
changed = true;
}
if (std::abs(frequency-other.frequency) >= (0.01*1e6))
{
changed = true;
isModified = true;
}
frequency = other.frequency;
pos = other.pos;
pbh = other.pbh;
height_rel = other.height_rel;
height_abs = other.height_abs;
return changed;
return isModified;
}
int left() const
@@ -178,17 +224,27 @@ namespace jay {
return pos + pbh;
}
pmt::pmt_t msg(int state)
pmt::pmt_t msg()
{
pmt::pmt_t dict = pmt::make_dict();
dict = pmt::dict_add(dict, pmt::string_to_symbol(std::string("id")), pmt::from_long(id));
dict = pmt::dict_add(dict, pmt::string_to_symbol(std::string("pos")), pmt::from_long(pos));
dict = pmt::dict_add(dict, pmt::string_to_symbol(std::string("freq_Hz")), pmt::from_float(frequency));
dict = pmt::dict_add(dict, pmt::string_to_symbol(std::string("height")), pmt::from_float(height_rel));
dict = pmt::dict_add(dict, pmt::string_to_symbol(std::string("height")), pmt::from_float(height_abs));
dict = pmt::dict_add(dict, pmt::string_to_symbol(std::string("state")), pmt::from_long(state));
isModified = false;
return dict;
}
void setState(int _state)
{
if (_state != state)
{
isModified = true;
}
state = _state;
}
};
private: