Merge branch 'thesis/2019/spaceweather-stream' of https://github.com/OpenSpace/OpenSpace into thesis/2019/spaceweather-stream

This commit is contained in:
Kollberg
2019-07-01 13:36:01 -04:00
4 changed files with 65 additions and 18 deletions
+4 -4
View File
@@ -29,9 +29,9 @@ local sunRadius = 695508000
--asset.require('./bastille_day/fieldlines')
-- Selected field lines + some additional field lines
asset.require('./testwsa/scs_oi')
asset.require('./testwsa/pfss_oi')
asset.require('./testwsa/pfss_io')
-- asset.require('./testwsa/scs_oi')
-- asset.require('./testwsa/pfss_oi')
-- asset.require('./testwsa/pfss_io')
-- Sun earth connection
-- asset.require('./testwsa/scs_oi_540')
@@ -44,7 +44,7 @@ asset.require('./testwsa/pfss_io')
-- Every N:th WSA field line
-- asset.require('./testwsa/scs_oi_25')
-- asset.require('./testwsa/pfss_oi_25')
-- asset.require('./testwsa/pfss_io_25')
asset.require('./testwsa/pfss_io_25')
asset.onInitialize(function ()
local now = openspace.time.currentWallTime()
@@ -372,7 +372,7 @@ void RenderableFieldlinesSequence::initializeGL() {
setRenderBin(Renderable::RenderBin::Overlay);
// ----------------- Initialize Web Fieldlines Manager things ---------------------//
WebFieldlinesManager webFieldlinesManager(_sourceFiles[0]);
//WebFieldlinesManager webFieldlinesManager(_sourceFiles[0]);
}
/**
@@ -1168,8 +1168,20 @@ void RenderableFieldlinesSequence::update(const UpdateData& data) {
}
const double currentTime = data.time.j2000Seconds();
// en liten fuling för att testa att trigga nedladdning
if(currentTime > 610056120.0 && currentTime < 610056120.2){
LERROR("downloading is starting");
WebFieldlinesManager webFieldlinesManager(_sourceFiles[0]);
webFieldlinesManager.downloadFieldlines(_sourceFiles, _startTimes, _nStates);
computeSequenceEndTime();
}
const bool isInInterval = (currentTime >= _startTimes[0]) &&
(currentTime < _sequenceEndTime);
// Check if current time in OpenSpace is within sequence interval
if (isInInterval) {
@@ -43,8 +43,9 @@ namespace openspace{
WebFieldlinesManager::WebFieldlinesManager(std::string syncDir){
// Using constructor for some testing
ghoul::filesystem::File tempFile = ghoul::filesystem::File(syncDir);
_syncDir = tempFile.directoryName();
// ghoul::filesystem::File tempFile = ghoul::filesystem::File(syncDir);
//_syncDir = tempFile.directoryName();
_syncDir = "/Users/shuy/Offline-dokument/OpenSpace/Spaceweather/OpenSpace/data/assets/testwsa/fl_pfss_io_25";
_flsType = PFSSIO;
_flsTypeString = "PFSSIO";
@@ -57,10 +58,35 @@ namespace openspace{
getAvailableTriggertimes();
LERROR("WebFieldlinesManager initialized");
// for (auto& tt : _availableTriggertimes){
// downloadOsfls(_flsType, tt);
// }
}
// For testing purposes
void WebFieldlinesManager::downloadFieldlines(std::vector<std::string>& _sourceFile, std::vector<double>& _startTimes, size_t& _nStates){
LERROR("starting download");
for (auto& tt : _availableTriggertimes){
downloadOsfls(_flsType, tt);
//add the timetrigger at the right place in the list
std::string sub = tt.substr(6, 23);
int temp;
triggerTimeString2Int(sub,temp);
double timetriggernumber = temp;
int i = 0;
while(timetriggernumber > _startTimes[i]){
if( i == _startTimes.size()) break;
else i++;
}
_sourceFile.insert(_sourceFile.begin() + i, _syncDir + '/' + tt.substr(6));
_startTimes.insert(_startTimes.begin() + i, timetriggernumber);
_nStates += 1;
}
}
void WebFieldlinesManager::update(){
@@ -68,13 +94,19 @@ namespace openspace{
}
void WebFieldlinesManager::downloadOsfls(FlsType type, std::string triggertime){
std::string url = "http://localhost:3000/WSA/" + triggertime;
std::string destinationpath = absPath(_syncDir + '/' + triggertime);
AsyncHttpFileDownload ashd = AsyncHttpFileDownload(url, destinationpath, HttpFileDownload::Overwrite::Yes);
HttpRequest::RequestOptions opt = {};
opt.requestTimeoutSeconds = 0;
ashd.start(opt);
ashd.wait();
std::string url = "http://localhost:3000/WSA/" + triggertime;
std::string destinationpath = absPath(_syncDir + '/' + triggertime.substr(6));
AsyncHttpFileDownload ashd = AsyncHttpFileDownload(url, destinationpath, HttpFileDownload::Overwrite::Yes);
HttpRequest::RequestOptions opt = {};
opt.requestTimeoutSeconds = 0;
ashd.start(opt);
ashd.wait();
if(ashd.hasSucceeded() == true ){
LERROR("succeeeded: " + destinationpath);
}
if(ashd.hasFailed() == true ){
LERROR("failed: " + destinationpath);
}
}
@@ -37,6 +37,10 @@ public:
// What model of FieldlinesSequence is this?
enum FlsType { PFSSIO, PFSSOI, SCSOI };
// For testing purposes
void downloadFieldlines(std::vector<std::string>& _sourceFile, std::vector<double>& _startTimes, size_t& _nStates);
private:
@@ -77,7 +81,6 @@ private:
// some temporary functions to translate the filenames to ints
void triggerTimeString2Int(std::string s, int& d);
void triggerTimeInt2String(int d, std::string& s);
};