# Command Interface The command interface for HELICS was introduced in HELICS 3. It is an asynchronous communication mechanism to send commands or other information to other components. Cores and Brokers will respond to a small subset of commands known by HELICS, but federates have a command interface to allow retrieval of commands for interpretation by a federate. The general function appears like ```cpp void sendCommand(const std::string& target, const std::string& commandStr, HelicsSequencingModes mode) ``` the same function is available for federates, cores, and brokers. Sequencing Mode determines the priority of the command and can be either - `HELICS_SEQUENCING_MODE_FAST` : send on priority channel - `HELICS_SEQUENCING_MODE_ORDERED` : send on normal channels ordered with other communication - `HELICS_SEQUENCING_MODE_DEFAULT` : use HELICS determined default mode ```c helicsFederateSendCommand(HelicsFederate fed, const char* target, const char* command, HelicsError* err) ``` All commands in C are sent with the default ordering for now. The use case for ordered commands is primarily testing for the time being so the interface has not been added to the C API as of yet. ## Targets A target is specified, and can be one of the following. A federate named one of the key words is valid for the federation, but cannot be queried using the name. ```{eval-rst} +------------------------------------------+---------------------------------------------------------------------------------------+ | target | Description | +==========================================+=======================================================================================+ | ``broker`` | The first broker encountered in the hierarchy from the caller | +------------------------------------------+---------------------------------------------------------------------------------------+ | ``root``, ``federation`` | The root broker of the federation | +------------------------------------------+---------------------------------------------------------------------------------------+ | ``core`` | The core of a federate, this is not a valid target if called from a broker | +------------------------------------------+---------------------------------------------------------------------------------------+ | ```` | any named object in the federation can also be queried, brokers, cores, and federates | +------------------------------------------+---------------------------------------------------------------------------------------+ ``` ## Command String The `commandStr` is a generic string, so can be anything that can be contained in a string object. It is expected that most command strings will have a json format, though a few simple ones are just plain strings. ### HELICS supported commands The following queries are defined directly in HELICS. Federates may specify a callback function which allows arbitrary user-defined queries. The queries defined here are available inside of HELICS. ```{eval-rst} +---------------------------+-------------------------------------------------------------------------------------------------+ | Command String | Description | +===========================+=================================================================================================+ | ``terminate`` | [all objects] disconnect the object from the federation | +---------------------------+-------------------------------------------------------------------------------------------------+ | ``echo`` | [all objects] send a command with a `commandStr`=`echo_reply` back to the sender | +---------------------------+-------------------------------------------------------------------------------------------------+ | ``log `` | [all objects] generate a log message in a particular object | +---------------------------+-------------------------------------------------------------------------------------------------+ | ``logbuffer `` | [all objects] set the log buffer to a particular size or `stop` | +---------------------------+-------------------------------------------------------------------------------------------------+ | ``monitor `` | [brokers] set up a federate as the time monitor = | +---------------------------+-------------------------------------------------------------------------------------------------+ | ``set barrier `` | [brokers,federates] set a time barrier =