resolved conflicts

This commit is contained in:
Kollberg
2019-06-26 09:02:43 -04:00
17 changed files with 262 additions and 14 deletions
@@ -50,6 +50,7 @@ SunTextureManager::SunTextureManager()
void SunTextureManager::update(std::unique_ptr<ghoul::opengl::Texture> &texture)
{
std::string currentTime = getOpenSpaceDateTime();
if (_textureToUpload.empty() && currentTime != _activeTextureDate && (_textureListGPU.find(currentTime) != _textureListGPU.end()))
{
@@ -29,6 +29,7 @@ set(HEADER_FILES
${CMAKE_CURRENT_SOURCE_DIR}/util/fieldlinesstate.h
${CMAKE_CURRENT_SOURCE_DIR}/util/commons.h
${CMAKE_CURRENT_SOURCE_DIR}/util/kameleonfieldlinehelper.h
${CMAKE_CURRENT_SOURCE_DIR}/util/webfieldlinesmanager.h
)
source_group("Header Files" FILES ${HEADER_FILES})
@@ -37,6 +38,7 @@ set(SOURCE_FILES
${CMAKE_CURRENT_SOURCE_DIR}/util/fieldlinesstate.cpp
${CMAKE_CURRENT_SOURCE_DIR}/util/commons.cpp
${CMAKE_CURRENT_SOURCE_DIR}/util/kameleonfieldlinehelper.cpp
${CMAKE_CURRENT_SOURCE_DIR}/util/webfieldlinesmanager.cpp
)
source_group("Source Files" FILES ${SOURCE_FILES})
@@ -282,6 +282,7 @@ RenderableFieldlinesSequence::RenderableFieldlinesSequence(
, _pJumpToStartBtn(TimeJumpButtonInfo)
{
_dictionary = std::make_unique<ghoul::Dictionary>(dictionary);
}
void RenderableFieldlinesSequence::initializeGL() {
@@ -316,6 +317,7 @@ void RenderableFieldlinesSequence::initializeGL() {
case SourceFileType::Osfls:
extractOsflsInfoFromDictionary();
if (_loadingStatesDynamically) {
//LERROR("Loading dynamically: " + _identifier);
if (!prepareForOsflsStreaming()) {
return;
}
@@ -362,6 +364,9 @@ void RenderableFieldlinesSequence::initializeGL() {
// Needed for additive blending
setRenderBin(Renderable::RenderBin::Overlay);
// ----------------- Initialize Web Fieldlines Manager things ---------------------//
WebFieldlinesManager webFieldlinesManager(_sourceFiles[0]);
}
/**
@@ -594,6 +599,7 @@ void RenderableFieldlinesSequence::loadOsflsStatesIntoRAM(const std::string& out
{
// Load states from .osfls files into RAM!
for (const std::string& filePath : _sourceFiles) {
//LERROR("Loading file into RAM: " + filePath);
FieldlinesState newState;
if (newState.loadStateFromOsfls(filePath)) {
addStateToSequence(newState);
@@ -855,6 +861,7 @@ void RenderableFieldlinesSequence::extractTriggerTimesFromFileNames() {
timeString.replace(16, 1, ":");
timeString.replace(19, 1, ".");
const double triggerTime = Time::convertTime(timeString);
//LERROR("Adding starttime " + this->_identifier + " : " + std::to_string(triggerTime));
_startTimes.push_back(triggerTime);
}
@@ -862,7 +869,9 @@ void RenderableFieldlinesSequence::extractTriggerTimesFromFileNames() {
void RenderableFieldlinesSequence::addStateToSequence(FieldlinesState& state) {
_states.push_back(state);
//LERROR("Adding state to list of states : " + std::to_string(state.triggerTime()));
_startTimes.push_back(state.triggerTime());
_nStates++;
}
@@ -1233,6 +1242,7 @@ void RenderableFieldlinesSequence::updateActiveTriggerTimeIndex(double currentTi
// Reading state from disk. Must be thread safe!
void RenderableFieldlinesSequence::readNewState(const std::string& filePath) {
_newState = std::make_unique<FieldlinesState>();
//LERROR("Creating new state: " + filePath);
if (_newState->loadStateFromOsfls(filePath)) {
_newStateIsReady = true;
}
@@ -28,6 +28,7 @@
#include <openspace/rendering/renderable.h>
#include <modules/fieldlinessequence/util/fieldlinesstate.h>
#include <modules/fieldlinessequence/util/webfieldlinesmanager.h>
#include <openspace/properties/optionproperty.h>
#include <openspace/properties/stringproperty.h>
#include <openspace/properties/triggerproperty.h>
@@ -196,6 +197,11 @@ private:
properties::TriggerProperty _pFocusOnOriginBtn;
// Button which executes a time jump to start of sequence
properties::TriggerProperty _pJumpToStartBtn;
// --------------------- Web Fieldlines Manager ----------------------------------- //
//WebFieldlinesManager _webFieldlinesManager;
// --------------------- FUNCTIONS USED DURING INITIALIZATION --------------------- //
void addStateToSequence(FieldlinesState& STATE);
@@ -0,0 +1,143 @@
/*****************************************************************************************
* *
* 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. *
****************************************************************************************/
#include <modules/fieldlinessequence/util/webfieldlinesmanager.h>
#include <ghoul/logging/logmanager.h>
#include <openspace/util/httprequest.h>
#include <modules/sync/syncs/httpsynchronization.h>
#include <ghoul/filesystem/filesystem.h>
#include <ghoul/filesystem/file.h>
#include <openspace/util/timemanager.h>
#include <openspace/engine/globals.h>
namespace {
constexpr const char* _loggerCat = "FieldlinesSequence[ Web FLs Manager ]";
} // namespace
namespace openspace{
WebFieldlinesManager::WebFieldlinesManager(std::string syncDir){
// Using constructor for some testing
ghoul::filesystem::File tempFile = ghoul::filesystem::File(syncDir);
_syncDir = tempFile.directoryName();
_flsType = PFSSIO;
_flsTypeString = "PFSSIO";
std::string testTime;
triggerTimeInt2String(610056000, testTime);
int testInt;
triggerTimeString2Int(testTime, testInt);
getAvailableTriggertimes();
// for (auto& tt : _availableTriggertimes){
// downloadOsfls(_flsType, tt);
// }
}
void WebFieldlinesManager::update(){
}
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();
}
void WebFieldlinesManager::getAvailableTriggertimes(){
std::string url = "http://localhost:3000/WSA/available/" + _flsTypeString;
SyncHttpMemoryDownload mmryDld = SyncHttpMemoryDownload(url);
HttpRequest::RequestOptions opt = {};
opt.requestTimeoutSeconds = 0;
mmryDld.download(opt);
// Put the results in a string and remove [ ]
std::string s;
std::transform(mmryDld.downloadedData().begin(), mmryDld.downloadedData().end(), std::back_inserter(s),
[](char c) {
return c;
});
parseTriggerTimesList(s);
}
void WebFieldlinesManager::setInitialSet(double openSpaceTime){
}
void WebFieldlinesManager::downloadInitialSequence(std::vector<double> triggertimes){
}
void WebFieldlinesManager::updateStartTimes(){
}
void WebFieldlinesManager::parseTriggerTimesList(std::string s){
// Turn into stringstream to parse the comma-delimited string into vector
std::stringstream ss(s);
char c;
std::string substr;
while(ss >> c)
{
if (c == '[' || c == ']' || c == '"' ) continue;
else if (c == ','){
_availableTriggertimes.push_back(substr);
substr.clear();
}
else substr += c;
}
_availableTriggertimes.push_back(substr);
}
void WebFieldlinesManager::triggerTimeString2Int(std::string s, int& i){
s.replace(13, 1, ":");
s.replace(16, 1, ":");
Time time = Time();
time.setTime(s);
i = static_cast<int> (time.j2000Seconds() - 69.185013294);
}
void WebFieldlinesManager::triggerTimeInt2String(int i, std::string& s){
double temp = i + 69.185013294;
Time time = Time();
time.setTime(temp);
s = time.ISO8601();
s.replace(13, 1, "-");
s.replace(16, 1, "-");
}
} // namespace openspace
@@ -0,0 +1,87 @@
/*****************************************************************************************
* *
* 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___WEBFIELDLINESMANAGER___H__
#define __OPENSPACE_MODULE_FIELDLINESSEQUENCE___WEBFIELDLINESMANAGER___H__
#include <vector>
#include <string>
namespace openspace {
class WebFieldlinesManager{
public:
WebFieldlinesManager();
WebFieldlinesManager(std::string syncDir);
// What model of FieldlinesSequence is this?
enum FlsType { PFSSIO, PFSSOI, SCSOI };
private:
// for now, it's the same as user entered i asset-file
std::string _syncDir;
FlsType _flsType;
std::string _flsTypeString;
// List of all triggertimes(field lines states) available for download
// ***turn into ints later***
std::vector<std::string> _availableTriggertimes;
// Function to run in FieldLinesSequence's update loop
void update();
// Download one file, given what model type and triggertime in J2000
// ***turn into ints later***
void downloadOsfls(FlsType type, std::string triggertime);
// Get list of all triggertimes(field lines states) available form the server
void getAvailableTriggertimes();
// Decide what the first sequence of fieldlines should be
// (can be empty during start up of openspace)
void setInitialSet(double openSpaceTime);
// Download a sequence
void downloadInitialSequence(std::vector<double> triggertimes);
// Update the list of osfls available on disk. Should be in sync with
// _startTimes member var in FieldLinesSequence
void updateStartTimes();
// Parse the data from http request
void parseTriggerTimesList(std::string s);
// some temporary functions to translate the filenames to ints
void triggerTimeString2Int(std::string s, int& d);
void triggerTimeInt2String(int d, std::string& s);
};
} // namespace openspace
#endif // __OPENSPACE_MODULE_FIELDLINESSEQUENCE___WEBFIELDLINESMANAGER___H__