Hopsan
ComponentSetupFunctions

Functions

void addConditionalConstant (const HString &rName, const HString &rDescription, std::vector< HString > &rConditions, int &rData)
 Add (register) a conditional constant parameter to the component. More...
 
void addConditionalConstant (const HString &rName, const HString &rDescription, std::vector< HString > &rConditions, const int defaultValue, int &rData)
 Add (register) a conditional constant parameter to the component. More...
 
void addConstant (const HString &rName, const HString &rDescription, const HString &rQuantityOrUnit, const double defaultValue, double &rData)
 Add (register) a constant parameter with a default value to the component. More...
 
void addConstant (const HString &rName, const HString &rDescription, const HString &rQuantity, const HString &rUnit, const double defaultValue, double &rData)
 Add (register) a constant parameter with a default value to the component. More...
 
PortaddPowerPort (const HString &rPortName, const HString &rNodeType, const HString &rDescription="", const Port::RequireConnectionEnumT reqConnect=Port::Required)
 Add a PowerPort with description to the component. More...
 
PortaddPowerMultiPort (const HString &rPortName, const HString &rNodeType, const HString &rDescription="", const Port::RequireConnectionEnumT reqConnect=Port::Required)
 Add a PowerMultiPort with description to the component. More...
 
PortaddReadMultiPort (const HString &rPortName, const HString &rNodeType, const HString &rDescription="", const Port::RequireConnectionEnumT reqConnect=Port::Required)
 Add a ReadMultiPort with description to the component. More...
 
PortaddReadPort (const HString &rPortName, const HString &rNodeType, const HString &rDescription="", const Port::RequireConnectionEnumT reqConnect=Port::Required)
 Add a ReadPort with description to the component. More...
 
PortaddWritePort (const HString &rPortName, const HString &rNodeType, const HString &rDescription="", const Port::RequireConnectionEnumT reqConnect=Port::Required)
 Add a WritePort with description to the component. More...
 
PortaddInputVariable (const HString &rName, const HString &rDescription, const HString &rQuantityOrUnit, const double defaultValue, double **ppNodeData=0)
 Add an inputVariable (Scalar signal ReadPort) More...
 
PortaddOutputVariable (const HString &rName, const HString &rDescription, const HString &rQuantityOrUnit, double **ppNodeData=0)
 Add an outputVariable (Scalar signal WritePort) without default value. More...
 
PortaddOutputVariable (const HString &rName, const HString &rDescription, const HString &rQuantityOrUnit, const double defaultValue, double **ppNodeData=0)
 Add an outputVariable (Scalar signal WritePort) with default value. More...
 
double getDefaultStartValue (Port *pPort, const size_t idx, const size_t portIdx=0)
 Get the an actual start value of a port. More...
 
double getDefaultStartValue (const HString &rPortName, const HString &rDataName, const size_t portIdx=0)
 Get the an actual start value of a port. More...
 
void setDefaultStartValue (Port *pPort, const size_t idx, const double value)
 Set the default startvalue in a port. More...
 
void setDefaultStartValue (const HString &rPortName, const HString &rDataName, const double value)
 Set the default startvalue in a port. More...
 
HString findFilePath (const HString &rFileName) const
 Find and return the full file path name of fileName within the system search path, parent systems included (path to HMF file is always in here) More...
 
void setConstantValue (const HString &rName, const double value)
 Set the value of a constant parameter. More...
 
void setConstantValue (const HString &rName, const int value)
 Set the value of a constant parameter. More...
 
void setConstantValue (const HString &rName, const HString &rValue)
 Set the value of a constant parameter. More...
 
void setConstantValue (const HString &rName, const char *value)
 Set the value of a constant parameter. More...
 
void setConstantValue (const HString &rName, const bool value)
 Set the value of a constant parameter. More...
 
void addConstant (const HString &rName, const HString &rDescription, const HString &rUnit, double &rData)
 Add (register) a constant parameter to the component. More...
 
void addConstant (const HString &rName, const HString &rDescription, const HString &rUnit, int &rData)
 Add (register) a constant parameter to the component. More...
 
void addConstant (const HString &rName, const HString &rDescription, const HString &rUnit, HString &rData)
 Add (register) a constant parameter to the component. More...
 
void addConstant (const HString &rName, const HString &rDescription, const HString &rUnit, bool &rData)
 Add (register) a constant parameter to the component. More...
 
void addConstant (const HString &rName, const HString &rDescription, const HString &rUnit, const int defaultValue, int &rData)
 Add (register) a constant parameter with a default value to the component. More...
 
void addConstant (const HString &rName, const HString &rDescription, const HString &rUnit, const HString &defaultValue, HString &rData)
 Add (register) a constant parameter with a default value to the component. More...
 
void addConstant (const HString &rName, const HString &rDescription, const HString &rUnit, const bool defaultValue, bool &rData)
 Add (register) a constant parameter with a default value to the component. More...
 

Detailed Description

Function Documentation

◆ addConditionalConstant() [1/2]

void addConditionalConstant ( const HString rName,
const HString rDescription,
std::vector< HString > &  rConditions,
const int  defaultValue,
int &  rData 
)

Add (register) a conditional constant parameter to the component.

Parameters
[in]rNameThe name of the constant
[in]rDescriptionThe description of the constant
[in]rConditionsThe condition descriptions as a vector of text
[in]defaultValueThe default value
[in]rDataA reference to the condition data constant

◆ addConditionalConstant() [2/2]

void addConditionalConstant ( const HString rName,
const HString rDescription,
std::vector< HString > &  rConditions,
int &  rData 
)

Add (register) a conditional constant parameter to the component.

Parameters
[in]rNameThe name of the constant
[in]rDescriptionThe description of the constant
[in]rConditionsThe condition descriptions as a vector of text
[in]rDataA reference to the condition data constant (it will automatically get default value 0)

◆ addConstant() [1/9]

void addConstant ( const HString rName,
const HString rDescription,
const HString rQuantity,
const HString rUnit,
const double  defaultValue,
double &  rData 
)

Add (register) a constant parameter with a default value to the component.

Parameters
[in]rNameThe name of the constant
[in]rDescriptionThe description of the constant
[in]rQuantityThe physical quantity type (if any)
[in]rUnitThe unit of the constant value
[in]defaultValueDefault constant value
[in]rDataA reference to the data variable

◆ addConstant() [2/9]

void addConstant ( const HString rName,
const HString rDescription,
const HString rQuantityOrUnit,
const double  defaultValue,
double &  rData 
)

Add (register) a constant parameter with a default value to the component.

Parameters
[in]rNameThe name of the constant
[in]rDescriptionThe description of the constant
[in]rQuantityOrUnitThe Quantity or Unit of the constant value
[in]defaultValueDefault constant value
[in]rDataA reference to the data variable

◆ addConstant() [3/9]

void addConstant ( const HString rName,
const HString rDescription,
const HString rUnit,
bool &  rData 
)

Add (register) a constant parameter to the component.

Parameters
[in]rNameThe name of the constant
[in]rDescriptionThe description of the constant
[in]rUnitThe unit of the constant value
[in]rDataA reference to the data constant

◆ addConstant() [4/9]

void addConstant ( const HString rName,
const HString rDescription,
const HString rUnit,
const bool  defaultValue,
bool &  rData 
)

Add (register) a constant parameter with a default value to the component.

Parameters
[in]rNameThe name of the constant
[in]rDescriptionThe description of the constant
[in]rUnitThe unit of the constant value
[in]defaultValueDefault constant value
[in]rDataA reference to the data variable

◆ addConstant() [5/9]

void addConstant ( const HString rName,
const HString rDescription,
const HString rUnit,
const HString defaultValue,
HString rData 
)

Add (register) a constant parameter with a default value to the component.

Parameters
[in]rNameThe name of the constant
[in]rDescriptionThe description of the constant
[in]rUnitThe unit of the constant value
[in]defaultValueDefault constant value
[in]rDataA reference to the data variable

◆ addConstant() [6/9]

void addConstant ( const HString rName,
const HString rDescription,
const HString rUnit,
const int  defaultValue,
int &  rData 
)

Add (register) a constant parameter with a default value to the component.

Parameters
[in]rNameThe name of the constant
[in]rDescriptionThe description of the constant
[in]rUnitThe unit of the constant value
[in]defaultValueDefault constant value
[in]rDataA reference to the data variable

◆ addConstant() [7/9]

void addConstant ( const HString rName,
const HString rDescription,
const HString rUnit,
double &  rData 
)

Add (register) a constant parameter to the component.

Parameters
[in]rNameThe name of the constant
[in]rDescriptionThe description of the constant
[in]rUnitThe unit of the constant value
[in]rDataA reference to the data constant

◆ addConstant() [8/9]

void addConstant ( const HString rName,
const HString rDescription,
const HString rUnit,
HString rData 
)

Add (register) a constant parameter to the component.

Parameters
[in]rNameThe name of the constant
[in]rDescriptionThe description of the constant
[in]rUnitThe unit of the constant value
[in]rDataA reference to the data constant

◆ addConstant() [9/9]

void addConstant ( const HString rName,
const HString rDescription,
const HString rUnit,
int &  rData 
)

Add (register) a constant parameter to the component.

Parameters
[in]rNameThe name of the constant
[in]rDescriptionThe description of the constant
[in]rUnitThe unit of the constant value
[in]rDataA reference to the data constant

◆ addInputVariable()

Port * addInputVariable ( const HString rName,
const HString rDescription,
const HString rQuantityOrUnit,
const double  defaultValue,
double **  ppNodeData = 0 
)
protected

Add an inputVariable (Scalar signal ReadPort)

Parameters
[in]rNameThe name of the variable
[in]rDescriptionThe description of the variable
[in]rQuantityOrUnitThe quantity or unit of the variable value
[in]defaultValueThe default variable value (if not connected)
[in,out]ppNodeDataOptional pointer to pointer to data. The data pointer will be registered and automatically assigned before initialisation)
Returns
A pointer to the port created.

◆ addOutputVariable() [1/2]

Port * addOutputVariable ( const HString rName,
const HString rDescription,
const HString rQuantityOrUnit,
const double  defaultValue,
double **  ppNodeData = 0 
)
protected

Add an outputVariable (Scalar signal WritePort) with default value.

Parameters
[in]rNameThe name of the variable
[in]rDescriptionThe description of the variable
[in]rQuantityOrUnitThe quantity or unit of the variable value
[in]defaultValueThe default variable value (if not connected)
[in,out]ppNodeDataOptional pointer to pointer to data. The data pointer will be registered and automatically assigned before initialisation)
Returns
A pointer to the port created.

◆ addOutputVariable() [2/2]

Port * addOutputVariable ( const HString rName,
const HString rDescription,
const HString rQuantityOrUnit,
double **  ppNodeData = 0 
)
protected

Add an outputVariable (Scalar signal WritePort) without default value.

Parameters
[in]rNameThe name of the variable
[in]rDescriptionThe description of the variable
[in]rQuantityOrUnitThe quantity or unit of the variable value
[in,out]ppNodeDataOptional pointer to pointer to data. The data pointer will be registered and automatically assigned before initialisation)
Returns
A pointer to the port created.

◆ addPowerMultiPort()

Port * addPowerMultiPort ( const HString rPortName,
const HString rNodeType,
const HString rDescription = "",
const Port::RequireConnectionEnumT  reqConnect = Port::Required 
)
protected

Add a PowerMultiPort with description to the component.

Parameters
[in]rPortNameThe desired name of the port (may be automatically changed)
[in]rNodeTypeThe type of node that must be connected to the port
[in]rDescriptionThe port description
[in]reqConnectSpecify if the port must be connected or if it is optional (Required or NotRequired)
Returns
A pointer to the created port

◆ addPowerPort()

Port * addPowerPort ( const HString rPortName,
const HString rNodeType,
const HString rDescription = "",
const Port::RequireConnectionEnumT  reqConnect = Port::Required 
)
protected

Add a PowerPort with description to the component.

Parameters
[in]rPortNameThe desired name of the port (may be automatically changed)
[in]rNodeTypeThe type of node that must be connected to the port
[in]rDescriptionThe port description
[in]reqConnectSpecify if the port must be connected or if it is optional (Required or NotRequired)
Returns
A pointer to the created port

◆ addReadMultiPort()

Port * addReadMultiPort ( const HString rPortName,
const HString rNodeType,
const HString rDescription = "",
const Port::RequireConnectionEnumT  reqConnect = Port::Required 
)
protected

Add a ReadMultiPort with description to the component.

Parameters
[in]rPortNameThe desired name of the port (may be automatically changed)
[in]rNodeTypeThe type of node that must be connected to the port
[in]rDescriptionThe port description
[in]reqConnectSpecify if the port must be connected or if it is optional (Required or NotRequired)
Returns
A pointer to the created port

◆ addReadPort()

Port * addReadPort ( const HString rPortName,
const HString rNodeType,
const HString rDescription = "",
const Port::RequireConnectionEnumT  reqConnect = Port::Required 
)
protected

Add a ReadPort with description to the component.

Note
Usually you should use addInputVariable instead of this one
Parameters
[in]rPortNameThe desired name of the port (may be automatically changed)
[in]rNodeTypeThe type of node that must be connected to the port
[in]rDescriptionThe port description
[in]reqConnectSpecify if the port must be connected or if it is optional (Required or NotRequired)
Returns
A pointer to the created port

◆ addWritePort()

Port * addWritePort ( const HString rPortName,
const HString rNodeType,
const HString rDescription = "",
const Port::RequireConnectionEnumT  reqConnect = Port::Required 
)
protected

Add a WritePort with description to the component.

Note
Usually you should use addOutputVariable instead of this one unless you need a "sniffer port"
Parameters
[in]rPortNameThe desired name of the port (may be automatically changed)
[in]rNodeTypeThe type of node that must be connected to the port
[in]rDescriptionThe port description
[in]reqConnectSpecify if the port must be connected or if it is optional (Required or NotRequired)
Returns
A pointer to the created port

◆ findFilePath()

HString findFilePath ( const HString rFileName) const

Find and return the full file path name of fileName within the system search path, parent systems included (path to HMF file is always in here)

With this function you can find external files based on a path relative to the model file path This makes it possible to avoid absolute paths for external file resources

Parameters
rFileNamethe name of the file to search for
Returns
full file name path, empty string if it does not exists

◆ getDefaultStartValue() [1/2]

double getDefaultStartValue ( const HString rPortName,
const HString rDataName,
const size_t  portIdx = 0 
)

Get the an actual start value of a port.

Parameters
[in]rPortNameis the port which should be read from
[in]rDataNameThe name of the data in the port to read from example: "Pressure"
[in]portIdxThe index of a subport in a multiport. If pPort is not a multiport this value will be ignored
Returns
The default start value

This slower version uses string names for lookup, and will report errors if names are incorrect

◆ getDefaultStartValue() [2/2]

double getDefaultStartValue ( Port pPort,
const size_t  idx,
const size_t  portIdx = 0 
)

Get the an actual start value of a port.

Parameters
[in]pPortis the port which should be read from
[in]idxis the index of the start value e.g. NodeHydraulic::Pressure
[in]portIdxThe index of a subport in a multiport. If pPort is not a multiport this value will be ignored
Returns
The default start value

◆ setConstantValue() [1/5]

void setConstantValue ( const HString rName,
const bool  value 
)

Set the value of a constant parameter.

Note
Don't use this function during simulation, it is slow

◆ setConstantValue() [2/5]

void setConstantValue ( const HString rName,
const char *  value 
)

Set the value of a constant parameter.

Note
Don't use this function during simulation, it is slow

◆ setConstantValue() [3/5]

void setConstantValue ( const HString rName,
const double  value 
)

Set the value of a constant parameter.

Note
Don't use this function during simulation, it is slow

◆ setConstantValue() [4/5]

void setConstantValue ( const HString rName,
const HString rValue 
)

Set the value of a constant parameter.

Note
Don't use this function during simulation, it is slow

◆ setConstantValue() [5/5]

void setConstantValue ( const HString rName,
const int  value 
)

Set the value of a constant parameter.

Note
Don't use this function during simulation, it is slow

◆ setDefaultStartValue() [1/2]

void setDefaultStartValue ( const HString rPortName,
const HString rDataName,
const double  value 
)

Set the default startvalue in a port.

Parameters
[in]rPortNameThe name of the port that should be written to
[in]rDataNameThe port variable to be written to, Example: "Pressure"
[in]valueis the start value that should be written

This slower version uses string names for lookup, and will report errors if names are incorrect

◆ setDefaultStartValue() [2/2]

void setDefaultStartValue ( Port pPort,
const size_t  idx,
const double  value 
)

Set the default startvalue in a port.

Parameters
[in]pPortis the port which should be written to
[in]idxis the index of the start value e.g. NodeHydraulic::Pressure
[in]valueis the start value that should be written