From 1177e4e4cf2fc2bb553bd28bf2556bb446ff099a Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Thu, 7 May 2015 18:26:23 +0200 Subject: [PATCH] Restructure parsers, send label parser information to GUI application --- include/openspace/util/sequenceparser.h | 73 ++++++++++++++----------- src/util/hongkangparser.cpp | 4 +- src/util/imagesequencer2.cpp | 1 + src/util/labelparser.cpp | 4 ++ src/util/sequenceparser.cpp | 9 +-- 5 files changed, 52 insertions(+), 39 deletions(-) diff --git a/include/openspace/util/sequenceparser.h b/include/openspace/util/sequenceparser.h index c39e649327..4eb3a42582 100644 --- a/include/openspace/util/sequenceparser.h +++ b/include/openspace/util/sequenceparser.h @@ -22,48 +22,52 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ - #ifndef __SEQUENCEPARSER_H__ #define __SEQUENCEPARSER_H__ -#include +#include #include #include #include namespace openspace { - struct Image{ - double startTime; - double stopTime; - std::string path; - std::vector activeInstruments; - std::string target; - bool projected; - }; - struct TimeRange{ - TimeRange() : _min(-1), _max(-1){}; - void setRange(double val){ - if (_min > val) _min = val; - if (_max < val) _max = val; - }; - bool inRange(double min, double max){ - return (min >= _min && max <= _max); - } - bool inRange(double val){ - return (val >= _min && val <= _max); - } - double _min; - double _max; - }; - struct ImageSubset{ - TimeRange _range; - std::vector < Image > _subset; - }; + +class Decoder; + +struct Image { + double startTime; + double stopTime; + std::string path; + std::vector activeInstruments; + std::string target; + bool projected; +}; + +struct TimeRange { + TimeRange() : _min(-1), _max(-1){}; + void setRange(double val){ + if (_min > val) _min = val; + if (_max < val) _max = val; + }; + bool inRange(double min, double max){ + return (min >= _min && max <= _max); + } + bool inRange(double val){ + return (val >= _min && val <= _max); + } + double _min; + double _max; +}; + +struct ImageSubset { + TimeRange _range; + std::vector _subset; +}; class SequenceParser { public: - virtual void create() = 0; + virtual void create() = 0; virtual std::map getSubsetMap() final; virtual std::vector> getIstrumentTimes() final; virtual std::vector> getTargetTimes() final; @@ -71,13 +75,16 @@ public: virtual std::vector getCaptureProgression() final; protected: - void sendPlaybookInformation(); + void sendPlaybookInformation(const std::string& name); std::map _subsetMap; std::vector> _instrumentTimes; std::vector> _targetTimes; std::vector _captureProgression; + NetworkEngine::MessageIdentifier _messageIdentifier; }; -} -#endif //__SEQUENCEPARSER_H__ \ No newline at end of file + +} // namespace openspace + +#endif //__SEQUENCEPARSER_H__ diff --git a/src/util/hongkangparser.cpp b/src/util/hongkangparser.cpp index 784cfd2f44..c2198e9766 100644 --- a/src/util/hongkangparser.cpp +++ b/src/util/hongkangparser.cpp @@ -40,7 +40,7 @@ namespace { const std::string _loggerCat = "HongKangParser"; const std::string keyTranslation = "DataInputTranslation"; - const std::string PlaybookIdentifierName = "Playbook"; + const std::string PlaybookIdentifierName = "HongKang"; } namespace openspace { @@ -251,7 +251,7 @@ void HongKangParser::create(){ } } - sendPlaybookInformation(); + sendPlaybookInformation(PlaybookIdentifierName); //std::ofstream myfile; //myfile.open("HongKangOutput.txt"); diff --git a/src/util/imagesequencer2.cpp b/src/util/imagesequencer2.cpp index 446cd20bf0..bae2259547 100644 --- a/src/util/imagesequencer2.cpp +++ b/src/util/imagesequencer2.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #include #include diff --git a/src/util/labelparser.cpp b/src/util/labelparser.cpp index ba68c15971..47e01423ed 100644 --- a/src/util/labelparser.cpp +++ b/src/util/labelparser.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -38,6 +39,8 @@ namespace { const std::string _loggerCat = "LabelParser"; const std::string keySpecs = "Read"; const std::string keyConvert = "Convert"; + + const std::string PlaybookIdentifierName = "LabelParser"; } namespace openspace { @@ -272,6 +275,7 @@ void LabelParser::create(){ } //myfile.close(); + sendPlaybookInformation(PlaybookIdentifierName); } diff --git a/src/util/sequenceparser.cpp b/src/util/sequenceparser.cpp index aaa60fc0c3..9b44c8092e 100644 --- a/src/util/sequenceparser.cpp +++ b/src/util/sequenceparser.cpp @@ -25,8 +25,8 @@ #include #include -#include #include +#include namespace { const std::string _loggerCat = "SequenceParser"; @@ -73,8 +73,9 @@ void writeToBuffer(std::vector& buffer, size_t& currentWriteL currentWriteLocation += length; } -void SequenceParser::sendPlaybookInformation() { - static const NetworkEngine::MessageIdentifier PlaybookIdentifier = OsEng.networkEngine()->identifier(PlaybookIdentifierName); +void SequenceParser::sendPlaybookInformation(const std::string& name) { + std::string fullName = PlaybookIdentifierName + "_" + name; + _messageIdentifier = OsEng.networkEngine()->identifier(fullName); std::vector buffer(1024); size_t currentWriteLocation = 0; @@ -164,7 +165,7 @@ void SequenceParser::sendPlaybookInformation() { buffer.resize(currentWriteLocation); //OsEng.networkEngine()->publishMessage(PlaybookIdentifier, buffer); - OsEng.networkEngine()->setInitialConnectionMessage(PlaybookIdentifier, buffer); + OsEng.networkEngine()->setInitialConnectionMessage(_messageIdentifier, buffer); } } \ No newline at end of file