コード例 #1
0
 /// <summary>
 /// Constructor
 /// </summary>
 public Nodes()
 {
     Ground      = new CircuitNode(CircuitNode.NodeType.Voltage);
     Ground.Name = "GND";
     map.Add(Ground.Name, Ground);
     map.Add("0", Ground);
 }
コード例 #2
0
        /// <summary>
        /// Map a node in the circuit
        /// </summary>
        /// <param name="name">Can be a node name or NULL for an internal node that does not need a name</param>
        /// <param name="type">The node type</param>
        /// <returns></returns>
        public CircuitNode Map(string name, CircuitNode.NodeType type = CircuitNode.NodeType.Voltage)
        {
            if (locked)
            {
                throw new CircuitException($"Nodes locked, mapping is not allowed");
            }

            // Check for an existing node
            if (name != null && map.ContainsKey(name))
            {
                return(map[name]);
            }

            // Create a new node
            var node = new CircuitNode(type, nodes.Count + 1);

            node.Name = name;
            nodes.Add(node);

            // Keep a reference if it is not an internal node (null)
            if (name != null)
            {
                map.Add(name, node);
            }
            return(node);
        }
コード例 #3
0
 /// <summary>
 /// Constructor
 /// </summary>
 public CircuitNodes()
 {
     Ground = new CircuitNode(new CircuitIdentifier("0"), CircuitNode.NodeType.Voltage);
     map.Add(Ground.Name, Ground);
     map.Add(new CircuitIdentifier("gnd"), Ground);
 }