Class Circuit
A Circuit contains arbitrary objects. Connections between the objects' members (fields and properties) automatically handle value propagation - if a source value changes, all the connected members will be set to the updated value.
This is the main object of the Xirkit package. Compare a Circuit to a real electronic circuit with the electronic components being instances of objects, their pins welded to the board being instances of IInPin and IOutPin connected to each others by conductive paths. Instead of electricity floating along the connections, a Circuit instance transmits values of certain types from node to node. If you are familiar with CINEMA 4D's XPresso, you know what a Circuit is. You can also compare Xirkit to WPF's Dependency Properties.
To build up a Circuit in code, create a new Circuit. For each arbitrary object that should be connected in the Circuit, create a hosting Node instance, passing the participating object to the Node's constructor. Use AddNode(Node) to add each new node (with the hosted object). Then use Attach(String, Node, String) to connect members (fields and properties) of objects contained in two different nodes to each others.
Technically a Circuit is a container filled with Node instances that are related to each others by connected (in- and out-) pins. A number of these nodes are specified as root nodes. Whenever a circuit is executed by calling its Execute() method, the values of all out-pins at the root nodes are propagated (and possibly converted) the their connected in-pins, which in turn might trigger subsequent propagation along the graph. Nodes exposing the ICalculationPerformer interface are triggered to perform their calculation before the values at their out-pins are further propagated.
Inheritance
Inherited Members
Namespace: Fusee.Xirkit
Assembly: Fusee.Xirkit.dll
Syntax
public class Circuit
Constructors
Circuit()
Initializes a new instance of the Circuit class.
Declaration
public Circuit()
Properties
NodeList
Gets list of nodes within this Circuit
Declaration
public List<Node> NodeList { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.List<Node> | The node list. |
RootList
Gets list of root nodes within this Circuit. Each root node should additionally be part of the node list.
Declaration
public List<Node> RootList { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.List<Node> | The root list. |
Methods
AddNode(Node)
Adds node to the circuit. The node only takes part in an execution as long as it is either also listed as a root node or it has in-pins connected to other nodes in the list.
Declaration
public void AddNode(Node node)
Parameters
Type | Name | Description |
---|---|---|
Node | node | The node. |
AddRoot(Node)
Adds a node to list of root nodes. Root nodes are the starting point of the value propagation when a graph is executed (when its Execute() method is called).
Declaration
public void AddRoot(Node root)
Parameters
Type | Name | Description |
---|---|---|
Node | root | A Node object to be added to the list of root nodes. |
DeleteNode(Int32)
This method is defunct since a user has no idea of what to specify at "pos".
Declaration
public void DeleteNode(int pos)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | pos | The position. |
DeleteRoot(Int32)
This method is defunct since a user has no idea of what to specify at "pos".
Declaration
public void DeleteRoot(int pos)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | pos | The position. |
Execute()
Executes this circuit. Propagates the values of all out-pins at the root nodes to the their connected in-pins. If these nodes have out-pins connected to subsequent nodes' in-pins, their values will be further propagated. Nodes exposing the ICalculationPerformer interface are triggered to perform their calculation before the values at their out-pins are further propagated.
Declaration
public void Execute()
Reset()
Resets all nodes within this circuit.
Declaration
public void Reset()