public GateDto(GateView view) { Location = view.MatrixLocation; Type = view.Type; Inputs = view.Inputs.Count(); Outputs = view.Outputs.Count(); }
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); }
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); }
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); }
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); }
public static IEnumerable <WireView> ConnectedOutputWires(SchemeView scheme, GateView gate) { return(scheme.Wires.Where(w => gate.WireStartConnects(w))); }
public Source(GateView gate, ExternalPortView port) { Gate = gate; Port = port; }