From 4a419c98a994105c37a47460117d3fc1b54f41cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9F=D0=B5=D0=BB=D0=B8=D0=BF=D0=B5=D0=BD=D0=BA=D0=BE=20?= =?UTF-8?q?=D0=98=D0=B2=D0=B0=D0=BD?= Date: Wed, 31 Aug 2016 11:21:07 +0000 Subject: [PATCH] git-svn-id: svn://db.shs.com.ru/pip@245 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5 --- src/io/piconnection.cpp | 38 ++++++++++++++++++++++++++++++++++++++ src/io/piconnection.h | 6 ++++++ 2 files changed, 44 insertions(+) diff --git a/src/io/piconnection.cpp b/src/io/piconnection.cpp index 5cc23bde..eb22186a 100755 --- a/src/io/piconnection.cpp +++ b/src/io/piconnection.cpp @@ -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(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) { PIString fp(PIIODevice::normalizeFullPath(full_path)); Extractor * p = extractors.value(name_.trimmed()); diff --git a/src/io/piconnection.h b/src/io/piconnection.h index 6606cc0d..c83baec0 100755 --- a/src/io/piconnection.h +++ b/src/io/piconnection.h @@ -95,6 +95,12 @@ public: //! 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);} + + //! 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" * \details If there is no devices bounded to this filter, it will be removed. Returns if device was removed */