Expose time interval to user in config file for sky browser topic. This will give the user control over how often data is passed. Hopefully a future proof fix for GPU crash

This commit is contained in:
Ylva Selling
2022-04-26 14:39:00 -04:00
parent 19103a1540
commit 8a292c1645
5 changed files with 24 additions and 4 deletions

View File

@@ -46,6 +46,7 @@ private:
int _targetDataCallbackHandle = UnsetOnChangeHandle;
bool _isDone = false;
std::chrono::system_clock::time_point _lastUpdateTime;
std::chrono::milliseconds _skyBrowserUpdateTime = std::chrono::milliseconds(100);
};
} // namespace openspace

View File

@@ -72,6 +72,10 @@ ServerInterface* ServerModule::serverInterfaceByIdentifier(const std::string& id
return si->get();
}
int ServerModule::skyBrowserUpdateTime() const {
return _skyBrowserUpdate;
}
void ServerModule::internalInitialize(const ghoul::Dictionary& configuration) {
global::callback::preSync->emplace_back([this]() {
ZoneScopedN("ServerModule")
@@ -110,6 +114,12 @@ void ServerModule::internalInitialize(const ghoul::Dictionary& configuration) {
_interfaces.push_back(std::move(serverInterface));
}
}
// Ylva Selling, 2022-04-26 hasValue<int> doesn't find the variable
if (configuration.hasValue<double>("SkyBrowserUpdateTime")) {
_skyBrowserUpdate = static_cast<int>(
configuration.value<double>("SkyBrowserUpdateTime")
);
}
}
void ServerModule::preSync() {

View File

@@ -55,6 +55,8 @@ public:
ServerInterface* serverInterfaceByIdentifier(const std::string& identifier);
int skyBrowserUpdateTime() const;
protected:
void internalInitialize(const ghoul::Dictionary& configuration) override;
@@ -76,6 +78,7 @@ private:
std::vector<ConnectionData> _connections;
std::vector<std::unique_ptr<ServerInterface>> _interfaces;
properties::PropertyOwner _interfaceOwner;
int _skyBrowserUpdate = 100;
};
} // namespace openspace

View File

@@ -25,6 +25,7 @@
#include "modules/server/include/topics/skybrowsertopic.h"
#include <modules/server/include/connection.h>
#include <modules/server/servermodule.h>
#include <modules/skybrowser/skybrowsermodule.h>
#include <modules/skybrowser/include/targetbrowserpair.h>
#include <openspace/engine/moduleengine.h>
@@ -38,7 +39,6 @@ namespace {
constexpr const char* EventKey = "event";
constexpr const char* SubscribeEvent = "start_subscription";
constexpr const char* UnsubscribeEvent = "stop_subscription";
constexpr const std::chrono::milliseconds TimeUpdateInterval(25);
} // namespace
using nlohmann::json;
@@ -47,7 +47,12 @@ namespace openspace {
SkyBrowserTopic::SkyBrowserTopic()
: _lastUpdateTime(std::chrono::system_clock::now())
{}
{
ServerModule* module = global::moduleEngine->module<ServerModule>();
if (module) {
_skyBrowserUpdateTime = std::chrono::milliseconds(module->skyBrowserUpdateTime());
}
}
SkyBrowserTopic::~SkyBrowserTopic() {
if (_targetDataCallbackHandle != UnsetOnChangeHandle) {
@@ -73,7 +78,7 @@ void SkyBrowserTopic::handleJson(const nlohmann::json& json) {
_targetDataCallbackHandle = global::timeManager->addTimeChangeCallback([this]() {
std::chrono::system_clock::time_point now = std::chrono::system_clock::now();
if (now - _lastUpdateTime > TimeUpdateInterval) {
if (now - _lastUpdateTime > _skyBrowserUpdateTime) {
sendBrowserData();
_lastUpdateTime = std::chrono::system_clock::now();
}

View File

@@ -151,6 +151,7 @@ ModuleConfigurations = {
},
Server = {
AllowAddresses = { "127.0.0.1", "localhost" },
SkyBrowserUpdateTime = 150,
Interfaces = {
{
Type = "TcpSocket",
@@ -188,7 +189,7 @@ ModuleConfigurations = {
Space = {
ShowExceptions = false
}
-- OBS! The settings for the SkyBrowser and Exoplanets modules are
-- OBS! The settings for the SkyBrowser and Exoplanets modules are
-- set in individual assets, see "data/assets/modules". Note that
-- any settings addded here might be overwritten by those assets
}