Example #1
0
        /// <summary>
        /// Connects a wire-mesh to the invoking circuit output, making
        /// the circuit output's value dependent on this wire.
        /// </summary>
        /// <param name="wire">The wire to connect</param>
        public void Connect(WireMesh wire)
        {
            // If we already connected to this wire, we're done!
            if (_outputWires.Contains(wire) || _inputWires.ContainsKey(wire))
            {
                return;
            }

            // If this wire doesn't come from somewhere, it comes from here.  Otherwise, it gives us value.
            if (!wire.HasSource)
            {
                _outputWires.Add(wire);
                wire.ConnectSource(this, 0);
            }
            else
            {
                _inputWires[wire] = wire.ConnectedEndpoints(this);
                wire.ConnectDependent(this);
            }
        }
Example #2
0
        /// <summary>
        /// Connects a wire-mesh as an input to the invoking logic gate.
        /// </summary>
        /// <param name="wire">The wire-mesh to connect</param>
        public void ConnectInput(WireMesh wire)
        {
            List <Sketch.EndPoint> connectedEndpoints = wire.ConnectedEndpoints(this);

            _inputWires[wire] = connectedEndpoints;
        }