Constructs

This section lists all the available constructs for defining an Huxon language application. For a graceful introduction to these constructs please refer to the Tutorial section.

List of constructs:

Defines

HUX_DECLARE_SENSOR(LABEL, TYPE, ...)

Declares a new sensor.

This macro declares a new TYPE sensor named LABEL. If SIMULATION_DATA_LABEL is supplied, the sensor can be simulated for offline debugging and testing purposes. On declaration, it is possible to specify an optional initial sensor configuration with the SENSOR_CONFIGURATION argument.

Parameters
  • LABEL – the label of the sensor, following the C/C++ variable naming restrictions

  • TYPE – the sensor type (any of the hux::sensors::[manufacturer]::[model] namespaces)

  • SIMULATION_DATA_LABEL – [OPTIONAL] the label of a simulation data trace declared via HUX_DECLARE_SIMULATION_DATA, the default value is {} which specifies empty simulation data

  • SENSOR_CONFIGURATION – [OPTIONAL] the initial sensor Configuration created with HUX_DECLARE_SENSOR_CONFIGURATION the default value is TYPE::default_configuration

Returns

void — this macro resolves to a statement

HUX_DECLARE_SIMULATION_DATA(LABEL, ...)

Declares a new sensor simulation data trace.

Wraps an hux::tuple of std::vector containing the simulation traces for each source of a sensor. The chosen LABEL can then be supplied to a HUX_DECLARE_SENSOR to make the sensor simulatable.

Parameters
  • LABEL – the label of the sensor simulation data trace

  • ... – an hux::tuple of std::vector containing the simulation traces for each source of a sensor. Can be manually specified or obtained from a CSV file using: hux::simulation::load_csv

Returns

void — this macro resolves to a statement

HUX_DECLARE_CHANNEL(LABEL, TYPE, ...)

Declares a new channel, specifying the joining strategy.

This macro declares a new channel named LABEL and based on the TYPE joining strategy.

Parameters
  • LABEL – the label of the channel, following the C/C++ variable naming restrictions

  • TYPE – Can be:

    • merge for channel flattening, similar to the ReactiveX Merge operator in the sense that the channel outputs all the samples from all the inputs as soon as they are produced;

    • zip_latest for channel combination, similar to the ReactiveX Zip operator in the sense that the channel outputs a hux::tuple that combines the most recent input samples from each input only when ALL the input channels have produced at least one new sample;

    • combine_latest for channel combination, similar to the ReactiveX Combine Latest operator in the sense that the channel outputs a hux::tuple that combines the most recent input samples from each input only when ANY of the input channels have produced at least one new sample;

    • on_change for channel filtering, similar to the ReactiveX distinct_until_changed operator in the sense that the channel outputs the input sample only if it has changed from the previous value or if it is the first input sample;

    • buffer<SIZE> for channel buffering, every SIZE input samples received as input the channel emits a std::array of input elements of size SIZE, if less than SIZE input samples are received no output is emitted;

  • ... – the inputs of the channel, being sensor sources, channels, or processing nodes. For on_change and buffer channels a single input must be provided.

Returns

void — this macro resolves to a statement

HUX_DECLARE_OUTPUT_VALUE(LABEL, SCHEMA, OUTPUT_NAME, ...)

Declares an output value.

This macro declares an output value named LABEL with a given SCHEMA, OUTPUT_NAME and an associated VALUE. Output values can be created starting from other output values by using the Object SCHEMA. Each output value can be translated into a json object that can be processed by third party applications. The json object generated from an output value is encode as:

{ “OUTPUT_NAME” : VALUE }

For SCHEMA Float, Double, Integer, Long, Boolean and String, VALUE is a scalar value. Instead, for the Object SCHEMA, VALUE is translated to a json object encoded as:

{ “OV1_OUTPUT_NAME” : OV1_VALUE, …, “OVn_OUTPUT_NAME” : OVn_VALUE}

where OV1, OV2, … OVn are the output values belonging to the Object.

Parameters
  • LABEL – the name of the value that can be used inside the code to reference the value being declared

  • SCHEMA – can be:

    • Float for VALUE of type float

    • Double for VALUE of type double

    • Integer for VALUE of type hux::int32_t

    • Long for VALUE of type hux::int64_t

    • Boolean for VALUE of type bool

    • String for VALUE of type hux::string

    • Object for VALUE which is a list of other output values

  • OUTPUT_NAME – the name to be used for this value when generating structured output in json format

  • ... – the actual VALUE, it can be either a single data point or, for SCHEMA Object, a list of other output values

Returns

void — this macro resolves to a statement

HUX_REGISTER_OUTPUT(OUTPUT)

Registers the output of the algorithm.

This macro registers the overall algorithm’s output. The output must be a either a processing node or a channel that generates an output value obtained from HUX_DECLARE_OUTPUT_VALUE.

Parameters
  • OUTPUT – the algorithm output, must be a either a processing node or a channel that generates an output value obtained from HUX_DECLARE_OUTPUT_VALUE.

Returns

void — this macro resolves to a statement

HUX_DECLARE_PROCESSING(LABEL, INPUT_CHANNEL, ...)

Declares a new processing node.

This macro declares a new processing node named LABEL. The node takes as input one item at the time from the INPUT_CHANNEL. The input can be used via the hux_input variable in the code BLOCK. The output of the node is supplied with a return statement in BLOCK.

Parameters
  • LABEL – the label of the computation node, following the C/C++ variable naming restrictions

  • INPUT_CHANNEL – the input of the computation node (a channel obtained with HUX_DECLARE_CHANNEL)

  • ... – the body of a function with a single argument called hux_input, representing the node’s input

Returns

void — this macro resolves to a statement

HUX_DECLARE_STATEFUL_PROCESSING(LABEL, STATE_TYPE, INPUT_CHANNEL, ...)

Declares a new stateful computation node.

This macro declares a new stateful computation node named LABEL. The node has access to a hux_state variable of type STATE_TYPE whose data is kept across subsequent call to the computation node The node takes as input one item at the time from the INPUT_CHANNEL. The input can be used via the hux_input variable in the code BLOCK. The output of the node is supplied with a return statement in BLOCK.

Parameters
  • LABEL – the label of the computation node, following the C/C++ variable naming restrictions

  • STATE_TYPE – the type of the hux_state variable whose data is kept across subsequent call to the computation node

  • INPUT_CHANNEL – the input of the computation node (a channel obtained with HUX_DECLARE_CHANNEL)

  • ... – the body of a function with a single argument called hux_input, representing the node’s input

Returns

void — this macro resolves to a statement

HUX_DECLARE_DT_ENSEMBLE(LABEL, DT_ENSAMBLE, INPUT_CHANNEL)

Declares a new Entree Decision Tree Ensemble computation node.

This macro declares a new Decision Tree Ensemble computation node, as generated by the Entree toolchain.

Parameters
  • LABEL – the label of the computation node, following the C/C++ variable naming restrictions

  • DT_ENSAMBLE – the namespace of the Entree Decision Tree Ensemble, as declared in the Entree-generated header file

  • INPUT_CHANNEL – the input of the computation node (a channel obtained with HUX_DECLARE_CHANNEL)

Returns

void — this macro resolves to a statement

HUX_SENSOR_CONFIGURATOR_BUILDER(SENSOR_TYPE)

Obtains the SensorConfigurationBuilder for the sensor type SENSOR_TYPE.

Obtains the SensorConfigurationBuilder for the sensor type SENSOR_TYPE

Parameters
  • SENSOR_TYPE – the sensor type (any of the hux::sensors::[manufacturer]::[model] namespaces)

Returns

the reference to an instance of SensorConfiguratorBuilder instance (rvalue)

HUX_REGISTER_SENSOR_CONFIGURATOR(SENSOR_LABEL, SENSOR_CONFIGURATOR)

Registers a SensorConfigurator for the Sensor labelled SENSOR_LABEL.

This macro registers a SensorConfigurator for a previously declared Sensor with name SENSOR_LABEL.

To construct a SensorConfigurator for a Sensor named SENSOR_LABEL, use a SensorConfiguratorBuilder obtained via HUX_SENSOR_CONFIGURATOR_BUILDER.

Parameters
  • SENSOR_LABEL – the label of the sensor as previously declared

  • SENSOR_CONFIGURATOR – the instance of SensorConfigurator to be registered

Returns

void — this macro resolves to a statement

HUX_DECLARE_SENSOR_CONFIGURATION(LABEL, SENSOR_TYPE, ...)

Declares a new sensor Configuration labelled CONFIGURATION_LABEL.

This macro declares a sensor Configuration for a given sensor type.

Parameters
  • LABEL – the label of the configuration following the C/C++ variable naming restrictions

  • SENSOR_TYPE – the sensor type (any of the hux::sensors::[manufacturer]::[model] namespaces)

  • ... – the content of an initializer list specifying configuration values for the Configuration of the given sensor type

Returns

void — this macro resolves to a statement