Skip to content
This repository was archived by the owner on May 15, 2019. It is now read-only.

Node Type

EtienneDx edited this page Apr 14, 2018 · 3 revisions

Node Type

This page will list the different components of a Node Type object.

You can create some by using the 'NodeTypeCreator.html' file, or by hand. Node Types should be kept in arrays, in the arduinode/src/Types/Nodes folder. This folder is also a good source of examples.

Structure

Here is how the flow type is defined :

type NodeType = {
  name : string,
  inputs : Array<{
    type : string,
    name : string,
  }>,
  outputs : Array<{
    type : string,
    name : string,
    becomes : ?string,
  }>,
  needsExecution : boolean,
  becomes : string,
  globalVars : ?(Array<{type : string, name : string}> | {type : string, name : string}),
  imports : ?(Array<string> | string),
  isStartupPoint : ?boolean,
}

This can seem a little heavy, but actually isn't.

  • name : the name of the node (has to be unique)
  • inputs : an array of connectors types, I'll come back to them below
  • outputs : an array of connectors types, I'll come back to them below
  • needsExecution : does the node uses execution pins (eg. digitalread doesn't, since it just reads the value and returns it, it can fit as an input for another node. On the contrary, digitalWrite doesn't return a value and needs to be an instruction of it's own, it cannot fit as an input for another node.). *Basically, if the node is just returning a value, it doesn't need execution, if it doesn't return a value and/or contains ';', it does require execution
  • becomes : What will the node become when 'translated' into code? I'll come back to it below
  • globalVars : This is a feature of a limited use, see below
  • imports : An array of string or a string listing the required imports, formatted like : ['"import1.h"', '<import2.h>']
  • isStartupPoint : is this node the origin of an instruction list? (eg. functions)

Inputs and Outputs

Inputs and outputs are objects used to represent the node connectors. They are constitued of two things :

  • type : The type of the connector, it should fit a VarType name.
  • name : The name of the connector, you can't have multiple connectors of the same type - input or output - have the same name.

If your NodeType requires execution, you need, for the time being, to specify the executables inputs / outputs.

For outputs, there is also an optionnal 'becomes' field. This field is used in nodes that require execution but also return one or multiple values. It is used with the global vars.

Global Vars

This feature may not be needed, but may be, so I'll leave it for the time being. Basically, it allows the creation of global vars for the nodes that require executions, but also return one or multiple values. It is formatted as an array of objects with two fields each:

  • type : this time, the type represents directly the type that will be written in the code (eg. in 'int someInt = 22;', it is the 'int')
  • name : this is the normal name of the variable. This name will be modified to avoid duplicated names.

Becomes

This is actually the import field. It is the template that will eb used to turn the node into code.

The translator will take this template and replace some strings with values :

<<inputs:someInput>>

will be replaced by the input, except for Executables inputs type

<<outputs:someOutput>>

will be replaced by the output. It works only for Executables outputs type

<<outputs:someOtherOutput?>>
// some code
<</outputs:someOtherOutput?>>

will be replaced by '' if 'someOtherOutput' is not connected, otherwise the <<>> will both be removed, leaving the code in between. This only works for Executable outputs.

If you use global vars, in the node becomes or in an output becomes, you can use <globalVars:varName>

Clone this wiki locally