示例#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;
 }