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_range = ::atoi(p6);
for (std::vector<char*>::const_iterator it = p7.cbegin(); it != p7.cend(); ++it) {
unsigned int tg = ::atoi(*it);
rewrite.m_exclTGs.push_back(tg);
const char* exclusion = *it;
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);
}
@@ -554,8 +562,16 @@ bool CConf::read()
rewrite.m_toTG = ::atoi(p5);
rewrite.m_range = ::atoi(p6);
for (std::vector<char*>::const_iterator it = p7.cbegin(); it != p7.cend(); ++it) {
unsigned int tg = ::atoi(*it);
rewrite.m_exclTGs.push_back(tg);
const char* exclusion = *it;
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);
}
@@ -676,8 +692,16 @@ bool CConf::read()
rewrite.m_toTG = ::atoi(p5);
rewrite.m_range = ::atoi(p6);
for (std::vector<char*>::const_iterator it = p7.cbegin(); it != p7.cend(); ++it) {
unsigned int tg = ::atoi(*it);
rewrite.m_exclTGs.push_back(tg);
const char* exclusion = *it;
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);
}
@@ -798,8 +822,16 @@ bool CConf::read()
rewrite.m_toTG = ::atoi(p5);
rewrite.m_range = ::atoi(p6);
for (std::vector<char*>::const_iterator it = p7.cbegin(); it != p7.cend(); ++it) {
unsigned int tg = ::atoi(*it);
rewrite.m_exclTGs.push_back(tg);
const char* exclusion = *it;
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);
}
@@ -920,8 +952,16 @@ bool CConf::read()
rewrite.m_toTG = ::atoi(p5);
rewrite.m_range = ::atoi(p6);
for (std::vector<char*>::const_iterator it = p7.cbegin(); it != p7.cend(); ++it) {
unsigned int tg = ::atoi(*it);
rewrite.m_exclTGs.push_back(tg);
const char* exclusion = *it;
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);
}

2
Conf.h
View File

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

View File

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

View File

@@ -25,7 +25,7 @@
#include <cassert>
#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(),
m_name(name),
m_slot(slot),
@@ -105,11 +105,15 @@ PROCESS_RESULT CRewriteDynTGRF::process(CDMRData& data, bool trace)
return RESULT_IGNORED;
}
if (slotNo == m_slot && std::find(m_exclTGs.cbegin(), m_exclTGs.cend(), dstId) != m_exclTGs.cend()) {
if (trace)
LogDebug("Rule Trace,\tRewriteDynTGRF from %s Slot=%u Dst=%u: not matched", m_name.c_str(), m_slot, dstId);
if (slotNo == m_slot) {
for (std::vector<std::pair<unsigned int, unsigned int>>::const_iterator it = m_exclTGs.cbegin(); it != m_exclTGs.cend(); ++it) {
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) {
@@ -159,8 +163,12 @@ void CRewriteDynTGRF::tgChange(unsigned int slot, unsigned int tg)
if (slot == m_slot && tg == m_statusPC)
return;
if (slot == m_slot && std::find(m_exclTGs.cbegin(), m_exclTGs.cend(), tg) != m_exclTGs.cend())
return;
if (slot == m_slot) {
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 (m_currentTG != tg) {

View File

@@ -30,7 +30,7 @@
class CRewriteDynTGRF : public CRewrite {
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 PROCESS_RESULT process(CDMRData& data, bool trace);
@@ -47,7 +47,7 @@ private:
unsigned int m_toTG;
unsigned int m_discPC;
unsigned int m_statusPC;
std::vector<unsigned int> m_exclTGs;
std::vector<std::pair<unsigned int, unsigned int>> m_exclTGs;
CRewriteDynTGNet* m_rewriteNet;
CDynVoice* m_voice;
unsigned int m_currentTG;

View File

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