예제 #1
0
 public GateDto(GateView view)
 {
     Location = view.MatrixLocation;
     Type     = view.Type;
     Inputs   = view.Inputs.Count();
     Outputs  = view.Outputs.Count();
 }
예제 #2
0
        private IEnumerable <GateView> GetSourceGates(GateView gate)
        {
            var inputWires = Navigation.NavigationHelper.ConnectedInputWires(scheme, gate);
            var sources    = inputWires.Select(x => Navigation.NavigationHelper.GetSource(scheme, x));

            var gates = sources.Where(x => x is GateView)
                        .Select(x => x as GateView);

            this.Log($"Found {gates.Count()} source gates");

            return(gates);
        }
예제 #3
0
        public static void Connect(this SchemeView scheme, GateView source, ExternalPortView destination, int index = 0)
        {
            var sourcePort = source.Outputs.ElementAt(index);

            sourcePort.Tap();

            destination.Tap();

            var lastWire = scheme.Wires.Last();

            Debug.Assert(source.WireStartConnects(lastWire));
            Debug.Assert(destination.WireEndConnects(lastWire));
            Debug.Assert(lastWire.Connection.StartPort == index);
        }
예제 #4
0
        public int GetRange(GateView gate)
        {
            // initial range for gates
            int range = 1;

            List <GateView> gates = GetSourceGates(gate).ToList();;

            while (gates.Any())
            {
                gates = gates.SelectMany(g => GetSourceGates(g)).ToList();
                range++;
            }

            return(range);
        }
예제 #5
0
        public static void Connect(this SchemeView scheme, GateView source, GateView destination, int srcIndex = 0, int dstIndex = 0)
        {
            var sourcePort = source.Outputs.ElementAt(srcIndex);

            sourcePort.Tap();

            var destinationPort = destination.Inputs.ElementAt(dstIndex);

            destinationPort.Tap();

            var lastWire = scheme.Wires.Last();

            Debug.Assert(source.WireStartConnects(lastWire));
            Debug.Assert(destination.WireEndConnects(lastWire));
            Debug.Assert(lastWire.Connection.StartPort == srcIndex);
            Debug.Assert(lastWire.Connection.EndPort == dstIndex);
        }
예제 #6
0
 public static IEnumerable <WireView> ConnectedOutputWires(SchemeView scheme, GateView gate)
 {
     return(scheme.Wires.Where(w => gate.WireStartConnects(w)));
 }
예제 #7
0
 public Source(GateView gate, ExternalPortView port)
 {
     Gate = gate;
     Port = port;
 }