Class Gate

Inheritance Relationships

Base Type

Class Documentation

class Gate : public dai::DeviceNodeCRTP<DeviceNode, Gate, GateProperties>

Gate Node.

This node acts as a valve for data pipelines. It controls the flow of messages from the ‘input’ to the ‘output’ based on the state configured via ‘inputControl’. It can be configured to stay open indefinitely, stay closed, or open for a specific number of messages.

Public Functions

Gate(std::unique_ptr<Properties> props)
Gate() = default
void setRunOnHost(bool runOnHost)

Specify whether to run on host or device By default, the node will run on device.

virtual bool runOnHost() const override

Check if the node is configured to run on the host.

Returns:

true if running on host, false otherwise.

virtual void run() override
inline DeviceNodeCRTP()
inline DeviceNodeCRTP(const std::shared_ptr<Device> &device)
inline DeviceNodeCRTP(std::unique_ptr<Properties> props)
inline DeviceNodeCRTP(std::unique_ptr<Properties> props, bool confMode)
inline DeviceNodeCRTP(const std::shared_ptr<Device> &device, std::unique_ptr<Properties> props, bool confMode)

Public Members

std::shared_ptr<GateControl> initialConfig = std::make_shared<GateControl>()
Input input = {*this, {"input", DEFAULT_GROUP, false, 1, {{{DatatypeEnum::Buffer, true}}}, DEFAULT_WAIT_FOR_MESSAGE}}

Main data input.

  • Accepts arbitrary Buffer messages (e.g., ImgFrame, NNData). If the Gate is Open, messages received here are forwarded to ‘output’. If the Gate is Closed, messages received here are discarded/dropped.

  • Default queue size: 1 Blocking: False

Output output = {*this, {"output", DEFAULT_GROUP, {{{DatatypeEnum::Buffer, true}}}}}

Main data output.

  • Forwards messages that were allowed through the Gate. The data type matches the input message.

Input inputControl = {*this, {"inputControl", DEFAULT_GROUP, false, 4, {{{DatatypeEnum::GateControl, false}}}, DEFAULT_WAIT_FOR_MESSAGE}}

Control input.

  • Accepts ‘GateControl’ messages to dynamically change the Gate’s state. Use this to Open/Close the gate or set it to pass a specific number of frames at runtime.

  • Default queue size: 4

Public Static Attributes

static constexpr const char *NAME = "Gate"

Protected Functions

virtual Properties &getProperties() override