fixed errors, but not working yet

update/render not running when folder is empty
This commit is contained in:
Sovanny Huy
2019-07-03 09:41:02 -04:00
parent fe00eafc1b
commit b6ce61dd92
4 changed files with 31 additions and 44 deletions
+2 -1
View File
@@ -13,7 +13,8 @@ local fieldlines = {
Parent = transforms.HNMReferenceFrame.Identifier,
Renderable = {
Type = "RenderableFieldlinesSequence",
SourceFolder = fieldlinesDirectory,
WebFieldlines = true,
--SourceFolder = fieldlinesDirectory,
FlowEnabled = false,
AlphaBlendlingEnabled = false,
InputFileType = "osfls",
@@ -55,7 +55,7 @@ namespace {
// [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";
constexpr const char* KeyWebFieldlines = "WebFieldlines";
// ---------------------- MANDATORY INPUT TYPE SPECIFIC KEYS ---------------------- //
// [STRING] Path to a .txt file containing seed points
@@ -293,6 +293,7 @@ void RenderableFieldlinesSequence::initializeGL() {
// EXTRACT MANDATORY INFORMATION FROM DICTIONARY
SourceFileType sourceFileType = SourceFileType::Invalid;
if (!extractMandatoryInfoFromDictionary(sourceFileType)) {
//wait for a fieldline
return;
}
@@ -419,21 +420,21 @@ bool RenderableFieldlinesSequence::extractMandatoryInfoFromDictionary(
}
std::string sourceFolderPath;
bool webFieldLine;
bool webFieldLines;
if (!_dictionary->getValue(KeySourceFolder, sourceFolderPath)) {
// 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));
if (!_dictionary->getValue(KeyWebFieldlines, webFieldLines)) {
LERROR(fmt::format("{}: The field {} is missing", _identifier, KeyWebFieldlines));
return false;
}
else if (!webFieldLine) {
else if (!webFieldLines) {
LERROR(fmt::format("{}: The field {} is missing", _identifier, KeySourceFolder));
return false;
}
}
if (webFieldLine) {
if (webFieldLines) {
initializeWebManager();
sourceFolderPath = _webFieldlinesManager.getDirectory();
}
@@ -466,6 +467,7 @@ bool RenderableFieldlinesSequence::extractMandatoryInfoFromDictionary(
}),
_sourceFiles.end()
);
// Ensure that there are available and valid source files left
if (_sourceFiles.empty()) {
LERROR(fmt::format(
@@ -614,6 +616,7 @@ bool RenderableFieldlinesSequence::loadJsonStatesIntoRAM(const std::string& outp
return true;
}
// streaming from means streaming from disk
bool RenderableFieldlinesSequence::prepareForOsflsStreaming() {
extractTriggerTimesFromFileNames();
FieldlinesState newState;
@@ -1179,7 +1182,7 @@ void RenderableFieldlinesSequence::render(const RenderData& data, RendererTasks&
}
void RenderableFieldlinesSequence::initializeWebManager() {
_webFieldlinesManager(_identifier, "PfssIo");
_webFieldlinesManager(_identifier, "PfssIo", _activeTriggerTimeIndex, _nStates, _sourceFiles, _startTimes);
}
void RenderableFieldlinesSequence::update(const UpdateData& data) {
@@ -1192,7 +1195,7 @@ void RenderableFieldlinesSequence::update(const UpdateData& data) {
// en liten fuling för att testa att trigga nedladdning
if(currentTime > 610056120.0 && currentTime < 610056120.2){
LERROR("downloading is starting");
webFieldlinesManager.downloadFieldlines();
_webFieldlinesManager.downloadFieldlines();
computeSequenceEndTime();
}
@@ -39,27 +39,6 @@ namespace {
} // namespace
namespace openspace{
WebFieldlinesManager::WebFieldlinesManager(std::string syncDir, int& _activeTriggerTimeIndex, size_t& _nStates, std::vector<std::string>& _sourceFiles, std::vector<double>& _startTimes){
// change to parameter
_syncDir = syncDir;
_flsType = "PfssIo";
_downloadMargin = 3;
_timeTriggerDelta = 7200;
rfs_activeTriggerTimeIndex = &_activeTriggerTimeIndex;
rfs_nStates = &_nStates;
rfs_sourceFiles = &_sourceFiles;
rfs_startTimes = &_startTimes;
getAvailableTriggertimes();
setInitialSet(global::timeManager.time().j2000Seconds());
LERROR("WebFieldlinesManager initialized");
}
// dowload files specified in _filestodownload
// I'm thinking we can replace the parameters with pointers to the lists that will be
@@ -90,19 +69,23 @@ namespace openspace{
// ------------------------------- OPERATORS ------------------------------- //
// Operator ()
void WebFieldlinesManager::operator()(std::string identifier, std::string fieldLineModelType)
void WebFieldlinesManager::operator()(std::string identifier, std::string fieldLineModelType, int& _activeTriggerTimeIndex, size_t& _nStates, std::vector<std::string>& _sourceFiles, std::vector<double>& _startTimes)
{
_flsType = fieldLineModelType;
_syncDir = initializeSyncDirectory(identifier);
std::string testTime;
triggerTimeInt2String(610056000, testTime);
int testInt;
triggerTimeString2Int(testTime, testInt);
_downloadMargin = 3;
_timeTriggerDelta = 7200;
rfs_activeTriggerTimeIndex = &_activeTriggerTimeIndex;
rfs_nStates = &_nStates;
rfs_sourceFiles = &_sourceFiles;
rfs_startTimes = &_startTimes;
getAvailableTriggertimes();
setInitialSet(global::timeManager.time().j2000Seconds());
LERROR("WebFieldlinesManager initialized");
}
@@ -118,11 +101,11 @@ namespace openspace{
// check how many are left until fieldlinessequence runs out - add direction information later
double nextTheroticalTimeTrigger;
double eps = 100;
if(*rfs_activeTriggerTimeIndex == *rfs_nStates - 1){
if(*rfs_activeTriggerTimeIndex == static_cast<int>(*rfs_nStates)-1){
// if it's at the last index, definetily start some downloading
return;
}
for (int i = *rfs_activeTriggerTimeIndex; i < *rfs_nStates; i++){
for (int i = *rfs_activeTriggerTimeIndex; i < static_cast<int>(*rfs_nStates); i++){
nextTheroticalTimeTrigger = (*rfs_startTimes)[i] +_timeTriggerDelta;
if((*rfs_startTimes)[i + 1] > (nextTheroticalTimeTrigger + eps)){
// do some downloading
@@ -193,8 +176,8 @@ namespace openspace{
int endInd = openspaceindex + _downloadMargin;
if(startInd < 0) startInd = 0;
if(endInd >= _availableTriggertimes.size())
endInd = _availableTriggertimes.size()-1;
if(endInd >= static_cast<int>(_availableTriggertimes.size()))
endInd = static_cast<int>(_availableTriggertimes.size())-1;
for(int i = startInd; i <= endInd; i++)
_filesToDownload.push_back(i);
@@ -34,7 +34,6 @@ class WebFieldlinesManager{
public:
// 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();
@@ -44,7 +43,7 @@ public:
// 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);
void operator ()(std::string identifier, std::string fieldLineModelType, int& _activeTriggerTimeIndex, size_t& _nStates, std::vector<std::string>& _sourceFiles, std::vector<double>& _startTimes);
// Returns the sync directory
std::string getDirectory();
@@ -56,6 +55,7 @@ private:
// What model is this field line derived from, may come to be the same as the identifier
std::string _flsType;
// How many fieldlines around the current time point
int _downloadMargin;
// How long between the timesteps?