public Circuit AddInput(InputNode node, NodeCurrent value)
        {
            node.Value = value;
            inputNodes?.Add(node);

            return(this);
        }
        //      (More inputs possible)
        //      (Goes by the rule: 'If all inputs are high or if all inputs are low, output a high signal')

        //      Input A  Input B  Output
        //      0        0        1
        //      0        1        0
        //      1        0        0
        //      1        1        1


        protected override NodeCurrent ProcessOutput(NodeCurrent value)
        {
            NodeCurrent output = NodeCurrent.None;
            NodeCurrent valueForHighCurrent = NodeCurrent.None;

            foreach (NodeCurrent input in InputValues)
            {
                if (valueForHighCurrent == NodeCurrent.None)
                {
                    valueForHighCurrent = input;
                    output = NodeCurrent.High;
                }
                else if (input == valueForHighCurrent && output == NodeCurrent.High)
                {
                    output = NodeCurrent.High;
                }
                else
                {
                    output = NodeCurrent.Low;
                }
            }

            Value = output;
            return(output);
        }
Exemple #3
0
        //      (Only 1 input possible)
        //      (Goes by the rule: 'Output the opposite value')

        //      Input A   Output
        //      0         1
        //      1         0



        protected override NodeCurrent ProcessOutput(NodeCurrent value)
        {
            NodeCurrent output = NodeCurrent.None;

            if (value == NodeCurrent.Low)
            {
                output = NodeCurrent.High;
            }
            else
            {
                output = NodeCurrent.Low;
            }

            Value = output;
            return(output);
        }
        //      (More inputs possible)
        //      (Goes by the rule: 'If 1 input is high, output a low signal')

        //      Input A  Input B  Output
        //      0        0        1
        //      0        1        0
        //      1        0        0
        //      1        1        0


        protected override NodeCurrent ProcessOutput(NodeCurrent value)
        {
            NodeCurrent output = NodeCurrent.None;

            foreach (NodeCurrent input in InputValues)
            {
                if (input == NodeCurrent.Low && output != NodeCurrent.Low)
                {
                    output = NodeCurrent.High;
                }
                else
                {
                    output = NodeCurrent.Low;
                }
            }

            Value = output;
            return(output);
        }
Exemple #5
0
        public void Step(NodeCurrent value)
        {
            if (value != NodeCurrent.High && value != NodeCurrent.Low)
            {
                // RECIEVED NONE VALUE, STOP ALL THE THINGS!
                return;
            }

            InputValues.Add(value);

            if (InputCount == InputValues.Count)
            {
                ProcessOutput(value);

                foreach (Node output in OutputNodes)
                {
                    output.Step(Value);
                }
            }
        }
Exemple #6
0
 public void Reset()
 {
     Value = NodeCurrent.None;
     InputValues.Clear();
 }
Exemple #7
0
 protected abstract NodeCurrent ProcessOutput(NodeCurrent value);
Exemple #8
0
 protected override NodeCurrent ProcessOutput(NodeCurrent value)
 {
     Value = value;
     return(value);
 }