Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/GMLC-TDC/HELICS/llms.txt

Use this file to discover all available pages before exploring further.

Queries are an asynchronous mechanism for interrogating the live state of a HELICS federation. While time-advancement requests and value exchanges are the primary communication paths during co-simulation, queries provide a separate channel for asking about configuration, topology, and current status—without interfering with the time-stepping logic. A federate can query its own broker, its core, another named federate, or the root broker, and receive back a JSON response describing the requested information. Brokers, cores, and federates all expose query interfaces, and federates can also define callbacks to answer custom queries.

What queries are and when to use them

Queries travel along priority channels (by default) and are non-blocking with respect to time advancement—they do not wait for any federate’s time request to be granted. This makes them suitable for:
  • Debugging: inspecting which federates have joined, what publications and subscriptions exist, or what time each component believes it is at.
  • Dynamic configuration: a late-joining federate can discover existing publications by querying the broker before subscribing.
  • Monitoring and visualization: an external tool can poll the federation state via the REST API without being a federate itself.
  • Health checks: confirm all expected federates have entered initialization mode before proceeding.
Queries that cannot be completed or target an unknown component return a JSON error object following HTTP error codes (404 for not found, 400 for unavailable, 500 for server failure).

Query targets

Every query must specify a target—the component in the federation that should answer the query. Targets can be specified by relationship to the calling federate or by the component’s name.
Target stringResolves to
brokerThe first broker in the hierarchy encountered from the caller
root, federation, rootbrokerThe root broker of the entire federation
globalA global variable value
parentThe parent of the calling component
coreThe core of the calling federate (invalid if called from a broker)
federateThe local federate or first federate of a core
<name>Any named broker, core, or federate in the federation
If a federate is named with the same string as a reserved target keyword (for example, naming a broker "broker"), it cannot be queried by that name. The keyword will always be resolved to the relationship rather than the component name.

Federate queries

The following queries can be made against any federate:
Query stringReturnsType
nameThe identifier of the federatestring
existsWhether the federate exists in the federationT/F
isinitWhether the federate has entered init modeT/F
stateCurrent state of the federatestring
global_stateCurrent state as a full structurestructure
versionHELICS library version stringstring
queriesList of all available queriesstring vector
tagsJSON structure of tags and valuesstructure
tag/<tagname>Value of a specific tagstring
barriersCurrent time barriersstructure
logsBuffered log messages (if log buffer enabled)structure
Query stringReturnsType
publicationsCurrent publications of the federatestring vector
publication_detailsDetailed publication informationstructure
subscriptionsCurrent subscriptions of the federatestring vector
inputsCurrent inputs of the federatestring vector
input_detailsDetailed input informationstructure
endpointsCurrent endpoints of the federatestring vector
endpoint_detailsDetailed endpoint informationstructure
endpoint_filtersFilters on endpointsstructure
Query stringReturnsType
current_timeCurrent time of the federatestructure
dependenciesObjects this federate depends onstring vector
dependentsObjects that depend on this federatestring vector
dependency_graphFull dependency graph from this federatestructure
data_flow_graphAll data connections involving this federatestructure
Query stringReturnsType
updated_input_indicesIndices of inputs updated since last time stepstring vector
updated_input_namesNames of updated inputsstring vector
updatesValues of all updated inputsstructure
valuesCurrent values of all inputsstructure
timeCurrent granted timestring

Core queries

Query stringReturnsType
nameIdentifier of the corestring
addressNetwork address of the corestring
isinitWhether the core has entered init modeT/F
isconnectedWhether the core is connectedT/F
versionHELICS library version stringstring
version_allVersion strings of all connected componentsstructure
counterA code value that changes when the core changesstring
federatesFederates registered in this corestring vector
federate_mapHierarchical map of federates in the corestructure
Query stringReturnsType
publicationsPublications defined in this corestring vector
inputsNamed inputs defined in this corestring vector
endpointsEndpoints defined in this corestring vector
filtersFilters defined in this corestring vector
publication_detailsDetailed publication informationstructure
input_detailsDetailed input informationstructure
endpoint_detailsDetailed endpoint informationstructure
filter_detailsDetailed filter informationstructure
current_timeLocally computed time sequencestructure
global_timeTime status of all federates and coresstructure
current_stateCurrent known status of the core’s componentsstructure
global_stateState of all components (requires reaching out to them)structure
dependency_graphDependencies in the core and its federatesstructure
data_flow_graphAll data connections from interfaces in this corestructure
global_time_debuggingDetailed time debugging statestructure
global_flushFlushes the system via ordered pathstructure

Broker queries

Query stringReturnsType
nameIdentifier of the brokerstring
addressNetwork address of the brokerstring
isinitWhether the broker has entered init modeT/F
isconnectedWhether the broker is connectedT/F
statusConnection status structurestructure
versionHELICS library version stringstring
version_allVersion strings of all broker componentsstructure
counterCode that changes when the federation changesstring
brokersCores and sub-brokers connected to this brokerstring vector
federatesAll federates under this broker’s hierarchystring vector
federate_mapHierarchical map of all federatesstructure
countsCount of brokers, federates, and interfacesstructure
Query stringReturnsType
publicationsPublications known to this brokerstring vector
endpointsEndpoints known to this brokerstring vector
inputsInputs known to this brokerstring vector
filtersFilters known to this brokerstring vector
publication_detailsDetailed publication informationstructure
input_detailsDetailed input informationstructure
endpoint_detailsDetailed endpoint informationstructure
filter_detailsDetailed filter informationstructure
current_timeLocally computed time, or #na if not availablestring
global_timeTime status of all federates and coresstructure
current_stateCurrent known status of brokers and federatesstructure
global_stateState of all system componentsstructure
global_statusCombination of global_time and current_statestructure
dependency_graphAll dependency connections in the broker hierarchystructure
data_flow_graphAll data connections in the federationstructure
barriersCurrent time barriersstructure
global_time_debuggingDetailed time debugging statestructure
global_flushFlushes the system via ordered path and returns IDsstructure
time_monitorCurrent time as reported by the monitor federatestructure
monitorName of the time monitor objectstring
logsBuffered log messagesstructure
Queries such as federate_map, dependency_graph, global_time, global_state, global_time_debugging, and data_flow_graph when directed at the root broker assemble information from every member of the federation and can take noticeable time. global_flush is additionally forced through the ordered (low-priority) path, making it slower still.

Sequencing modes

As of HELICS 2.7, queries accept an optional sequencing mode parameter:
  • HELICS_SEQUENCING_MODE_FAST (default): the query travels along priority channels and returns as quickly as possible, identical to behaviour before HELICS 2.7.
  • HELICS_SEQUENCING_MODE_ORDERED: the query travels through standard message channels and is ordered with respect to all other messages. Use this when you need the query result to reflect all messages that have already been sent.

Making queries programmatically

C++ API

The Federate object exposes two query methods:
// Query with an explicit target
std::string result = fed.query("broker", "federates");

// Query the local federate (no target needed)
std::string local_result = fed.query("publications");
An asynchronous (non-blocking) version is also available:
// Start query without blocking
query_id_t qid = fed.queryAsync("root", "global_state");

// ... do other work ...

// Retrieve the result when ready
std::string result = fed.queryComplete(qid);

// Or check non-blocking
bool done = fed.isQueryComplete(qid);
Helper functions in <helics/queryFunctions.hpp> provide utilities for waiting until a federate enters initialization mode, waiting for a specific federate to join, and converting string-vector query results into std::vector<std::string>.

C API

// Create a query object
HelicsQuery q = helicsQueryCreate("broker", "federates");

// Execute the query from a federate
const char* result = helicsQueryExecute(q, fed, &err);

// Modify target or query string after creation
helicsQuerySetTarget(q, "root");
helicsQuerySetQueryString(q, "global_state");

// Execute asynchronously
helicsQueryExecuteAsync(q, fed, &err);
// ... later ...
const char* async_result = helicsQueryExecuteComplete(q, &err);

// Free the query when done
helicsQueryFree(q);

Python API

import helics as h

# Create and execute a query
q = h.helicsCreateQuery("broker", "federates")
result = h.helicsQueryExecute(q, fed)
print(result)
h.helicsQueryFree(q)

Query response format

All queries return valid JSON. A successful structural query looks like:
{
  "brokers": [],
  "cores": [
    {
      "federates": [
        { "id": 131072, "name": "fedA_1", "parent": 1879048192 }
      ],
      "id": 1879048192,
      "name": "core-abc123",
      "parent": 1
    }
  ],
  "id": 1,
  "name": "brokerA"
}
String-vector results use a semicolon-delimited format:
[fedA_1;fedA_2;fedB_1]
Error responses follow HTTP status codes:
{
  "error": {
    "code": 404,
    "message": "target not found"
  }
}

REST API queries via the webserver

The HELICS webserver (available as of HELICS 2.4) exposes queries over HTTP and WebSocket, enabling external tools to inspect a running federation without being a federate. Start the broker server with the HTTP interface enabled:
helics_broker_server --http --zmq --duration=30minutes
The webserver defaults to localhost:43542. You can then query via standard HTTP GET requests:
GET http://localhost/brokerA/federate_map
Which returns the same JSON as the in-process query. Multiple URL formats are equivalent:
http://localhost/brokerA/publications
http://localhost/brokerA?query=publications
http://localhost?broker=brokerA&query=publications&target=root
Queries can also be sent as JSON in the request body:
{
  "command": "search",
  "broker": "broker1",
  "target": "federate0",
  "query": "current_state"
}
See the webserver documentation for full details on HTTP verbs, parameters, and WebSocket responses.

Query timeouts

Queries have a built-in timeout (default 15 seconds) so they do not block forever if a federate fails. If a query times out, the returned string will be #timeout. You can change the timeout on brokers and cores:
helics_broker --querytimeout=30s
For very large federations where complex queries like global_state may legitimately take longer, increase this value accordingly.

Example: dynamic configuration via queries

A full co-simulation example demonstrating how queries enable dynamic configuration is available in the HELICS Examples repository.

Build docs developers (and LLMs) love