Restructure parsers, send label parser information to GUI application

This commit is contained in:
Alexander Bock
2015-05-07 18:26:23 +02:00
parent dac1f213b5
commit 1177e4e4cf
5 changed files with 52 additions and 39 deletions

View File

@@ -22,48 +22,52 @@
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#ifndef __SEQUENCEPARSER_H__
#define __SEQUENCEPARSER_H__
#include <openspace/util/decoder.h>
#include <openspace/network/networkengine.h>
#include <map>
#include <string>
#include <vector>
namespace openspace {
struct Image{
double startTime;
double stopTime;
std::string path;
std::vector<std::string> 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<std::string> 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 SequenceParser {
public:
virtual void create() = 0;
virtual void create() = 0;
virtual std::map<std::string, ImageSubset> getSubsetMap() final;
virtual std::vector<std::pair<std::string, TimeRange>> getIstrumentTimes() final;
virtual std::vector<std::pair<double, std::string>> getTargetTimes() final;
@@ -71,13 +75,16 @@ public:
virtual std::vector<double> getCaptureProgression() final;
protected:
void sendPlaybookInformation();
void sendPlaybookInformation(const std::string& name);
std::map<std::string, ImageSubset> _subsetMap;
std::vector<std::pair<std::string, TimeRange>> _instrumentTimes;
std::vector<std::pair<double, std::string>> _targetTimes;
std::vector<double> _captureProgression;
NetworkEngine::MessageIdentifier _messageIdentifier;
};
}
#endif //__SEQUENCEPARSER_H__
} // namespace openspace
#endif //__SEQUENCEPARSER_H__

View File

@@ -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");

View File

@@ -29,6 +29,7 @@
#include <ghoul/filesystem/directory.h>
#include <openspace/util/time.h>
#include <ghoul/filesystem/cachemanager.h>
#include <openspace/util/decoder.h>
#include <openspace/util/spicemanager.h>
#include <fstream>

View File

@@ -27,6 +27,7 @@
#include <ghoul/filesystem/directory.h>
#include <openspace/util/time.h>
#include <openspace/util/spicemanager.h>
#include <openspace/util/decoder.h>
#include <fstream>
#include <iterator>
#include <iomanip>
@@ -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);
}

View File

@@ -25,8 +25,8 @@
#include <openspace/util/sequenceparser.h>
#include <openspace/engine/openspaceengine.h>
#include <openspace/network/networkengine.h>
#include <openspace/util/spicemanager.h>
#include <openspace/util/decoder.h>
namespace {
const std::string _loggerCat = "SequenceParser";
@@ -73,8 +73,9 @@ void writeToBuffer<std::string>(std::vector<char>& 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<char> 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);
}
}