### Logic Circuit

The Logic Circuit sample allows the user to make circuits using gates and wires, which are updated whenever a Link is modified and at intervals by a looped setTimeout function.

The updateStates function calls a function to update each node according to type, which uses the color of the links into the node to determine the color of those exiting it. Red means zero or false; green means one or true. Double-clicking an input node will toggle true/false.

Mouse over a node to see its category, displayed using a shared Adornment set as the tooltip. A Palette to the left of the main diagram allows the user to drag and drop new nodes. These nodes can then be linked using ports which are defined on the various node templates. Each input port can only have one input link, while output ports can have many output links. This is controlled by the GraphObject.toMaxLinks property.

Diagram Model saved in JSON format:
{ "class": "go.GraphLinksModel", "linkFromPortIdProperty": "fromPort", "linkToPortIdProperty": "toPort", "nodeDataArray": [ {"category":"input", "key":"input1", "loc":"-150 -80" }, {"category":"or", "key":"or1", "loc":"-70 0" }, {"category":"not", "key":"not1", "loc":"10 0" }, {"category":"xor", "key":"xor1", "loc":"100 0" }, {"category":"or", "key":"or2", "loc":"200 0" }, {"category":"output", "key":"output1", "loc":"200 -100" } ], "linkDataArray": [ {"from":"input1", "fromPort":"out", "to":"or1", "toPort":"in1"}, {"from":"or1", "fromPort":"out", "to":"not1", "toPort":"in"}, {"from":"not1", "fromPort":"out", "to":"or1", "toPort":"in2"}, {"from":"not1", "fromPort":"out", "to":"xor1", "toPort":"in1"}, {"from":"xor1", "fromPort":"out", "to":"or2", "toPort":"in1"}, {"from":"or2", "fromPort":"out", "to":"xor1", "toPort":"in2"}, {"from":"xor1", "fromPort":"out", "to":"output1", "toPort":""} ]}