mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-05-04 18:11:01 -05:00
back to where it works. More TODOs
This commit is contained in:
@@ -197,7 +197,7 @@ asset.onInitialize(function ()
|
||||
|
||||
-- Set different deltatimes
|
||||
sceneHelper.setDeltaTimeKeys({
|
||||
1801, 3600, 430000
|
||||
1, 3600, 430000
|
||||
})
|
||||
|
||||
openspace.setDefaultGuiSorting()
|
||||
|
||||
+1
-1
Submodule ext/ghoul updated: 0461bf1f44...1c0ccf9655
@@ -307,7 +307,7 @@ void RenderableTimeVaryingSphere::update(const UpdateData& data) {
|
||||
|
||||
if (!_webContentUrl.empty()) {
|
||||
if (!_webFieldlinesManager.hasUpdated &&
|
||||
_webFieldlinesManager.checkIfWindowIsReadyToLoad())
|
||||
_webFieldlinesManager.isWindowReadyToLoad())
|
||||
{
|
||||
_triggerTimes.clear();
|
||||
extractTriggerTimesFromFileNames();
|
||||
@@ -580,7 +580,6 @@ void RenderableTimeVaryingSphere::readNewTexture(const std::string& filePath) {
|
||||
}
|
||||
|
||||
std::vector<float> RenderableTimeVaryingSphere::processWSAFitsFile(std::string filePath){
|
||||
std::vector<float> res;
|
||||
|
||||
FitsFileReader fitsFileReader(false);
|
||||
|
||||
@@ -595,7 +594,7 @@ std::vector<float> RenderableTimeVaryingSphere::processWSAFitsFile(std::string f
|
||||
// Observatory header value
|
||||
//const std::string wsaMapType = *fitsFileReader.readHeaderValueString("OBSER");
|
||||
|
||||
std::vector<std::vector<float>> rgbLayers;
|
||||
std::vector<glm::vec3> rgbLayers;
|
||||
float r, g, b;
|
||||
|
||||
// the numbers 64800, 16200 means, grab the fifth layer in the fits file, where the
|
||||
@@ -607,10 +606,8 @@ std::vector<float> RenderableTimeVaryingSphere::processWSAFitsFile(std::string f
|
||||
// since they have varying results depending on solar activity
|
||||
float damper = 1.0f;
|
||||
float multiplyer = 20.0f;
|
||||
|
||||
for (float mapvalue : magnetogram) {
|
||||
float colorIntensity = abs(mapvalue) / maxvalue; // normalized value
|
||||
|
||||
// would be neat to be able choose color scheme interactively
|
||||
//r = 1.0f, g = 1.0f, b = 1.0f; // white
|
||||
//r = 0.0f, g = 0.0f, b = 0.0f; // black
|
||||
@@ -640,11 +637,14 @@ std::vector<float> RenderableTimeVaryingSphere::processWSAFitsFile(std::string f
|
||||
}
|
||||
}
|
||||
// glm vec3
|
||||
std::vector<float> rgb = {r,g,b};
|
||||
glm::vec3 rgb = glm::vec3(r,g,b);
|
||||
rgbLayers.push_back(rgb);
|
||||
}
|
||||
|
||||
// shift with leading edge value and divide by two to match resolution (180)
|
||||
// long0 is the 0 longitude of the sun. The rotate-double-forloop shifts
|
||||
// each column to map it correctly.
|
||||
std::vector<float> res;
|
||||
int shift = (360 - long0) / 2;
|
||||
|
||||
for(int i = 0; i < 90; i++) {
|
||||
@@ -653,9 +653,9 @@ std::vector<float> RenderableTimeVaryingSphere::processWSAFitsFile(std::string f
|
||||
rgbLayers.begin() + (i * 180) + 179 );
|
||||
for(int j = 0; j < 180; j++){
|
||||
int index = i * 180 + j;
|
||||
res.push_back(rgbLayers[index][0]);
|
||||
res.push_back(rgbLayers[index][1]);
|
||||
res.push_back(rgbLayers[index][2]);
|
||||
res.push_back(rgbLayers[index].x); // vector[i] == vec3, .x == r
|
||||
res.push_back(rgbLayers[index].y); // vector[i] == vec3, .y == g
|
||||
res.push_back(rgbLayers[index].z); // vector[i] == vec3, .z == b
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -41,6 +41,9 @@
|
||||
#include <fstream>
|
||||
#include <thread>
|
||||
|
||||
// Tracy
|
||||
#include <Tracy.hpp>
|
||||
|
||||
namespace {
|
||||
constexpr const char* _loggerCat = "RenderableFieldlinesSequence";
|
||||
|
||||
@@ -483,13 +486,13 @@ bool RenderableFieldlinesSequence::extractMandatoryInfoFromDictionary(
|
||||
);
|
||||
|
||||
// Ensure that there are available and valid source files left
|
||||
if (_sourceFiles.empty()) {
|
||||
/*if (_sourceFiles.empty()) {
|
||||
LERROR(fmt::format(
|
||||
"{}: {} contains no {} files",
|
||||
_identifier, sourceFolderPath, inputFileTypeString
|
||||
));
|
||||
return false;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
else {
|
||||
LERROR(fmt::format(
|
||||
@@ -1200,16 +1203,21 @@ void RenderableFieldlinesSequence::initializeWebManager() {
|
||||
}
|
||||
|
||||
void RenderableFieldlinesSequence::update(const UpdateData& data) {
|
||||
ZoneScoped
|
||||
if (_shaderProgram->isDirty()) {
|
||||
ZoneScopedN("Rebuild from file if dirty")
|
||||
_shaderProgram->rebuildFromFile();
|
||||
}
|
||||
|
||||
const double currentTime = data.time.j2000Seconds();
|
||||
|
||||
if (_dynamicWebContent) {
|
||||
ZoneScopedN("If dynamicWebContent. Update manager")
|
||||
|
||||
if (!_webFieldlinesManager.hasUpdated &&
|
||||
_webFieldlinesManager.checkIfWindowIsReadyToLoad())
|
||||
_webFieldlinesManager.isWindowReadyToLoad())
|
||||
{
|
||||
ZoneScopedN("If window is ready to load")
|
||||
_startTimes.clear();
|
||||
extractTriggerTimesFromFileNames();
|
||||
|
||||
@@ -1230,6 +1238,7 @@ void RenderableFieldlinesSequence::update(const UpdateData& data) {
|
||||
|
||||
// Check if current time in OpenSpace is within sequence interval
|
||||
if (isInInterval) {
|
||||
ZoneScopedN("Is in interval")
|
||||
const size_t nextIdx = _activeTriggerTimeIndex + 1;
|
||||
|
||||
if (
|
||||
@@ -1240,6 +1249,7 @@ void RenderableFieldlinesSequence::update(const UpdateData& data) {
|
||||
// true => We stepped forward to a time represented by another state
|
||||
(nextIdx < _nStates && currentTime >= _startTimes[nextIdx]))
|
||||
{
|
||||
ZoneScopedN("Update Active Trigger Time Index ()")
|
||||
updateActiveTriggerTimeIndex(currentTime);
|
||||
|
||||
if (_loadingStatesDynamically) {
|
||||
@@ -1260,6 +1270,8 @@ void RenderableFieldlinesSequence::update(const UpdateData& data) {
|
||||
}
|
||||
|
||||
if (_dynamicWebContent && _webFieldlinesManager.notifyUpdate) {
|
||||
ZoneScopedN("If fieldlines manager notifyUpdate")
|
||||
|
||||
updateActiveTriggerTimeIndex(currentTime);
|
||||
computeSequenceEndTime();
|
||||
_webFieldlinesManager.notifyUpdate = false;
|
||||
@@ -1267,6 +1279,8 @@ void RenderableFieldlinesSequence::update(const UpdateData& data) {
|
||||
|
||||
if (_mustLoadNewStateFromDisk) {
|
||||
if (!_isLoadingStateFromDisk && !_newStateIsReady) {
|
||||
ZoneScopedN(" readNewState. Atempt to thread actually!")
|
||||
|
||||
_isLoadingStateFromDisk = true;
|
||||
_mustLoadNewStateFromDisk = false;
|
||||
std::string filePath = _sourceFiles[_activeTriggerTimeIndex];
|
||||
@@ -1278,6 +1292,7 @@ void RenderableFieldlinesSequence::update(const UpdateData& data) {
|
||||
}
|
||||
|
||||
if (_needsUpdate || _newStateIsReady) {
|
||||
ZoneScopedN("If new state is ready or needs update. Updates vertex pos buffer")
|
||||
|
||||
if (_loadingStatesDynamically) {
|
||||
_states[0] = std::move(*_newState);
|
||||
@@ -1296,11 +1311,13 @@ void RenderableFieldlinesSequence::update(const UpdateData& data) {
|
||||
}
|
||||
|
||||
if (_shouldUpdateColorBuffer) {
|
||||
ZoneScopedN("updates vertex color buffer")
|
||||
updateVertexColorBuffer();
|
||||
_shouldUpdateColorBuffer = false;
|
||||
}
|
||||
|
||||
if (_shouldUpdateMaskingBuffer) {
|
||||
ZoneScopedN("update vertex masking buffer")
|
||||
updateVertexMaskingBuffer();
|
||||
_shouldUpdateMaskingBuffer = false;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2019 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#ifndef __OPENSPACE_MODULE_FIELDLINESSEQUENCE___DATASTRUCTURES___H__
|
||||
#define __OPENSPACE_MODULE_FIELDLINESSEQUENCE___DATASTRUCTURES___H__
|
||||
|
||||
//#include <algorithm>
|
||||
#include <string>
|
||||
|
||||
struct TriggerTime {
|
||||
double triggertime = 0.0;
|
||||
std::string url;
|
||||
bool downloaded = false;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -130,6 +130,8 @@ bool FieldlinesState::loadStateFromOsfls(const std::string& pathToOsflsFile) {
|
||||
_extraQuantityNames[i] = varName;
|
||||
}
|
||||
|
||||
ifs.close();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -34,6 +34,9 @@
|
||||
|
||||
#include <ghoul/filesystem/cachemanager.h>
|
||||
|
||||
// Tracy
|
||||
//#include <Tracy.hpp>
|
||||
|
||||
namespace {
|
||||
constexpr const char* _loggerCat = "WebFieldlinesManager";
|
||||
|
||||
@@ -69,14 +72,14 @@ std::string WebFieldlinesManager::initializeSyncDirectory(std::string identifier
|
||||
|
||||
// this does not work since cacheManager assumes that the given
|
||||
// file is the one being cached
|
||||
// std::string path = FileSys.cacheManager()->cachedFilename(
|
||||
// identifier,
|
||||
// "WebFieldlinesManager",
|
||||
// ghoul::filesystem::CacheManager::Persistent::No
|
||||
// );
|
||||
// //remove file name
|
||||
// ghoul::filesystem::File f(path);
|
||||
// path = f.directoryName();
|
||||
// std::string path = FileSys.cacheManager()->cachedFilename(
|
||||
// identifier,
|
||||
// "WebFieldlinesManager",
|
||||
// ghoul::filesystem::CacheManager::Persistent::No
|
||||
// );
|
||||
// //remove file name
|
||||
// ghoul::filesystem::File f(path);
|
||||
// path = f.directoryName();
|
||||
|
||||
std::string path = absPath("${TEMPORARY}") + FileSys.PathSeparator + identifier;
|
||||
|
||||
@@ -132,31 +135,45 @@ void WebFieldlinesManager::preDownload(std::string dUrl){
|
||||
}
|
||||
|
||||
// TODO(Axel): Change this endpoint to be dynamic for each dataset
|
||||
std::string url = "https://iswa.ccmc.gsfc.nasa.gov/iswa_data_tree/model/solar/WSA4.5/WSA4.5_fieldlines/" + type + "/2017/09/2017-09-28T00-23-22.000.osfls";
|
||||
std::string destinationpath = absPath(_syncDir + ghoul::filesystem::FileSystem::PathSeparator + "2017-09-28T00-23-22.000.osfls"); // what the downloaded filename is to be
|
||||
std::string url = "https://iswa.ccmc.gsfc.nasa.gov/iswa_data_tree/model/solar/";
|
||||
url += "WSA4.5/WSA4.5_fieldlines/" + type + "/2017/09/2017-09-28T00-23-22.000.osfls";
|
||||
std::string destinationpath = absPath(_syncDir +
|
||||
ghoul::filesystem::FileSystem::PathSeparator +
|
||||
"2017-09-28T00-23-22.000.osfls"); // what the downloaded filename is to be
|
||||
|
||||
|
||||
/* For experimentation with suntexturemanager & parker solor probe, hopefully this hardcoding can go away */
|
||||
/* For experimentation with suntexturemanager & parker solor probe,
|
||||
hopefully this hardcoding can go away */
|
||||
if (ID == 1180) {
|
||||
url = "https://iswa.ccmc.gsfc.nasa.gov/iswa_data_tree/model/solar/WSA4.5/" + type + "/2017/09/wsa_201709280023R000_gong.fits";
|
||||
destinationpath = absPath(_syncDir + ghoul::filesystem::FileSystem::PathSeparator + "wsa_201709280023R000_gong.fits"); // what the downloaded filename is to be
|
||||
url = "https://iswa.ccmc.gsfc.nasa.gov/iswa_data_tree/model/solar/WSA4.5/"
|
||||
+ type + "/2017/09/wsa_201709280023R000_gong.fits";
|
||||
destinationpath = absPath(_syncDir +
|
||||
ghoul::filesystem::FileSystem::PathSeparator +
|
||||
"wsa_201709280023R000_gong.fits"); // what the downloaded filename is to be
|
||||
}
|
||||
// For parker solar probe
|
||||
if (ID > 1190) {
|
||||
url = "https://iswa.ccmc.gsfc.nasa.gov/iswa_data_tree/model/solar/ADAPT_WSA4.5/ADAPT_WSA4.5_fieldlines/" + type + "/2018/11/2018-11-01T00-00-00.000.osfls";
|
||||
destinationpath = absPath(_syncDir + ghoul::filesystem::FileSystem::PathSeparator + "2018-11-01T00-00-00.000.osfls"); // what the downloaded filename is to be
|
||||
url = "https://iswa.ccmc.gsfc.nasa.gov/iswa_data_tree/model/solar/ADAPT_WSA4.5/";
|
||||
url += "ADAPT_WSA4.5_fieldlines/" + type +
|
||||
"/2018/11/2018-11-01T00-00-00.000.osfls";
|
||||
destinationpath = absPath(_syncDir +
|
||||
ghoul::filesystem::FileSystem::PathSeparator +
|
||||
"2018-11-01T00-00-00.000.osfls"); // what the downloaded filename is to be
|
||||
}
|
||||
|
||||
if (ID == 1196) {
|
||||
url = "https://iswa.ccmc.gsfc.nasa.gov/iswa_data_tree/model/solar/ADAPT_WSA4.5/" + type + "/2018/11/wsa_201811010000R007_agong.fits";
|
||||
destinationpath = absPath(_syncDir + ghoul::filesystem::FileSystem::PathSeparator + "wsa_201811010000R007_agong.fits"); // what the downloaded filename is to be
|
||||
url = "https://iswa.ccmc.gsfc.nasa.gov/iswa_data_tree/model/solar/ADAPT_WSA4.5/"
|
||||
+ type + "/2018/11/wsa_201811010000R007_agong.fits";
|
||||
destinationpath = absPath(_syncDir +
|
||||
ghoul::filesystem::FileSystem::PathSeparator +
|
||||
"wsa_201811010000R007_agong.fits"); // what the downloaded filename is to be
|
||||
}
|
||||
/* End of experiment */
|
||||
|
||||
AsyncHttpFileDownload ashd = AsyncHttpFileDownload(url, destinationpath,
|
||||
HttpFileDownload::Overwrite::Yes);
|
||||
HttpRequest::RequestOptions opt = {};
|
||||
opt.requestTimeoutSeconds = 5;
|
||||
opt.requestTimeoutSeconds = 0;
|
||||
ashd.start(opt);
|
||||
ashd.wait();
|
||||
}
|
||||
@@ -180,20 +197,27 @@ void WebFieldlinesManager::update(){
|
||||
!_webFieldlinesWindow.expectedWindowIsOutOfBounds(openspaceTime) ||
|
||||
_webFieldlinesWindow.checkWorkerEdgeMode())
|
||||
{
|
||||
//ZoneScopedN("time is in, not out of bounds")
|
||||
|
||||
// Check if in window
|
||||
if (_webFieldlinesWindow.edgeWindowReady() ||
|
||||
_webFieldlinesWindow.timeIsInWindow(openspaceTime))
|
||||
{
|
||||
//ZoneScopedN("time is in window")
|
||||
|
||||
// Check if in the edge of the window,
|
||||
// so we can start downloading a new one
|
||||
if (!_webFieldlinesWindow.edgeWindowReady() &&
|
||||
_webFieldlinesWindow.timeIsInWindowMargin(openspaceTime, deltaTime))
|
||||
{
|
||||
//ZoneScopedN("If time is in window margin. newWindow()")
|
||||
// get new window
|
||||
_webFieldlinesWindow.newWindow(openspaceTime);
|
||||
hasUpdated = false;
|
||||
}
|
||||
else {
|
||||
//ZoneScopedN("download worker")
|
||||
|
||||
// If it's in the middle of the window,
|
||||
// we can just sit back and relax and let the worker work
|
||||
_webFieldlinesWindow.executeDownloadWorker();
|
||||
@@ -203,6 +227,8 @@ void WebFieldlinesManager::update(){
|
||||
}
|
||||
}
|
||||
else {
|
||||
//ZoneScopedN("Big Else! New window")
|
||||
|
||||
// get new window
|
||||
|
||||
_webFieldlinesWindow.newWindow(openspaceTime);
|
||||
@@ -210,12 +236,14 @@ void WebFieldlinesManager::update(){
|
||||
}
|
||||
}
|
||||
else {
|
||||
//ZoneScopedN("even bigger else. Get new trigger times web list")
|
||||
|
||||
_webFieldlinesWindow.getNewTriggerTimesWebList(openspaceTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool WebFieldlinesManager::checkIfWindowIsReadyToLoad()
|
||||
bool WebFieldlinesManager::isWindowReadyToLoad()
|
||||
{
|
||||
return _webFieldlinesWindow.workerWindowIsReady();
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ public:
|
||||
void update();
|
||||
|
||||
// Returns wether the worker has finished downloading a window.
|
||||
bool checkIfWindowIsReadyToLoad();
|
||||
bool isWindowReadyToLoad();
|
||||
|
||||
void resetWorker();
|
||||
|
||||
|
||||
@@ -32,6 +32,9 @@
|
||||
#include <openspace/util/timemanager.h>
|
||||
#include <openspace/engine/globals.h>
|
||||
|
||||
// Tracy
|
||||
//#include <Tracy.hpp>
|
||||
|
||||
|
||||
namespace {
|
||||
constexpr const char* _loggerCat = "WebFieldlinesWindow";
|
||||
@@ -44,14 +47,14 @@ WebFieldlinesWindow::WebFieldlinesWindow(std::string syncDir, std::string server
|
||||
std::vector<std::string>& _sourceFiles,
|
||||
std::vector<double>& _startTimes)
|
||||
{
|
||||
|
||||
_window.backWidth = 3;
|
||||
_window.forwardWidth = 3;
|
||||
_window.nTriggerTimes = _sourceFiles.size();
|
||||
|
||||
for(int i = 0; i < _window.nTriggerTimes ; i++){
|
||||
_window.triggerTimes.push_back(
|
||||
std::make_pair(_startTimes[i], _sourceFiles[i])
|
||||
);
|
||||
TriggerTime tt = { _startTimes[i], _sourceFiles[i], true };
|
||||
_window.triggerTimes.push_back(tt);
|
||||
}
|
||||
|
||||
rfs_sourceFiles = &_sourceFiles;
|
||||
@@ -61,7 +64,7 @@ WebFieldlinesWindow::WebFieldlinesWindow(std::string syncDir, std::string server
|
||||
_worker = WebFieldlinesWorker(syncDir, serverUrl);
|
||||
|
||||
for (int i = 0; i < _window.nTriggerTimes; i++) {
|
||||
_worker.addToDownloadedList(std::make_pair(_startTimes[i], _sourceFiles[i]));
|
||||
_worker.addToDownloadedList(_startTimes[i], _sourceFiles[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,10 +78,10 @@ bool WebFieldlinesWindow::timeIsInWindow(double time) {
|
||||
// Returns true if time is at edge of the current window,
|
||||
// and will probably need to update window
|
||||
bool WebFieldlinesWindow::timeIsInWindowMargin(double time, double direction) {
|
||||
const int threshold = 2; // base this on speed later
|
||||
const int threshold = 2; //TODO base this on speed later
|
||||
|
||||
if (direction > 0){ // If time is moving forward
|
||||
if (time >= _window.triggerTimes[_window.nTriggerTimes - threshold].first) {
|
||||
if (time >= _window.triggerTimes[_window.nTriggerTimes - threshold].triggertime) {
|
||||
if (time > windowEnd()) {
|
||||
return false;
|
||||
}
|
||||
@@ -87,7 +90,7 @@ bool WebFieldlinesWindow::timeIsInWindowMargin(double time, double direction) {
|
||||
else return false;
|
||||
}
|
||||
else{ // If time is moving backwards
|
||||
if (time <= _window.triggerTimes[threshold].first){
|
||||
if (time <= _window.triggerTimes[threshold].triggertime){
|
||||
if (time < windowStart()) {
|
||||
return false;
|
||||
}
|
||||
@@ -126,12 +129,13 @@ void WebFieldlinesWindow::newWindow(double time) {
|
||||
// it is checked wether the current position is within
|
||||
// the boundaries with respect to back & forward width
|
||||
for(int i = std::max(index - _window.backWidth,0);
|
||||
i <= std::min(index + _window.forwardWidth,
|
||||
static_cast<int>(_triggerTimesWeb.size() -1));
|
||||
i++) {
|
||||
_window.triggerTimes.push_back(
|
||||
std::make_pair(_triggerTimesWeb[i].first, _triggerTimesWeb[i].second)
|
||||
);
|
||||
i <= std::min(index + _window.forwardWidth,
|
||||
static_cast<int>(_triggerTimesWeb.size() -1));
|
||||
i++) {
|
||||
|
||||
//bool onFile = FileSys.fileExists(); //put onFile instead of false next line
|
||||
TriggerTime tt = {_triggerTimesWeb[i].first, _triggerTimesWeb[i].second, false };
|
||||
_window.triggerTimes.push_back(tt);
|
||||
_window.nTriggerTimes++;
|
||||
}
|
||||
|
||||
@@ -155,6 +159,7 @@ bool WebFieldlinesWindow::timeIsInTriggerTimesWebList(double time) {
|
||||
}
|
||||
|
||||
void WebFieldlinesWindow::getNewTriggerTimesWebList(double time) {
|
||||
// _triggerTimesWeb gets initialized here
|
||||
_worker.getRangeOfAvailableTriggerTimes(time, _triggerTimesWeb);
|
||||
_nAvailableWeb = static_cast<int>(_triggerTimesWeb.size());
|
||||
}
|
||||
@@ -198,12 +203,12 @@ bool WebFieldlinesWindow::edgeWindowReady(){
|
||||
|
||||
// Returns first trigger of window
|
||||
double WebFieldlinesWindow::windowStart(){
|
||||
return _window.triggerTimes.front().first;
|
||||
return _window.triggerTimes.front().triggertime;
|
||||
}
|
||||
|
||||
// Returns last trigger of window
|
||||
double WebFieldlinesWindow::windowEnd(){
|
||||
return _window.triggerTimes.back().first;
|
||||
return _window.triggerTimes.back().triggertime;
|
||||
}
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#ifndef __OPENSPACE_MODULE_FIELDLINESSEQUENCE___WEBFIELDLINESWINDOW___H__
|
||||
#define __OPENSPACE_MODULE_FIELDLINESSEQUENCE___WEBFIELDLINESWINDOW___H__
|
||||
|
||||
#include <modules/fieldlinessequence/util/datastructures.h>
|
||||
#include <modules/fieldlinessequence/util/webfieldlinesworker.h>
|
||||
#include <vector>
|
||||
|
||||
@@ -33,8 +34,9 @@ namespace openspace {
|
||||
struct Window {
|
||||
|
||||
// This is the essence of the Window, pairs of triggertimes and download keys
|
||||
std::vector<std::pair<double, std::string>> triggerTimes;
|
||||
|
||||
// std::vector<std::pair<double, std::string>> triggerTimes;
|
||||
std::vector<TriggerTime> triggerTimes;
|
||||
|
||||
int activeTriggerTime;
|
||||
|
||||
// Amount of steps from current timetrigger to first respectively last trigger in window
|
||||
@@ -65,6 +67,7 @@ struct Window {
|
||||
|
||||
class WebFieldlinesWindow{
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
WebFieldlinesWindow() = default;
|
||||
|
||||
|
||||
@@ -31,6 +31,11 @@
|
||||
#include <openspace/engine/globals.h>
|
||||
#include <openspace/json.h>
|
||||
|
||||
// Tracy
|
||||
//#include <Tracy.hpp>
|
||||
|
||||
#include <ghoul/misc/assert.h>
|
||||
|
||||
|
||||
namespace {
|
||||
constexpr const char* _loggerCat = "FieldlinesSequence[ Web FLs Worker ]";
|
||||
@@ -39,7 +44,7 @@ namespace {
|
||||
|
||||
namespace openspace{
|
||||
|
||||
WebFieldlinesWorker::WebFieldlinesWorker(std::string syncDir, std::string serverUrl)
|
||||
WebFieldlinesWorker::WebFieldlinesWorker(std::string syncDir, std::string serverUrl)
|
||||
: _syncDir(syncDir), _serverUrl(serverUrl) {
|
||||
// Maybe to be used
|
||||
_endpointSingleDownload = _serverUrl;
|
||||
@@ -102,14 +107,14 @@ void WebFieldlinesWorker::getRangeOfAvailableTriggerTimes(double time,
|
||||
AsyncHttpMemoryDownload mmryDld = AsyncHttpMemoryDownload(url);
|
||||
_availableTimesDownloader = std::make_unique<AsyncHttpMemoryDownload>(url);
|
||||
HttpRequest::RequestOptions opt = {};
|
||||
opt.requestTimeoutSeconds = 5;
|
||||
opt.requestTimeoutSeconds = 0;
|
||||
_availableTimesDownloader->start(opt);
|
||||
_availableTimesDownloader->wait();
|
||||
}
|
||||
|
||||
if (!_noMoreRequests && _availableTimesDownloader &&
|
||||
_availableTimesDownloader->hasStarted() &&
|
||||
_availableTimesDownloader->hasSucceeded()) {
|
||||
_availableTimesDownloader->wait();
|
||||
std::string stringResult;
|
||||
std::vector<std::string> urlList;
|
||||
std::vector<std::string> timeList;
|
||||
@@ -122,8 +127,8 @@ void WebFieldlinesWorker::getRangeOfAvailableTriggerTimes(double time,
|
||||
_availableTimesDownloader->downloadedData().end(),
|
||||
std::back_inserter(stringResult),
|
||||
[](char c) {
|
||||
return c;
|
||||
}
|
||||
return c;
|
||||
}
|
||||
);
|
||||
|
||||
auto res = json::parse(stringResult);
|
||||
@@ -173,8 +178,9 @@ void WebFieldlinesWorker::getRangeOfAvailableTriggerTimes(double time,
|
||||
// future timesteps, then steps backwards from the startingpoint
|
||||
// TODO(Axel): Different behaviour depending on direction the user is moving in,
|
||||
// might be wanted?
|
||||
//#pragma optimize( "", off ) // unoptimized code section
|
||||
void WebFieldlinesWorker::downloadWindow(
|
||||
std::vector<std::pair<double, std::string>> triggerTimes)
|
||||
std::vector<TriggerTime> triggerTimes)
|
||||
{
|
||||
// Helper variables
|
||||
size_t startingPoint = triggerTimes.size() / 2;
|
||||
@@ -188,39 +194,56 @@ void WebFieldlinesWorker::downloadWindow(
|
||||
|
||||
// Is there a download thread to be joined and added to the list?
|
||||
if (_downloading && _downloading->hasSucceeded() && _newWindow) {
|
||||
_downloading->wait();
|
||||
addToDownloadedList(_latestDownload);
|
||||
//ZoneScopedN("wait(), add to downloaded list")
|
||||
|
||||
if (true) {
|
||||
//ZoneScopedN("Actually still waited for something to download")
|
||||
_downloading->wait();
|
||||
}
|
||||
addToDownloadedList(_latestDownload.triggertime, _latestDownload.url);
|
||||
_latestDownload.downloaded = true;
|
||||
_readyToDownload = true;
|
||||
// This is to trigger one update of the fieldline timestamp that the user is
|
||||
// currently on, while the rest of them will be downloaded in the background,
|
||||
// and updated once ready
|
||||
if (_latestDownload.second == triggerTimes[startingPoint].second)
|
||||
if (_latestDownload.url == triggerTimes[startingPoint].url) {
|
||||
oneUpdate = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (_readyToDownload) {
|
||||
// Forwards
|
||||
std::vector<std::pair<double, std::string>>::iterator forwardIt =
|
||||
triggerTimes.begin();
|
||||
//ZoneScopedN("is ready to download")
|
||||
|
||||
// Forwards
|
||||
std::vector<TriggerTime>::iterator forwardIt =
|
||||
triggerTimes.begin();
|
||||
std::advance(forwardIt, startingPoint);
|
||||
std::for_each(forwardIt, triggerTimes.end(), [this, &downloaded](auto it) {
|
||||
if (!downloaded && !fileIsOnDisk(it.first, it.second)) {
|
||||
|
||||
//TODO it.downloaded is redundant as it is now. Ment to replace "DownloadedList"
|
||||
std::for_each(forwardIt, triggerTimes.end(), [this, &downloaded](TriggerTime& it){
|
||||
if (!downloaded && !it.downloaded &&
|
||||
!isFileInDownloadedList(it.triggertime)) {
|
||||
//ZoneScopedN("Forward")
|
||||
|
||||
downloadOsfls(it);
|
||||
downloaded = true;
|
||||
it.downloaded = true;
|
||||
_doneUpdating = false;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// Backwards
|
||||
if (!downloaded) {
|
||||
std::for_each(
|
||||
triggerTimes.rbegin(),
|
||||
triggerTimes.rend(),
|
||||
[this, &downloaded](auto it) {
|
||||
if (!downloaded && !fileIsOnDisk(it.first, it.second)) {
|
||||
[this, &downloaded](TriggerTime it) {
|
||||
if (!downloaded && !it.downloaded &&
|
||||
!isFileInDownloadedList(it.triggertime)) {
|
||||
//ZoneScopedN("Backwards")
|
||||
downloadOsfls(it);
|
||||
downloaded = true;
|
||||
it.downloaded = true;
|
||||
_doneUpdating = false;
|
||||
}
|
||||
}
|
||||
@@ -243,10 +266,11 @@ void WebFieldlinesWorker::downloadWindow(
|
||||
oneUpdate = false;
|
||||
}
|
||||
}
|
||||
//#pragma optimize( "", on ) // end of unoptimized code session
|
||||
|
||||
// Updates the list of available sourcefiles, owned by renderablefieldlinessequence.
|
||||
// TODO RFLS
|
||||
void WebFieldlinesWorker::updateRFSSourceFiles(std::vector<std::string>& _sourceFiles) {
|
||||
void WebFieldlinesWorker::updateRFSSourceFiles(std::vector<std::string>& sourceFiles) {
|
||||
if (_readyToUpdateSourceFiles) {
|
||||
std::vector<std::string> toInsert;
|
||||
std::transform(
|
||||
@@ -258,30 +282,30 @@ void WebFieldlinesWorker::updateRFSSourceFiles(std::vector<std::string>& _source
|
||||
}
|
||||
);
|
||||
|
||||
auto sourcePtr = _sourceFiles.begin();
|
||||
auto sourcePtr = sourceFiles.begin();
|
||||
std::for_each(
|
||||
toInsert.begin(),
|
||||
toInsert.end(),
|
||||
[&sourcePtr, &_sourceFiles] (auto insertableElement) {
|
||||
for (sourcePtr; sourcePtr != _sourceFiles.end(); sourcePtr++) {
|
||||
if (sourcePtr != (--_sourceFiles.end())) {
|
||||
[&sourcePtr, &sourceFiles] (auto insertableElement) {
|
||||
for (sourcePtr; sourcePtr != sourceFiles.end(); sourcePtr++) {
|
||||
if (sourcePtr != (--sourceFiles.end())) {
|
||||
if (insertableElement > *sourcePtr &&
|
||||
insertableElement < *sourcePtr++)
|
||||
{
|
||||
_sourceFiles.insert(sourcePtr++, insertableElement);
|
||||
sourceFiles.insert(sourcePtr++, insertableElement);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (insertableElement < *sourcePtr) {
|
||||
sourcePtr = _sourceFiles.insert(sourcePtr, insertableElement);
|
||||
sourcePtr = sourceFiles.insert(sourcePtr, insertableElement);
|
||||
break;
|
||||
}
|
||||
if (insertableElement == *sourcePtr) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (sourcePtr == _sourceFiles.end()) {
|
||||
sourcePtr = _sourceFiles.insert(sourcePtr, insertableElement);
|
||||
if (sourcePtr == sourceFiles.end()) {
|
||||
sourcePtr = sourceFiles.insert(sourcePtr, insertableElement);
|
||||
}
|
||||
}
|
||||
);
|
||||
@@ -318,14 +342,14 @@ bool WebFieldlinesWorker::edgeMode() {
|
||||
return _noMoreRequests && _bigWindowHasData;
|
||||
}
|
||||
|
||||
std::string WebFieldlinesWorker::downloadOsfls(std::pair<double,std::string> downloadKey){
|
||||
void WebFieldlinesWorker::downloadOsfls(TriggerTime downloadKey){
|
||||
_downloadedSomething = true;
|
||||
_latestDownload = downloadKey;
|
||||
|
||||
const std::string fileName =
|
||||
downloadKey.second.substr(downloadKey.second.find_last_of("\\/",
|
||||
downloadKey.second.size() - 1));
|
||||
std::string url = downloadKey.second;
|
||||
downloadKey.url.substr(downloadKey.url.find_last_of("\\/",
|
||||
downloadKey.url.size() - 1));
|
||||
std::string url = downloadKey.url;
|
||||
std::string destinationPath =
|
||||
absPath(_syncDir + ghoul::filesystem::FileSystem::PathSeparator + fileName);
|
||||
// what the downloaded filename is to be
|
||||
@@ -340,30 +364,35 @@ std::string WebFieldlinesWorker::downloadOsfls(std::pair<double,std::string> dow
|
||||
);
|
||||
|
||||
HttpRequest::RequestOptions opt = {};
|
||||
opt.requestTimeoutSeconds = 5;
|
||||
opt.requestTimeoutSeconds = 0;
|
||||
if (true) { //only to scope the ZoneScopedN
|
||||
ZoneScopedN("before Start")
|
||||
_downloading->start(opt);
|
||||
_downloading->wait();
|
||||
_readyToDownload = false;
|
||||
}
|
||||
|
||||
_downloading->start(opt);
|
||||
_downloading->wait();
|
||||
|
||||
_readyToDownload = false;
|
||||
|
||||
return destinationPath;
|
||||
//return destinationPath;
|
||||
}
|
||||
|
||||
|
||||
// This function searches for triggerTime in _downloadedTriggerTimes,
|
||||
// to see weather a file has already been downloaded or not
|
||||
bool WebFieldlinesWorker::fileIsOnDisk(double triggerTime, std::string path) {
|
||||
|
||||
bool exists = FileSys.fileExists(path);
|
||||
|
||||
bool inList = std::find_if(
|
||||
_downloadedTriggerTimes.begin(),
|
||||
_downloadedTriggerTimes.end(),
|
||||
[&triggerTime] (std::pair<double, std::string> const &element) {
|
||||
return element.first == triggerTime;
|
||||
}) != _downloadedTriggerTimes.end();
|
||||
bool WebFieldlinesWorker::isFileInDownloadedList(const double time) {
|
||||
//ZoneScopedN("file is on disk")
|
||||
|
||||
return inList; //(exists&&
|
||||
//bool exists = FileSys.fileExists(path);
|
||||
|
||||
std::vector<std::pair<double, std::string>>::const_iterator inList = std::find_if(
|
||||
_downloadedTriggerTimes.cbegin(),
|
||||
_downloadedTriggerTimes.cend(),
|
||||
[&time](const std::pair<double, std::string>& element) {
|
||||
return element.first == time;
|
||||
}
|
||||
);
|
||||
|
||||
return inList != _downloadedTriggerTimes.cend();
|
||||
//return exists;
|
||||
}
|
||||
|
||||
void WebFieldlinesWorker::parseTriggerTimesList(std::string s,
|
||||
@@ -411,15 +440,32 @@ void WebFieldlinesWorker::triggerTimeDouble2String(double i, std::string& s) {
|
||||
s.replace(16, 1, "-");
|
||||
}
|
||||
|
||||
|
||||
// Inserts the pair in sorted order
|
||||
void WebFieldlinesWorker::addToDownloadedList(std::pair<double, std::string> pair) {
|
||||
const std::string fileName = pair.second.substr(pair.second.find_last_of('/',
|
||||
pair.second.size() - 1) + 1);
|
||||
void WebFieldlinesWorker::addToDownloadedList(const double time, const std::string path){
|
||||
const size_t begin = path.find_last_of("\\/");
|
||||
const std::string fileName = path.substr(begin + 1);
|
||||
|
||||
ghoul_assert(std::is_sorted(_downloadedTriggerTimes.begin(),
|
||||
_downloadedTriggerTimes.end()));
|
||||
|
||||
_downloadedTriggerTimes.insert(
|
||||
std::upper_bound(
|
||||
_downloadedTriggerTimes.begin(), _downloadedTriggerTimes.end(), pair
|
||||
), std::make_pair(pair.first, fileName)
|
||||
std::find_if(
|
||||
_downloadedTriggerTimes.cbegin(),
|
||||
_downloadedTriggerTimes.cend(),
|
||||
[&time](const std::pair<double, std::string>& p ) {
|
||||
return p.first > time;
|
||||
}
|
||||
),
|
||||
// this pair is inserted when finding the first bigger time stamp
|
||||
std::make_pair(time, fileName)
|
||||
);
|
||||
|
||||
//_downloadedTriggerTimes.insert(
|
||||
// std::upper_bound(
|
||||
// _downloadedTriggerTimes.begin(), _downloadedTriggerTimes.end(), pair
|
||||
// ), std::make_pair(pair.first, fileName)
|
||||
//);
|
||||
}
|
||||
|
||||
bool WebFieldlinesWorker::compareTimetriggersEqual(double first, double second) {
|
||||
|
||||
@@ -25,15 +25,18 @@
|
||||
#ifndef __OPENSPACE_MODULE_FIELDLINESSEQUENCE___WEBFIELDLINESWORKER___H__
|
||||
#define __OPENSPACE_MODULE_FIELDLINESSEQUENCE___WEBFIELDLINESWORKER___H__
|
||||
|
||||
#include <modules/fieldlinessequence/util/datastructures.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <openspace/util/timemanager.h>
|
||||
#include <openspace/util/httprequest.h>
|
||||
|
||||
|
||||
namespace openspace {
|
||||
|
||||
class WebFieldlinesWorker{
|
||||
public:
|
||||
|
||||
// Constructor
|
||||
WebFieldlinesWorker() = default;
|
||||
|
||||
@@ -48,9 +51,9 @@ public:
|
||||
|
||||
// Download all the steps within one window.
|
||||
// Spawn one thread per file to download?
|
||||
void downloadWindow(std::vector<std::pair<double, std::string>> triggerTimes);
|
||||
void downloadWindow(std::vector<TriggerTime> triggerTimes);
|
||||
|
||||
void updateRFSSourceFiles(std::vector<std::string>& _sourceFiles);
|
||||
void updateRFSSourceFiles(std::vector<std::string>& sourceFiles);
|
||||
|
||||
// Returns true when the worker has downloaded a window and saved the path
|
||||
// to the files in _sourceFiles
|
||||
@@ -68,7 +71,7 @@ public:
|
||||
bool edgeMode();
|
||||
|
||||
// Add a downloaded file to the list of downloaded files
|
||||
void addToDownloadedList(std::pair<double, std::string> pair);
|
||||
void addToDownloadedList(const double time, const std::string path);
|
||||
|
||||
private:
|
||||
|
||||
@@ -84,7 +87,7 @@ private:
|
||||
Time _minTime;
|
||||
|
||||
// Might need this later
|
||||
std::pair<double, std::string> _latestDownload;
|
||||
TriggerTime _latestDownload;
|
||||
|
||||
// Contains a list of all the trigger times that has been downloaded already,
|
||||
std::vector<std::pair<double, std::string>> _downloadedTriggerTimes;
|
||||
@@ -114,9 +117,9 @@ private:
|
||||
std::pair<double, double> acceptableToStartRequestingAgain = std::make_pair(0.0, 0.0);
|
||||
|
||||
// Download one file to sync directory
|
||||
std::string downloadOsfls(std::pair<double, std::string> downloadKey);
|
||||
void downloadOsfls(TriggerTime downloadKey);
|
||||
|
||||
bool fileIsOnDisk(double triggerTime, std::string path);
|
||||
bool isFileInDownloadedList(const double triggerTime);
|
||||
|
||||
/********************************************
|
||||
| Helper Functions |
|
||||
|
||||
@@ -1082,6 +1082,8 @@ void OpenSpaceEngine::preSynchronization() {
|
||||
FileSys.triggerFilesystemEvents();
|
||||
|
||||
if (_hasScheduledAssetLoading) {
|
||||
ZoneScoped
|
||||
|
||||
LINFO(fmt::format("Loading asset: {}", _scheduledAssetPathToLoad));
|
||||
loadSingleAsset(_scheduledAssetPathToLoad);
|
||||
_hasScheduledAssetLoading = false;
|
||||
|
||||
Reference in New Issue
Block a user