From bbf2469431440ad4895f548c18b8fe8c59278c78 Mon Sep 17 00:00:00 2001 From: f4exb Date: Tue, 15 Dec 2015 02:55:12 +0100 Subject: [PATCH] BFM demod: RDS GUI part #6: implemented groups 1,2 and 8 --- plugins/channel/bfm/bfmdemod.h | 1 + plugins/channel/bfm/bfmdemodgui.cpp | 113 +++++++++- plugins/channel/bfm/bfmdemodgui.ui | 331 ++++++++++++++++++++++++++-- plugins/channel/bfm/rdsdecoder.cpp | 2 +- plugins/channel/bfm/rdsdecoder.h | 1 + plugins/channel/bfm/rdsparser.cpp | 62 +++++- plugins/channel/bfm/rdsparser.h | 21 ++ 7 files changed, 503 insertions(+), 28 deletions(-) diff --git a/plugins/channel/bfm/bfmdemod.h b/plugins/channel/bfm/bfmdemod.h index 1ca9b260e..b82266569 100644 --- a/plugins/channel/bfm/bfmdemod.h +++ b/plugins/channel/bfm/bfmdemod.h @@ -63,6 +63,7 @@ public: Real getPilotLevel() const { return m_pilotPLL.get_pilot_level(); } Real getDecoderQua() const { return m_rdsDecoder.m_qua; } + bool getDecoderSynced() const { return m_rdsDecoder.synced(); } Real getDemodAcc() const { return m_rdsDemod.m_report.acc; } Real getDemodQua() const { return m_rdsDemod.m_report.qua; } Real getDemodFclk() const { return m_rdsDemod.m_report.fclk; } diff --git a/plugins/channel/bfm/bfmdemodgui.cpp b/plugins/channel/bfm/bfmdemodgui.cpp index 3f2aba317..3b501d95c 100644 --- a/plugins/channel/bfm/bfmdemodgui.cpp +++ b/plugins/channel/bfm/bfmdemodgui.cpp @@ -37,6 +37,7 @@ #include "bfmdemodgui.h" #include "ui_bfmdemodgui.h" #include "bfmdemod.h" +#include "rdstmc.h" const int BFMDemodGUI::m_rfBW[] = { 80000, 100000, 120000, 140000, 160000, 180000, 200000, 220000, 250000 @@ -249,8 +250,11 @@ void BFMDemodGUI::on_showPilot_clicked() void BFMDemodGUI::on_rds_clicked() { - m_rdsParser.clearAllFields(); - rdsUpdate(true); + if (ui->rds->isChecked()) { + m_rdsParser.clearAllFields(); + rdsUpdate(true); + } + applySettings(); } @@ -418,14 +422,14 @@ void BFMDemodGUI::channelSampleRateChanged() void BFMDemodGUI::rdsUpdateFixedFields() { ui->g00Label->setText(m_rdsParser.rds_group_acronym_tags[0].c_str()); - //ui->g01Label->setText(m_rdsParser.rds_group_acronym_tags[1].c_str()); - //ui->g02Label->setText(m_rdsParser.rds_group_acronym_tags[2].c_str()); + ui->g01Label->setText(m_rdsParser.rds_group_acronym_tags[1].c_str()); + ui->g02Label->setText(m_rdsParser.rds_group_acronym_tags[2].c_str()); //ui->g03Label->setText(m_rdsParser.rds_group_acronym_tags[3].c_str()); ui->g04Label->setText(m_rdsParser.rds_group_acronym_tags[4].c_str()); //ui->g05Label->setText(m_rdsParser.rds_group_acronym_tags[5].c_str()); //ui->g06Label->setText(m_rdsParser.rds_group_acronym_tags[6].c_str()); //ui->g07Label->setText(m_rdsParser.rds_group_acronym_tags[7].c_str()); - //ui->g08Label->setText(m_rdsParser.rds_group_acronym_tags[8].c_str()); + ui->g08Label->setText(m_rdsParser.rds_group_acronym_tags[8].c_str()); //ui->g09Label->setText(m_rdsParser.rds_group_acronym_tags[9].c_str()); //ui->g14Label->setText(m_rdsParser.rds_group_acronym_tags[14].c_str()); @@ -451,6 +455,12 @@ void BFMDemodGUI::rdsUpdate(bool force) ui->accumText->setText(QString("%1 dB").arg(accDb, 0, 'f', 1)); ui->fclkText->setText(QString("%1 Hz").arg(m_bfmDemod->getDemodFclk(), 0, 'f', 2)); + if (m_bfmDemod->getDecoderSynced()) { + ui->decoderQLabel->setStyleSheet("QLabel { background-color : green; }"); + } else { + ui->decoderQLabel->setStyleSheet("QLabel { background:rgb(79,79,79); }"); + } + // PI group if (m_rdsParser.m_pi_updated || force) { @@ -516,6 +526,45 @@ void BFMDemodGUI::rdsUpdate(bool force) ui->g00Label->setStyleSheet("QLabel { background:rgb(79,79,79); }"); } + // G1 group + if (m_rdsParser.m_g1_updated || force) + { + ui->g01Label->setStyleSheet("QLabel { background-color : green; }"); + ui->g01CountText->setNum((int) m_rdsParser.m_g1_count); + + if ((m_rdsParser.m_g1_country_page_index >= 0) && (m_rdsParser.m_g1_country_index >= 0)) { + ui->g01CountryCode->setText(QString((m_rdsParser.pi_country_codes[m_rdsParser.m_g1_country_page_index][m_rdsParser.m_g1_country_index]).c_str())); + } + + if (m_rdsParser.m_g1_language_index >= 0) { + ui->g01Language->setText(QString(m_rdsParser.language_codes[m_rdsParser.m_g1_language_index].c_str())); + } + + ui->g01DHM->setText(QString(str(boost::format("%id:%i:%i") % m_rdsParser.m_g1_pin_day % m_rdsParser.m_g1_pin_hour % m_rdsParser.m_g1_pin_minute).c_str())); + } + else + { + ui->g01Label->setStyleSheet("QLabel { background:rgb(79,79,79); }"); + } + + // G2 group + if (m_rdsParser.m_g2_updated || force) + { + ui->g02Label->setStyleSheet("QLabel { background-color : green; }"); + ui->g02CountText->setNum((int) m_rdsParser.m_g2_count); + ui->go2Text->setText(QString(m_rdsParser.m_g2_radiotext)); + } + else + { + ui->g02Label->setStyleSheet("QLabel { background:rgb(79,79,79); }"); + } + + // G3 group + if (m_rdsParser.m_g3_updated || force) + { + ui->g03CountText->setNum((int) m_rdsParser.m_g3_count); + } + // G4 group if (m_rdsParser.m_g4_updated || force) { @@ -530,5 +579,59 @@ void BFMDemodGUI::rdsUpdate(bool force) ui->g04Label->setStyleSheet("QLabel { background:rgb(79,79,79); }"); } + // G5 group + if (m_rdsParser.m_g5_updated || force) + { + ui->g05CountText->setNum((int) m_rdsParser.m_g5_count); + } + + // G6 group + if (m_rdsParser.m_g6_updated || force) + { + ui->g06CountText->setNum((int) m_rdsParser.m_g6_count); + } + + // G7 group + if (m_rdsParser.m_g7_updated || force) + { + ui->g07CountText->setNum((int) m_rdsParser.m_g7_count); + } + + // G8 group + if (m_rdsParser.m_g8_updated || force) + { + ui->g08Label->setStyleSheet("QLabel { background-color : green; }"); + ui->g08CountText->setNum((int) m_rdsParser.m_g8_count); + + std::ostringstream os; + os << (m_rdsParser.m_g8_sign ? "-" : "+") << m_rdsParser.m_g8_extent + 1; + ui->g08Extent->setText(QString(os.str().c_str())); + int event_line = RDSTMC::get_tmc_event_code_index(m_rdsParser.m_g8_event, 1); + ui->g08TMCEvent->setText(QString(RDSTMC::get_tmc_events(event_line, 1).c_str())); + ui->g08Location->setNum((int) m_rdsParser.m_g8_location); + + if (m_rdsParser.m_g8_label_index >= 0) { + ui->g08Description->setText(QString(m_rdsParser.label_descriptions[m_rdsParser.m_g8_label_index].c_str())); + } + + ui->g08Content->setNum(m_rdsParser.m_g8_content); + } + else + { + ui->g08Label->setStyleSheet("QLabel { background:rgb(79,79,79); }"); + } + + // G9 group + if (m_rdsParser.m_g9_updated || force) + { + ui->g09CountText->setNum((int) m_rdsParser.m_g9_count); + } + + // G14 group + if (m_rdsParser.m_g14_updated || force) + { + ui->g14CountText->setNum((int) m_rdsParser.m_g14_count); + } + m_rdsParser.clearUpdateFlags(); } diff --git a/plugins/channel/bfm/bfmdemodgui.ui b/plugins/channel/bfm/bfmdemodgui.ui index 3b826f6c2..a0a02b667 100644 --- a/plugins/channel/bfm/bfmdemodgui.ui +++ b/plugins/channel/bfm/bfmdemodgui.ui @@ -6,7 +6,7 @@ 0 0 - 514 + 676 729 @@ -436,8 +436,8 @@ 10 150 - 500 - 201 + 561 + 301 @@ -678,6 +678,12 @@ + + + 34 + 16777215 + + PI @@ -695,6 +701,12 @@ + + + 34 + 16777215 + + G00 @@ -712,6 +724,12 @@ + + + 34 + 16777215 + + G03 @@ -719,6 +737,12 @@ + + + 34 + 16777215 + + G01 @@ -736,6 +760,12 @@ + + + 34 + 16777215 + + G02 @@ -753,6 +783,12 @@ + + + 34 + 16777215 + + G08 @@ -760,6 +796,12 @@ + + + 34 + 16777215 + + G07 @@ -777,6 +819,12 @@ + + + 34 + 16777215 + + G04 @@ -794,6 +842,12 @@ + + + 34 + 16777215 + + G05 @@ -811,6 +865,12 @@ + + + 34 + 16777215 + + G06 @@ -848,6 +908,12 @@ + + + 34 + 16777215 + + G09 @@ -865,6 +931,12 @@ + + + 34 + 16777215 + + G14 @@ -890,7 +962,7 @@ - + @@ -908,7 +980,7 @@ - + Qt::Vertical @@ -918,7 +990,7 @@ - 80 + 40 16777215 @@ -931,7 +1003,7 @@ - + Qt::Vertical @@ -955,6 +1027,18 @@ + + + 100 + 0 + + + + + 16777215 + 16777215 + + Program type @@ -965,6 +1049,18 @@ + + + 100 + 0 + + + + + 16777215 + 16777215 + + Program coverage @@ -973,10 +1069,107 @@ + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Qt::Vertical + + + + + + + + 30 + 16777215 + + + + G01 + + + + + + + Qt::Vertical + + + + + + + + 20 + 0 + + + + + 16777215 + 16777215 + + + + __ + + + + + + + + 100 + 0 + + + + + 16777215 + 16777215 + + + + ___ + + + + + + + + 80 + 0 + + + + + 16777215 + 16777215 + + + + 0d 00:00 + + + - + @@ -994,7 +1187,7 @@ - + Qt::Vertical @@ -1012,12 +1205,12 @@ Program Service Name - ........ + PSN - + Qt::Vertical @@ -1077,14 +1270,45 @@ Alternate frequencies (MHz) - + 00.00 - + + + + + + 30 + 16777215 + + + + G02 + + + + + + + Qt::Vertical + + + + + + + Radiotext + + + + + + + @@ -1099,7 +1323,7 @@ - + Qt::Vertical @@ -1109,10 +1333,16 @@ - 200 + 0 0 + + + 150 + 16777215 + + ../../.. ..:..:.. @@ -1133,6 +1363,77 @@ + + + + + + + 30 + 16777215 + + + + G08 + + + + + + + Qt::Vertical + + + + + + + + 40 + 16777215 + + + + +0 + + + + + + + ___ + + + + + + + ___ + + + + + + + ___ + + + + + + + + 30 + 16777215 + + + + 0 + + + + + diff --git a/plugins/channel/bfm/rdsdecoder.cpp b/plugins/channel/bfm/rdsdecoder.cpp index 7e7f7922b..da7e8d15f 100644 --- a/plugins/channel/bfm/rdsdecoder.cpp +++ b/plugins/channel/bfm/rdsdecoder.cpp @@ -88,7 +88,7 @@ bool RDSDecoder::frameSync(bool bit) } else { - qDebug("RDSDecoder::frameSync: Sync State Detected"); + //qDebug("RDSDecoder::frameSync: Sync State Detected"); enter_sync(j); } } diff --git a/plugins/channel/bfm/rdsdecoder.h b/plugins/channel/bfm/rdsdecoder.h index 6b70d6635..349df09a0 100644 --- a/plugins/channel/bfm/rdsdecoder.h +++ b/plugins/channel/bfm/rdsdecoder.h @@ -26,6 +26,7 @@ public: bool frameSync(bool bit); unsigned int *getGroup() { return m_group; } + bool synced() const { return m_sync == SYNC; } float m_qua; diff --git a/plugins/channel/bfm/rdsparser.cpp b/plugins/channel/bfm/rdsparser.cpp index abb5bc673..a2ccf200a 100644 --- a/plugins/channel/bfm/rdsparser.cpp +++ b/plugins/channel/bfm/rdsparser.cpp @@ -127,7 +127,7 @@ const std::string RDSParser::rds_group_acronyms[16] = { const std::string RDSParser::rds_group_acronym_tags[16] = { "BAS", "PIN", - "RTX", + "TXT", "AID", "TIM", "TDC", @@ -147,7 +147,7 @@ const std::string RDSParser::rds_group_acronym_tags[16] = { /* see page 84, Annex J in the standard */ const std::string RDSParser::language_codes[44] = { - "Unkown/not applicable", + "N/A", "Albanian", "Breton", "Catalan", @@ -243,9 +243,20 @@ void RDSParser::clearUpdateFlags() m_pi_updated = false; m_g0_updated = false; m_g0_af_updated = false; + m_g1_updated = false; m_g2_updated = false; m_g4_updated = false; + m_g5_updated = false; + m_g6_updated = false; + m_g7_updated = false; m_g8_updated = false; + m_g9_updated = false; + m_g10_updated = false; + m_g11_updated = false; + m_g12_updated = false; + m_g13_updated = false; + m_g14_updated = false; + m_g15_updated = false; } void RDSParser::clearAllFields() @@ -310,6 +321,15 @@ void RDSParser::clearAllFields() m_g8_label_index = -1; m_g8_content = 0; + // Group 09..15 data + m_g9_count = 0; + m_g10_count = 0; + m_g11_count = 0; + m_g12_count = 0; + m_g13_count = 0; + m_g14_count = 0; + m_g15_count = 0; + clearUpdateFlags(); } @@ -318,9 +338,10 @@ void RDSParser::parseGroup(unsigned int *group) unsigned int group_type = (unsigned int)((group[1] >> 12) & 0xf); bool ab = (group[1] >> 11 ) & 0x1; + /* qDebug() << "RDSParser::parseGroup:" << " type: " << group_type << (ab ? 'B' :'A') - << " (" << rds_group_acronyms[group_type].c_str() << ")"; + << " (" << rds_group_acronyms[group_type].c_str() << ")";*/ m_pi_count++; m_pi_updated = true; @@ -674,6 +695,10 @@ void RDSParser::decode_type3(unsigned int *group, bool B) int message = group[2]; int aid = group[3]; + + m_g3_updated = true; + m_g3_count++; + qDebug() << "RDSParser::decode_type3: aid group: " << application_group << " " << (group_type ? 'B' : 'A'); @@ -752,14 +777,20 @@ void RDSParser::decode_type4(unsigned int *group, bool B) void RDSParser::decode_type5(unsigned int *group, bool B) { qDebug() << "RDSParser::decode_type5: type5 not implemented yet"; + m_g5_updated = true; + m_g5_count++; } void RDSParser::decode_type6(unsigned int *group, bool B) { qDebug() << "RDSParser::decode_type6: type 6 not implemented yet"; + m_g6_updated = true; + m_g6_count++; } void RDSParser::decode_type7(unsigned int *group, bool B) { qDebug() << "RDSParser::decode_type7: type 7 not implemented yet"; + m_g7_updated = true; + m_g7_count++; } void RDSParser::decode_type8(unsigned int *group, bool B) @@ -800,7 +831,7 @@ void RDSParser::decode_type8(unsigned int *group, bool B) m_g8_sign = (group[2] >> 14) & 0x1; // event direction, 0 = +, 1 = - m_g8_extent = (group[2] >> 11) & 0x7; // number of segments affected m_g8_event = group[2] & 0x7ff; // event code, defined in ISO 14819-2 - unsigned int location = group[3]; // location code, defined in ISO 14819-3 + m_g8_location = group[3]; // location code, defined in ISO 14819-3 qDebug() << "RDSParser::decode_type8: #user msg# " << (D ? "diversion recommended, " : ""); @@ -814,7 +845,7 @@ void RDSParser::decode_type8(unsigned int *group, bool B) qDebug() << "RDSParser::decode_type8: extent:" << (m_g8_sign ? "-" : "") << m_g8_extent + 1 << " segments" << ", event" << m_g8_event << ":" << RDSTMC::get_tmc_events(event_line, 1).c_str() - << ", location:" << location; + << ", location:" << m_g8_location; } else @@ -859,30 +890,41 @@ void RDSParser::decode_optional_content(int no_groups, unsigned long int *free_f ff_pointer -= content_length; m_g8_content = (free_format[i] && (int(std::pow(2, content_length) - 1) << ff_pointer)); + /* qDebug() << "RDSParser::decode_optional_content: TMC optional content (" << label_descriptions[m_g8_label_index].c_str() - << "):" << m_g8_content; + << "):" << m_g8_content;*/ } } } void RDSParser::decode_type9(unsigned int *group, bool B){ qDebug() << "RDSParser::decode_type9: type 9 not implemented yet"; + m_g9_updated = true; + m_g9_count++; } void RDSParser::decode_type10(unsigned int *group, bool B){ qDebug() << "RDSParser::decode_type10: type 10 not implemented yet"; + m_g10_updated = true; + m_g10_count++; } void RDSParser::decode_type11(unsigned int *group, bool B){ qDebug() << "RDSParser::decode_type11: type 11 not implemented yet"; + m_g11_updated = true; + m_g11_count++; } void RDSParser::decode_type12(unsigned int *group, bool B){ qDebug() << "RDSParser::decode_type12: type 12 not implemented yet"; + m_g12_updated = true; + m_g12_count++; } void RDSParser::decode_type13(unsigned int *group, bool B){ qDebug() << "RDSParser::decode_type13: type 13 not implemented yet"; + m_g13_updated = true; + m_g13_count++; } void RDSParser::decode_type14(unsigned int *group, bool B) @@ -898,6 +940,9 @@ void RDSParser::decode_type14(unsigned int *group, bool B) double af_1 = 0; double af_2 = 0; + m_g14_updated = true; + m_g14_count++; + if (!B) { switch (variant_code) @@ -975,7 +1020,8 @@ void RDSParser::decode_type14(unsigned int *group, bool B) if (pi_on) { - qDebug() << "RDSParser::decode_type14: PI(ON):" << pi_on; + std::string pistring = str(boost::format("%04X") % pi_on); + qDebug() << "RDSParser::decode_type14: PI(ON):" << pistring.c_str(); if (tp_on) { qDebug() << "RDSParser::decode_type14: TP(ON)"; @@ -985,5 +1031,7 @@ void RDSParser::decode_type14(unsigned int *group, bool B) void RDSParser::decode_type15(unsigned int *group, bool B){ qDebug() << "RDSParser::decode_type5: type 15 not implemented yet"; + m_g15_updated = true; + m_g15_count++; } diff --git a/plugins/channel/bfm/rdsparser.h b/plugins/channel/bfm/rdsparser.h index 776a342ba..0ad74a225 100644 --- a/plugins/channel/bfm/rdsparser.h +++ b/plugins/channel/bfm/rdsparser.h @@ -73,6 +73,7 @@ public: char m_g2_radiotext[64+1]; // G3 data + bool m_g3_updated; unsigned int m_g3_count; // G4 data @@ -87,6 +88,9 @@ public: double m_g4_local_time_offset; // G5..G7 data + bool m_g5_updated; + bool m_g6_updated; + bool m_g7_updated; unsigned int m_g5_count; unsigned int m_g6_count; unsigned int m_g7_count; @@ -99,9 +103,26 @@ public: bool m_g8_sign; unsigned int m_g8_extent; unsigned int m_g8_event; + unsigned int m_g8_location; int m_g8_label_index; //!< negative if not received int m_g8_content; + // G9..G15 data + bool m_g9_updated; + bool m_g10_updated; + bool m_g11_updated; + bool m_g12_updated; + bool m_g13_updated; + bool m_g14_updated; + bool m_g15_updated; + unsigned int m_g9_count; + unsigned int m_g10_count; + unsigned int m_g11_count; + unsigned int m_g12_count; + unsigned int m_g13_count; + unsigned int m_g14_count; + unsigned int m_g15_count; + // Static tables static const unsigned int offset_pos[5]; static const unsigned int offset_word[5];