Bus data traversal

Recently i’ve been working on getting data to traverse the graph. I’ve already made the nodes, input and ouput pins and busses. So all i have to do now is to make output pins output data which can be consumed by input pins. The problem is that the type of data that pins will be outputting isn’t know to the engine, so we cant simply  get the data from one pin and pass it to another.

Data interfaces

To enable nodes to output any kind of data i’ve introduced a single shared interface which needs to be implemented by every datatype. This interface enables the engine to pass around data objects between pins without knowing the actual data type. Within the nodes the shared interface can be queried for the interface to the actual data type. For example, when a node needs to use the Real datatype it would look something like this:










By using this interfacing aproach we can support an undetermined amount of different data types. This is because plugins can just register a datatype and the engine doesn’t need to be updated as long as that datatype inherits from the shared interface.

Graph traversal

There’s several steps that nodes and the engine need to take to make data traverse the graph:

  1. A loaded plugin needs to expose a datatype. This is done by making the plugin implement a IDataFactory  interface. When loading the plugin the engine will get the data factory and then it will ask the data factory what kinds of datatypes it exposes. The data factory returns Universally Unique IDentifiers for each exposed datatype.
  2. The node’s output pins need to request an instance of a datatype. It does this by asking the engine’s plugin library if it can create a data object for a certain UUID. The engine will invoke the data factory from plugin that exposed the datatype. The data factory is responsible for actually instantiating the datatype.
  3. While the graph is running nodes can just set values to their output pin’s data instances. They do this from within the node’s Process call.
  4. When the engine encounters a bus between an output and an input pin it will get the data instance from the output pin. In normal circumstances it will directly set this instance to the node’s input pin.
  5. Sometimes datatypes for output pins dont match those of the input pins to which it is connected. In this case the engine will ask the datatype to convert itself to the required datatype. If this is not possible it will instead ask the required datatype to convert itself from the provided data type. This way when new datatypes are added later they can still be converted to/from old datatypes.

Here is the first graph where data actually traverses from node to node:

What you see here is the Sine Wave node outputting a Real value. The engine is moving this value to the In pin of the Grapher node, which outputs it as a graph to the console.

©2017 Echo Gaming Entries (RSS) and Comments (RSS)  Raindrops Theme