Hopsan
Node Class Reference

The Node base class. More...

Inheritance diagram for Node:
NodeElectric NodeEmpty NodeHydraulic NodeHydraulicTemperature NodeMechanic NodeMechanic2D NodeMechanicRotational NodeModelica NodePetriNet NodePneumatic NodeSignal NodeSignalND

Public Member Functions

 Node (const size_t datalength)
 
virtual void setSignalNumDimensions (size_t numDims)
 
const HStringgetNiceName () const
 
const HStringgetNodeType () const
 returns the node type
 
size_t getNumDataVariables () const
 Returns the total number of variables in a node.
 
int getDataIdFromName (const HString &rName) const
 This function gives you the data Id for a named data variable. More...
 
double getDataValue (const size_t dataId) const
 get data from node More...
 
void setDataValue (const size_t dataId, const double data)
 set data in node More...
 
const std::vector< NodeDataDescription > * getDataDescriptions () const
 Get the vector of data descriptions for the node. More...
 
const NodeDataDescriptiongetDataDescription (const size_t id) const
 
virtual void setSignalQuantity (const HString &rQuantity, const HString &rUnit, const size_t dataId=0)
 This function can be used to set unit string and displayName for signal nodes ONLY.
 
virtual void setSignalQuantityModifyable (bool tf, const size_t dataId=0)
 
virtual HString getSignalQuantity (const size_t dataId=0) const
 
virtual bool getSignalQuantityModifyable (const size_t dataId=0) const
 
void logData (const size_t logSlot)
 Copy current data vector into log storage at given logslot. More...
 
int getNumberOfPortsByType (const int type) const
 Returns the number of attached ports of a specific type.
 
size_t getNumConnectedPorts () const
 
bool isConnectedToPort (const Port *pPort) const
 
PortgetSortOrderSourcePort () const
 
ComponentgetWritePortComponentPtr () const
 Returns a pointer to the component with the write port in the node. If connection is ok, any node can only have one write port. If no write port exists, a null pointer is returned.
 
ComponentSystemgetOwnerSystem () const
 Returns a pointer to the ComponentSystem that own this Node.
 

Protected Member Functions

void setNiceName (const HString &rNicename)
 
void setDataCharacteristics (const size_t id, const HString &rName, const HString &rShortname, const HString &rQuantityOrUnit, const NodeDataVariableTypeEnumT vartype=DefaultType)
 Set data name and unit for a specified data variable. More...
 
void copyNodeDataValuesTo (Node *pOtherNode) const
 Copy variable values from this to pNode. More...
 
virtual void copySignalQuantityAndUnitTo (Node *pOtherNode) const
 
virtual void setTLMNodeDataValuesTo (Node *pOtherNode) const
 
void preAllocateLogSpace (const size_t nLogSlots)
 Pre allocate memory for the needed amount of log data.
 
double * getDataPtr (const size_t data_type)
 

Protected Attributes

HString mNiceName
 
std::vector< NodeDataDescriptionmDataDescriptions
 
std::vector< double > mDataValues
 

Friends

class Port
 
class MultiPort
 
class PowerPort
 
class WritePort
 
class Component
 
class ComponentSystem
 
class ConnectionAssistant
 
class HopsanEssentials
 

Detailed Description

The Node base class.

Constructor & Destructor Documentation

◆ Node()

Node ( const size_t  datalength)

Node base class constructor

Parameters
[in]datalengthThe length of the data vector

Member Function Documentation

◆ copyNodeDataValuesTo()

void copyNodeDataValuesTo ( Node pOtherNode) const
protected

Copy variable values from this to pNode.

Parameters
pOtherNodeThe destination node to copy into

◆ getDataDescription()

const NodeDataDescription * getDataDescription ( const size_t  id) const

Get a specific data name and unit

Parameters
[in]idThis is the ENUM data id
Returns
A pointer to the desired description or 0 if out of bounds

◆ getDataDescriptions()

const std::vector< NodeDataDescription > * getDataDescriptions ( ) const

Get the vector of data descriptions for the node.

Returns
A pointer to the descriptions vector

◆ getDataIdFromName()

int getDataIdFromName ( const HString rName) const

This function gives you the data Id for a named data variable.

Parameters
[in]rNameThe data name
Returns
The Id, -1 if requested data name is not found

◆ getDataValue()

double getDataValue ( const size_t  dataId) const
inline

get data from node

Parameters
[in]dataIdIdentifier for the type of node data to get, (no bounds check is performed)
Returns
The data value

◆ isConnectedToPort()

bool isConnectedToPort ( const Port pPort) const

Check if a specified port is connected to this node

Parameters
[in]pPortThe port pointer to find
Returns
Is specified port connected (true or false)

◆ logData()

void logData ( const size_t  logSlot)

Copy current data vector into log storage at given logslot.

Warning
No bounds check is done

◆ setDataCharacteristics()

void setDataCharacteristics ( const size_t  id,
const HString rName,
const HString rShortname,
const HString rQuantityOrUnit,
const NodeDataVariableTypeEnumT  vartype = DefaultType 
)
protected

Set data name and unit for a specified data variable.

Parameters
[in]idThis is the ENUM data id
[in]rNameThe variable name
[in]rShortnameThe short variable name
[in]rQuantityOrUnitThe quantity or unit of the variable
[in]vartypeThe type of the variable

◆ setDataValue()

void setDataValue ( const size_t  dataId,
const double  data 
)
inline

set data in node

Parameters
[in]dataIdIdentifier for the type of node data to set, (no bounds check is performed)
[in]dataThe data value