Add Lua functions to print cluster id (closes #704)

This commit is contained in:
Alexander Bock
2018-08-28 13:58:32 -04:00
parent 8acddf74a9
commit 1f7b482efa
6 changed files with 45 additions and 0 deletions

View File

@@ -65,6 +65,7 @@ public:
bool hasGuiWindow() const override;
bool isGuiWindow() const override;
bool isMaster() const override;
int clusterId() const override;
bool isUsingSwapGroups() const override;
bool isSwapGroupMaster() const override;

View File

@@ -207,6 +207,13 @@ public:
*/
virtual bool isMaster() const;
/**
* Returns the unique identifier of this OpenSpace instance within the current cluster
* configuration. If this instance is not part of a cluster, this value is always 0.
* \return The cluster identifier of this OpenSpace instance
*/
virtual int clusterId() const;
/**
* Returns <code>true</code> if the current rendering window is using swap groups.
*/

View File

@@ -1564,6 +1564,23 @@ scripting::LuaLibrary OpenSpaceEngine::luaLibrary() {
{},
"string, string",
"Removes a tag (second argument) from a scene graph node (first argument)"
},
{
"isMaster",
&luascriptfunctions::isMaster,
{},
"",
"Returns whether the current OpenSpace instance is the master node of a "
"cluster configuration. If this instance is not part of a cluster, this "
"function also returns 'true'."
},
{
"clusterId",
&luascriptfunctions::clusterId,
{},
"Returns the zero-based identifier for this OpenSpace instance in a "
"cluster configuration. If this instance is not part of a cluster, this "
"identifier is always 0."
}
},
{

View File

@@ -262,4 +262,16 @@ int downloadFile(lua_State* L) {
return 0;
}
int isMaster(lua_State* L) {
ghoul::lua::checkArgumentsAndThrow(L, 0, "lua::isMaster");
ghoul::lua::push(L, OsEng.windowWrapper().isMaster());
return 1;
}
int clusterId(lua_State* L) {
ghoul::lua::checkArgumentsAndThrow(L, 0, "lua::clusterId");
ghoul::lua::push(L, OsEng.windowWrapper().clusterId());
return 1;
}
} // namespace openspace::luascriptfunctions

View File

@@ -217,6 +217,10 @@ bool SGCTWindowWrapper::isMaster() const {
return sgct::Engine::instance()->isMaster();
}
int SGCTWindowWrapper::clusterId() const {
return sgct_core::ClusterManager::instance()->getThisNodeId();
}
bool SGCTWindowWrapper::isSwapGroupMaster() const {
return sgct::Engine::instance()->getCurrentWindowPtr()->isSwapGroupMaster();
}

View File

@@ -145,6 +145,10 @@ bool WindowWrapper::isMaster() const {
return false;
}
int WindowWrapper::clusterId() const {
return 0;
}
bool WindowWrapper::isSwapGroupMaster() const {
return false;
}