/****************************************************************************/1// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo2// Copyright (C) 2001-2025 German Aerospace Center (DLR) and others.3// This program and the accompanying materials are made available under the4// terms of the Eclipse Public License 2.0 which is available at5// https://www.eclipse.org/legal/epl-2.0/6// This Source Code may also be made available under the following Secondary7// Licenses when the conditions for such availability set forth in the Eclipse8// Public License 2.0 are satisfied: GNU General Public License, version 29// or later which is available at10// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html11// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later12/****************************************************************************/13/// @file Element.h14/// @author Jakub Sevcik (RICE)15/// @author Jan Prikryl (RICE)16/// @date 2019-12-1517///18/// @note based on work 2017 Ahmad Khaled, Ahmad Essam, Omnia Zakaria, Mary Nader19///20// Representation of electric circuit elements: resistors, voltage and current sources21/****************************************************************************/22#pragma once23#include <config.h>2425#include <string>26#include <iostream>272829// ===========================================================================30// class declarations31// ===========================================================================32class Node;333435// ===========================================================================36// class definitions37// ===========================================================================38/**39* An element is any component in the circuit (resistor, current source, voltage source)40* Every element has two terminals pNode (positive terminal) and nNode (negative terminal)41* value is the resistance in case of a resistor, current in case of a current source42* and voltage in case of voltage source.43*44* Conventions used:45*46* 1 - in case of a current source, "value" represents the current going from nNode to pNode,47* 2 - in case of a voltage source, "value" represents the voltage difference of pNode - nNode.48*/49class Element {5051public:52enum ElementType {53RESISTOR_traction_wire,54CURRENT_SOURCE_traction_wire,55VOLTAGE_SOURCE_traction_wire,56ERROR_traction_wire57};5859private:60Node* pNode;61Node* nNode;62double voltage;63double current;64double resistance;65double powerWanted;66ElementType type;67std::string name; // unique property, each object has distinctive and unique name68int id; // a sequential ID number, might be useful when making the equation69bool isenabled;7071public:72// a constructor. same functionality as init functions in the last project73Element(std::string name, ElementType type, double value);7475//getters and setters76double getVoltage(); // get the voltage across the element77double getCurrent(); // get the current running through the element78double getResistance();79double getPowerWanted();80double getPower();81int getId();82Node* getPosNode();83Node* getNegNode();84ElementType getType();85std::string getName();86bool isEnabled();8788void setPosNode(Node* node);89void setNegNode(Node* node);90void setId(int id);91void setVoltage(double voltage);92void setCurrent(double current);93void setResistance(double resistance);94void setPowerWanted(double powerWanted);95void setEnabled(bool isenabled);9697// if node == pNode, return nNode, else if node == nNode return pNode, else return NULL98Node* getTheOtherNode(Node* node);99// sets the type of elements100void setType(ElementType ET);101102};103104105