This commit is contained in:
Sovanny Huy
2019-07-02 16:04:09 -04:00
4 changed files with 87 additions and 12 deletions

View File

@@ -54,6 +54,8 @@ namespace {
constexpr const char* KeyInputFileType = "InputFileType";
// [STRING] should be path to folder containing the input files
constexpr const char* KeySourceFolder = "SourceFolder";
// [BOOLEAN] should specify whether field line data should be fetched online or not
constexpr const char* KeyWebFieldline = "WebFieldline";
// ---------------------- MANDATORY INPUT TYPE SPECIFIC KEYS ---------------------- //
// [STRING] Path to a .txt file containing seed points
@@ -371,8 +373,6 @@ void RenderableFieldlinesSequence::initializeGL() {
// Needed for additive blending
setRenderBin(Renderable::RenderBin::Overlay);
// ----------------- Initialize Web Fieldlines Manager things ---------------------//
//WebFieldlinesManager webFieldlinesManager(_sourceFiles[0]);
}
/**
@@ -419,9 +419,23 @@ bool RenderableFieldlinesSequence::extractMandatoryInfoFromDictionary(
}
std::string sourceFolderPath;
bool webFieldLine;
if (!_dictionary->getValue(KeySourceFolder, sourceFolderPath)) {
LERROR(fmt::format("{}: The field {} is missing", _identifier, KeySourceFolder));
return false;
// If this is a web-fieldline, we don't need no sourcefolder
if (!_dictionary->getValue(KeyWebFieldline, webFieldLine)) {
LERROR(fmt::format("{}: The field {} is missing", _identifier, KeySourceFolder));
return false;
}
else if (!webFieldLine) {
LERROR(fmt::format("{}: The field {} is missing", _identifier, KeySourceFolder));
return false;
}
}
if (webFieldLine) {
initializeWebManager();
sourceFolderPath = _webFieldlinesManager.getDirectory();
}
// Ensure that the source folder exists and then extract
@@ -530,7 +544,9 @@ void RenderableFieldlinesSequence::extractOptionalInfoFromDictionary(
}
}
// The reason this exists is because some values are read from the properties in the GUI.
// This function may change the default values of those properties, if the user has specified them
// in the asset file
void RenderableFieldlinesSequence::extractPropertyInfoFromDictionary() {
// Specified weather to use uniform coloring or by specified quantity.
std::string coloringMethodDictionary;
@@ -1162,6 +1178,10 @@ void RenderableFieldlinesSequence::render(const RenderData& data, RendererTasks&
}
}
void RenderableFieldlinesSequence::initializeWebManager() {
_webFieldlinesManager(_identifier, "PfssIo");
}
void RenderableFieldlinesSequence::update(const UpdateData& data) {
if (_shaderProgram->isDirty()) {
_shaderProgram->rebuildFromFile();
@@ -1171,7 +1191,6 @@ void RenderableFieldlinesSequence::update(const UpdateData& data) {
// en liten fuling för att testa att trigga nedladdning
if(currentTime > 610056120.0 && currentTime < 610056120.2){
WebFieldlinesManager webFieldlinesManager(_activeTriggerTimeIndex, _nStates, _sourceFiles, _startTimes);
LERROR("downloading is starting");
webFieldlinesManager.downloadFieldlines();
computeSequenceEndTime();

View File

@@ -52,6 +52,7 @@ public:
bool isReady() const override;
void render(const RenderData& data, RendererTasks& rendererTask) override;
void initializeWebManager();
void update(const UpdateData& data) override;
private:
@@ -200,7 +201,9 @@ private:
// --------------------- Web Fieldlines Manager ----------------------------------- //
//WebFieldlinesManager _webFieldlinesManager;
// Web Fieldlines manager downloads and updates renderable field lines with //
// field lines downloaded from the web. //
WebFieldlinesManager _webFieldlinesManager;
// --------------------- FUNCTIONS USED DURING INITIALIZATION --------------------- //

View File

@@ -40,10 +40,10 @@ namespace {
namespace openspace{
WebFieldlinesManager::WebFieldlinesManager(int& _activeTriggerTimeIndex, size_t& _nStates, std::vector<std::string>& _sourceFiles, std::vector<double>& _startTimes){
WebFieldlinesManager::WebFieldlinesManager(std::string syncDir, int& _activeTriggerTimeIndex, size_t& _nStates, std::vector<std::string>& _sourceFiles, std::vector<double>& _startTimes){
// change to parameter
_syncDir = "/Users/shuy/Offline-dokument/OpenSpace/Spaceweather/OpenSpace/data/assets/testwsa/fl_pfss_io_25";
_syncDir = syncDir;
_flsType = "PfssIo";
_downloadMargin = 3;
_timeTriggerDelta = 7200;
@@ -86,6 +86,32 @@ namespace openspace{
(*rfs_nStates) += 1;
}
}
// ------------------------------- OPERATORS ------------------------------- //
// Operator ()
void WebFieldlinesManager::operator()(std::string identifier, std::string fieldLineModelType)
{
_flsType = fieldLineModelType;
_syncDir = initializeSyncDirectory(identifier);
std::string testTime;
triggerTimeInt2String(610056000, testTime);
int testInt;
triggerTimeString2Int(testTime, testInt);
getAvailableTriggertimes();
LERROR("WebFieldlinesManager initialized");
}
std::string WebFieldlinesManager::getDirectory(){
return _syncDir;
}
// --------------------------- PRIVATE FUNCTIONS --------------------------- //
// this function aint done
void WebFieldlinesManager::update(){
@@ -121,6 +147,21 @@ namespace openspace{
}
return destinationpath;
}
// Make sure that the sync directory exists
// Also creates a new directory in the web_fieldlines directory corresponding to the field line identifier
std::string WebFieldlinesManager::initializeSyncDirectory(std::string identifier) {
std::string path = absPath("${BASE}/sync/http/web_fieldlines") + FileSys.PathSeparator;
if (!FileSys.directoryExists(path)) {
FileSys.createDirectory(path);
}
path = absPath(path + identifier);
if(!FileSys.directoryExists(path)) {
FileSys.createDirectory(path);
}
return path;
}
void WebFieldlinesManager::getAvailableTriggertimes(){

View File

@@ -32,18 +32,28 @@ namespace openspace {
class WebFieldlinesManager{
public:
WebFieldlinesManager();
WebFieldlinesManager(int& _activeTriggerTimeIndex, size_t& _nStates, std::vector<std::string>& _sourceFiles, std::vector<double>& _startTimes);
// Constructor
WebFieldlinesManager() = default;
WebFieldlinesManager(std::string syncDir, int& _activeTriggerTimeIndex, size_t& _nStates, std::vector<std::string>& _sourceFiles, std::vector<double>& _startTimes);
// download files specified in _filestodownload
void downloadFieldlines();
//---------------- OPERATORS ------------------------- //
// To replace the constructor, takes the identifier of the field line, is used for storing the field lines mainly
// Also takes a second parameter containing the name of the field line model used.
// These may in the future be the same.
void operator ()(std::string identifier, std::string fieldLineModelType);
// Returns the sync directory
std::string getDirectory();
private:
std::string _syncDir;
// What model is this field line derived from, may come to be the same as the identifier
std::string _flsType;
int _downloadMargin;
@@ -78,6 +88,8 @@ private:
// ***turn into ints later***
std::string downloadOsfls(std::string triggertime);
std::string initializeSyncDirectory(std::string identifier);
// Get list of all triggertimes(field lines states) available form the server
void getAvailableTriggertimes();