示例#1
0
            /// <summary>
            /// Initializes a new instance of the <see cref="Subcircuit"/> class.
            /// </summary>
            /// <param name="name">The name.</param>
            public Instance(string type, string name, GraphicalCircuit definition, Options options, IEnumerable <IPin> pins)
                : base(name, options)
            {
                Type = type;
                _ckt = definition;

                // Find the pins in the subcircuit
                var           taken         = new HashSet <string>(StringComparer.OrdinalIgnoreCase);
                List <string> possibleNames = new();

                foreach (var pin in pins)
                {
                    possibleNames.Clear();

                    // Check with the name of the pin owner
                    string pinName = pin.Owner.Name;
                    if (taken.Add(pinName))
                    {
                        possibleNames.Add(pinName);
                    }

                    // Make a shorthand notation for DIR
                    if (pinName.StartsWith("DIR") && pinName.Length > 3)
                    {
                        pinName = pinName.Substring(3);
                        if (taken.Add(pinName))
                        {
                            possibleNames.Add(pinName);
                        }
                    }

                    // General names!
                    foreach (string pn in pin.Owner.Pins.NamesOf(pin))
                    {
                        pinName = $"{pin.Owner.Name}_{pn}";
                        if (taken.Add(pinName))
                        {
                            possibleNames.Add(pinName);
                        }
                    }

                    if (pin is IOrientedPin op)
                    {
                        Pins.Add(new FixedOrientedPin($"{pin.Owner.Name}_{pin.Name}", pin.Description, this, pin.Location, op.Orientation),
                                 possibleNames);
                    }
                    else
                    {
                        Pins.Add(new FixedPin($"{pin.Owner.Name}_{pin.Name}", pin.Description, this, pin.Location),
                                 possibleNames);
                    }
                }
                DrawingVariants = Variant.Do(DrawSubcircuit);
            }
示例#2
0
            public Instance(string name, Options options)
                : base(name, options)
            {
                Pins.Add(new FixedOrientedPin("p", "The one and only pin.", this, new(0, 0), new(0, -1)), "a", "p");

                if (options?.SmallSignal ?? false)
                {
                    AddVariant("signal");
                }

                DrawingVariants = Variant.FirstOf(
                    Variant.If("earth").Then(DrawEarth),
                    Variant.If("signal").Then(DrawSignalGround),
                    Variant.Do(DrawGround));
            }
示例#3
0
 public Instance(string name, Options options)
     : base(name, options)
 {
     Pins.Add(new FixedOrientedPin("p", "The pin.", this, new Vector2(), new Vector2(1, 0)), "p", "a", "o", "i");
     DrawingVariants = Variant.Do(DrawTerminal);
 }
示例#4
0
 public Instance(string name, Options options)
     : base(name, options)
 {
     Pins.Add(new FixedOrientedPin("a", "The pin.", this, new(), new(0, 1)), "x", "p", "a");
     DrawingVariants = Variant.Do(DrawPower);
 }
示例#5
0
 public Instance(string name)
     : base(name)
 {
     Pins.Add(new FixedPin(name, "The point.", this, new()), "x", "p", "a");
     DrawingVariants = Variant.Do(DrawPoint);
 }