- 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>
|
<type>float</type>
|
||||||
<vlen>$vlen</vlen>
|
<vlen>$vlen</vlen>
|
||||||
</source>
|
</source>
|
||||||
|
<source>
|
||||||
|
<name>status</name>
|
||||||
|
<type>message</type>
|
||||||
|
<optional>1</optional>
|
||||||
|
</source>
|
||||||
</block>
|
</block>
|
||||||
|
|||||||
@@ -72,7 +72,12 @@ namespace gr {
|
|||||||
std::stringstream str;
|
std::stringstream str;
|
||||||
str << name() << unique_id();
|
str << name() << unique_id();
|
||||||
m_tag_id = pmt::string_to_symbol(str.str());
|
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 &peak = m_peakHistory[j];
|
||||||
peak.heightUpdate_rel(m_pXds, nitems_per_block);
|
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);
|
temp.push_back(peak);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Output OFF-tags
|
// 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_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);
|
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);
|
temp.push_back(peak);
|
||||||
|
|
||||||
// Output ON-tags
|
// 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_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);
|
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:
|
private:
|
||||||
|
void set_msg(pmt::pmt_t msg)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
Peak peakCheck(float const *pData, Peak const &peak, float thresh)
|
Peak peakCheck(float const *pData, Peak const &peak, float thresh)
|
||||||
{
|
{
|
||||||
Peak result;
|
Peak result;
|
||||||
@@ -219,6 +223,8 @@ namespace jay {
|
|||||||
std::vector<Peak> m_peakHistory;
|
std::vector<Peak> m_peakHistory;
|
||||||
std::vector<Peak> temp;
|
std::vector<Peak> temp;
|
||||||
uint64_t m_peak_id;
|
uint64_t m_peak_id;
|
||||||
|
pmt::pmt_t m_msg_port_in;
|
||||||
|
pmt::pmt_t m_msg_port_out;
|
||||||
|
|
||||||
public:
|
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);
|
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);
|
||||||
|
|||||||
+92
-8
@@ -323,6 +323,53 @@
|
|||||||
<value>counter_slider</value>
|
<value>counter_slider</value>
|
||||||
</param>
|
</param>
|
||||||
</block>
|
</block>
|
||||||
|
<block>
|
||||||
|
<key>variable_qtgui_check_box</key>
|
||||||
|
<param>
|
||||||
|
<key>comment</key>
|
||||||
|
<value></value>
|
||||||
|
</param>
|
||||||
|
<param>
|
||||||
|
<key>value</key>
|
||||||
|
<value>0</value>
|
||||||
|
</param>
|
||||||
|
<param>
|
||||||
|
<key>_enabled</key>
|
||||||
|
<value>True</value>
|
||||||
|
</param>
|
||||||
|
<param>
|
||||||
|
<key>false</key>
|
||||||
|
<value>0</value>
|
||||||
|
</param>
|
||||||
|
<param>
|
||||||
|
<key>_coordinate</key>
|
||||||
|
<value>(656, 540)</value>
|
||||||
|
</param>
|
||||||
|
<param>
|
||||||
|
<key>gui_hint</key>
|
||||||
|
<value></value>
|
||||||
|
</param>
|
||||||
|
<param>
|
||||||
|
<key>_rotation</key>
|
||||||
|
<value>0</value>
|
||||||
|
</param>
|
||||||
|
<param>
|
||||||
|
<key>id</key>
|
||||||
|
<value>variable_test_tone_scale</value>
|
||||||
|
</param>
|
||||||
|
<param>
|
||||||
|
<key>label</key>
|
||||||
|
<value>Test tones</value>
|
||||||
|
</param>
|
||||||
|
<param>
|
||||||
|
<key>true</key>
|
||||||
|
<value>1</value>
|
||||||
|
</param>
|
||||||
|
<param>
|
||||||
|
<key>type</key>
|
||||||
|
<value>int</value>
|
||||||
|
</param>
|
||||||
|
</block>
|
||||||
<block>
|
<block>
|
||||||
<key>analog_noise_source_x</key>
|
<key>analog_noise_source_x</key>
|
||||||
<param>
|
<param>
|
||||||
@@ -398,7 +445,7 @@
|
|||||||
</param>
|
</param>
|
||||||
<param>
|
<param>
|
||||||
<key>_enabled</key>
|
<key>_enabled</key>
|
||||||
<value>1</value>
|
<value>0</value>
|
||||||
</param>
|
</param>
|
||||||
<param>
|
<param>
|
||||||
<key>_coordinate</key>
|
<key>_coordinate</key>
|
||||||
@@ -437,7 +484,7 @@
|
|||||||
<key>analog_sig_source_x</key>
|
<key>analog_sig_source_x</key>
|
||||||
<param>
|
<param>
|
||||||
<key>amp</key>
|
<key>amp</key>
|
||||||
<value>0.1</value>
|
<value>0.1*variable_test_tone_scale</value>
|
||||||
</param>
|
</param>
|
||||||
<param>
|
<param>
|
||||||
<key>alias</key>
|
<key>alias</key>
|
||||||
@@ -500,7 +547,7 @@
|
|||||||
<key>analog_sig_source_x</key>
|
<key>analog_sig_source_x</key>
|
||||||
<param>
|
<param>
|
||||||
<key>amp</key>
|
<key>amp</key>
|
||||||
<value>variable_amp_2</value>
|
<value>variable_amp_2*variable_test_tone_scale</value>
|
||||||
</param>
|
</param>
|
||||||
<param>
|
<param>
|
||||||
<key>alias</key>
|
<key>alias</key>
|
||||||
@@ -563,7 +610,7 @@
|
|||||||
<key>analog_sig_source_x</key>
|
<key>analog_sig_source_x</key>
|
||||||
<param>
|
<param>
|
||||||
<key>amp</key>
|
<key>amp</key>
|
||||||
<value>0.5</value>
|
<value>0.5*variable_test_tone_scale</value>
|
||||||
</param>
|
</param>
|
||||||
<param>
|
<param>
|
||||||
<key>alias</key>
|
<key>alias</key>
|
||||||
@@ -716,6 +763,37 @@
|
|||||||
<value>N_FFT</value>
|
<value>N_FFT</value>
|
||||||
</param>
|
</param>
|
||||||
</block>
|
</block>
|
||||||
|
<block>
|
||||||
|
<key>blocks_message_debug</key>
|
||||||
|
<param>
|
||||||
|
<key>alias</key>
|
||||||
|
<value></value>
|
||||||
|
</param>
|
||||||
|
<param>
|
||||||
|
<key>comment</key>
|
||||||
|
<value></value>
|
||||||
|
</param>
|
||||||
|
<param>
|
||||||
|
<key>affinity</key>
|
||||||
|
<value></value>
|
||||||
|
</param>
|
||||||
|
<param>
|
||||||
|
<key>_enabled</key>
|
||||||
|
<value>True</value>
|
||||||
|
</param>
|
||||||
|
<param>
|
||||||
|
<key>_coordinate</key>
|
||||||
|
<value>(856, 920)</value>
|
||||||
|
</param>
|
||||||
|
<param>
|
||||||
|
<key>_rotation</key>
|
||||||
|
<value>0</value>
|
||||||
|
</param>
|
||||||
|
<param>
|
||||||
|
<key>id</key>
|
||||||
|
<value>blocks_message_debug_0</value>
|
||||||
|
</param>
|
||||||
|
</block>
|
||||||
<block>
|
<block>
|
||||||
<key>blocks_multiply_const_vxx</key>
|
<key>blocks_multiply_const_vxx</key>
|
||||||
<param>
|
<param>
|
||||||
@@ -889,7 +967,7 @@
|
|||||||
</param>
|
</param>
|
||||||
<param>
|
<param>
|
||||||
<key>display</key>
|
<key>display</key>
|
||||||
<value>True</value>
|
<value>False</value>
|
||||||
</param>
|
</param>
|
||||||
<param>
|
<param>
|
||||||
<key>_enabled</key>
|
<key>_enabled</key>
|
||||||
@@ -897,7 +975,7 @@
|
|||||||
</param>
|
</param>
|
||||||
<param>
|
<param>
|
||||||
<key>_coordinate</key>
|
<key>_coordinate</key>
|
||||||
<value>(888, 708)</value>
|
<value>(888, 716)</value>
|
||||||
</param>
|
</param>
|
||||||
<param>
|
<param>
|
||||||
<key>_rotation</key>
|
<key>_rotation</key>
|
||||||
@@ -1200,7 +1278,7 @@
|
|||||||
</param>
|
</param>
|
||||||
<param>
|
<param>
|
||||||
<key>peak_height_min</key>
|
<key>peak_height_min</key>
|
||||||
<value>18</value>
|
<value>15</value>
|
||||||
</param>
|
</param>
|
||||||
<param>
|
<param>
|
||||||
<key>peak_width_max</key>
|
<key>peak_width_max</key>
|
||||||
@@ -3284,7 +3362,7 @@
|
|||||||
</param>
|
</param>
|
||||||
<param>
|
<param>
|
||||||
<key>_enabled</key>
|
<key>_enabled</key>
|
||||||
<value>0</value>
|
<value>1</value>
|
||||||
</param>
|
</param>
|
||||||
<param>
|
<param>
|
||||||
<key>_coordinate</key>
|
<key>_coordinate</key>
|
||||||
@@ -3557,6 +3635,12 @@
|
|||||||
<source_key>1</source_key>
|
<source_key>1</source_key>
|
||||||
<sink_key>0</sink_key>
|
<sink_key>0</sink_key>
|
||||||
</connection>
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<source_block_id>jay_peak_detect_1</source_block_id>
|
||||||
|
<sink_block_id>blocks_message_debug_0</sink_block_id>
|
||||||
|
<source_key>status</source_key>
|
||||||
|
<sink_key>print</sink_key>
|
||||||
|
</connection>
|
||||||
<connection>
|
<connection>
|
||||||
<source_block_id>uhd_usrp_source_1</source_block_id>
|
<source_block_id>uhd_usrp_source_1</source_block_id>
|
||||||
<sink_block_id>blocks_add_xx_0</sink_block_id>
|
<sink_block_id>blocks_add_xx_0</sink_block_id>
|
||||||
|
|||||||
Reference in New Issue
Block a user