mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-04-27 06:19:51 -05:00
some comments and cleanup, renamed checkSignal to isSignalActive
This commit is contained in:
@@ -33,7 +33,7 @@ namespace openspace {
|
||||
constexpr const char* KeyDataFileType = "DataFileType";
|
||||
|
||||
struct DsnManager::DsnData DsnManager::_dsnData;
|
||||
std::vector<double> DsnManager::_startTimes;
|
||||
std::vector<double> DsnManager::_fileStartTimes;
|
||||
std::vector<std::string> DsnManager::_dataFiles;
|
||||
|
||||
//Filetypes
|
||||
@@ -152,7 +152,7 @@ namespace openspace {
|
||||
timeString.replace(FilenameSize-1, 1, "T");
|
||||
|
||||
const double triggerTime = Time::convertTime(timeString);
|
||||
_startTimes.push_back(triggerTime);
|
||||
_fileStartTimes.push_back(triggerTime);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -202,6 +202,7 @@ namespace openspace {
|
||||
|
||||
//Add signals to vector of signals
|
||||
_dsnData.signals.push_back(structSignal);
|
||||
//_dsnData.signalStartTimes.push_back(Time::convertTime(structSignal.startTime));
|
||||
}
|
||||
|
||||
_dsnData.isLoaded = true;
|
||||
|
||||
@@ -59,20 +59,27 @@ namespace openspace {
|
||||
|
||||
static struct DsnData {
|
||||
//filename is on the format of YYYY-DDDT (excluding '.json')
|
||||
//std::string filenamestring;
|
||||
bool isLoaded = false;
|
||||
double sequenceStartTime;
|
||||
double sequenceEndTime = sequenceStartTime + 86400.0; // 24 hours from startTime
|
||||
std::vector<Signal> signals;
|
||||
//std::vector<double> signalStartTimes;
|
||||
};
|
||||
|
||||
/* The data that is currently loaded into open space*/
|
||||
static DsnData _dsnData;
|
||||
static std::vector<double> _startTimes;
|
||||
/* A vector with all start times for our datafiles*/
|
||||
static std::vector<double> _fileStartTimes;
|
||||
/* A vector with all our datafile paths*/
|
||||
static std::vector<std::string> _dataFiles;
|
||||
|
||||
/* Extracts all the mandatory information we need from our asset file */
|
||||
static bool extractMandatoryInfoFromDictionary(const char* identifier, std::unique_ptr<ghoul::Dictionary> &dictionary);
|
||||
static glm::vec3 approximateSpacecraftPosition(const char* dishId, glm::vec3 dishPos);
|
||||
/* Approximates a spacecraft position using XXXXX */
|
||||
static glm::vec3 approximateSpacecraftPosition(const char* dishId, glm::vec3 dishPos);
|
||||
/* Saves all filenames in a vector to be compared current time in open space */
|
||||
static void extractTriggerTimesFromFileNames(std::vector<std::string> _dataFiles);
|
||||
/* parses data from a file given an index in our preloaded filename vector */
|
||||
static bool jsonParser(int index);
|
||||
|
||||
private:
|
||||
|
||||
@@ -40,15 +40,6 @@ namespace openspace {
|
||||
extractData();
|
||||
}
|
||||
|
||||
bool CommunicationLines::checkSignal(double currentTime, std::string signalStartTime, std::string signalEndTime) {
|
||||
double startTimeInSeconds = SpiceManager::ref().ephemerisTimeFromDate(signalStartTime);
|
||||
double endTimeInSeconds = SpiceManager::ref().ephemerisTimeFromDate(signalEndTime);
|
||||
|
||||
if (startTimeInSeconds <= currentTime && endTimeInSeconds >= currentTime)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void CommunicationLines::extractData() {
|
||||
|
||||
@@ -88,7 +79,7 @@ namespace openspace {
|
||||
if (!isTimeInFileInterval) {
|
||||
DsnManager::_dsnData.isLoaded = false;
|
||||
|
||||
int activeFileIndex = findFileIndexForCurrentTime(currentTime);
|
||||
int activeFileIndex = findFileIndexForCurrentTime(currentTime, DsnManager::_fileStartTimes);
|
||||
//parse data for that file
|
||||
if (!DsnManager::_dsnData.isLoaded)
|
||||
{
|
||||
@@ -99,24 +90,19 @@ namespace openspace {
|
||||
return;
|
||||
}
|
||||
|
||||
DsnManager::DsnData signalDataVector = DsnManager::_dsnData;
|
||||
// Make space for the vertex renderinformation
|
||||
_vertexArray.clear();
|
||||
|
||||
//update focusnode information
|
||||
//update focusnode information used to calculate spacecraft positions
|
||||
_focusNode = global::navigationHandler.focusNode();
|
||||
_lineRenderInformation._localTransformSpacecraft = glm::translate(glm::dmat4(1.0), _focusNode->worldPosition());
|
||||
|
||||
//todo : binary search instead of for loop
|
||||
for (int i = 0; i < signalDataVector.signals.size(); i++) {
|
||||
//Todo; keep track of active index for signalvector, or swap for loop for binary search
|
||||
for (int i = 0; i < DsnManager::_dsnData.signals.size(); i++) {
|
||||
|
||||
DsnManager::Signal currentSignal = signalDataVector.signals[i];
|
||||
|
||||
if (checkSignal(currentTime, DsnManager::_dsnData.signals[i].startTime, DsnManager::_dsnData.signals[i].endTime))
|
||||
{
|
||||
DsnManager::Signal currentSignal = DsnManager::_dsnData.signals[i];
|
||||
if(isSignalActive(currentTime, currentSignal.startTime,currentSignal.endTime))
|
||||
pushSignalDataToVertexArray(currentSignal);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
// ... and upload them to the GPU
|
||||
@@ -144,17 +130,16 @@ namespace openspace {
|
||||
glBindVertexArray(0);
|
||||
}
|
||||
|
||||
|
||||
int CommunicationLines::findFileIndexForCurrentTime(double time) {
|
||||
int CommunicationLines::findFileIndexForCurrentTime(double time, std::vector<double> vec) {
|
||||
// upper_bound has O(log n) for sorted vectors, more efficient than for loop
|
||||
auto iter = std::upper_bound(DsnManager::_startTimes.begin(), DsnManager::_startTimes.end(), time);
|
||||
auto iter = std::upper_bound(vec.begin(), vec.end(), time);
|
||||
|
||||
int fileIndex = -1;
|
||||
//check what index we got
|
||||
if (iter != DsnManager::_startTimes.end()) {
|
||||
if (iter != DsnManager::_startTimes.begin()) {
|
||||
if (iter != vec.end()) {
|
||||
if (iter != vec.begin()) {
|
||||
fileIndex = static_cast<int>(
|
||||
std::distance(DsnManager::_startTimes.begin(), iter)
|
||||
std::distance(vec.begin(), iter)
|
||||
) - 1;
|
||||
}
|
||||
else {
|
||||
@@ -162,7 +147,7 @@ namespace openspace {
|
||||
}
|
||||
}
|
||||
else {
|
||||
fileIndex = static_cast<int>(DsnManager::_startTimes.size()) - 1;
|
||||
fileIndex = static_cast<int>(vec.size()) - 1;
|
||||
}
|
||||
|
||||
return fileIndex;
|
||||
@@ -195,6 +180,16 @@ namespace openspace {
|
||||
|
||||
}
|
||||
|
||||
bool CommunicationLines::isSignalActive(double currentTime, std::string signalStartTime, std::string signalEndTime) {
|
||||
double startTimeInSeconds = SpiceManager::ref().ephemerisTimeFromDate(signalStartTime);
|
||||
double endTimeInSeconds = SpiceManager::ref().ephemerisTimeFromDate(signalEndTime);
|
||||
|
||||
if (startTimeInSeconds <= currentTime && endTimeInSeconds >= currentTime)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Since our station dishes have a static translation from Earth, we
|
||||
* can get their local translation. The reason to handle it differently
|
||||
* compared to the spacecrafts is to keep an exact render position
|
||||
@@ -237,7 +232,6 @@ namespace openspace {
|
||||
return position;
|
||||
}
|
||||
|
||||
|
||||
RenderableCommunicationPackage::PositionVBOLayout
|
||||
CommunicationLines::getPositionForGeocentricSceneGraphNode(const char* id) {
|
||||
|
||||
@@ -260,8 +254,6 @@ namespace openspace {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
|
||||
|
||||
@@ -55,16 +55,20 @@ namespace openspace {
|
||||
/*Returns a position calculated where the focusNode position is origin(0,0,0) */
|
||||
glm::dvec3 getCoordinatePosFromFocusNode(SceneGraphNode* node);
|
||||
/*Returns an index for our filenames */
|
||||
int findFileIndexForCurrentTime(double time);
|
||||
int findFileIndexForCurrentTime(double time, std::vector<double> vec);
|
||||
/*Adds the signaldata to _vertexArray*/
|
||||
void pushSignalDataToVertexArray(DsnManager::Signal signal);
|
||||
|
||||
|
||||
private:
|
||||
bool checkSignal(double currentTime, std::string signalStartTime, std::string signalEndTime);
|
||||
/*Checks if the current time is within a signal's start and endtime*/
|
||||
bool isSignalActive(double currentTime, std::string signalStartTime, std::string signalEndTime);
|
||||
|
||||
const char* _identifier = "CommunicationLines";
|
||||
std::unique_ptr<ghoul::Dictionary> _dictionary;
|
||||
SceneGraphNode* _focusNode;
|
||||
|
||||
int _signalVectorStartIndex;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user