The following coding style is the preferred in all Hopsan C++ code.
Bracket Style
- For functions there shall be one line break before the first curly brace.
- For if statements, loops and similar, the starting brace shall come at the same line.
- Single line statements must always be enclosed in braces.
Example:
int MyFunction(int a, int b)
{
int returnValue;
if(a > b) {
returnValue = b-a;
}
else if (a == b) {
returnValue = a+b;
}
else {
returnValue = a-b;
}
return returnValue;
}
Note! The previous (deprecated) style is still used in most of the code. The previous style said that "There shall be one line break before all brackets." This style can still be used if it makes the code easier to read.
Example:
int MyFunctionWithOldBracketStyle(int a, int b)
{
int returnValue;
if(a > b)
{
returnValue = b-a;
}
else
{
returnValue = a-b;
}
return returnValue;
}
Exceptions can be made for short one-line code blocks, but are generally not recommended.
Example:
Variable Names
All code shall be self commenting. This means that non-obvious abbreviations shall be avoided. The purpose of a variable shall be well described by its name. Exceptions are component equations, where the physical denotation of the variable is to be used.
Correct:
- currentTimeStep
- distanceToCenter
- Kc
- rho
Incorrect:
- cTimeStep
- cTstep
- distToC
- distC
- flowCoefficient
- oilDensity
Variables begin with small letters, while every new word in the name shall be capitalized.
Correct:
- someHopsanVariable
Incorrect:
- somehopsanvariable
- SomeHopsanVariable
Certain variables shall have one or more small description letters prepended:
- g = Global variable (can be used anywhere in program)
- m = Member variable (can only be used in the current class)
- p = Pointer
Optional:
- v = Vector (array)
- n = Number variable
More than one letter can be used at a time. When these letters are prepended, the first letter in the actual variable name shall be capitalized.
Examples:
- mSomeHopsanVariable (member variable)
- mpSomeHopsanVariable (member pointer)
- vpDataVariables (vector with pointers in each element)
- mpvDataVariables (member pointer to vector)
- gSomeHopsanVariable (global variable)
- nThreads (variable describing "number of threads")
All global variables, member variables, pointers and number variables should have these prepended letters. An exception is made for public variables used in a data struct (public class) when its main purpose is to act as a simple data container.
Example:
struct Message
{
int type;
string text;
}
Message myMessage;
- myMessage.type (will return the type id of the message)
void setString(const char *str)
Set the string by copying const char*.
Definition: HString.cpp:119
double getDataValue(const size_t dataId) const
get data from node
Definition: Node.h:90
The FirstOrderTransferFunction class implements a first order time discrete transfer function using b...
Definition: FirstOrderTransferFunction.h:43
std::vector< Port * > getConnectedPorts(const int subPortIdx=-1) const
Get all the connected ports.
Definition: Port.cpp:1281
std::vector< HString > getSubComponentNames() const
Definition: ComponentSystem.cpp:879
const std::vector< double > & getNodeDataVector() const
Returns a reference to the Node data in the port.
Definition: Port.h:119
double updateWithBackup(double u)
Make a backup of states and then calls update.
Definition: FirstOrderTransferFunction.cpp:193
bool hasKey(const _Key &rIdKey) const
Check if the factory has key registered.
Definition: ClassFactory.hpp:108
Definition: NodeRWHelpfuncs.hpp:162
double value()
Definition: IntegratorLimited.cpp:125
void setSubTypeName(const HString &rSubTypeName)
Set the SubType name of the component.
Definition: Component.cpp:420
void stopSimulation(const HString &rReason="")
Terminate/stop a running initialization or simulation.
Definition: Component.cpp:430
void renameSubComponent(const HString &rOldName, const HString &rNewName)
Rename a sub component and automatically fix unique names.
Definition: ComponentSystem.cpp:398
Port * addSystemPort(HString portName, const HString &rDescription="")
Adds a transparent SubSystemPort.
Definition: ComponentSystem.cpp:1082
Definition: PLOParser.h:45
Port * addSubPort()
Adds a subport to a readmultiport.
Definition: Port.cpp:1341
~Vec()
Definition: matrix.cpp:260
ComponentSystem * createComponentSystem()
Creates a ComponentSystem.
Definition: HopsanEssentials.cpp:267
void writeNode(const size_t idx, const double value)
Writes a value to the connected node.
Definition: Port.h:95
ParameterEvaluatorHandler(Component *pComponent)
Constructor.
Definition: Parameters.cpp:524
virtual bool isComponentQ() const
Check if a component is a Q-Component.
Definition: Component.cpp:785
void restoreBackup(size_t nSteps=1)
Restore the backup at the given step.
Definition: Integrator.h:104
Component * getSubComponentOrThisIfSysPort(const HString &rName)
Get a Component ptr to the component with supplied name, can also return a ptr to self if no subcompo...
Definition: ComponentSystem.cpp:825
void addErrorMessage(const HString &rMessage, const HString &rTag="", const int dbglevel=0)
Convenience function to add error message.
Definition: HopsanCoreMessageHandler.cpp:171
const char * c_str() const
Returns a c_str pointer to internal data.
Definition: HString.cpp:188
Matrix(const Matrix &src)
copy constructor
Definition: matrix.h:102
void * getDataPtr()
Returns a pointer directly to the parameter data variable.
Definition: Parameters.cpp:85
Template class for automatic object instantiation by key-value.
Definition: ClassFactory.hpp:50
bool isComponentSignal() const
Check if a component is a Signal-Component.
Definition: Component.h:321
std::vector< double > * getDataVectorPtr(const size_t subPortIdx=0)
Definition: Port.cpp:1166
bool isComponentSystem() const
Check if a component is a System-Component.
Definition: ComponentSystem.h:66
_Base * createInstance(const _Key &rIdKey)
Creates an instance based on the key using creator function (if registered)
Definition: ClassFactory.hpp:91
void solveMidpointMethod()
Solves a system using midpoint method.
Definition: EquationSystemSolver.cpp:265
double getTotalMeasuredTime()
Returns the total sum of the measured time of the components in the system.
Definition: ComponentSystem.cpp:3200
virtual void deconfigure()
Deconfigure a component, use this to cleanup and memory/resource allocations you have made in configu...
Definition: Component.cpp:1725
double value() const
Definition: SecondOrderTransferFunction.cpp:215
Definition: SecondOrderTransferFunction.h:75
Definition: NodeRWHelpfuncs.hpp:100
const HString & getNodeType() const
Returns the type of node that can be connected to this port.
Definition: Port.cpp:96
void restoreBackup(size_t nSteps=1)
Restore the backup at the given step.
Definition: FirstOrderTransferFunction.cpp:102
bool hasParameter(const HString &rName) const
Check if a component has a specific parameter.
Definition: Component.cpp:118
double dfIfPositive(const double x, const double, const double)
Derivative of IfPositive with respect to y1.
Definition: AuxiliarySimulationFunctions.h:199
CQSEnumT getTypeCQS() const
Get the C, Q or S type of the component as enum.
Definition: Component.h:320
void ifMultiportCleanupAfterDissconnect(Port *pMaybeMultiport, Port **ppActualPort, const bool wasSucess)
Definition: ConnectionAssistant.cpp:220
virtual double readNodeSafe(const size_t idx, const size_t subPortIdx=0) const
Reads a value from the connected node.
Definition: Port.cpp:196
This class gives access to HopsanCore for model and externalLib loading as well as component creation...
Definition: HopsanEssentials.h:54
virtual bool isConnected() const
Check if the port is currently connected.
Definition: Port.cpp:689
double onNegative(const double x)
Returns 1.0 if x is negative, else returns 0.0.
Definition: AuxiliarySimulationFunctions.h:135
virtual bool isComponentC() const
Check if a component is a C-Component.
Definition: Component.cpp:778
HString renameSystemPort(const HString &rOldname, const HString &rNewname)
Rename system port.
Definition: ComponentSystem.cpp:1095
bool hasParameter(const HString &rName) const
Check if a parameter with given name exist among the parameters.
Definition: Parameters.cpp:818
virtual void writeNode(const size_t idx, const double value, const size_t subPortIdx)
Writes a value to the connected node.
Definition: Port.h:105
Definition: HopsanTypes.h:33
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.
Definition: Node.cpp:139
PortTypesEnumT getInternalPortType()
Get the Internal port type (virtual, should be overloaded in systemports only)
Definition: Port.cpp:844
double value() const
Returns the integrator value.
Definition: Integrator.h:72
void registerCreatorFunction(const _Key &rIdKey, CreatorFunctionT classCreator)
Used to register creator functions.
Definition: ClassFactory.hpp:68
Definition: HopsanCoreMessageHandler.h:44
void addFatalMessage(const HString &rMessage, const HString &rTag="") const
Writes a Fatal message and tells the receiver of the message to close program in a controlled way....
Definition: Component.cpp:1512
virtual bool preInitialize()
Definition: ComponentSystem.cpp:1949
size_t getNumActuallyLoggedSamples() const
Returns the number of actually logged data samples.
Definition: ComponentSystem.cpp:200
double dtIfPositive(const double x, const double, const double)
Derivative of IfPositive with respect to y1.
Definition: AuxiliarySimulationFunctions.h:189
PowerPort(const HString &rNodeType, const HString &rPortName, Component *pParentComponent, Port *pParentPort=0)
PowerPort constructor.
Definition: Port.cpp:917
Port * addSubPort()
Adds a subport to a powermultiport.
Definition: Port.cpp:1320
void getDimDataAt(const size_t dim, const size_t idx, std::vector< double > &rData)
Get a "slice" of data at idx at given dimension.
Definition: LookupTable.h:241
bool isConnected() const
Check if the port is currently connected.
Definition: Port.cpp:1231
DataIndexEnumT
The data variable indexes, DataLength is used internally.
Definition: Nodes.h:321
Component * getComponent() const
Returns the parent component.
Definition: Port.cpp:103
void * getParameterDataPtr(const HString &rName)
Returns a pointer directly to the parameter data variable.
Definition: Parameters.cpp:672
void setDataValue(const size_t dataId, const double data)
set data in node
Definition: Node.h:97
void setBackupLength(int nSteps)
Setup the number of backup steps to remember (size of the backup buffer)
Definition: Integrator.h:94
Component * createComponent(const HString &rTypeName)
Creates a component with the specified key-value and returns a pointer to this component.
Definition: HopsanEssentials.cpp:223
virtual bool isObsolete() const
Check if component is tagged as obsolete.
Definition: Component.cpp:813
Definition: HopsanCoreMessageHandler.h:69
bool renameParameter(const HString &rOldName, const HString &rNewName)
Rename a system parameter.
Definition: ComponentSystem.cpp:1029
void solveRungeKutta()
Solves a system using Runge-Kutta (RK4)
Definition: EquationSystemSolver.cpp:421
Vec & apply(V_FCT_PTR fct)
applys function fct element-by-element
Definition: matrix.cpp:310
DataIndexEnumT
The data variable indexes, DataLength is used internally.
Definition: Nodes.h:185
Definition: ComponentSystem.h:271
void append(const T &data)
Append data.
Definition: HVector.hpp:128
void getParameterValue(const HString &rName, HString &rValue)
Get the value of specified parameter.
Definition: Parameters.cpp:657
Vec & set(double v)
set to constant value
Definition: matrix.h:66
bool setParameterValue(const HString &rName, const HString &rValue, bool force=false)
Set the parameter value for an existing parameter.
Definition: Parameters.cpp:736
void solveForwardEuler()
Solves a system using forward Euler method.
Definition: EquationSystemSolver.cpp:253
Definition: FirstOrderTransferFunction.h:81
void clear()
Clear the delay buffer, deleting all data.
Definition: Delay.hpp:176
Port * addInputVariable(const HString &rName, const HString &rDescription, const HString &rQuantityOrUnit, const double defaultValue, double **ppNodeData=0)
Add an inputVariable (Scalar signal ReadPort)
Definition: Component.cpp:1343
Definition: ValveHysteresis.h:61
bool initializeSystem(const double startT, const double stopT, ComponentSystem *pSystem)
Definition: SimulationHandler.cpp:45
DataIndexEnumT
The data variable indexes, DataLength is used internally.
Definition: Nodes.h:50
void addErrorMessage(const HString &rMessage, const HString &rTag="") const
Write an Error message.
Definition: Component.cpp:1487
virtual void simulateMultiThreaded(const double startT, const double stopT, const size_t nDesiredThreads=0, const bool noChanges=false, ParallelAlgorithmT algorithm=OfflineSchedulingAlgorithm)
Simulate function that overrides multi-threaded simulation call with a single-threaded call In case m...
Definition: ComponentSystem.cpp:3271
virtual const std::vector< double > & getNodeDataVector(const size_t subPortIdx) const
Returns a reference to the Node data in the port.
Definition: Port.h:135
const HString & getVariableAlias(const size_t id) const
Get the alias name for a specific node variable id.
Definition: Port.cpp:383
const HString & getNodeType() const
returns the node type
Definition: Node.cpp:103
This class handles loading and unloading of external component and node libs.
Definition: LoadExternal.h:56
void setName(HString name)
Set the desired component name.
Definition: Component.cpp:346
const HString & getComponentName() const
Get the name of the component that the port is attached to.
Definition: Port.cpp:784
double max()
returns maximum Vec element
Definition: matrix.cpp:282
void clear()
Clear the array.
Definition: HVector.hpp:74
double HOPSANCORE_DLLAPI CDragInd(const double alpha, const double AR, const double e, const double CLalpha, const double ap, const double an, const double expclp, const double expcln)
Induced drag coefficient for aircraft model.
Definition: AuxiliarySimulationFunctions.cpp:185
bool runNumHopScript(const HString &rScript, bool printOutput, HString &rOutput)
Interprets and evaluates (runs) a numhop scripts.
Definition: ComponentSystem.cpp:2156
void writeNode(const size_t idx, const double value, const size_t subPortIdx)
Writes a value to the connected node.
Definition: Port.h:288
HString & operator+=(const HString &rhs)
Definition: HString.cpp:437
bool evaluateParameterExpression(const HString &rExpression, HString &rEvaluatedParameterValue)
Definition: Parameters.cpp:800
void determineCQSType()
This function automatically determines the CQS type depending on the what has been connected to the s...
Definition: ComponentSystem.cpp:1198
double value()
Read current filter output value.
Definition: FirstOrderTransferFunction.cpp:336
double HOPSANCORE_DLLAPI dxLowLimit2(const double x, const double sx, const double xmin)
Sets the derivative of x to zero if x is outside of limits.
Definition: AuxiliarySimulationFunctions.cpp:316
std::vector< double > & getNodeDataVector()
Returns a reference to the Node data in the port.
Definition: Port.h:114
void initialize(const int delaySteps, const T initValue)
Initialize delay size based on known number of delay steps.
Definition: Delay.hpp:71
size_t getSize() const
Get the size of the delay buffer (the number of buffer elements)
Definition: Delay.hpp:170
DataIndexEnumT
The data variable indexes, DataLength is used internally.
Definition: Nodes.h:353
double limit2(const double x, const double, const double xmin, const double xmax)
Overloads double hopsan::limit() to also include sx (derivative of x) as input.
Definition: AuxiliarySimulationFunctions.h:213
The 2d signal node.
Definition: Nodes.h:151
void swaprows(int i, int j)
swap rows
Definition: matrix.cpp:99
Definition: DummyComponent.hpp:42
T getOldest() const
Get the oldest value in the buffer.
Definition: Delay.hpp:125
virtual std::list< HString > getModelAssets() const
Definition: Component.cpp:212
const HString & getSubTypeName() const
Get the SubType name of the component.
Definition: Component.cpp:414
void removeSubNode(Node *pNode)
Removes a previously added node.
Definition: ComponentSystem.cpp:926
double HOPSANCORE_DLLAPI dxArcSinL(const double x)
derivative of AsinL
Definition: AuxiliarySimulationFunctions.cpp:155
void simulate(const double stopT)
Simulate function for single-threaded simulations.
Definition: ComponentSystem.cpp:3503
virtual bool isComponentSystem() const
Check if a component is a System-Component.
Definition: Component.cpp:792
bool checkModelBeforeSimulation()
Checks that everything is OK before simulation.
Definition: ComponentSystem.cpp:1784
LoadExternal(ComponentFactory *pComponentFactory, NodeFactory *pNodefactory, HopsanCoreMessageHandler *pMessenger)
This function loads a library with given path.
Definition: LoadExternal.cpp:56
void simulate(const double stopT)
Simulate function for single-threaded simulations.
Definition: ComponentSystem.cpp:3343
Definition: Integrator.h:44
double readNodeSafe(const size_t idx, const size_t subPortIdx) const
Reads a value from the connected node.
Definition: Port.cpp:1031
T getIdx(const size_t i) const
Returns a specific value, 0=newest, 1=nextnewest, 2=nextnextnewest and so on, no range check is perfo...
Definition: Delay.hpp:140
bool splitNodeConnection(Port *pPort1, Port *pPort2)
Definition: ConnectionAssistant.cpp:462
virtual size_t getNumDataVariables() const
Returns the number of data variables in the node.
Definition: Port.cpp:617
HopsanCoreMessageHandler * getCoreMessageHandler()
Returns a pointer to the core message handler, do NOT use this function to get messages.
Definition: HopsanEssentials.cpp:324
double boolToDouble(const bool value)
Converts a boolean value to a float point number.
Definition: AuxiliarySimulationFunctions.h:107
double HOPSANCORE_DLLAPI Atan2L(const double y, const double x)
Safe variant of atan2.
Definition: AuxiliarySimulationFunctions.cpp:134
virtual void setSignalQuantity(const HString &rQuantity, const HString &rUnit, const size_t dataId=Value)
This function can be used to set unit string and displayName for signal nodes ONLY.
Definition: Nodes.h:54
bool initialize(const double startT, const double stopT)
Initializes a system and all its contained components before a simulation. Also allocates log data me...
Definition: ComponentSystem.cpp:2185
void setDescription(const HString &rDescription)
Set port description.
Definition: Port.cpp:798
DataIndexEnumT
The data variable indexes, DataLength is used internally.
Definition: Nodes.h:463
void addWarningMessage(const HString &rMessage, const HString &rTag="") const
Write an Warning message.
Definition: Component.cpp:1474
void setDesiredTimestep(const double timestep)
Sets the desired time step in a component system.
Definition: ComponentSystem.cpp:1568
const HString & getName() const
Get the component name.
Definition: Component.cpp:370
void solveDormandPrince()
Solves a system using Dormand-Prince.
Definition: EquationSystemSolver.cpp:480
void initialize(const double timeDelay, const double Ts, const T initValue)
Initialize delay buffer size based on timeDelay and timestep, Td/Ts must be multiple of 1 and >= 1.
Definition: Delay.hpp:62
double HOPSANCORE_DLLAPI lowLimit(const double x, const double xmin)
Limits a value to a lower limit.
Definition: AuxiliarySimulationFunctions.cpp:265
Definition: Component.h:65
double value() const
Read current transfer function output value.
Definition: FirstOrderTransferFunction.cpp:202
Definition: AliasHandler.h:47
void setNumLogSamples(const size_t nLogSamples)
Set the desired number of log samples.
Definition: ComponentSystem.cpp:177
bool addParameter(const HString &rName, const HString &rValue, const HString &rDescription, const HString &rQuantity, const HString &rUnit, const HString &rType, void *pData=0, bool force=false, std::vector< HString > conditions=std::vector< HString >())
Add a new parameter.
Definition: Parameters.cpp:551
void backup()
Pushes a backup of transfer function states into the backup buffer.
Definition: Integrator.h:117
bool doubleToBool(const double value)
Converts a float point number to a boolean.
Definition: AuxiliarySimulationFunctions.h:99
The base class for n-dimensional signal nodes, (that can be dynamically sized, but size should be kep...
Definition: Nodes.h:106
NumericalIntegrationSolver(Component *pParentComponent, std::vector< double > *pStateVars, double tolerance=1e-6, size_t maxIter=1000)
Constructor for solver utility using numerical integration methods.
Definition: EquationSystemSolver.cpp:191
void clearSysPortNodeTypeIfEmpty(Port *pPort)
Helpfunction that clears the nodetype in empty systemports, It will not clear the type if the port is...
Definition: ConnectionAssistant.cpp:306
Definition: TempDirectoryHandle.h:43
T update(const T newValue)
Updates delay with a new value, "pop old", "push new". You should likely run this at the end of each ...
Definition: Delay.hpp:99
A mechanic node.
Definition: Nodes.h:317
Definition: HopsanTypes.h:34
virtual double getStartValue(const size_t idx, const size_t subPortIdx=0)
Get the actual start value of the port.
Definition: Port.cpp:627
void determineWhereToStoreNodeAndStoreIt(Node *pNode)
Find the system highest up in the model hierarchy for the ports connected to this node and store the ...
Definition: ConnectionAssistant.cpp:378
static double dot(const Vec &a, const Vec &b)
returns dot product of a and b
Definition: matrix.h:138
Definition: LookupTable.h:544
HString renamePort(const HString &rOldname, const HString &rNewname)
Rename a port.
Definition: Component.cpp:973
void stopSimulation()
Set the stop simulation flag to abort the initialization or simulation loops, (without messages being...
Definition: ComponentSystem.cpp:240
double HOPSANCORE_DLLAPI dxSegare(const double x, const double d)
Segment area, used to calculate valve openings with circular holes.
Definition: AuxiliarySimulationFunctions.cpp:228
const NodeDataDescription * getNodeDataDescription(const size_t dataid, const size_t subPortIdx=0) const
Get a specific node data description from a connected sub port node.
Definition: Port.cpp:1097
bool copyRow(const size_t rowIdx, std::vector< double > &rRow)
Definition: CSVParser.cpp:169
void writeNodeSafe(const size_t idx, const double value, const size_t subPortIdx)
Writes a value to the connected node.
Definition: Port.cpp:1047
ComponentSystem * getOwnerSystem() const
Returns a pointer to the ComponentSystem that own this Node.
Definition: Node.cpp:405
void setKeepValuesAsStartValues(bool load)
Set if node data values should be used as start values instead of the default start values or express...
Definition: ComponentSystem.cpp:1776
virtual void setSignalNodeQuantityModifyable(bool tf)
Definition: Port.cpp:526
Vec & operator=(const Vec &src)
Definition: matrix.h:71
const std::vector< NodeDataDescription > * getNodeDataDescriptions(const size_t subPortIdx=0) const
Get all node data descriptions from a connected sub port node.
Definition: Port.cpp:1084
void initialize(double timestep, double num[3], double den[3], double u0=0.0, double y0=0.0, double min=-1.5E+300, double max=1.5E+300, double sy0=0.0)
Constructor.
Definition: SecondOrderTransferFunction.cpp:61
void loadStartValues()
Load start values by copying the start values from the port to the node.
Definition: Port.cpp:1194
virtual void configure()
Configures a component by setting up ports, variables, constants and other resources.
Definition: Component.cpp:1704
double * getNodeDataPtr(const size_t idx, const size_t subPortIdx) const
Definition: Port.cpp:1068
~ParameterEvaluatorHandler()
Destructor.
Definition: Parameters.cpp:530
const Node * getNodePtr(const size_t subPortIdx=0) const
Returns the node pointer from one of the subports in the port (const version)
Definition: Port.cpp:1062
void evaluateParametersRecursively()
Recurse through the model system hierarchy and evaluate all parameters.
Definition: ComponentSystem.cpp:2054
virtual double * getNodeDataPtr(const size_t idx, const size_t subPortIdx=0) const
Get a ptr to the data variable in the node.
Definition: Port.cpp:241
virtual PortTypesEnumT getPortType() const =0
Get the port type.
void removeSubPort(Port *ptr)
Removes a specific subport.
Definition: Port.cpp:1243
void redoIntegrate(double u)
Re-integrates last step Last step must have been called with integrateWithUndo() for this to work.
Definition: DoubleIntegratorWithDampingAndCoulumbFriction.cpp:154
void unRegisterStartValueParameters()
Unregisters all startvalue parameters from the start node.
Definition: Port.cpp:153
void setBackupLength(size_t nSteps)
Setup the number of backup steps to remember (size of the backup buffer)
Definition: FirstOrderTransferFunction.cpp:131
void clearFactory()
Clear the entire factory map (unregister everything)
Definition: ClassFactory.hpp:163
virtual void loadStartValues()
Load start values by copying the start values from the port to the node.
Definition: Port.cpp:966
bool haveSubComponent(const HString &rName) const
Check if a system has a subcomponent with given name.
Definition: ComponentSystem.cpp:896
Definition: NodeRWHelpfuncs.hpp:171
const HString & getType() const
Returns the type of the parameter.
Definition: Parameters.cpp:165
Definition: HVector.hpp:35
double valueSecond()
Returns second primitive from double integration.
Definition: DoubleIntegratorWithDamping.cpp:103
Definition: WhiteGaussianNoise.h:43
virtual std::vector< double > * getDataVectorPtr(const size_t subPortIdx=0)
Definition: Port.cpp:602
bool isNummeric() const
Check if the string can be interpreted as a number.
Definition: HString.cpp:258
bool compare(const char *other) const
Compare string to const char*.
Definition: HString.cpp:217
Definition: NumHopHelper.h:40
int getVariableIdByAlias(const HString &rAlias) const
Get the variable id for a specific alias name.
Definition: Port.cpp:399
void removeSubComponent(const HString &rName, bool doDelete=false)
Remove a dub component from a system, can also be used to actually delete the component.
Definition: ComponentSystem.cpp:429
virtual void setDefaultStartValue(const size_t idx, const double value, const size_t subPortIdx=0)
Set the an actual start value of the port.
Definition: Port.cpp:647
bool changeSubComponentSystemTypeCQS(const HString &rName, const CQSEnumT newType)
Change the CQS type of a stored subsystem component.
Definition: ComponentSystem.cpp:1176
void setVariableAlias(const HString &rAlias, const size_t id)
Definition: Port.cpp:354
DataIndexEnumT
The data variable indexes, DataLength is used internally.
Definition: Nodes.h:481
Definition: Component.h:49
virtual void writeNodeSafe(const size_t idx, const double value, const size_t subPortIdx=0)
Writes a value to the connected node.
Definition: Port.cpp:215
bool keepsValuesAsStartValues()
Returns whether or not to keep node values instead of over writing with defaultStartValues.
Definition: ComponentSystem.cpp:1767
void resize(size_t s, const T &defaultValue)
Resize the array, initializing all values to defaultValue.
Definition: HVector.hpp:119
bool evaluate(HString &rResult)
Evaluate the parameter.
Definition: Parameters.cpp:232
void stopSimulation(const HString &rReason)
Set the stop simulation flag to abort the initialization or simulation loops.
Definition: ComponentSystem.cpp:210
Matrix(int rows, int cols)
constructs a Matrix of specified size
Definition: matrix.h:101
const double pi
A const double definition of pi that you can use in your code.
Definition: AuxiliarySimulationFunctions.h:45
PortTypesEnumT getPortType() const
Get the port type.
Definition: Port.h:352
A hydraulic node.
Definition: Nodes.h:248
double valueFirst()
Returns first primitive from double integration.
Definition: DoubleIntegratorWithDampingAndCoulumbFriction.cpp:163
bool wasSimulationAborted() const
Check if the simulation was aborted.
Definition: ComponentSystem.cpp:258
void addDebugMessage(const HString &rMessage, const HString &rTag="") const
Write an Debug message, i.e. for debugging purposes.
Definition: Component.cpp:1461
void createStartNode(const HString &rNodeType)
Creates a start node in the port.
Definition: Port.cpp:327
Definition: Integrator.h:84
void print() const
prints Matrix (using mprint)
Definition: matrix.cpp:381
void clear()
Clear the string.
Definition: HString.cpp:482
long int toLongInt(bool *isOK) const
Definition: HString.cpp:294
PortTypesEnumT getPortType() const
Get the port type.
Definition: Port.h:250
Definition: Component.h:326
void ifMultiportCleanupAfterConnect(Port *pMaybeMultiport, Port **ppActualPort, const bool wasSucess)
Definition: ConnectionAssistant.cpp:202
Definition: Component.h:83
void clearRegisterStatus()
Clears the internal error status vector.
Definition: ClassFactory.hpp:157
bool mWarnIfUnusedSystemParameters
This bool can be toggled off in programmed subsystems to avoid annoying warnings.
Definition: ComponentSystem.h:184
bool isConnectedToPort(const Port *pPort) const
Definition: Node.cpp:343
virtual std::vector< Port * > getConnectedPorts(const int subPortIdx=-1) const
Get a vector of pointers to all other ports connected connected to this one.
Definition: Port.cpp:311
virtual void unRegisterParameter(const HString &rName)
Removes a parameter from the component.
Definition: Component.cpp:737
double HOPSANCORE_DLLAPI segare(const double x, const double d)
Segment area, used to calculate valve openings with circular holes.
Definition: AuxiliarySimulationFunctions.cpp:205
bool haveLogData(const size_t subPortIdx=0)
Check if log data exist in the ports node.
Definition: Port.cpp:1124
void unRegisterCreatorFunction(const _Key &rIdKey)
Unregister creator functions for given key.
Definition: ClassFactory.hpp:134
HString getErrorString() const
Definition: PLOParser.cpp:181
A signal node.
Definition: Nodes.h:46
void integrateWithUndo(double u)
Integrates one step, but saves previous step in case step has to be re-integrated.
Definition: DoubleIntegratorWithDampingAndCoulumbFriction.cpp:142
bool evaluateNumHopScriptRecursively()
Recurse through the model system hierarchy and evaluate all system-level numhop scripts.
Definition: ComponentSystem.cpp:2109
void solve()
Solves a system of equations. Requires pre-defined pointers to jacobian, equations and state variable...
Definition: EquationSystemSolver.cpp:165
void registerStartValueParameters()
This function registers the startvalue parameters from the start node.
Definition: Port.cpp:136
double breakFrequency() const
Return the break frequency for this filter.
Definition: FirstOrderTransferFunction.cpp:365
Definition: SimulationHandler.h:53
const std::vector< double > & getNodeDataVector(const size_t subPortIdx) const
Returns a reference to the Node data in the port.
Definition: Port.h:302
size_t findIndexAlongDim(const size_t dim, const double x) const
Definition: LookupTable.h:326
EquationSystemSolver(Component *pParentComponent, int n)
Constructor for equation system solver utility.
Definition: EquationSystemSolver.cpp:68
void addSubNode(Node *pNode)
Add a node as subnode in the system, if the node is already owned by someone else,...
Definition: ComponentSystem.cpp:914
const HString & getDescription() const
Get port description.
Definition: Port.cpp:791
virtual std::vector< double > & getNodeDataVector(const size_t subPortIdx)
Returns a reference to the Node data in the port.
Definition: Port.h:129
void HOPSANCORE_DLLAPI limitValue(double &rValue, double min, double max)
Limits a value so it is between min and max.
Definition: AuxiliarySimulationFunctions.cpp:52
double valueSecond()
Returns second primitive from double integration.
Definition: DoubleIntegratorWithDampingAndCoulumbFriction.cpp:170
double & operator[](int n)
subscript operator (non-const object)
Definition: matrix.h:68
double HOPSANCORE_DLLAPI dxLowLimit(const double x, const double xmin)
Sets the derivative of x to zero if x is outside of limits.
Definition: AuxiliarySimulationFunctions.cpp:305
double value()
Definition: SecondOrderTransferFunction.cpp:352
virtual double readNode(const size_t idx, const size_t subPortIdx) const
Reads a value from the connected node.
Definition: Port.h:85
bool setOrAddSystemParameter(const HString &rName, const HString &rValue, const HString &rType, const HString &rDescription="", const HString &rUnitOrQuantity="", const bool force=false)
Set, add or change a system parameter including all meta data.
Definition: ComponentSystem.cpp:290
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)
Definition: Port.cpp:486
bool empty() const
Check if the array is empty.
Definition: HVector.hpp:191
bool empty() const
Check if string is empty.
Definition: HString.cpp:209
void eraseConnectedPort(Port *pPort, const size_t subPortIdx=0)
Removes a pointer to an other connected port from a port.
Definition: Port.cpp:288
void initialize(double timestep, double wc, double u0=0.0, double y0=0.0, double min=-1.5E+300, double max=1.5E+300)
Initialize the filter utility.
Definition: FirstOrderTransferFunction.cpp:355
void addInfoMessage(const HString &rMessage, const HString &rTag="") const
Write an Info message.
Definition: Component.cpp:1500
void loadStartValuesFromSimulation()
Load start values from last simulation to start value container.
Definition: ComponentSystem.cpp:2036
bool checkParameters(HString &rErrParName)
Check all parameters that need evaluation are able to be evaluated.
Definition: Parameters.cpp:838
PortTypesEnumT getPortType() const
Get the port type.
Definition: Port.h:430
Definition: ComponentSystem.h:52
A pneumatic node.
Definition: Nodes.h:282
bool renameParameter(const HString &rOldName, const HString &rNewName)
Rename a parameter (only useful for system parameters)
Definition: Parameters.cpp:613
int rows() const
Definition: matrix.h:107
The FirstOrderLowpassFilter utility is derived from the FirstOrderTransferFunction and extends it wit...
Definition: FirstOrderTransferFunction.h:73
DataIndexEnumT
The data variable indexes, DataLength is used internally.
Definition: Nodes.h:286
size_t capacity() const
Returns the reserved number of element slots in the array.
Definition: HVector.hpp:184
CQSEnumT getTypeCQS() const
Get the C, Q or S type of the component as enum.
Definition: ComponentSystem.cpp:166
Definition: DoubleIntegratorWithDampingAndCoulumbFriction.h:43
A hydraulic node.
Definition: Nodes.h:181
Definition: TurbulentFlowFunction.h:45
double HOPSANCORE_DLLAPI ArcSinL(const double x)
Safe variant of asin.
Definition: AuxiliarySimulationFunctions.cpp:148
bool evaluateInComponent(const HString &rName, HString &rEvaluatedParameterValue, const HString &rType)
Evaluate a specific parameter.
Definition: Parameters.cpp:747
virtual Node * getNodePtr(const size_t subPortIdx=0)
Returns a pointer to the connected node or 0 if no node exist.
Definition: Port.cpp:114
Definition: ConnectionAssistant.h:47
double getValue(double xs, double xh, double xd)
Definition: ValveHysteresis.h:64
virtual const NodeDataDescription * getNodeDataDescription(const size_t dataid, const size_t subPortIdx=0) const
Get a specific node data description.
Definition: Port.cpp:465
double valueFirst()
Returns first primitive from double integration.
Definition: DoubleIntegratorWithDamping.cpp:96
bool setParameterValue(const HString &rValue, ParameterEvaluator **ppNeedEvaluation=0, bool force=false)
Set the parameter value for an existing parameter.
Definition: Parameters.cpp:137
Definition: Component.h:333
void solve(int solver)
Solves a system using numerical integration.
Definition: EquationSystemSolver.cpp:218
void setTypeCQS(CQSEnumT cqs_type, bool doOnlyLocalSet=false)
Set the type C, Q, or S of the subsystem.
Definition: ComponentSystem.cpp:1116
bool connect(Port *pPort1, Port *pPort2)
Connect two components with specified ports to each other.
Definition: ComponentSystem.cpp:1330
int cols() const
returns the number of columns
Definition: matrix.h:106
bool isSaturated() const
Check if the transfer function is saturated (has reached the set limits)
Definition: FirstOrderTransferFunction.cpp:219
T getNewest() const
Get the newest value in the buffer.
Definition: Delay.hpp:132
double update(const double u)
Updates the integrator one timestep and returns the new value.
Definition: Integrator.h:61
virtual PortTypesEnumT getPortType() const
Get the port type.
Definition: Port.cpp:743
virtual void configure()
Configures a component by setting up ports, variables, constants and other resources.
Definition: ComponentSystem.cpp:161
size_t mModelHierarchyDepth
This variable contains the depth of the system in the model hierarchy, (used by connect to figure out...
Definition: Component.h:280
bool copyRangeFromColumn(const size_t columnIdx, const size_t startRow, const size_t numRows, std::vector< double > &rColumn)
Definition: CSVParser.cpp:209
virtual bool isConnectedTo(Port *pOtherPort)
Check if this port is connected to other port.
Definition: Port.cpp:696
double HOPSANCORE_DLLAPI dxLimit(const double x, const double xmin, const double xmax)
Sets the derivative of x to zero if x is outside of limits.
Definition: AuxiliarySimulationFunctions.cpp:285
void solveBackwardEuler()
Solves a system using implicit Euler.
Definition: EquationSystemSolver.cpp:300
Definition: DoubleIntegratorWithDamping.h:43
static const std::vector< HString > getAvailableSolverTypes()
Returns a list of available integration methods.
Definition: EquationSystemSolver.cpp:203
A petri net node.
Definition: Nodes.h:477
DataIndexEnumT
The data variable indexes, DataLength is used internally.
Definition: Nodes.h:385
PortTypesEnumT getPortType() const
Get the port type.
Definition: Port.h:363
RequireConnectionEnumT
This enum specifies the RequiredConnection enums.
Definition: Port.h:65
void configure()
Configures a component by setting up ports, variables, constants and other resources.
Definition: DummyComponent.hpp:51
Port * ifMultiportAddSubport(Port *pMaybeMultiport)
Detects if a port is a multiport and then adds and returns a subport.
Definition: ConnectionAssistant.cpp:156
double upperLimit(const double value, const double limit)
Apply a upper limit to a value.
Definition: AuxiliarySimulationFunctions.h:233
ConditionalComponentSystem * createConditionalComponentSystem()
Creates a ConditionalComponentSystem.
Definition: HopsanEssentials.cpp:275
void addComponent(Component *pComponent)
Add a component to the system.
Definition: ComponentSystem.cpp:349
void assign_from(const T *pData, size_t count)
Assign from C-array param [in] pData A pointer to the array param [in] count The number of elements t...
Definition: HVector.hpp:138
double getTime() const
Get the current simulation time.
Definition: Component.h:209
void disableLog()
Disable node data logging.
Definition: ComponentSystem.cpp:3477
bool isSaturated() const
Check if the transfer function is saturated (har reached the set limits)
Definition: SecondOrderTransferFunction.cpp:242
double sign(const double x)
Returns the sign of a double (-1.0 or +1.0)
Definition: AuxiliarySimulationFunctions.h:173
void setNode(Node *pNode)
Set the node that the port is connected to.
Definition: Port.cpp:1303
Definition: Quantities.h:42
void deleteSystemPort(const HString &rName)
Delete a System port from the component.
Definition: ComponentSystem.cpp:1108
bool evaluate()
Evaluate the parameter.
Definition: Parameters.cpp:177
double lowerLimit(const double value, const double limit)
Apply a lower limit to a value.
Definition: AuxiliarySimulationFunctions.h:223
A 2D mechanic node.
Definition: Nodes.h:410
void logTimeAndNodes(const size_t simStep)
Definition: ComponentSystem.cpp:1008
virtual CQSEnumT getTypeCQS() const
Get the C, Q or S type of the component as enum.
Definition: Component.cpp:377
bool isMultiPort() const
Convenience function to check if port is multiport.
Definition: Port.cpp:1019
void create(int size)
creates (or resets) vector length and allocated space
Definition: matrix.cpp:263
const HString & getTypeName() const
Get the TypeName of the component.
Definition: Component.cpp:408
void configure()
Configures a component by setting up ports, variables, constants and other resources.
Definition: ComponentSystem.cpp:3496
void addConnectedPort(Port *pPort, const size_t subPortIdx=0)
Adds a pointer to an other connected port to a port.
Definition: Port.cpp:278
bool setVariableAlias(const HString &rAlias, const HString &rCompName, const HString &rPortName, const HString &rVarName)
Definition: AliasHandler.cpp:69
void backup()
Pushes a backup of transfer function states into the backup buffer.
Definition: FirstOrderTransferFunction.cpp:115
void integrateWithUndo(double u)
Integrates one step, but saves previous step in case step has to be re-integrated.
Definition: DoubleIntegratorWithDamping.cpp:74
A numerical solver utility for equation systems using LU-decomposition.
Definition: EquationSystemSolver.h:47
Definition: NodeRWHelpfuncs.hpp:540
bool unLoad(const HString &rLibpath)
This function unloads a library and its components and nodes.
Definition: LoadExternal.cpp:277
A rotational mechanic node.
Definition: Nodes.h:349
RegStatusVectorT getRegisterStatus()
Get a copy of the internal error vector, it maps key values against error codes, error codes come fro...
Definition: ClassFactory.hpp:151
void getLibPathByTypeName(const HString &rTypeName, HString &rLibPath)
Returns library path (to dll or so file) for a component type.
Definition: LoadExternal.cpp:332
virtual size_t loadParameterValues(const HString &rFilePath)
Loads parameters from a file.
Definition: Component.cpp:239
double HOPSANCORE_DLLAPI limit(const double x, const double xmin, const double xmax)
Overloads void hopsan::limitValue() with a return value.
Definition: AuxiliarySimulationFunctions.cpp:253
HVector(const HVector< T > &rOther)
copy constructor
Definition: HVector.hpp:50
int length() const
returns the length (number of elements) of the vector
Definition: matrix.h:62
virtual bool isExperimental() const
Check if component is tagged as experimental.
Definition: Component.cpp:806
PortTypesEnumT getPortType() const
Get the port type.
Definition: Port.h:375
void addComponents(std::vector< Component * > &rComponents)
Add multiple components to the system.
Definition: ComponentSystem.cpp:339
Component HOPSANCORE_DLLAPI * createSafeComponent(ComponentSystem *pSystem, const HString &rType)
Help function to create components and abort safely if that fails.
Definition: HopsanPowerUser.cpp:37
void getLibContents(const HString &rLibpath, std::vector< HString > &rComponents, std::vector< HString > &rNodes)
Returns the components and nodes registered by specified library.
Definition: LoadExternal.cpp:351
double readNode(const size_t idx) const
Reads a value from the connected node.
Definition: Port.h:75
void replace(const size_t pos, const size_t len, const char *str)
Definition: HString.cpp:492
void reserve(size_t s)
Reserve capacity for the array.
Definition: HVector.hpp:86
T * getSafeConstantDataPtr(ComponentSystem *pSystem, Component *pComp, const HString &rConstantName)
Help function to safely get the internal parameter data pointer from a subcomponent,...
Definition: HopsanPowerUser.h:47
void addDebugMessage(const HString &rMessage, const HString &rTag="", const int dbglevel=0)
Convenience function to add debug message.
Definition: HopsanCoreMessageHandler.cpp:180
virtual bool isMultiPort() const
Convenience function to check if port is multiport.
Definition: Port.cpp:732
Definition: LoadExternal.h:46
virtual void setSignalNodeQuantityOrUnit(const HString &rQuantityOrUnit)
A help function that makes it possible to overwrite the unit or quantity of scalar signal node variab...
Definition: Port.cpp:501
void simulateOneTimestep()
Simulates one time step. This component must be overloaded en each component.
Definition: DummyComponent.hpp:63
virtual void setNode(Node *pNode)
Set the node that the port is connected to.
Definition: Port.cpp:257
Delay template class, implementing a circular buffer containing values of specified type.
Definition: Delay.hpp:45
HString substr(const size_t pos, const size_t len=npos) const
Extract substring.
Definition: HString.cpp:520
std::vector< double > * getLogTimeVectorPtr(const size_t subPortIdx=0)
Definition: Port.cpp:1133
void unReserveUniqueName(const HString &rName)
unReserves a unique name in the system
Definition: ComponentSystem.cpp:503
void finalize()
Finalizes a system component and all its contained components after a simulation.
Definition: ComponentSystem.cpp:3386
FactoryMapT mFactoryMap
Map where the construction info is stored.
Definition: ClassFactory.hpp:61
PortTypesEnumT getPortType() const
Get the port type.
Definition: Port.h:411
The IntegratorLimited class implements a integrator using bilinear transform which integrates a varia...
Definition: IntegratorLimited.h:44
Vec()
default no-argument constructor
Definition: matrix.cpp:257
void resize(size_t s)
Resize the array, keeping old data if any.
Definition: HVector.hpp:103
size_t loadParameterValues(const HString &rFilePath)
Loads parameters from a file.
Definition: ComponentSystem.cpp:2100
virtual bool isConnectedTo(Port *pOtherPort)
Check if this port is connected to other port.
Definition: Port.cpp:1211
void initialize()
The initialize function must be overloaded in each component, it is used to initialize the component ...
Definition: DummyComponent.hpp:57
void * getParameterDataPtr(const HString &rName)
Returns a pointer directly to the parameter data variable.
Definition: Component.cpp:130
std::vector< double > & getNodeDataVector(const size_t subPortIdx)
Returns a reference to the Node data in the port.
Definition: Port.h:297
void setNumHopScript(const HString &rScript)
Set the system-level numhop script.
Definition: ComponentSystem.cpp:2170
double update(double u)
Updates the transfer function.
Definition: FirstOrderTransferFunction.cpp:141
The 3d signal node.
Definition: Nodes.h:166
HString getTypeCQSString() const
Get the CQStype as string.
Definition: Component.cpp:384
An electric node.
Definition: Nodes.h:381
double ifPositive(const double x, const double y1, const double y2)
Returns y1 or y2 depending on the value of x.
Definition: AuxiliarySimulationFunctions.h:90
const std::vector< _Key > getRegisteredKeys() const
Return a vector with all registered keys.
Definition: ClassFactory.hpp:121
bool disconnect(const HString &compname1, const HString &portname1, const HString &compname2, const HString &portname2)
Disconnect two ports, string version.
Definition: ComponentSystem.cpp:1468
CQSEnumT
Enum type for all CQS types.
Definition: Component.h:91
void reverseAlongDim(size_t d)
Definition: LookupTable.h:430
double HOPSANCORE_DLLAPI dxLimit2(const double x, const double sx, const double xmin, const double xmax)
Limits the derivative of x when x is outside of its limits.Returns 1.0 if x is within borders,...
Definition: AuxiliarySimulationFunctions.cpp:329
T getOldIdx(const size_t i) const
Returns a specific value, 0=oldest, 1=nextoldest, 2=nextnextoldest and so on, no range check is perfo...
Definition: Delay.hpp:156
double rad2deg(const double rad)
Converts an angle in radians to degrees.
Definition: AuxiliarySimulationFunctions.h:251
int getDataIdFromName(const HString &rName) const
This function gives you the data Id for a named data variable.
Definition: Node.cpp:206
void unRegisterParameter(const HString &name)
Removes a parameter from the component.
Definition: ComponentSystem.cpp:332
Definition: LookupTable.h:584
bool mergeNodeConnection(Port *pPort1, Port *pPort2)
Definition: ConnectionAssistant.cpp:332
bool isBool() const
Check if the string can be interpreted as bool (true, false, 1, 0)
Definition: HString.cpp:273
ParameterEvaluator(const HString &rName, const HString &rValue, const HString &rDescription, const HString &rQuantity, const HString &rUnit, const HString &rType, void *pDataPtr=0, ParameterEvaluatorHandler *pParameterEvalHandler=0)
Constructor.
Definition: Parameters.cpp:65
std::vector< std::vector< double > > * getLogDataVectorPtr(const size_t subPortIdx=0)
Definition: Port.cpp:1142
void loadStartValuesFromSimulation()
Load start values to the start value container from the node (last values from simulation)
Definition: Port.cpp:1206
The CSV file parser utility.
Definition: CSVParser.h:52
void solvevariableTimeStep()
Solves a system using trapezoid rule with variable step size (experimental, do not use)
Definition: EquationSystemSolver.cpp:570
HString reserveUniqueName(const HString &rDesiredName, const UniqeNameEnumT type=UniqueReservedNameType)
Reserves a unique name in the system.
Definition: ComponentSystem.cpp:494
bool equalSignsBool(const double x, const double y)
Check if input variables have the same sign.
Definition: AuxiliarySimulationFunctions.h:259
virtual void disableStartValue(const size_t idx)
Disables start value for specified data type.
Definition: Port.cpp:670
const double & operator[](int n) const
subscript operator (const object)
Definition: matrix.h:70
bool simulateAndMeasureTime(const size_t nSteps)
Helper function that simulates all components and measure their average time requirements.
Definition: ComponentSystem.cpp:3109
virtual void initialize()
The initialize function must be overloaded in each component, it is used to initialize the component ...
Definition: Component.cpp:314
Definition: EquationSystemSolver.h:106
bool HOPSANCORE_DLLAPI fuzzyEqual(const double x, const double y, const double epsilon=0.00001)
checks if two double variables are equal with a tolerance
Definition: AuxiliarySimulationFunctions.cpp:78
double updateWithBackup(double u)
Make a backup of states and then calls update.
Definition: Integrator.h:126
Definition: LookupTable.h:46
void sortComponentVectorsByMeasuredTime()
Helper function that sorts C- and Q- component vectors by simulation time for each component.
Definition: ComponentSystem.cpp:3225
bool evaluateParameters()
Evaluate all parameters.
Definition: Parameters.cpp:764
virtual void loadStartValues()
Load start values by copying the start values from the port to the node.
Definition: Port.cpp:170
void addInfoMessage(const HString &rMessage, const HString &rTag="", const int dbglevel=0)
Convenience function to add info message.
Definition: HopsanCoreMessageHandler.cpp:153
void simulateMultiThreaded(const double startT, const double stopT, const size_t nDesiredThreads, const bool noChanges, ParallelAlgorithmT algorithm)
Simulate function that overrides multi-threaded simulation call with a single-threaded call In case m...
Definition: ComponentSystem.cpp:3538
virtual Port * addSubPort()
Adds a subport to a multiport.
Definition: Port.cpp:122
void redoIntegrate(double u)
Re-integrates last step Last step must have been called with integrateWithUndo() for this to work.
Definition: DoubleIntegratorWithDamping.cpp:86
double deg2rad(const double deg)
Converts an angle in degrees to radians.
Definition: AuxiliarySimulationFunctions.h:242
The SecondOrderTransferFunction class implements a second order transfer function using bilinear tran...
Definition: SecondOrderTransferFunction.h:43
double HOPSANCORE_DLLAPI diffAngle(const double fi1, const double fi2)
difference between two angles, fi1-fi2
Definition: AuxiliarySimulationFunctions.cpp:162
double getStartValue(const size_t idx, const size_t subPortIdx=0)
Get the an actual start value of the port.
Definition: Port.cpp:1180
void enableLog()
Enable node data logging.
Definition: ComponentSystem.cpp:3470
const HString & getName() const
Get the port name.
Definition: Port.cpp:777
bool HOPSANCORE_DLLAPI smartConnect(ComponentSystem *pSystem, Port *pPort1, Port *pPort2)
Help function that only call connect if the ports are not already connected to each other.
Definition: HopsanPowerUser.cpp:55
double getTimestep() const
Returns the component simulation time step.
Definition: Component.cpp:1681
virtual void removeSubPort(Port *pPort)
Removes a subport from multiport.
Definition: Port.cpp:129
size_t getNumDataVariables() const
Returns the total number of variables in a node.
Definition: Node.cpp:109
PortTypesEnumT getExternalPortType()
Get the External port type (virtual, should be overloaded in systemports only)
Definition: Port.cpp:812
The Node base class.
Definition: Node.h:66
Node(const size_t datalength)
Definition: Node.cpp:67
void deleteParameter(const HString &rName)
Deletes a parameter.
Definition: Parameters.cpp:582
Definition: NodeRWHelpfuncs.hpp:371
bool HOPSANCORE_DLLAPI smartDisconnect(ComponentSystem *pSystem, Port *pPort1, Port *pPort2)
Help function that only call disconnect if the ports are connected to each other.
Definition: HopsanPowerUser.cpp:81
int getNodeDataIdFromName(const HString &rName, const size_t subPortIdx=0)
Ask the node for the dataId for a particular data name such as (Pressure)
Definition: Port.cpp:1115
void solveTrapezoidRule()
Solves a system using trapezoid rule of integration.
Definition: EquationSystemSolver.cpp:356
bool ensureConnectionOK(Node *pNode, Port *pPort1, Port *pPort2)
Definition: ConnectionAssistant.cpp:44
Port * getPort(const HString &rPortname) const
Returns a pointer to the port with the given name.
Definition: Component.cpp:1278
size_t size() const
Returns the number of elements in the array.
Definition: HVector.hpp:177
size_t getNumLogSamples() const
Returns the desired number of log samples.
Definition: ComponentSystem.cpp:193
PortTypesEnumT getPortType() const
Get the port type.
Definition: Port.h:397
Definition: LookupTable.h:505
double readNode(const size_t idx, const size_t subPortIdx) const
Reads a value from the connected node.
Definition: Port.h:278
void deletePort(const HString &rName)
Removes and deletes a port from a component.
Definition: Component.cpp:998
double d2Atan2L(const double y, const double x)
Derivative of ATAN2L with respect to x.
Definition: AuxiliarySimulationFunctions.h:164
bool reserveKey(const _Key &rIdKey)
Reserve keyword by inserting NULL ptr,.
Definition: ClassFactory.hpp:83
void print() const
prints vector contents to stdout
Definition: matrix.cpp:401
Definition: NodeRWHelpfuncs.hpp:381
Definition: Component.h:318
std::vector< Port * > getPortPtrVector() const
Definition: Component.cpp:1263
RegStatusVectorT mRegStatusVector
Error status map.
Definition: ClassFactory.hpp:63
double onPositive(const double x)
Returns 1.0 if x is positive, else returns 0.0.
Definition: AuxiliarySimulationFunctions.h:119
Definition: Parameters.h:47
void addSearchPath(HString searchPath)
Adds a search path that can be used by its components to look for external files, e....
Definition: ComponentSystem.cpp:265
Matrix()
default (no argument) constructor
Definition: matrix.h:99
double HOPSANCORE_DLLAPI CLift(const double alpha, const double CLalpha, const double ap, const double an, const double expclp, const double expcln)
Lift coefficient for aircraft model.
Definition: AuxiliarySimulationFunctions.cpp:176
virtual void setSignalQuantity(const HString &rQuantity, const HString &rUnit, const size_t dataId=Value)
This function can be used to set unit string and displayName for signal nodes ONLY.
Definition: Nodes.h:115
Definition: Parameters.h:93
bool setSystemParameter(const HString &rName, const HString &rValue, const HString &rType, const HString &rDescription="", const HString &rUnitOrQuantity="", const bool force=false)
Set or change a system parameter including all meta data.
Definition: ComponentSystem.cpp:322
double min()
returns minimum Vec element
Definition: matrix.cpp:289
double HOPSANCORE_DLLAPI CMoment(double alpha, const double Cm0, const double Cmfs, const double ap, const double an, const double expclp, const double expcln)
Moment coefficient for aircraft model.
Definition: AuxiliarySimulationFunctions.cpp:195
bool isEmpty() const
Checks if a system is empty (if there are no components or systemports)
Definition: ComponentSystem.cpp:902
Port * addPort(const HString &rPortName, const PortTypesEnumT portType, const HString &rNodeType, const HString &rDescription, const Port::RequireConnectionEnumT reqConnection)
Adds a port to the component, do not call this function directly unless you have to.
Definition: Component.cpp:833
void writeNodeSafe(const size_t idx, const double value, const size_t subPortIdx=0)
Writes a value to the connected node.
Definition: Port.cpp:941
void setMeasuredTime(const double time)
Definition: Component.cpp:1444
Component()
Component base class Constructor.
Definition: Component.cpp:70
Definition: EquationSystemSolver.h:72
void loadStartValues()
Load start values by telling each component to load their start values.
Definition: ComponentSystem.cpp:1978
double equalSigns(const double x, const double y)
Check if input variables have the same sign.
Definition: AuxiliarySimulationFunctions.h:269
double getMeasuredTime() const
Returns the measured time variable for the component. This is used to measure time requirements when ...
Definition: Component.cpp:1451