Hopsan
|
Public Member Functions | |
void | configure () |
Configures a component by setting up ports, variables, constants and other resources. | |
void | initialize () |
The initialize function must be overloaded in each component, it is used to initialize the component just before simulation begins. | |
void | simulateOneTimestep () |
Simulates one time step. This component must be overloaded en each component. | |
Public Member Functions inherited from ComponentSignal | |
CQSEnumT | getTypeCQS () const |
Get the C, Q or S type of the component as enum. | |
bool | isComponentSignal () const |
Check if a component is a Signal-Component. | |
Public Member Functions inherited from Component | |
virtual void | reconfigure () |
Re-configures a component, depending on e.g. parameter values or external files. | |
virtual void | deconfigure () |
Deconfigure a component, use this to cleanup and memory/resource allocations you have made in configure. | |
virtual bool | preInitialize () |
This function can be used to automate things prior to component initialization, only use this if you know what you are doing. | |
virtual bool | checkModelBeforeSimulation () |
virtual bool | initialize (const double startT, const double stopT) |
Virtual Function, base version which gives you an error if you try to use it. | |
virtual void | simulate (const double stopT) |
Simulates the component from current simulation position to stopT using previously set timestep. | |
void | setDisabled (bool value) |
bool | isDisabled () const |
void | setDesiredTimestep (const double timestep) |
void | setInheritTimestep (const bool inherit=true) |
Set whether the component should inherit timestep from its system parent. | |
bool | doesInheritTimestep () const |
Check if a component inherits timestep from its system parent. | |
void | setName (HString name) |
Set the desired component name. | |
const HString & | getName () const |
Get the component name. | |
const HString & | getTypeName () const |
Get the TypeName of the component. | |
const HString & | getSubTypeName () const |
Get the SubType name of the component. | |
void | setSubTypeName (const HString &rSubTypeName) |
Set the SubType name of the component. | |
HString | getTypeCQSString () const |
Get the CQStype as string. | |
virtual bool | isComponentC () const |
Check if a component is a C-Component. | |
virtual bool | isComponentQ () const |
Check if a component is a Q-Component. | |
virtual bool | isComponentSystem () const |
Check if a component is a System-Component. | |
virtual bool | isExperimental () const |
Check if component is tagged as experimental. | |
virtual bool | isObsolete () const |
Check if component is tagged as obsolete. | |
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. | |
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. | |
void | addConstant (const HString &rName, const HString &rDescription, HTextBlock &rData) |
void | addConstant (const HString &rName, const HString &rDescription, HFilePath &rData) |
void | addConditionalConstant (const HString &rName, const HString &rDescription, std::vector< HString > &rConditions, int &rData) |
Add (register) a conditional constant parameter to the component. | |
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. | |
void | setReconfigurationParameter (const HString &rName) |
const std::vector< VariameterDescription > * | getVariameters () |
virtual std::list< HString > | getModelAssets () const |
virtual size_t | loadParameterValues (const HString &rFilePath) |
Loads parameters from a file. | |
void | registerConditionalParameter (const HString &rName, const HString &rDescription, std::vector< HString > &rConditions, int &rValue) |
Register a conditional parameter value so that it can be accessed for read and write. | |
virtual void | unRegisterParameter (const HString &rName) |
Removes a parameter from the component. | |
bool | hasParameter (const HString &rName) const |
Check if a component has a specific parameter. | |
void | getParameterNames (std::vector< HString > &rParameterNames) |
const std::vector< ParameterEvaluator * > * | getParametersVectorPtr () const |
const ParameterEvaluator * | getParameter (const HString &rName) |
void | getParameterValue (const HString &rName, HString &rValue) |
void * | getParameterDataPtr (const HString &rName) |
Returns a pointer directly to the parameter data variable. | |
bool | setParameterValue (const HString &rName, const HString &rValue, bool force=false) |
bool | checkParameters (HString &errParName) |
void | evaluateParameters () |
bool | evaluateParameter (const HString &rName, HString &rEvaluatedParameterValue, const HString &rType) |
void | setDefaultStartValue (Port *pPort, const size_t idx, const double value) |
Set the default startvalue in a port. | |
void | setDefaultStartValue (const HString &rPortName, const HString &rDataName, const double value) |
Set the default startvalue in a port. | |
double | getDefaultStartValue (Port *pPort, const size_t idx, const size_t portIdx=0) |
Get the an actual start value of a port. | |
double | getDefaultStartValue (const HString &rPortName, const HString &rDataName, const size_t portIdx=0) |
Get the an actual start value of a port. | |
void | disableStartValue (Port *pPort, const size_t idx) |
Disable a start value to prevent the user from setting it, this is usefully if you calculate the value internally. | |
void | disableStartValue (const HString &rPortName, const size_t idx) |
Disable a start value to prevent the user from setting it, this is usefully if you calculate the value internally. | |
void | disableStartValue (const HString &rPortName, const HString &rDataName) |
Disable a start value to prevent the user from setting it, this is usefully if you calculate the value internally. | |
virtual void | loadStartValues () |
Loads the default start values to the connected node in each port on the component. | |
virtual void | loadStartValuesFromSimulation () |
std::vector< Port * > | getPortPtrVector () const |
Port * | getPort (const HString &rPortname) const |
Returns a pointer to the port with the given name. | |
std::vector< HString > | getPortNames () |
Returns a string vector containing names of all ports in the component. | |
double * | getSafeNodeDataPtr (Port *pPort, const int dataId) |
Get a pointer to the node data variable, (Port pointer version) | |
double * | getSafeNodeDataPtr (const HString &rPortName, const int dataId) |
Get a pointer to the node data variable, (Port name version) | |
double * | getSafeMultiPortNodeDataPtr (Port *pPort, const size_t portIdx, const int dataId) |
Get a pointer to node data in a subport in a multiport. | |
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) | |
double | readNodeSafe (const HString &rPortName, const HString &rDataName, const size_t subPortIdx=0) |
Read value based on the port and node data name. | |
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. | |
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. | |
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. | |
ComponentSystem * | getSystemParent () const |
size_t | getModelHierarchyDepth () const |
double | getTimestep () const |
Returns the component simulation time step. | |
double * | getTimePtr () |
Returns a pointer to the simulation time variable in the component. | |
double | getTime () const |
Get the current simulation time. | |
void | setMeasuredTime (const double time) |
double | getMeasuredTime () const |
Returns the measured time variable for the component. This is used to measure time requirements when sorting components for multicore purposes. | |
void | addDebugMessage (const HString &rMessage, const HString &rTag="") const |
Write an Debug message, i.e. for debugging purposes. | |
void | addWarningMessage (const HString &rMessage, const HString &rTag="") const |
Write an Warning message. | |
void | addErrorMessage (const HString &rMessage, const HString &rTag="") const |
Write an Error message. | |
void | addInfoMessage (const HString &rMessage, const HString &rTag="") const |
Write an Info message. | |
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. Also prints message to log file. | |
void | stopSimulation (const HString &rReason="") |
Terminate/stop a running initialization or simulation. | |
HopsanEssentials * | getHopsanEssentials () |
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) | |
std::vector< HString > | getSearchPaths () const |
virtual void | reInitializeValuesFromNodes () |
virtual void | solveSystem () |
virtual double | getStateVariableDerivative (int) |
virtual double | getStateVariableSecondDerivative (int) |
virtual void | getResiduals (double *, double *) |
virtual void | getJacobian (double *, double *, double *) |
void | addConstant (const HString &rName, const HString &rDescription, const HString &rUnit, double &rData) |
Add (register) a constant parameter to the component. | |
void | addConstant (const HString &rName, const HString &rDescription, const HString &rUnit, int &rData) |
Add (register) a constant parameter to the component. | |
void | addConstant (const HString &rName, const HString &rDescription, const HString &rUnit, HString &rData) |
Add (register) a constant parameter to the component. | |
void | addConstant (const HString &rName, const HString &rDescription, const HString &rUnit, bool &rData) |
Add (register) a constant parameter to the component. | |
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. | |
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. | |
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. | |
void | setConstantValue (const HString &rName, const double value) |
Set the value of a constant parameter. | |
void | setConstantValue (const HString &rName, const int value) |
Set the value of a constant parameter. | |
void | setConstantValue (const HString &rName, const HString &rValue) |
Set the value of a constant parameter. | |
void | setConstantValue (const HString &rName, const char *value) |
Set the value of a constant parameter. | |
void | setConstantValue (const HString &rName, const bool value) |
Set the value of a constant parameter. | |
Static Public Member Functions | |
static Component * | Creator () |
Additional Inherited Members | |
Public Types inherited from Component | |
enum | CQSEnumT { CType , QType , SType , UndefinedCQSType } |
Enum type for all CQS types. | |
Protected Member Functions inherited from Component | |
Component () | |
Component base class Constructor. | |
virtual void | finalize () |
Optional function that is called after every simulation, can be used to clean up memory allocation made in initialize. | |
virtual void | setTimestep (const double timestep) |
virtual size_t | calcNumSimSteps (const double startT, const double stopT) const |
Port * | addInputVariable (const HString &rName, const HString &rDescription, const HString &rQuantityOrUnit, const double defaultValue, double **ppNodeData=0) |
Add an inputVariable (Scalar signal ReadPort) | |
Port * | addOutputVariable (const HString &rName, const HString &rDescription, const HString &rQuantityOrUnit, double **ppNodeData=0) |
Add an outputVariable (Scalar signal WritePort) without default value. | |
Port * | addOutputVariable (const HString &rName, const HString &rDescription, const HString &rQuantityOrUnit, const double defaultValue, double **ppNodeData=0) |
Add an outputVariable (Scalar signal WritePort) with default value. | |
void | initializeAutoSignalNodeDataPtrs () |
Automatically retrieve and assign node data pointers that have been registered. | |
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. | |
Port * | addPowerPort (const HString &rPortName, const HString &rNodeType, const HString &rDescription="", const Port::RequireConnectionEnumT reqConnect=Port::Required) |
Add a PowerPort with description to the component. | |
Port * | addReadPort (const HString &rPortName, const HString &rNodeType, const HString &rDescription="", const Port::RequireConnectionEnumT reqConnect=Port::Required) |
Add a ReadPort with description to the component. | |
Port * | addPowerMultiPort (const HString &rPortName, const HString &rNodeType, const HString &rDescription="", const Port::RequireConnectionEnumT reqConnect=Port::Required) |
Add a PowerMultiPort with description to the component. | |
Port * | addReadMultiPort (const HString &rPortName, const HString &rNodeType, const HString &rDescription="", const Port::RequireConnectionEnumT reqConnect=Port::Required) |
Add a ReadMultiPort with description to the component. | |
Port * | addWritePort (const HString &rPortName, const HString &rNodeType, const HString &rDescription="", const Port::RequireConnectionEnumT reqConnect=Port::Required) |
Add a WritePort with description to the component. | |
void | removePort (const HString &rPortName) |
bool | getPort (const HString &rPortname, Port *&rpPort) |
Get a port as reference to pointer. | |
HString | renamePort (const HString &rOldname, const HString &rNewname) |
Rename a port. | |
void | deletePort (const HString &rName) |
Removes and deletes a port from a component. | |
virtual HString | determineUniquePortName (const HString &rPortname) |
a virtual function that determines a unique port name, needs to be overloaded in ComponentSystem to do this slightly different | |
Protected Attributes inherited from Component | |
ComponentSystem * | mpSystemParent |
bool | mInheritTimestep |
double | mTimestep |
double | mDesiredTimestep |
double | mTime = 0 |
size_t | mModelHierarchyDepth |
This variable contains the depth of the system in the model hierarchy, (used by connect to figure out where to store nodes) | |
std::vector< HString > | mSearchPaths |
|
inlinevirtual |
Configures a component by setting up ports, variables, constants and other resources.
Every function must overload this function, in this function ports variables and constants will be added The component author is however free to add any other desired code as well. This function is called immediately after a component instance has been created
Reimplemented from Component.
|
inlinevirtual |
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 from Component.
|
inlinevirtual |
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 from Component.