- added messsage port
- emit peak messages git-svn-id: http://moon:8086/svn/software/trunk/projects/GnuRadio@481 b431acfa-c32f-4a4a-93f1-934dc6c82436
This commit is contained in:
@@ -79,4 +79,9 @@
|
||||
<type>float</type>
|
||||
<vlen>$vlen</vlen>
|
||||
</source>
|
||||
<source>
|
||||
<name>status</name>
|
||||
<type>message</type>
|
||||
<optional>1</optional>
|
||||
</source>
|
||||
</block>
|
||||
|
||||
@@ -72,7 +72,12 @@ namespace gr {
|
||||
std::stringstream str;
|
||||
str << name() << unique_id();
|
||||
m_tag_id = pmt::string_to_symbol(str.str());
|
||||
|
||||
|
||||
m_msg_port_in = pmt::mp("msgIn");
|
||||
m_msg_port_out = pmt::mp("status");
|
||||
message_port_register_in(m_msg_port_in);
|
||||
message_port_register_out(m_msg_port_out);
|
||||
set_msg_handler(m_msg_port_in, boost::bind(&peak_detect_impl::set_msg, this, _1));
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -284,17 +289,18 @@ namespace gr {
|
||||
Peak &peak = m_peakHistory[j];
|
||||
peak.heightUpdate_rel(m_pXds, nitems_per_block);
|
||||
|
||||
if (peak.height_rel >= (m_peak_height_min-6.f))
|
||||
if (peak.height_rel >= (m_peak_height_min-10.f))
|
||||
{
|
||||
temp.push_back(peak);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Output OFF-tags
|
||||
std::string msgStr(std::string("id=") + std::to_string(peak.id) + std::string(":pos=") + std::to_string(peak.pos) + std::string(":state=") + std::string("OFF"));
|
||||
pmt::pmt_t tag_key = pmt::string_to_symbol(std::string("peak"));
|
||||
pmt::pmt_t tag_value = pmt::string_to_symbol(std::string("id=") + std::to_string(peak.id) + std::string(":pos=") + std::to_string(peak.pos) + std::string(":state=") + std::string("OFF"));
|
||||
pmt::pmt_t tag_value = pmt::string_to_symbol(msgStr);
|
||||
add_item_tag(DATA, nitems_written(DATA) + k, tag_key, tag_value, m_tag_id);
|
||||
fprintf(stderr, "Lost Peak #%u at %d\n", (int)peak.id, (int)peak.pos);
|
||||
message_port_pub(m_msg_port_out, pmt::string_to_symbol(msgStr));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -318,10 +324,15 @@ namespace gr {
|
||||
temp.push_back(peak);
|
||||
|
||||
// Output ON-tags
|
||||
std::string msgStr(std::string("id=") + std::to_string(peak.id) + std::string(":pos=") + std::to_string(peak.pos) + std::string(":state=") + std::string("ON"));
|
||||
pmt::pmt_t tag_key = pmt::string_to_symbol(std::string("peak"));
|
||||
pmt::pmt_t tag_value = pmt::string_to_symbol(std::string("id=") + std::to_string(peak.id) + std::string(":pos=") + std::to_string(peak.pos) + std::string(":state=") + std::string("ON"));
|
||||
pmt::pmt_t tag_value = pmt::string_to_symbol(msgStr);
|
||||
add_item_tag(DATA, nitems_written(DATA) + k, tag_key, tag_value, m_tag_id);
|
||||
fprintf(stderr, "New Peak #%u at %d\n", (int)peak.id, (int)peak.pos);
|
||||
|
||||
// pmt::pmt_t dict = pmt::make_dict();
|
||||
// pmt::dict_add(dict, pmt::string_to_symbol(std::string("id=")), pmt::from_long(peak.id));
|
||||
// message_port_pub(m_msg_port_out, dict);
|
||||
message_port_pub(m_msg_port_out, pmt::string_to_symbol(msgStr));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -172,7 +172,11 @@ namespace jay {
|
||||
};
|
||||
|
||||
private:
|
||||
|
||||
void set_msg(pmt::pmt_t msg)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Peak peakCheck(float const *pData, Peak const &peak, float thresh)
|
||||
{
|
||||
Peak result;
|
||||
@@ -219,6 +223,8 @@ namespace jay {
|
||||
std::vector<Peak> m_peakHistory;
|
||||
std::vector<Peak> temp;
|
||||
uint64_t m_peak_id;
|
||||
pmt::pmt_t m_msg_port_in;
|
||||
pmt::pmt_t m_msg_port_out;
|
||||
|
||||
public:
|
||||
peak_detect_impl(int vlen, float framerate, float peak_height_min, int peak_width_min, int peak_width_max, float alpha_s, float alpha_m);
|
||||
|
||||
Reference in New Issue
Block a user