git-svn-id: svn://db.shs.com.ru/pip@245 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
This commit is contained in:
@@ -463,6 +463,44 @@ PIPacketExtractor * PIConnection::addFilter(const PIString & name_, const PIStri
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
PIPacketExtractor * PIConnection::addFilter(PIPacketExtractor * filter, const PIString & full_path) {
|
||||||
|
PIString fp(PIIODevice::normalizeFullPath(full_path));
|
||||||
|
Extractor * e = 0;
|
||||||
|
if (full_path.isEmpty()) return (e == 0 ? 0 : e->extractor);
|
||||||
|
PIIODevice * dev = deviceByFullPath(fp);
|
||||||
|
PIPacketExtractor * pe(0);
|
||||||
|
if (extractors.value(full_path) != 0) pe = extractors.value(full_path)->extractor;
|
||||||
|
if (pe != 0) dev = pe;
|
||||||
|
if (dev == 0) {
|
||||||
|
piCoutObj << "\"addFilter\" error: no such device \"" << full_path << "\"!";
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (e == 0) {
|
||||||
|
e = new Extractor();
|
||||||
|
extractors[filter->name()] = e;
|
||||||
|
}
|
||||||
|
if (e->extractor == 0) {
|
||||||
|
e->extractor = filter;
|
||||||
|
e->extractor->setThreadedReadData(new PIPair<PIConnection * , PIString>(this, filter->name()));
|
||||||
|
__device_pool__->lock();
|
||||||
|
if (diags_.value(e->extractor, 0) == 0) {
|
||||||
|
PIDiagnostics * d = new PIDiagnostics(false);
|
||||||
|
d->setInterval(10.);
|
||||||
|
diags_[e->extractor] = d;
|
||||||
|
CONNECTU(d, qualityChanged, this, diagQualityChanged);
|
||||||
|
}
|
||||||
|
__device_pool__->unlock();
|
||||||
|
CONNECT2(void, uchar * , int, e->extractor, packetReceived, this, packetExtractorReceived)
|
||||||
|
}
|
||||||
|
if (!e->devices.contains(dev)) {
|
||||||
|
bounded_extractors[dev] << e->extractor;
|
||||||
|
//if (PIString(dev->className()) == "PIPacketExtractor") dev->setThreadSafe(false);
|
||||||
|
e->devices << dev;
|
||||||
|
}
|
||||||
|
return e->extractor;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool PIConnection::removeFilter(const PIString & name_, const PIString & full_path) {
|
bool PIConnection::removeFilter(const PIString & name_, const PIString & full_path) {
|
||||||
PIString fp(PIIODevice::normalizeFullPath(full_path));
|
PIString fp(PIIODevice::normalizeFullPath(full_path));
|
||||||
Extractor * p = extractors.value(name_.trimmed());
|
Extractor * p = extractors.value(name_.trimmed());
|
||||||
|
|||||||
@@ -96,6 +96,12 @@ public:
|
|||||||
//! Add filter with name "name" to device "dev"
|
//! Add filter with name "name" to device "dev"
|
||||||
PIPacketExtractor * addFilter(const PIString & name, const PIIODevice * dev, PIPacketExtractor::SplitMode mode = PIPacketExtractor::None) {return addFilter(name, devFPath(dev), mode);}
|
PIPacketExtractor * addFilter(const PIString & name, const PIIODevice * dev, PIPacketExtractor::SplitMode mode = PIPacketExtractor::None) {return addFilter(name, devFPath(dev), mode);}
|
||||||
|
|
||||||
|
//! Add filter with "filter" to device "dev"
|
||||||
|
PIPacketExtractor * addFilter(PIPacketExtractor * filter, const PIString & full_path_name);
|
||||||
|
|
||||||
|
//! Add filter with "filter" to device "dev"
|
||||||
|
PIPacketExtractor * addFilter(PIPacketExtractor * filter, const PIIODevice * dev) {return addFilter(filter, devFPath(dev));}
|
||||||
|
|
||||||
/*! \brief Remove from filter with name "name" device with full path "full_path_name" or filter "full_path_name"
|
/*! \brief Remove from filter with name "name" device with full path "full_path_name" or filter "full_path_name"
|
||||||
* \details If there is no devices bounded to this filter, it will be removed. Returns if device was removed */
|
* \details If there is no devices bounded to this filter, it will be removed. Returns if device was removed */
|
||||||
bool removeFilter(const PIString & name, const PIString & full_path_name);
|
bool removeFilter(const PIString & name, const PIString & full_path_name);
|
||||||
|
|||||||
Reference in New Issue
Block a user