Hopsan
|
Public Types | |
enum | RequireConnectionEnumT { Required , NotRequired } |
This enum specifies the RequiredConnection enums. | |
Public Member Functions | |
Port (const HString &rNodeType, const HString &rPortName, Component *pParentComponent, Port *pParentPort=0) | |
Port base class constructor. | |
virtual | ~Port () |
Destructor. | |
double | readNode (const size_t idx) const |
Reads a value from the connected node. | |
virtual double | readNode (const size_t idx, const size_t subPortIdx) const |
Reads a value from the connected node. | |
void | writeNode (const size_t idx, const double value) |
Writes a value to the connected node. | |
virtual void | writeNode (const size_t idx, const double value, const size_t subPortIdx) |
Writes a value to the connected node. | |
virtual double | readNodeSafe (const size_t idx, const size_t subPortIdx=0) const |
Reads a value from the connected node. | |
virtual void | writeNodeSafe (const size_t idx, const double value, const size_t subPortIdx=0) |
Writes a value to the connected node. | |
virtual Node * | getNodePtr (const size_t subPortIdx=0) |
Returns a pointer to the connected node or 0 if no node exist. | |
virtual const Node * | getNodePtr (const size_t subPortIdx=0) const |
Returns the node pointer in the port. | |
virtual double * | getNodeDataPtr (const size_t idx, const size_t subPortIdx=0) const |
Get a ptr to the data variable in the node. | |
virtual std::vector< double > * | getDataVectorPtr (const size_t subPortIdx=0) |
virtual size_t | getNumDataVariables () const |
Returns the number of data variables in the node. | |
virtual const std::vector< NodeDataDescription > * | getNodeDataDescriptions (const size_t subPortIdx=0) const |
Get all node data descriptions. | |
virtual const NodeDataDescription * | getNodeDataDescription (const size_t dataid, const size_t subPortIdx=0) const |
Get a specific node data description. | |
virtual int | getNodeDataIdFromName (const HString &rName, const size_t subPortIdx=0) |
Ask the node for the dataId for a particular data name such as (Pressure) | |
virtual void | setSignalNodeQuantityOrUnit (const HString &rQuantityOrUnit) |
A help function that makes it possible to overwrite the unit or quantity of scalar signal node variables. | |
virtual void | setSignalNodeQuantityModifyable (bool tf) |
virtual HString | getSignalNodeQuantity () const |
virtual bool | getSignalNodeQuantityModifyable () const |
const HString & | getVariableAlias (const size_t id) const |
Get the alias name for a specific node variable id. | |
int | getVariableIdByAlias (const HString &rAlias) const |
Get the variable id for a specific alias name. | |
virtual bool | haveLogData (const size_t subPortIdx=0) |
Check if log data exist in the ports node. | |
virtual std::vector< double > * | getLogTimeVectorPtr (const size_t subPortIdx=0) |
virtual std::vector< std::vector< double > > * | getLogDataVectorPtr (size_t subPortIdx=0) |
virtual const std::vector< std::vector< double > > * | getLogDataVectorPtr (size_t subPortIdx=0) const |
virtual void | setEnableLogging (const bool enableLog) |
bool | isLoggingEnabled () const |
virtual bool | isConnected () const |
Check if the port is currently connected. | |
virtual bool | isConnectedTo (Port *pOtherPort) |
Check if this port is connected to other port. | |
bool | isConnectionRequired () |
Check if the port MUST be connected. | |
virtual std::vector< Port * > | getConnectedPorts (const int subPortIdx=-1) const |
Get a vector of pointers to all other ports connected connected to this one. | |
size_t | getNumConnectedPorts (const int subPortIdx=-1) |
Returns the number of ports connected to this port. | |
virtual size_t | getNumPorts () |
bool | isInterfacePort () const |
virtual bool | isMultiPort () const |
Convenience function to check if port is multiport. | |
const HString & | getNodeType () const |
Returns the type of node that can be connected to this port. | |
virtual PortTypesEnumT | getPortType () const |
Get the port type. | |
virtual PortTypesEnumT | getExternalPortType () |
Get the External port type (virtual, should be overloaded in systemports only) | |
virtual PortTypesEnumT | getInternalPortType () |
Get the Internal port type (virtual, should be overloaded in systemports only) | |
virtual SortHintEnumT | getSortHint () const |
virtual void | setSortHint (SortHintEnumT hint) |
virtual SortHintEnumT | getInternalSortHint () |
Port * | getParentPort () const |
Component * | getComponent () const |
Returns the parent component. | |
const HString & | getName () const |
Get the port name. | |
const HString & | getComponentName () const |
Get the name of the component that the port is attached to. | |
const HString & | getDescription () const |
Get port description. | |
void | setDescription (const HString &rDescription) |
Set port description. | |
virtual double | getStartValue (const size_t idx, const size_t subPortIdx=0) |
Get the actual start value of the port. | |
virtual void | loadStartValues () |
Load start values by copying the start values from the port to the node. | |
virtual void | loadStartValuesFromSimulation () |
Load start values to the start value container from the node (last values from simulation) | |
std::vector< double > & | getNodeDataVector () |
Returns a reference to the Node data in the port. | |
const std::vector< double > & | getNodeDataVector () const |
Returns a reference to the Node data in the port. | |
virtual std::vector< double > & | getNodeDataVector (const size_t subPortIdx) |
Returns a reference to the Node data in the port. | |
virtual const std::vector< double > & | getNodeDataVector (const size_t subPortIdx) const |
Returns a reference to the Node data in the port. | |
Protected Member Functions | |
virtual void | setDefaultStartValue (const size_t idx, const double value, const size_t subPortIdx=0) |
Set the an actual start value of the port. | |
virtual void | disableStartValue (const size_t idx) |
Disables start value for specified data type. | |
virtual Node * | getStartNodePtr () |
Get a pointer to the start node. | |
virtual void | setNode (Node *pNode) |
Set the node that the port is connected to. | |
virtual Port * | addSubPort () |
Adds a subport to a multiport. | |
virtual void | removeSubPort (Port *pPort) |
Removes a subport from multiport. | |
void | registerStartValueParameters () |
This function registers the startvalue parameters from the start node. | |
void | unRegisterStartValueParameters () |
Unregisters all startvalue parameters from the start node. | |
void | addConnectedPort (Port *pPort, const size_t subPortIdx=0) |
Adds a pointer to an other connected port to a port. | |
void | eraseConnectedPort (Port *pPort, const size_t subPortIdx=0) |
Removes a pointer to an other connected port from a port. | |
void | createStartNode (const HString &rNodeType) |
Creates a start node in the port. | |
void | eraseStartNode () |
Removes the start node in the port and unregisters all start value parameters. | |
void | setVariableAlias (const HString &rAlias, const size_t id) |
Protected Attributes | |
HString | mNodeType |
SortHintEnumT | mSortHint |
Component * | mpComponent |
Port * | mpParentPort |
bool | mEnableLogging |
std::vector< Port * > | mConnectedPorts |
Friends | |
class | Component |
class | ComponentSystem |
class | ConnectionAssistant |
class | AliasHandler |
class | MultiPort |
|
protected |
Adds a pointer to an other connected port to a port.
[in] | pPort | A pointer to the other port |
[in] | subPortIdx | Ignored for non multi ports |
|
protectedvirtual |
Adds a subport to a multiport.
Reimplemented in PowerMultiPort, and ReadMultiPort.
|
protected |
Creates a start node in the port.
[in] | rNodeType | The type of node to create (Such as NodeHydraulic) |
<
|
protectedvirtual |
Disables start value for specified data type.
idx | Data index of start value to be disabled |
|
protected |
Removes a pointer to an other connected port from a port.
[in] | pPort | The pointer to the other port to be removed |
[in] | subPortIdx | Ignored for non multi ports |
|
virtual |
Get a vector of pointers to all other ports connected connected to this one.
[in] | subPortIdx | Ignored for non multi ports |
Reimplemented in MultiPort.
|
virtual |
[in] | subPortIdx | Ignored on non multi ports |
Reimplemented in MultiPort.
|
virtual |
Get the External port type (virtual, should be overloaded in systemports only)
Reimplemented in SystemPort.
|
virtual |
Get the Internal port type (virtual, should be overloaded in systemports only)
Reimplemented in SystemPort.
|
virtual |
[in] | subPortIdx | Ignored on non multi ports |
Reimplemented in MultiPort.
|
virtual |
[in] | subPortIdx | Ignored on non multi ports |
Reimplemented in MultiPort.
|
virtual |
Get a specific node data description.
[in] | dataid | The node data id (Such as NodeHydraulic::Pressure) |
[in] | subPortIdx | Ignored on non multi ports |
Reimplemented in MultiPort.
|
virtual |
Get all node data descriptions.
[in] | subPortIdx | Ignored on non multi ports |
Reimplemented in MultiPort.
|
virtual |
Ask the node for the dataId for a particular data name such as (Pressure)
This is a wrapper function for the actual Node function,
[in] | rName | The name of the variable (Such as Pressure) |
[in] | subPortIdx | Ignored on non multi ports |
Reimplemented in MultiPort.
|
virtual |
Get a ptr to the data variable in the node.
[in] | idx | The id of the data variable to return ptr to |
[in] | subPortIdx | Ignored for non multi ports |
Reimplemented in MultiPort.
|
inline |
Returns a reference to the Node data in the port.
|
inline |
Returns a reference to the Node data in the port.
|
inlinevirtual |
|
inlinevirtual |
|
virtual |
Returns a pointer to the connected node or 0 if no node exist.
[in] | subPortIdx | Ignored on non multi ports |
Reimplemented in MultiPort.
|
virtual |
Returns the node pointer in the port.
[in] | subPortIdx | Ignored for non multi ports |
Reimplemented in MultiPort.
size_t getNumConnectedPorts | ( | const int | subPortIdx = -1 | ) |
Returns the number of ports connected to this port.
[in] | subPortIdx | The index of the subPort to check. Ignored on non multi ports |
|
virtual |
Returns the number of data variables in the node.
|
virtual |
Get the port type.
Reimplemented in BiDirectionalSignalPort, MultiPort, PowerMultiPort, PowerPort, ReadMultiPort, ReadPort, SystemPort, and WritePort.
|
protectedvirtual |
Get a pointer to the start node.
|
virtual |
Get the actual start value of the port.
[in] | idx | is the index of the start value e.g. NodeHydraulic::Pressure |
[in] | subPortIdx | Ignored on non multi ports |
Reimplemented in MultiPort.
const HString & getVariableAlias | ( | const size_t | id | ) | const |
Get the alias name for a specific node variable id.
[in] | id | The node data id of the requested variable (Ex: NodeHydraulic::Pressure) |
int getVariableIdByAlias | ( | const HString & | rAlias | ) | const |
Get the variable id for a specific alias name.
[in] | rAlias | The alias name to search for |
|
virtual |
Check if log data exist in the ports node.
[in] | subPortIdx | Ignored on non multi ports |
Reimplemented in MultiPort.
|
virtual |
|
virtual |
Check if this port is connected to other port.
Reimplemented in MultiPort.
|
virtual |
Convenience function to check if port is multiport.
Reimplemented in MultiPort.
|
virtual |
|
virtual |
Load start values to the start value container from the node (last values from simulation)
Reimplemented in MultiPort.
|
protectedvirtual |
Removes a subport from multiport.
Reimplemented in MultiPort.
|
protectedvirtual |
Set the an actual start value of the port.
[in] | idx | is the index of the start value e.g. NodeHydraulic::Pressure |
[in] | value | is the start value that should be written |
[in] | subPortIdx | Ignored on non multi ports |
void setDescription | ( | const HString & | rDescription | ) |
Set port description.
[in] | rDescription | The new description |
|
protectedvirtual |
|
virtual |
|
virtual |
A help function that makes it possible to overwrite the unit or quantity of scalar signal node variables.
|
protected |