Octave API: Is there a better way than having constant

Since Octave API doesn’t support self.publish like Python, which enable sending messages during running (not event based as Octave), I had to create a constant block to be able to read properties during run time, is there a better approach?

As shown in the YonoArc Octave API docs, all the event handlers can return output_messages which is:

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).

So whenever an event handler is called, if you would like to publish any messages on the output ports, you can return the output_messages structure.

The on_new_messages handler is called according to the execution mode of the block:

  • Async: Whenever a new message arrives at any of the input ports, the message is delivered to the block.
  • Sync: The messages arriving at all the input ports are time synchronized and delivered together to the block. The interval parameter defines the delay (in seconds) with which messages can be synchronized. Note that this mode can cause messages to be dropped if they are not synchronized.
  • Triggered: Whenever a new message arrives at the primary port (selected by the developer), the message along with all the latest messages from the other ports are delivered to the block. Note that this mode means that messages on the secondary ports may be dropped or delivered multiple times.
  • Periodic: Deliver the latest messages at all the input ports at a given rate (specified by the interval parameter, in seconds) regardless of how fast the messages arrive. Note that this mode means that messages can be dropped if they arrive faster than the desired interval since only the latest messages are delivered.

So if you would like on_new_messages to be called periodically regardless of the input ports, you should select the Periodic execution mode from the block manager.

One last note, if you need the block to react to the user actions, you need to add a property of the type button. In this case, whenever the user presses the button, the on_button_clicked handler will be invoked.

I moved this post to the discussions category since it is more of a discussion. I also created this issue because the execution mode doesn’t appear for Octave-based custom block.

I hope that helps. Please let me know if you have any more questions.