Hopsan
|
Functions | |
double | readNode (const size_t idx) const |
Reads a value from the connected node. More... | |
virtual double | readNode (const size_t idx, const size_t subPortIdx) const |
Reads a value from the connected node. More... | |
void | writeNode (const size_t idx, const double value) |
Writes a value to the connected node. More... | |
virtual void | writeNode (const size_t idx, const double value, const size_t subPortIdx) |
Writes a value to the connected node. More... | |
double | readNode (const size_t idx, const size_t subPortIdx) const |
Reads a value from the connected node. More... | |
void | writeNode (const size_t idx, const double value, const size_t subPortIdx) |
Writes a value to the connected node. More... | |
virtual void | initialize () |
The initialize function must be overloaded in each component, it is used to initialize the component just before simulation begins. More... | |
virtual void | simulateOneTimestep () |
Simulates one time step. This component must be overloaded en each component. More... | |
virtual void | finalize () |
Optional function that is called after every simulation, can be used to clean up memory allocation made in initialize. | |
void | stopSimulation (const HString &rReason="") |
Terminate/stop a running initialization or simulation. More... | |
double * | getSafeNodeDataPtr (Port *pPort, const int dataId) |
Get a pointer to the node data variable, (Port pointer version) More... | |
double * | getSafeNodeDataPtr (const HString &rPortName, const int dataId) |
Get a pointer to the node data variable, (Port name version) More... | |
double * | getSafeMultiPortNodeDataPtr (Port *pPort, const size_t portIdx, const int dataId) |
Get a pointer to node data in a subport in a multiport. More... | |
double * | getSafeMultiPortNodeDataPtr (Port *pPort, const size_t portIdx, const int dataId, const double defaultValue) |
Get a pointer to node data in a subport in a multiport (also setting initial value at the same time) More... | |
double | readNodeSafe (const HString &rPortName, const HString &rDataName, const size_t subPortIdx=0) |
Read value based on the port and node data name. More... | |
double | readNodeSafe (const HString &rPortName, const size_t dataId, const size_t subPortIdx=0) |
Read value based on the port name and node data id. More... | |
void | writeNodeSafe (const HString &rPortName, const HString &rDataName, const double value, const size_t subPortIdx=0) |
Write node data based on port and data name. More... | |
void | writeNodeSafe (const HString &rPortName, const size_t dataId, const double value, const size_t subPortIdx=0) |
Write node data based on port and data id. More... | |
virtual double | readNodeSafe (const size_t idx, const size_t subPortIdx=0) const |
Reads a value from the connected node. More... | |
virtual void | writeNodeSafe (const size_t idx, const double value, const size_t subPortIdx=0) |
Writes a value to the connected node. More... | |
double | readNodeSafe (const size_t idx, const size_t subPortIdx) const |
Reads a value from the connected node. More... | |
void | writeNodeSafe (const size_t idx, const double value, const size_t subPortIdx) |
Writes a value to the connected node. More... | |
double * getSafeMultiPortNodeDataPtr | ( | Port * | pPort, |
const size_t | portIdx, | ||
const int | dataId | ||
) |
Get a pointer to node data in a subport in a multiport.
[in] | pPort | A pointer to the port from which to fetch NodeData pointer |
[in] | portIdx | The index of the subport in a multiport |
[in] | dataId | The enum id for the node value to fetch pointer to |
double * getSafeMultiPortNodeDataPtr | ( | Port * | pPort, |
const size_t | portIdx, | ||
const int | dataId, | ||
const double | defaultValue | ||
) |
Get a pointer to node data in a subport in a multiport (also setting initial value at the same time)
[in] | pPort | A pointer to the port from which to fetch NodeData pointer |
[in] | portIdx | The index of the subport in a multiport |
[in] | dataId | The enum id for the node value to fetch pointer to |
[in] | defaultValue | The initial value to set for this node data |
double * getSafeNodeDataPtr | ( | const HString & | rPortName, |
const int | dataId | ||
) |
Get a pointer to the node data variable, (Port name version)
[in] | rPortName | The name of the port from which to fetch the node data pointer |
[in] | dataId | The enum id for the node value to fetch pointer to, (Ex: ModeHydraulic::Pressure) |
double * getSafeNodeDataPtr | ( | Port * | pPort, |
const int | dataId | ||
) |
Get a pointer to the node data variable, (Port pointer version)
[in] | pPort | A pointer to the port from which to fetch the node data pointer |
[in] | dataId | The enum id for the node value to fetch pointer to, (Ex: ModeHydraulic::Pressure) |
|
protectedvirtual |
The initialize function must be overloaded in each component, it is used to initialize the component just before simulation begins.
In this function you should get node data ptrs and calculate initial values to write to the nodes You are not allowed to reconnect internal connections in this function, as other components may already have initialized and fetch data pointers to ports/nodes in this component
Reimplemented in DummyComponent.
|
inline |
Reads a value from the connected node.
[in] | idx | The data id of the data to read |
|
inlinevirtual |
Reads a value from the connected node.
[in] | idx | The data id of the data to read |
[in] | subPortIdx | (Ignored on non multi ports) |
Reimplemented in MultiPort.
|
inlinevirtual |
Reads a value from the connected node.
[in] | idx | The data id of the data to read |
[in] | subPortIdx | The subPort to read from (range is NOT checked) |
Reimplemented from Port.
double readNodeSafe | ( | const HString & | rPortName, |
const HString & | rDataName, | ||
const size_t | subPortIdx = 0 |
||
) |
Read value based on the port and node data name.
[in] | rPortName | The port to write data to |
[in] | rDataName | The data variable name for the data to be written |
[in] | subPortIdx | The index of a multiport subport |
double readNodeSafe | ( | const HString & | rPortName, |
const size_t | dataId, | ||
const size_t | subPortIdx = 0 |
||
) |
Read value based on the port name and node data id.
[in] | rPortName | The port to write data to |
[in] | dataId | The data variable id for the data to be written |
[in] | subPortIdx | The index of a multiport subport |
|
virtual |
Reads a value from the connected node.
[in] | idx | The data id of the data to read |
[in] | subPortIdx | The subPort index in the multi port Safe but slow version, will not crash if idx out of bounds |
Reimplemented from Port.
|
virtual |
Reads a value from the connected node.
[in] | idx | The data id of the data to read |
[in] | subPortIdx | The subPort index of a port in a multiport, (ignored if not a multiport) Safe but slow version, will not crash if idx out of bounds |
Reimplemented in MultiPort.
|
protectedvirtual |
Simulates one time step. This component must be overloaded en each component.
This is the function where all the component model equations should be written. This function is called once for every time step
Reimplemented in DummyComponent.
void stopSimulation | ( | const HString & | rReason = "" | ) |
Terminate/stop a running initialization or simulation.
[in] | rReason | An optional HString describing the reason for the stop Typically used inside components simulateOneTimestep method |
|
inline |
Writes a value to the connected node.
[in] | idx | The data id of the data to write |
[in] | value | The value to write |
|
inlinevirtual |
Writes a value to the connected node.
[in] | idx | The data id of the data to write |
[in] | value | The value to write |
[in] | subPortIdx | (Ignored on non multi ports) |
Reimplemented in MultiPort.
|
inlinevirtual |
Writes a value to the connected node.
[in] | idx | The data id of the data to write |
[in] | value | The value to write |
[in] | subPortIdx | The subPort to write to (range is NOT checked) |
Reimplemented from Port.
void writeNodeSafe | ( | const HString & | rPortName, |
const HString & | rDataName, | ||
const double | value, | ||
const size_t | subPortIdx = 0 |
||
) |
Write node data based on port and data name.
[in] | rPortName | The port to write data to |
[in] | rDataName | The data variable name for the data to be written |
[in] | value | The value to write |
[in] | subPortIdx | The index of a multiport subport |
void writeNodeSafe | ( | const HString & | rPortName, |
const size_t | dataId, | ||
const double | value, | ||
const size_t | subPortIdx = 0 |
||
) |
Write node data based on port and data id.
[in] | rPortName | The port to write data to |
[in] | dataId | The data variable id for the data to be written |
[in] | value | The value to write |
[in] | subPortIdx | The index of a multiport subport |
|
virtual |
Writes a value to the connected node.
[in] | idx | The data id of the data to write (Such as NodeHydraulic::Pressure) |
[in] | value | The value of the data to read |
[in] | subPortIdx | The subport to write to, (range check is performed) Safe but slow version, will not crash if idx out of bounds |
Reimplemented from Port.
|
virtual |
Writes a value to the connected node.
[in] | idx | The data id of the data to write (Such as NodeHydraulic::Pressure) |
[in] | value | The value of the data to read |
[in] | subPortIdx | Ignored for non multi ports Safe but slow version, will not crash if idx out of bounds |