Add ranges to dynamic rewrite exclusion private calls/talk groups.

This commit is contained in:
Jonathan Naylor
2020-05-03 22:24:37 +01:00
parent 8e75b2453b
commit d0ceb64163
6 changed files with 73 additions and 25 deletions

View File

@@ -432,8 +432,16 @@ bool CConf::read()
rewrite.m_toTG = ::atoi(p5); rewrite.m_toTG = ::atoi(p5);
rewrite.m_range = ::atoi(p6); rewrite.m_range = ::atoi(p6);
for (std::vector<char*>::const_iterator it = p7.cbegin(); it != p7.cend(); ++it) { for (std::vector<char*>::const_iterator it = p7.cbegin(); it != p7.cend(); ++it) {
unsigned int tg = ::atoi(*it); const char* exclusion = *it;
rewrite.m_exclTGs.push_back(tg); const char* p = NULL;
if ((p = ::strchr(exclusion, '-')) != NULL) {
unsigned int tgstart = (unsigned int)::atoi(exclusion);
unsigned int tgend = (unsigned int)::atoi(p + 1U);
rewrite.m_exclTGs.push_back(std::make_pair(tgstart, tgend));
} else {
unsigned int tg = (unsigned int)::atoi(*it);
rewrite.m_exclTGs.push_back(std::make_pair(tg, tg));
}
} }
m_dmrNetwork1TGDynRewrites.push_back(rewrite); m_dmrNetwork1TGDynRewrites.push_back(rewrite);
} }
@@ -554,8 +562,16 @@ bool CConf::read()
rewrite.m_toTG = ::atoi(p5); rewrite.m_toTG = ::atoi(p5);
rewrite.m_range = ::atoi(p6); rewrite.m_range = ::atoi(p6);
for (std::vector<char*>::const_iterator it = p7.cbegin(); it != p7.cend(); ++it) { for (std::vector<char*>::const_iterator it = p7.cbegin(); it != p7.cend(); ++it) {
unsigned int tg = ::atoi(*it); const char* exclusion = *it;
rewrite.m_exclTGs.push_back(tg); const char* p = NULL;
if ((p = ::strchr(exclusion, '-')) != NULL) {
unsigned int tgstart = (unsigned int)::atoi(exclusion);
unsigned int tgend = (unsigned int)::atoi(p + 1U);
rewrite.m_exclTGs.push_back(std::make_pair(tgstart, tgend));
} else {
unsigned int tg = (unsigned int)::atoi(*it);
rewrite.m_exclTGs.push_back(std::make_pair(tg, tg));
}
} }
m_dmrNetwork2TGDynRewrites.push_back(rewrite); m_dmrNetwork2TGDynRewrites.push_back(rewrite);
} }
@@ -676,8 +692,16 @@ bool CConf::read()
rewrite.m_toTG = ::atoi(p5); rewrite.m_toTG = ::atoi(p5);
rewrite.m_range = ::atoi(p6); rewrite.m_range = ::atoi(p6);
for (std::vector<char*>::const_iterator it = p7.cbegin(); it != p7.cend(); ++it) { for (std::vector<char*>::const_iterator it = p7.cbegin(); it != p7.cend(); ++it) {
unsigned int tg = ::atoi(*it); const char* exclusion = *it;
rewrite.m_exclTGs.push_back(tg); const char* p = NULL;
if ((p = ::strchr(exclusion, '-')) != NULL) {
unsigned int tgstart = (unsigned int)::atoi(exclusion);
unsigned int tgend = (unsigned int)::atoi(p + 1U);
rewrite.m_exclTGs.push_back(std::make_pair(tgstart, tgend));
} else {
unsigned int tg = (unsigned int)::atoi(*it);
rewrite.m_exclTGs.push_back(std::make_pair(tg, tg));
}
} }
m_dmrNetwork3TGDynRewrites.push_back(rewrite); m_dmrNetwork3TGDynRewrites.push_back(rewrite);
} }
@@ -798,8 +822,16 @@ bool CConf::read()
rewrite.m_toTG = ::atoi(p5); rewrite.m_toTG = ::atoi(p5);
rewrite.m_range = ::atoi(p6); rewrite.m_range = ::atoi(p6);
for (std::vector<char*>::const_iterator it = p7.cbegin(); it != p7.cend(); ++it) { for (std::vector<char*>::const_iterator it = p7.cbegin(); it != p7.cend(); ++it) {
unsigned int tg = ::atoi(*it); const char* exclusion = *it;
rewrite.m_exclTGs.push_back(tg); const char* p = NULL;
if ((p = ::strchr(exclusion, '-')) != NULL) {
unsigned int tgstart = (unsigned int)::atoi(exclusion);
unsigned int tgend = (unsigned int)::atoi(p + 1U);
rewrite.m_exclTGs.push_back(std::make_pair(tgstart, tgend));
} else {
unsigned int tg = (unsigned int)::atoi(*it);
rewrite.m_exclTGs.push_back(std::make_pair(tg, tg));
}
} }
m_dmrNetwork4TGDynRewrites.push_back(rewrite); m_dmrNetwork4TGDynRewrites.push_back(rewrite);
} }
@@ -920,8 +952,16 @@ bool CConf::read()
rewrite.m_toTG = ::atoi(p5); rewrite.m_toTG = ::atoi(p5);
rewrite.m_range = ::atoi(p6); rewrite.m_range = ::atoi(p6);
for (std::vector<char*>::const_iterator it = p7.cbegin(); it != p7.cend(); ++it) { for (std::vector<char*>::const_iterator it = p7.cbegin(); it != p7.cend(); ++it) {
unsigned int tg = ::atoi(*it); const char* exclusion = *it;
rewrite.m_exclTGs.push_back(tg); const char* p = NULL;
if ((p = ::strchr(exclusion, '-')) != NULL) {
unsigned int tgstart = (unsigned int)::atoi(exclusion);
unsigned int tgend = (unsigned int)::atoi(p + 1U);
rewrite.m_exclTGs.push_back(std::make_pair(tgstart, tgend));
} else {
unsigned int tg = (unsigned int)::atoi(*it);
rewrite.m_exclTGs.push_back(std::make_pair(tg, tg));
}
} }
m_dmrNetwork5TGDynRewrites.push_back(rewrite); m_dmrNetwork5TGDynRewrites.push_back(rewrite);
} }

2
Conf.h
View File

@@ -61,7 +61,7 @@ struct CTGDynRewriteStruct {
unsigned int m_statusPC; unsigned int m_statusPC;
unsigned int m_toTG; unsigned int m_toTG;
unsigned int m_range; unsigned int m_range;
std::vector<unsigned int> m_exclTGs; std::vector<std::pair<unsigned int, unsigned int>> m_exclTGs;
}; };
struct CIdRewriteStruct { struct CIdRewriteStruct {

View File

@@ -34,10 +34,10 @@ public:
void setCurrentTG(unsigned int tg); void setCurrentTG(unsigned int tg);
private: private:
std::string m_name; std::string m_name;
unsigned int m_slot; unsigned int m_slot;
unsigned int m_toTG; unsigned int m_toTG;
unsigned int m_currentTG; unsigned int m_currentTG;
}; };
#endif #endif

View File

@@ -25,7 +25,7 @@
#include <cassert> #include <cassert>
#include <algorithm> #include <algorithm>
CRewriteDynTGRF::CRewriteDynTGRF(const std::string& name, unsigned int slot, unsigned int fromTG, unsigned int toTG, unsigned int discPC, unsigned int statusPC, unsigned int range, const std::vector<unsigned int>& exclTGs, CRewriteDynTGNet* rewriteNet, CDynVoice* voice) : CRewriteDynTGRF::CRewriteDynTGRF(const std::string& name, unsigned int slot, unsigned int fromTG, unsigned int toTG, unsigned int discPC, unsigned int statusPC, unsigned int range, const std::vector<std::pair<unsigned int, unsigned int>>& exclTGs, CRewriteDynTGNet* rewriteNet, CDynVoice* voice) :
CRewrite(), CRewrite(),
m_name(name), m_name(name),
m_slot(slot), m_slot(slot),
@@ -105,11 +105,15 @@ PROCESS_RESULT CRewriteDynTGRF::process(CDMRData& data, bool trace)
return RESULT_IGNORED; return RESULT_IGNORED;
} }
if (slotNo == m_slot && std::find(m_exclTGs.cbegin(), m_exclTGs.cend(), dstId) != m_exclTGs.cend()) { if (slotNo == m_slot) {
if (trace) for (std::vector<std::pair<unsigned int, unsigned int>>::const_iterator it = m_exclTGs.cbegin(); it != m_exclTGs.cend(); ++it) {
LogDebug("Rule Trace,\tRewriteDynTGRF from %s Slot=%u Dst=%u: not matched", m_name.c_str(), m_slot, dstId); if (dstId >= (*it).first && dstId <= (*it).second) {
if (trace)
LogDebug("Rule Trace,\tRewriteDynTGRF from %s Slot=%u Dst=%u: not matched", m_name.c_str(), m_slot, dstId);
return RESULT_UNMATCHED; return RESULT_UNMATCHED;
}
}
} }
if (slotNo == m_slot && dstId >= m_fromTGStart && dstId <= m_fromTGEnd) { if (slotNo == m_slot && dstId >= m_fromTGStart && dstId <= m_fromTGEnd) {
@@ -159,8 +163,12 @@ void CRewriteDynTGRF::tgChange(unsigned int slot, unsigned int tg)
if (slot == m_slot && tg == m_statusPC) if (slot == m_slot && tg == m_statusPC)
return; return;
if (slot == m_slot && std::find(m_exclTGs.cbegin(), m_exclTGs.cend(), tg) != m_exclTGs.cend()) if (slot == m_slot) {
return; for (std::vector<std::pair<unsigned int, unsigned int>>::const_iterator it = m_exclTGs.cbegin(); it != m_exclTGs.cend(); ++it) {
if (tg >= (*it).first && tg <= (*it).second)
return;
}
}
if (slot == m_slot && tg >= m_fromTGStart && tg <= m_fromTGEnd) { if (slot == m_slot && tg >= m_fromTGStart && tg <= m_fromTGEnd) {
if (m_currentTG != tg) { if (m_currentTG != tg) {

View File

@@ -30,7 +30,7 @@
class CRewriteDynTGRF : public CRewrite { class CRewriteDynTGRF : public CRewrite {
public: public:
CRewriteDynTGRF(const std::string& name, unsigned int slot, unsigned int fromTG, unsigned int toTG, unsigned int discPC, unsigned int statusPC, unsigned int range, const std::vector<unsigned int>& exclTGs, CRewriteDynTGNet* rewriteNet, CDynVoice* voice); CRewriteDynTGRF(const std::string& name, unsigned int slot, unsigned int fromTG, unsigned int toTG, unsigned int discPC, unsigned int statusPC, unsigned int range, const std::vector<std::pair<unsigned int, unsigned int>>& exclTGs, CRewriteDynTGNet* rewriteNet, CDynVoice* voice);
virtual ~CRewriteDynTGRF(); virtual ~CRewriteDynTGRF();
virtual PROCESS_RESULT process(CDMRData& data, bool trace); virtual PROCESS_RESULT process(CDMRData& data, bool trace);
@@ -47,7 +47,7 @@ private:
unsigned int m_toTG; unsigned int m_toTG;
unsigned int m_discPC; unsigned int m_discPC;
unsigned int m_statusPC; unsigned int m_statusPC;
std::vector<unsigned int> m_exclTGs; std::vector<std::pair<unsigned int, unsigned int>> m_exclTGs;
CRewriteDynTGNet* m_rewriteNet; CRewriteDynTGNet* m_rewriteNet;
CDynVoice* m_voice; CDynVoice* m_voice;
unsigned int m_currentTG; unsigned int m_currentTG;

View File

@@ -19,6 +19,6 @@
#if !defined(VERSION_H) #if !defined(VERSION_H)
#define VERSION_H #define VERSION_H
const char* VERSION = "20200421"; const char* VERSION = "20200503";
#endif #endif