Workspaces as Nodes

Workspaces can be created for reuse in other workspaces. You can make a smaller subroutine that performs an operation and drag and drop it from Explorer Panel just like any other node. This tutorial will demonstrate how to create such nodes.

  1. Create Reuse workspace - this will be our primary workspace where we will test the subroutine.
  2. Under tutorial.reuse, add SubProcess workspace. It doesn't have to be located there, but it is more convenient to organise it this way since we aren't going to use SubProcess anywhere else.

We are going to create a node which accepts a message, displays it in the text box and provides two buttons: Accept and Reject. Pressing Accept will pass control to one output slot, and output formatted message, and pressing Reject will pass control to the other output slot and clear output slot. To start, we add the and arrange controls in the view area.

Now we add two input slots: control and message, and three output slots: accepted, rejected and data. We can also add initial connections to reflect our intent.

In order to test current setup, we add a couple of debug nodes that we will remove later on.

When testing current setup we can see that it doesn't perform quite as expected:

  1. We want to generate output data when Accept button is pressed
  2. And we want to clear output data when Reject button is pressed

We add two Barrier nodes to synchronise control slot and data outputs, and also connect the output from Accept to input of message in order to push through its current value. So when we click Accept, text from message and control from Accept reach Barrier and pass through. We do the same for Reject, except we add an extra TextValue to represent empty value.

Additionally we can add formatting to data connection coming from message (note the quotes are missing in the video):

{
  "message": "${}"
}

The SubProcess workspace is now almost ready.

We remove debug nodes and reset workspace state so that it doesn't have any debugging leftovers when we use it in Reuse.

Optionally we can add some description to the node in Description tab. This description and a snapshot will be displayed in Explorer Panel.

WARNING: You may have to reload the application for description to be refreshed in Explorer Panel.

Now we can open Reuse workspace and add SubProcess node. We can add a TextValue for input and test Accept and Reject buttons. You may notice, however, that Reject doesn't work properly - it does not pass control to rejected slot. Fixing this bug is quite simple:

  1. Open SubProcess workspace
  2. Fix the problem and save it
  3. Go back to Reuse workspace and select SubProcess node
  4. Click Reload / Upgrade button in properties panel to load the changes
  5. Test again

Now to finalise Reuse workspace we add TextStream node and push "accepted: <message>" and "rejected" text when a corresponding button is pressed. The only problem that we need to address is that we are trying to index a string value in TextFormatControl node. In order to convert string output from SubProcess into a map, we add an empty filter to the relevant connection.