Hopsan
ComponentSystem Class Reference
Inheritance diagram for ComponentSystem:
Component ConditionalComponentSystem

Public Types

enum  UniqeNameEnumT {
  UniqueComponentNameType, UniqueSysportNameTyp, UniqueSysparamNameType, UniqueAliasNameType,
  UniqueReservedNameType
}
 
typedef std::map< HString, std::pair< std::vector< HString >, std::vector< HString > > > SetParametersMapT
 
- Public Types inherited from Component
enum  CQSEnumT { CType, QType, SType, UndefinedCQSType }
 Enum type for all CQS types.
 

Public Member Functions

virtual void configure ()
 Configures a component by setting up ports, variables, constants and other resources. More...
 
bool isComponentSystem () const
 Check if a component is a System-Component. More...
 
CQSEnumT getTypeCQS () const
 Get the C, Q or S type of the component as enum.
 
void setTypeCQS (CQSEnumT cqs_type, bool doOnlyLocalSet=false)
 Set the type C, Q, or S of the subsystem.
 
bool changeSubComponentSystemTypeCQS (const HString &rName, const CQSEnumT newType)
 Change the CQS type of a stored subsystem component.
 
void determineCQSType ()
 This function automatically determines the CQS type depending on the what has been connected to the systemports. More...
 
bool isTopLevelSystem () const
 
bool isExternalSystem () const
 
void setExternalModelFilePath (const HString &rPath)
 
HString getExternalModelFilePath () const
 
void addComponents (std::vector< Component * > &rComponents)
 Add multiple components to the system.
 
void addComponent (Component *pComponent)
 Add a component to the system. More...
 
void renameSubComponent (const HString &rOldName, const HString &rNewName)
 Rename a sub component and automatically fix unique names.
 
void removeSubComponent (const HString &rName, bool doDelete=false)
 Remove a dub component from a system, can also be used to actually delete the component. More...
 
void removeSubComponent (Component *pComponent, bool doDelete=false)
 Remove a sub component from a system, can also be used to actually delete the component. More...
 
HString reserveUniqueName (const HString &rDesiredName, const UniqeNameEnumT type=UniqueReservedNameType)
 Reserves a unique name in the system. More...
 
void unReserveUniqueName (const HString &rName)
 unReserves a unique name in the system More...
 
bool renameParameter (const HString &rOldName, const HString &rNewName)
 Rename a system parameter.
 
virtual std::list< HStringgetModelAssets () const
 
PortaddSystemPort (HString portName, const HString &rDescription="", const Port::RequireConnectionEnumT reqConnect=Port::Required)
 Adds a transparent SubSystemPort.
 
HString renameSystemPort (const HString &rOldname, const HString &rNewname)
 Rename system port.
 
void deleteSystemPort (const HString &rName)
 Delete a System port from the component. More...
 
ComponentgetSubComponentOrThisIfSysPort (const HString &rName)
 Get a Component ptr to the component with supplied name, can also return a ptr to self if no subcomponent found but systemport with name found. More...
 
ComponentgetSubComponent (const HString &rName) const
 
const std::vector< Component * > getSubComponents () const
 
ComponentSystemgetSubComponentSystem (const HString &rName) const
 
std::vector< HStringgetSubComponentNames () const
 
bool haveSubComponent (const HString &rName) const
 Check if a system has a subcomponent with given name. More...
 
bool isEmpty () const
 Checks if a system is empty (if there are no components or systemports)
 
AliasHandlergetAliasHandler ()
 
bool connect (Port *pPort1, Port *pPort2)
 Connect two components with specified ports to each other. More...
 
bool connect (const HString &compname1, const HString &portname1, const HString &compname2, const HString &portname2)
 Connect two components, string version. More...
 
bool disconnect (const HString &compname1, const HString &portname1, const HString &compname2, const HString &portname2)
 Disconnect two ports, string version. More...
 
bool disconnect (Port *pPort1, Port *pPort2)
 Disconnects two ports and remove node if no one is using it any more. More...
 
bool keepsValuesAsStartValues ()
 Returns whether or not to keep node values instead of over writing with defaultStartValues.
 
void setKeepValuesAsStartValues (bool load)
 Set if node data values should be used as start values instead of the default start values or expressions. More...
 
void loadStartValues ()
 Load start values by telling each component to load their start values. More...
 
void loadStartValuesFromSimulation ()
 Load start values from last simulation to start value container.
 
void evaluateParametersRecursively ()
 Recurse through the model system hierarchy and evaluate all parameters.
 
size_t loadParameterValues (const HString &rFilePath)
 Loads parameters from a file. More...
 
bool evaluateNumHopScriptRecursively ()
 Recurse through the model system hierarchy and evaluate all system-level numhop scripts. More...
 
bool runNumHopScript (const HString &rScript, bool printOutput, HString &rOutput)
 Interprets and evaluates (runs) a numhop scripts. More...
 
void setNumHopScript (const HString &rScript)
 Set the system-level numhop script. More...
 
HString getNumHopScript () const
 
bool checkModelBeforeSimulation ()
 Checks that everything is OK before simulation. More...
 
virtual bool preInitialize ()
 
bool initialize (const double startT, const double stopT)
 Initializes a system and all its contained components before a simulation. Also allocates log data memory. More...
 
void simulate (const double stopT)
 Simulate function for single-threaded simulations. More...
 
bool startRealtimeSimulation (double realTimeFactor=1)
 
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 multi-threaded support is not available.
 
void finalize ()
 Finalizes a system component and all its contained components after a simulation.
 
bool simulateAndMeasureTime (const size_t nSteps)
 Helper function that simulates all components and measure their average time requirements. More...
 
double getTotalMeasuredTime ()
 Returns the total sum of the measured time of the components in the system.
 
void sortComponentVectorsByMeasuredTime ()
 Helper function that sorts C- and Q- component vectors by simulation time for each component. More...
 
void distributeCcomponents (std::vector< std::vector< Component * > > &rSplitCVector, size_t nThreads)
 
void distributeQcomponents (std::vector< std::vector< Component * > > &rSplitQVector, size_t nThreads)
 
void distributeSignalcomponents (std::vector< std::vector< Component * > > &rSplitSignalVector, size_t nThreads)
 
void distributeNodePointers (std::vector< std::vector< Node * > > &rSplitNodeVector, size_t nThreads)
 
void reschedule (size_t nThreads)
 
void setDesiredTimestep (const double timestep)
 Sets the desired time step in a component system. More...
 
void setInheritTimestep (const bool inherit=true)
 
bool doesInheritTimestep () const
 
double getDesiredTimeStep () const
 
void logTimeAndNodes (const size_t simStep)
 
void enableLog ()
 Enable node data logging.
 
void disableLog ()
 Disable node data logging.
 
std::vector< double > * getLogTimeVector ()
 
void setNumLogSamples (const size_t nLogSamples)
 Set the desired number of log samples.
 
double getLogStartTime () const
 
void setLogStartTime (const double logStartTime)
 
size_t getNumLogSamples () const
 Returns the desired number of log samples.
 
size_t getNumActuallyLoggedSamples () const
 Returns the number of actually logged data samples. More...
 
void stopSimulation (const HString &rReason)
 Set the stop simulation flag to abort the initialization or simulation loops. More...
 
void stopSimulation ()
 Set the stop simulation flag to abort the initialization or simulation loops, (without messages being added) More...
 
bool wasSimulationAborted () const
 Check if the simulation was aborted. More...
 
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.
 
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.
 
void unRegisterParameter (const HString &name)
 Removes a parameter from the component.
 
void addSearchPath (HString searchPath)
 Adds a search path that can be used by its components to look for external files, e.g. area curves. More...
 
void addSubNode (Node *pNode)
 Add a node as subnode in the system, if the node is already owned by someone else, transfer ownership to this system.
 
void removeSubNode (Node *pNode)
 Removes a previously added node.
 
- Public Member Functions inherited from Component
virtual void reconfigure ()
 Re-configures a component, depending on e.g. parameter values or external files. More...
 
virtual void deconfigure ()
 Deconfigure a component, use this to cleanup and memory/resource allocations you have made in configure. More...
 
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. More...
 
bool doesInheritTimestep () const
 Check if a component inherits timestep from its system parent. More...
 
void setName (HString name)
 Set the desired component name. More...
 
const HStringgetName () const
 Get the component name.
 
const HStringgetTypeName () const
 Get the TypeName of the component.
 
const HStringgetSubTypeName () 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. More...
 
virtual bool isComponentQ () const
 Check if a component is a Q-Component. More...
 
virtual bool isComponentSignal () const
 Check if a component is a Signal-Component. More...
 
virtual bool isExperimental () const
 Check if component is tagged as experimental. More...
 
virtual bool isObsolete () const
 Check if component is tagged as obsolete. 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...
 
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. 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 setReconfigurationParameter (const HString &rName)
 
const std::vector< VariameterDescription > * getVariameters ()
 
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. More...
 
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 ParameterEvaluatorgetParameter (const HString &rName)
 
void getParameterValue (const HString &rName, HString &rValue)
 
void * getParameterDataPtr (const HString &rName)
 Returns a pointer directly to the parameter data variable. More...
 
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. More...
 
void setDefaultStartValue (const HString &rPortName, const HString &rDataName, const double value)
 Set the default startvalue in a port. 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 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. More...
 
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. More...
 
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. More...
 
std::vector< Port * > getPortPtrVector () const
 
PortgetPort (const HString &rPortname) const
 Returns a pointer to the port with the given name. More...
 
std::vector< HStringgetPortNames ()
 Returns a string vector containing names of all ports in the component. 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...
 
ComponentSystemgetSystemParent () const
 
size_t getModelHierarchyDepth () const
 
double getTimestep () const
 Returns the component simulation time step. More...
 
double * getTimePtr ()
 Returns a pointer to the simulation time variable in the component. More...
 
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. More...
 
void addWarningMessage (const HString &rMessage, const HString &rTag="") const
 Write an Warning message. More...
 
void addErrorMessage (const HString &rMessage, const HString &rTag="") const
 Write an Error message. More...
 
void addInfoMessage (const HString &rMessage, const HString &rTag="") const
 Write an Info message. More...
 
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. More...
 
void stopSimulation (const HString &rReason="")
 Terminate/stop a running initialization or simulation. More...
 
HopsanEssentialsgetHopsanEssentials ()
 
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...
 
std::vector< HStringgetSearchPaths () 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. 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...
 
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...
 

Static Public Member Functions

static ComponentCreator ()
 

Protected Types

typedef std::map< HString, Component * > SubComponentMapT
 

Protected Attributes

bool mWarnIfUnusedSystemParameters
 This bool can be toggled off in programmed subsystems to avoid annoying warnings.
 
std::vector< size_t > mLogTheseTimeSteps
 
size_t mTotalTakenSimulationSteps
 
SubComponentMapT mSubComponentMap
 
NumHopHelpermpNumHopHelper
 
HString mNumHopScript
 
- Protected Attributes inherited from Component
ComponentSystemmpSystemParent
 
bool mInheritTimestep
 
double mTimestep
 
double mDesiredTimestep
 
double mTime
 
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< HStringmSearchPaths
 

Friends

class ConnectionAssistant
 
class AliasHandler
 

Additional Inherited Members

- Protected Member Functions inherited from Component
 Component ()
 Component base class Constructor.
 
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 size_t calcNumSimSteps (const double startT, const double stopT) const
 
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...
 
void initializeAutoSignalNodeDataPtrs ()
 Automatically retrieve and assign node data pointers that have been registered.
 
PortaddPort (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. 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...
 
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...
 
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...
 
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...
 
void removePort (const HString &rPortName)
 
bool getPort (const HString &rPortname, Port *&rpPort)
 Get a port as reference to pointer. More...
 
HString renamePort (const HString &rOldname, const HString &rNewname)
 Rename a port. More...
 
void deletePort (const HString &rName)
 Removes and deletes a port from a component. More...
 

Member Function Documentation

◆ addComponent()

void addComponent ( Component pComponent)

Add a component to the system.

◆ addSearchPath()

void addSearchPath ( HString  searchPath)

Adds a search path that can be used by its components to look for external files, e.g. area curves.

Parameters
[in]rSearchPathThe search path to be added

◆ checkModelBeforeSimulation()

bool checkModelBeforeSimulation ( )
virtual

Checks that everything is OK before simulation.

Returns
true if everything is OK, else false (simulation not permitted)

Reimplemented from Component.

◆ configure()

void configure ( )
virtual

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.

Reimplemented in ConditionalComponentSystem.

◆ connect() [1/2]

bool connect ( const HString compname1,
const HString portname1,
const HString compname2,
const HString portname2 
)

Connect two components, string version.

Parameters
[in]compname1The name of the first component
[in]portname1The name of the port on the first component
[in]compname2The name of the second component
[in]portname2The name of the port on the second component
Returns
True if success else False

◆ connect() [2/2]

bool connect ( Port pPort1,
Port pPort2 
)

Connect two components with specified ports to each other.

Parameters
[in]pPort1A pointer to the first port
[in]pPort2A pointer to the second port
Returns
True if success, False if failed

◆ deleteSystemPort()

void deleteSystemPort ( const HString rName)

Delete a System port from the component.

Parameters
[in]rNameThe name of the port to delete

◆ determineCQSType()

void determineCQSType ( )

This function automatically determines the CQS type depending on the what has been connected to the systemports.

◆ disconnect() [1/2]

bool disconnect ( const HString compname1,
const HString portname1,
const HString compname2,
const HString portname2 
)

Disconnect two ports, string version.

Parameters
[in]compname1The name of the first component
[in]portname1The name of the port on the first component
[in]compname2The name of the second component
[in]portname2The name of the port on the second component
Returns
True if success, False if failed

◆ disconnect() [2/2]

bool disconnect ( Port pPort1,
Port pPort2 
)

Disconnects two ports and remove node if no one is using it any more.

Parameters
pPort1Pointer to first port
pPort2Pointer to second port

◆ evaluateNumHopScriptRecursively()

bool evaluateNumHopScriptRecursively ( )

Recurse through the model system hierarchy and evaluate all system-level numhop scripts.

Returns
true if no errors occurred, false otherwise

◆ getNumActuallyLoggedSamples()

size_t getNumActuallyLoggedSamples ( ) const

Returns the number of actually logged data samples.

Returns
Number of available logged data samples in storage

◆ getSubComponentNames()

std::vector< HString > getSubComponentNames ( ) const

◆ getSubComponentOrThisIfSysPort()

Component * getSubComponentOrThisIfSysPort ( const HString rName)

Get a Component ptr to the component with supplied name, can also return a ptr to self if no subcomponent found but systemport with name found.

For this to work we need to make sure that the sub components and systemports have unique names

◆ haveSubComponent()

bool haveSubComponent ( const HString rName) const

Check if a system has a subcomponent with given name.

Parameters
[in]rNameThe name to check for
Returns
true or false

◆ initialize()

bool initialize ( const double  startT,
const double  stopT 
)
virtual

Initializes a system and all its contained components before a simulation. Also allocates log data memory.

Parameters
[in]startTStart time of simulation
[in]stopTStop time of simulation

Reimplemented from Component.

◆ isComponentSystem()

bool isComponentSystem ( ) const
inlinevirtual

Check if a component is a System-Component.

Returns
true or false

Reimplemented from Component.

◆ loadParameterValues()

size_t loadParameterValues ( const HString rFilePath)
virtual

Loads parameters from a file.

Parameters
[in]rFilePathThe file to load from
Returns
Number of changed parameters

Reimplemented from Component.

◆ loadStartValues()

void loadStartValues ( )
virtual

Load start values by telling each component to load their start values.

Reimplemented from Component.

◆ logTimeAndNodes()

void logTimeAndNodes ( const size_t  simStep)

◆ preInitialize()

bool preInitialize ( )
virtual

Reimplemented from Component.

◆ removeSubComponent() [1/2]

void removeSubComponent ( Component pComponent,
bool  doDelete = false 
)

Remove a sub component from a system, can also be used to actually delete the component.

Parameters
[in]pComponentA pointer to the component to remove
[in]doDeleteSet this to true if the component should be deleted after removal

◆ removeSubComponent() [2/2]

void removeSubComponent ( const HString rName,
bool  doDelete = false 
)

Remove a dub component from a system, can also be used to actually delete the component.

Parameters
[in]rNameThe name of the component to remove from the system
[in]doDeleteSet this to true if the component should be deleted after removal

◆ reserveUniqueName()

HString reserveUniqueName ( const HString rDesiredName,
const UniqeNameEnumT  type = UniqueReservedNameType 
)

Reserves a unique name in the system.

Parameters
[in]rDesiredNameThe desired name to reserve
[in]typeThe type of entity that the unique name represents
Returns
The actual name reserved

◆ runNumHopScript()

bool runNumHopScript ( const HString rScript,
bool  printOutput,
HString rOutput 
)

Interprets and evaluates (runs) a numhop scripts.

Parameters
[in]rScriptThe script string
[in]printOutputToggle whether to print output
[out]rOutputThe output string to print to, (if printing activated)
Returns
true if no errors occurred, false otherwise

◆ setDesiredTimestep()

void setDesiredTimestep ( const double  timestep)

Sets the desired time step in a component system.

Parameters
[in]timestepNew desired time step

◆ setKeepValuesAsStartValues()

void setKeepValuesAsStartValues ( bool  tf)

Set if node data values should be used as start values instead of the default start values or expressions.

If this is true, start values will not be loaded, if it is false default start values will be loaded

Parameters
[in]tftrue or false, whether to keep node values instead of over writing with defaultStartValues

◆ setNumHopScript()

void setNumHopScript ( const HString rScript)

Set the system-level numhop script.

Parameters
[in]rScriptThe script string

◆ simulate()

void simulate ( const double  stopT)
virtual

Simulate function for single-threaded simulations.

Parameters
[in]stopTSimulate from current time until stop time

Reimplemented from Component.

Reimplemented in ConditionalComponentSystem.

◆ simulateAndMeasureTime()

bool simulateAndMeasureTime ( const size_t  nSteps)

Helper function that simulates all components and measure their average time requirements.

Parameters
stepsHow many steps to simulate

◆ sortComponentVectorsByMeasuredTime()

void sortComponentVectorsByMeasuredTime ( )

Helper function that sorts C- and Q- component vectors by simulation time for each component.

◆ stopSimulation() [1/2]

void stopSimulation ( )

Set the stop simulation flag to abort the initialization or simulation loops, (without messages being added)

◆ stopSimulation() [2/2]

void stopSimulation ( const HString rReason)

Set the stop simulation flag to abort the initialization or simulation loops.

Parameters
[in]rReasonAn optional HString describing the reason for the stop This method can be used by users e.g. GUIs to stop an start a initialization/simulation process

◆ unReserveUniqueName()

void unReserveUniqueName ( const HString rName)

unReserves a unique name in the system

Parameters
[in]rNameThe name to unreserve

◆ wasSimulationAborted()

bool wasSimulationAborted ( ) const

Check if the simulation was aborted.

Returns
true if Initialize, Simulate, or Finalize was aborted