Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
Element.h
Go to the documentation of this file.
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/****************************************************************************/
21// Representation of electric circuit elements: resistors, voltage and current sources
22/****************************************************************************/
23#pragma once
24#include <config.h>
25
26#include <string>
27#include <iostream>
28
29
30// ===========================================================================
31// class declarations
32// ===========================================================================
33class Node;
34
35
36// ===========================================================================
37// class definitions
38// ===========================================================================
50class Element {
51
52public:
59
60private:
63 double voltage;
64 double current;
65 double resistance;
68 std::string name; // unique property, each object has distinctive and unique name
69 int id; // a sequential ID number, might be useful when making the equation
71
72public:
73 // a constructor. same functionality as init functions in the last project
74 Element(std::string name, ElementType type, double value);
75
76 //getters and setters
77 double getVoltage(); // get the voltage across the element
78 double getCurrent(); // get the current running through the element
79 double getResistance();
80 double getPowerWanted();
81 double getPower();
82 int getId();
86 std::string getName();
87 bool isEnabled();
88
89 void setPosNode(Node* node);
90 void setNegNode(Node* node);
91 void setId(int id);
92 void setVoltage(double voltage);
93 void setCurrent(double current);
94 void setResistance(double resistance);
95 void setPowerWanted(double powerWanted);
96 void setEnabled(bool isenabled);
97
98 // if node == pNode, return nNode, else if node == nNode return pNode, else return NULL
100 // sets the type of elements
101 void setType(ElementType ET);
102
103};
void setId(int id)
Definition Element.cpp:133
ElementType getType()
Definition Element.cpp:119
double getResistance()
Definition Element.cpp:99
void setNegNode(Node *node)
Definition Element.cpp:130
void setVoltage(double voltage)
Definition Element.cpp:60
void setCurrent(double current)
Definition Element.cpp:63
std::string name
Definition Element.h:68
double getPowerWanted()
Definition Element.cpp:102
ElementType type
Definition Element.h:67
Node * getNegNode()
Definition Element.cpp:115
std::string getName()
Definition Element.cpp:122
double powerWanted
Definition Element.h:66
int id
Definition Element.h:69
double getCurrent()
Definition Element.cpp:85
void setType(ElementType ET)
Definition Element.cpp:156
void setPosNode(Node *node)
Definition Element.cpp:126
int getId()
Definition Element.cpp:108
Node * getPosNode()
Definition Element.cpp:112
double getVoltage()
Definition Element.cpp:76
bool isEnabled()
Definition Element.cpp:148
double getPower()
Definition Element.cpp:105
void setResistance(double resistance)
Definition Element.cpp:66
void setPowerWanted(double powerWanted)
Definition Element.cpp:73
Node * getTheOtherNode(Node *node)
Definition Element.cpp:138
void setEnabled(bool isenabled)
Definition Element.cpp:152
Node * pNode
Definition Element.h:61
bool isenabled
Definition Element.h:70
Node * nNode
Definition Element.h:62
double resistance
Definition Element.h:65
double current
Definition Element.h:64
double voltage
Definition Element.h:63
ElementType
Definition Element.h:53
@ RESISTOR_traction_wire
Definition Element.h:54
@ CURRENT_SOURCE_traction_wire
Definition Element.h:55
@ VOLTAGE_SOURCE_traction_wire
Definition Element.h:56
@ ERROR_traction_wire
Definition Element.h:57
Definition Node.h:39