Line data Source code
1 : /****************************************************************************/
2 : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3 : // Copyright (C) 2001-2024 German Aerospace Center (DLR) and others.
4 : // This program and the accompanying materials are made available under the
5 : // terms of the Eclipse Public License 2.0 which is available at
6 : // https://www.eclipse.org/legal/epl-2.0/
7 : // This Source Code may also be made available under the following Secondary
8 : // Licenses when the conditions for such availability set forth in the Eclipse
9 : // Public License 2.0 are satisfied: GNU General Public License, version 2
10 : // or later which is available at
11 : // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 : // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 : /****************************************************************************/
14 : /// @file Node.h
15 : /// @author Jakub Sevcik (RICE)
16 : /// @author Jan Prikryl (RICE)
17 : /// @date 2019-12-15
18 : ///
19 : /// @note based on work 2017 Ahmad Khaled, Ahmad Essam, Omnia Zakaria, Mary Nader
20 : ///
21 : // Representation of electric circuit nodes, i.e. wire junctions and connection points.
22 : /****************************************************************************/
23 : #pragma once
24 : #include <config.h>
25 :
26 : #include <vector>
27 : #include <string>
28 :
29 :
30 : // ===========================================================================
31 : // class declarations
32 : // ===========================================================================
33 : class Element;
34 :
35 :
36 : // ===========================================================================
37 : // class definitions
38 : // ===========================================================================
39 223 : class Node {
40 :
41 : private:
42 : bool isground;
43 : bool isremovable;
44 : std::string name; // unique property, each object has distinctive and unique name
45 : int id; // a sequential ID number, might be useful when making the equation
46 : int num_matrixRow; // number of matrix row during solving the equations
47 : int num_matrixCol; // number of matrix column during solving the equations
48 : double voltage;
49 : std::vector<Element*>* elements; // too lazy to implement a linked list
50 : // each node is connected to one or more element, an element is a resistor or voltage/current source
51 :
52 : public:
53 : // A constructor, same functionality as "init" functions
54 : Node(std::string name, int id);
55 :
56 : // connects an element to the node
57 : void addElement(Element* element);
58 : // disconnects an element to the node
59 : void eraseElement(Element* element);
60 : // getters and setters
61 : double getVoltage();
62 : void setVoltage(double volt);
63 : int getNumOfElements();
64 : // iterates through the vector of the node's elements and returns the first, which is not equal to "element" in the argument of the function
65 : Element* getAnOtherElement(Element* element);
66 : std::string& getName();
67 : bool isGround();
68 : bool isRemovable() const {
69 30058 : return isremovable;
70 : }
71 : void setGround(bool isground);
72 : int getId();
73 : void setNumMatrixRow(int num);
74 : int getNumMatrixRow();
75 : void setNumMatrixCol(int num);
76 : int getNumMatrixCol();
77 : void setId(int id);
78 : std::vector<Element*>* getElements();
79 : void setRemovability(bool isremovable);
80 : };
|