예제 #1
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);
        }
예제 #2
0
 /// <summary>
 /// Helper function for binding an extra equation
 /// </summary>
 /// <param name="ckt">The circuit</param>
 /// <param name="type">The type</param>
 /// <returns></returns>
 protected CircuitNode CreateNode(Circuit ckt, CircuitIdentifier name, CircuitNode.NodeType type = CircuitNode.NodeType.Voltage)
 {
     // Map the extra equations
     return(ckt.Nodes.Create(name, type));
 }
예제 #3
0
 /// <summary>
 /// Helper function for binding an extra equation
 /// </summary>
 /// <param name="ckt">The circuit</param>
 /// <param name="type">The type</param>
 /// <returns></returns>
 protected CircuitNode CreateNode(Circuit ckt, CircuitNode.NodeType type = CircuitNode.NodeType.Voltage)
 {
     // Map the extra equations
     return(ckt.Nodes.Map(null, type));
 }