Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Communication with External Applications

WebSocket APIs

Apart from manual editing the config.json configuration script or modifying it through the GUI, FusionHub also offers a WebSocket API for external application to change its configuratuion. In fact the GUI uses this interface to access FusionHub’s settings.

Note that the websocket communication is currently not encrypted, it is not secure. Please take your own precautions to make sure network traffic for the configuration isn’t intercepted in some way. We might add an option for secure communication in future releases.

The WebSocket server can be accessed via 19358 port on the machine hosting the FusionHub service. To accelerate development download the Simple WebSocket Client Chrome plugin. This allows you to manually enter API commands and check the replies from the server.

Endpoint

Sample Requests

Sample Response / Description

getConfig

Code Block
languagejson
{
  "command": "getConfig"
}

Get in memory configurations.

getSavedConfig

Code Block
languagejson
{
  "command": "getSavedConfig"
}

Get on disk configurations.

saveConfig

Code Block
languagejson
{
  "command": "saveConfig"
}

Save the in-memory configurations to the disk.

setConfig

Code Block
languagejson
{
  "command": "setConfig",
  "data": {
    "sources": {
      "optical": {
        "settings": {
          "port": 5005
        }
      }
    }
  }
}

Update in-memory configurations. This api create new key-value pairs, or update the existing values.

It does not save configurations to the disk.

Note that in "data" you just need to specify the path to the json key to update: the exmaple on the right would change the port to 5005 while everything else is left unchanged.

overwriteConfig

Code Block
languagejson
{
  "command": "overwriteConfig",
  "data": {
    "settings": { ... },
    "sources": { ... },
    "sinks": { ... }
  }
}

Overwrite the in-memory configurations. This is suitable when user want to remove a key from the configuration.

getIntercalibrationStatus

Code Block
languagejson
{
  "command": "getIntercalibrationStatus"
}

Get the current intercalibration status. Useful for refetching current status when the frontnend accidentally disconnects.

applyIntercalibrationResults

Code Block
languagejson
{
  "command": "applyIntercalibrationResults"
}

Apply the current intercalibration quaternion to the in-memory copy of config. This does NOT save to disk.

restartBackend

Code Block
{
  "command": "restartBackend"
}

Restart the backend. Internally the while loop reset the DataBlock, causing all sources and sinks to be freed from memory, and instantiate them again.

getVersion

Code Block
languagejson
{
  "command": "getVersion"
}
Code Block
languagejson
{
  "command": "getVersion",
  "status": "ok",
  "data": {
    "version": "1.0.0"
  }
}

Sending FusionHub Data to External Applications via the ZeroMQ Interface

...