- 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>
|
||||
|
||||
@@ -73,6 +73,11 @@ namespace gr {
|
||||
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,6 +172,10 @@ namespace jay {
|
||||
};
|
||||
|
||||
private:
|
||||
void set_msg(pmt::pmt_t msg)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Peak peakCheck(float const *pData, Peak const &peak, float thresh)
|
||||
{
|
||||
@@ -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);
|
||||
|
||||
+92
-8
@@ -323,6 +323,53 @@
|
||||
<value>counter_slider</value>
|
||||
</param>
|
||||
</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>
|
||||
<key>analog_noise_source_x</key>
|
||||
<param>
|
||||
@@ -398,7 +445,7 @@
|
||||
</param>
|
||||
<param>
|
||||
<key>_enabled</key>
|
||||
<value>1</value>
|
||||
<value>0</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>_coordinate</key>
|
||||
@@ -437,7 +484,7 @@
|
||||
<key>analog_sig_source_x</key>
|
||||
<param>
|
||||
<key>amp</key>
|
||||
<value>0.1</value>
|
||||
<value>0.1*variable_test_tone_scale</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>alias</key>
|
||||
@@ -500,7 +547,7 @@
|
||||
<key>analog_sig_source_x</key>
|
||||
<param>
|
||||
<key>amp</key>
|
||||
<value>variable_amp_2</value>
|
||||
<value>variable_amp_2*variable_test_tone_scale</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>alias</key>
|
||||
@@ -563,7 +610,7 @@
|
||||
<key>analog_sig_source_x</key>
|
||||
<param>
|
||||
<key>amp</key>
|
||||
<value>0.5</value>
|
||||
<value>0.5*variable_test_tone_scale</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>alias</key>
|
||||
@@ -716,6 +763,37 @@
|
||||
<value>N_FFT</value>
|
||||
</param>
|
||||
</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>
|
||||
<key>blocks_multiply_const_vxx</key>
|
||||
<param>
|
||||
@@ -889,7 +967,7 @@
|
||||
</param>
|
||||
<param>
|
||||
<key>display</key>
|
||||
<value>True</value>
|
||||
<value>False</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>_enabled</key>
|
||||
@@ -897,7 +975,7 @@
|
||||
</param>
|
||||
<param>
|
||||
<key>_coordinate</key>
|
||||
<value>(888, 708)</value>
|
||||
<value>(888, 716)</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>_rotation</key>
|
||||
@@ -1200,7 +1278,7 @@
|
||||
</param>
|
||||
<param>
|
||||
<key>peak_height_min</key>
|
||||
<value>18</value>
|
||||
<value>15</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>peak_width_max</key>
|
||||
@@ -3284,7 +3362,7 @@
|
||||
</param>
|
||||
<param>
|
||||
<key>_enabled</key>
|
||||
<value>0</value>
|
||||
<value>1</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>_coordinate</key>
|
||||
@@ -3557,6 +3635,12 @@
|
||||
<source_key>1</source_key>
|
||||
<sink_key>0</sink_key>
|
||||
</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>
|
||||
<source_block_id>uhd_usrp_source_1</source_block_id>
|
||||
<sink_block_id>blocks_add_xx_0</sink_block_id>
|
||||
|
||||
Reference in New Issue
Block a user