1. Home
  2. Docs
  3. Yonohub
  4. YonoArc
  5. YonoArc Octave API

YonoArc Octave API

The API of YonoArc is event-driven. A block is represented by a folder having multiple .m files, each implementing one of the supported event handlers below. It is important to note that every port or property has a unique key that you select while creating the block on the User Interface. This is to allow the block to know on which port a particular message is received and the values of the different properties.

One major difference between the Python 3 API and the Octave API is that the latter represents a message as a structure (not an object). For example, a message having the following definition would be delivered or published as {“x”: 1, “y”: 2} where 1 and 2 are the values in the message.

int32 x
int32 y

YonoArc supports the following event handlers. Each handler must be provided in a .m file with the same name as the handler (e.g., on_start.m).

  • on_start is called at the beginning when the block starts.
function output_messages = on_start (properties)

% properties: A structure of the keys and values of the block properties. It also includes the execution mode of the block (e.g., {"type": "async"}, {"type": "sync", "interval": 1}, {"type": "triggered", "port_key": port_key}, or {"type": "periodic", "interval": 1})

% output_messages: [Optional] A structure of the port keys and the values of the outgoing messages (e.g., {'output_image': image, 'boxes': boxes} where 'output_image' and 'boxes' are the port keys and image and boxes are two dictionaries, each representing its corresponding message).

endfunction
  • on_new_messages is called according to the execution mode of the block.
function output_messages = on_new_messages (messages)

% messages: A structure of the port keys and the values of the incoming messages.

% output_messages: [Optional] A structure of the port keys and the values of the outgoing messages (e.g., {'output_image': image, 'boxes': boxes} where 'output_image' and 'boxes' are the port keys and image and boxes are two dictionaries, each representing its corresponding message).

endfunction
  • on_properties_changed is called when one or more block properties are changed in live mode.
function output_messages = on_properties_changed (affected_properties)

% affected_properties: A structure of the keys and values of the affected properties.

% output_messages: [Optional] A structure of the port keys and the values of the outgoing messages (e.g., {'output_image': image, 'boxes': boxes} where 'output_image' and 'boxes' are the port keys and image and boxes are two dictionaries, each representing its corresponding message).

endfunction
  • on_button_clicked is called when a block button is clicked in live mode.
function output_messages = on_button_clicked (button_key)

% button_key: The key of the button that has been clicked.

% output_messages: [Optional] A structure of the port keys and the values of the outgoing messages (e.g., {'output_image': image, 'boxes': boxes} where 'output_image' and 'boxes' are the port keys and image and boxes are two dictionaries, each representing its corresponding message).

endfunction