SimulationChain
 All Classes Functions Variables Pages
CRegulator Class Referenceabstract

#include <Regulator.h>

Inheritance diagram for CRegulator:
Collaboration diagram for CRegulator:

Public Member Functions

 CRegulator (int nID=0, ObjType Type=regulator, std::string sName="regulator")
 
virtual double Simulate (double) override=0
 Outputs one step of the simualtion given one sample of the input. More...
 
void SetSetpointValue (double dSV)
 Sets setopoint value. More...
 
double GetSetpointValue () const
 Returns setpoint value.
 
void AddGenerator (std::shared_ptr< IGenerator > Gen)
 Adds generator to the list. More...
 
void ResetGenerators ()
 Resets generator to the entry state.
 
void DeleteGenerators ()
 Drops the generator list.
 
void ResetMemory () override
 Resets objects memory (reset generators if present). More...
 
void GetName (boost::property_tree::ptree &nameTree) const override
 Builds a tree containing names and types of all children nodes. More...
 
void GetGeneratorList (std::list< std::weak_ptr< IGenerator > > &genList)
 Returns list of generators. More...
 
IGeneratorFindGenerator (const std::string &sName)
 Searches for a generator holding given name. More...
 
ISISOSearchObject (const std::string &s) override
 Searches all the children of the object to find object with the specified name. More...
 
void LoadGeneratorState (const boost::property_tree::ptree &pt)
 Deserializes generators data. More...
 
void SaveGeneratorHistory ()
 Saves generators states to load using LoadGeneratorHistory().
 
void LoadGeneratorHistory ()
 Loads generators states saved with SaveGeneratorHistory().
 
- Public Member Functions inherited from CSimNode
 CSimNode (int nID=0, ObjType Type=simobject, std::string const &sName=std::string("node"))
 Constructs the base abstract class for simulation object handling. More...
 
void GetOutputHistory (std::vector< double > &vHist) const override
 Outputs all output samples recorded by far. More...
 
void EraseOutputHistory () override
 Deletes all recorded samples of output. More...
 
virtual void SetOutputHistory (std::vector< double > &vHist) override
 Set output history. More...
 
virtual void SetInputHistory (std::vector< double > &vHist) override
 Set input history. More...
 
void SaveState (boost::property_tree::ptree &pt) const override=0
 Adds internal object state data to the stream object. More...
 
void LoadState (boost::property_tree::ptree::value_type const &v) override=0
 Load internal object state data from tree. Each object manages the data itself. More...
 
void SetID (int nID=0) override
 Enables user to set an ID of the object. User must ensure that the name is unique. More...
 
int GetID () const override
 Fetches object's ID. More...
 
void SetName (std::string &sName) override
 Registers a name with the object. User must ensure that the name is unique. More...
 
const std::string & GetName () const override
 Fetches object's name. More...
 
void GetName (boost::property_tree::ptree &nameTree) const override
 Builds a tree containing names and types of all children nodes. More...
 
void SetParent (ISISO *Parent) override
 Sets object's parent. There can be only one parent of the same object. More...
 
ISISOGetParent () override
 Fetches object's parent pointer. More...
 
void AddChild (std::shared_ptr< ISISO > Child) override
 Allows adding children to the object. More...
 
void RemoveChild (std::shared_ptr< ISISO > Child)
 Removes a child of the object. More...
 
void GetChildren (std::list< std::weak_ptr< ISISO > > &lChildren) const override
 Fetches the list of object's children. More...
 
bool RemoveObject (int nID) override
 Allows to remove the object. Function searches all the children of the object. More...
 
ISISOSearchObject (const std::string &s) override
 Searches all the children of the object to find object with the specified name. More...
 
ISISOFindFirstRegulator () override
 Searches the tree for the first regulator object.
 
ObjType GetType () const override
 Retrive object functional type. More...
 
void SetType (ObjType Type) override
 Set object functional type. More...
 
void SetStreamForOutput (std::shared_ptr< std::ostream > oStream) override
 Set the output stream for object output values. More...
 
void SetVariableToStoreCurrentOutput (std::weak_ptr< double > dOutVal)
 Set the variable to store the current output value. More...
 
void SetVariableToStoreCurrentInput (std::weak_ptr< double > dInVal)
 Set the variable to store the current input value. More...
 
void RemoveStreamForOutput () override
 Disable the output stream for objects input values. More...
 
bool MoveObjectToFront (ISISO *FrontObject) override
 Move object to the front so it can be run first. More...
 
void ResetMemory () override
 Resets objects memory (reset generators if present). More...
 

Protected Member Functions

double GetNextGeneratorValue ()
 Will predict next generated value from all generators. Use with LoadGeneratorHistory() and SaveGeneratorHistory() methods. More...
 

Protected Attributes

double m_dSV
 setpoint value
 
std::list< std::shared_ptr
< IGenerator > > 
m_lGen
 list containing generators
 
- Protected Attributes inherited from CSimNode
int m_nID
 Objects unique ID.
 
std::string m_sName
 Objects unique name.
 
CHistorian m_OutputHistory
 Output sample history.
 
CHistorian m_InputHistory
 Input sample history.
 
std::list< std::shared_ptr
< ISISO > > 
m_lChildren
 List of children.
 
ISISOm_Parent
 Pointer to parent.
 
ObjType m_Type
 Objects type.
 
std::shared_ptr< std::ostream > m_oStream
 Output stream.
 
std::weak_ptr< double > m_dOutVal
 Pointer to variable storing last output value.
 
std::weak_ptr< double > m_dInVal
 Pointer to variable storing last input value.
 

Detailed Description

Regulator abstract base class with all the necessary functionality.

Main features:
  • storing list of the generators,
  • implementation of the necessary generator functionalities, eg. searching generator with the given name, bulk saving and loading generator states,
  • SearchObject method override to search through generator list as well.

Member Function Documentation

void CRegulator::AddGenerator ( std::shared_ptr< IGenerator Gen)
inline

Adds generator to the list.

Parameters
[in]Generatorto add.

Here is the caller graph for this function:

IGenerator * CRegulator::FindGenerator ( const std::string &  sName)

Searches for a generator holding given name.

Parameters
[in]sNameName of the generator to find.
Returns
Pointer to found generator or nullptr.

Here is the caller graph for this function:

void CRegulator::GetGeneratorList ( std::list< std::weak_ptr< IGenerator > > &  genList)

Returns list of generators.

Parameters
[out]genListList to store generator pointers.

Here is the caller graph for this function:

void CRegulator::GetName ( boost::property_tree::ptree &  nameTree) const
overridevirtual

Builds a tree containing names and types of all children nodes.

Parameters
[out]nameTreeTree with all collected names of the children and generators.

Implements ISISO.

Here is the call graph for this function:

double CRegulator::GetNextGeneratorValue ( )
protected

Will predict next generated value from all generators. Use with LoadGeneratorHistory() and SaveGeneratorHistory() methods.

Returns
Future generator value.

Here is the caller graph for this function:

void CRegulator::LoadGeneratorState ( const boost::property_tree::ptree &  pt)

Deserializes generators data.

Parameters
[in]ptTree holding generator parameters.

Here is the call graph for this function:

Here is the caller graph for this function:

void CRegulator::ResetMemory ( )
overridevirtual

Resets objects memory (reset generators if present).

Implements ISISO.

Here is the call graph for this function:

Here is the caller graph for this function:

ISISO * CRegulator::SearchObject ( const std::string &  s)
overridevirtual

Searches all the children of the object to find object with the specified name.

Returns
Pointer to found object or nullptr. In case of regulator if the name is the name of its generator this method returns the regulator to which the generator belongs.
Parameters
[in]sName of the object or generator to find.
Returns
Pointer to found object or nullptr.

Implements ISISO.

Here is the call graph for this function:

void CRegulator::SetSetpointValue ( double  dSV)
inline

Sets setopoint value.

Parameters
[in]dSVSets setpoint value.

Here is the caller graph for this function:

virtual double CRegulator::Simulate ( double  )
overridepure virtual

Outputs one step of the simualtion given one sample of the input.

Returns
Next simulation output.

Implements CSimNode.

Implemented in CGPC, CPIDRegulator, and CPRegulator.


The documentation for this class was generated from the following files: