SimulationChain
 All Classes Functions Variables Pages
SLogic Class Reference

#include <SLogic.h>

Public Member Functions

void Run ()
 Main program flow is defined in this function.
 
void RunSimulation (int nTime, int nPeriod)
 Main simulation procedure. Takes time and period as milliseconds. More...
 
void ToggleSimulation ()
 Runs or pauses simulation. Uses m_nTime and m_nPeriod values.
 
void SetSimulationParameters (int nTime, int nPeriod)
 Sets parameters. Accepts values in miliseconds. More...
 
bool IsSimulatonChainReady ()
 Checks if simulation can be executed properly. More...
 
void ResetSimulation ()
 Resets all memory values from the simulation chain. Does not delete objects parameters or generators.
 
bool SaveSimChain (const std::string sFileName)
 Commands to write the simualtion chain data into the specified file. More...
 
bool LoadSimChain (const std::string sFileName)
 Tries to load the simulation chain from the .xml file. More...
 
bool SaveObjectOutputToFile (const std::string sObjName, std::string sFileName="")
 Sets object to save its output to specified file. More...
 
bool StopSavingObjectOutputToFile (const std::string sObjName)
 Disables the file output for a chosen object. More...
 
int GetPeriod () const
 Returns simulation period.
 
void ChangeIdentificationParams (int nNomDegree, int nDenomDegree, int nDelay, int nTreshold, double dForgettingFactor)
 Changes identification parameters. More...
 
void GetLastIdentifiedNominator (std::vector< double > &vNom)
 Retrieves last identified nominator. More...
 
void GetLastIdentifiedDenominator (std::vector< double > &vDenom)
 Retrieves last identified denominator. More...
 
void SetGUIInstance (MainWindow *MainWindowPtr)
 Set the GUI handle. This method has to be called as soon as possible after creation of the SLogic instance. More...
 
void ObjectFocusChange (std::string &sObjName)
 When user selects an object in GUI, this method is called. It searches object with the given name and builds its property tree. More...
 
void ExtractPropertySubtree (QString &qsParentName, const boost::property_tree::ptree &p)
 Helper method to call recursively when building property tree. More...
 
void SelectedObjectEdited (const std::string &sObjName, const std::string &sKey, const std::string &sValue)
 Called from GUI when the value is edited. More...
 
bool UpdateTreeValue (boost::property_tree::ptree &p, const std::string &sObjName, const std::string &sKey, const std::string &sNewValue)
 Called from SelectedObjectEdited(). Helper method to update simulation tree. More...
 

Static Public Member Functions

static SLogicGetInstance ()
 Returns the only one instance of the singleton.
 
static void DestroyInstance ()
 Deletes the only instance. This must be called after the Run() function in order to dealocate program memory in managed way.
 

Detailed Description

Implemenets Control module of the MVC model.

  1. Responsible for connecting GUI with simulation data model and organising data flow.
  2. Enables saving and loading the state of the program from and external file.
  3. Features simulation in an external thread.
  4. Owns root of the simulation chain and identification algorithm visible to the user via GUI.
    Note
    Implements multi-threading safe singleton pattern.
    Warning
    This class is not a RAII class. It needs to be explicitly destroyed by the end of the application lifetime to avoid potential invalid memory accesses.

Member Function Documentation

void SLogic::ChangeIdentificationParams ( int  nNomDegree,
int  nDenomDegree,
int  nDelay,
int  nTreshold,
double  dForgettingFactor 
)
inline

Changes identification parameters.

Parameters
[in]nNomDegreeNominator degree.
[in]nDenomDegreeDenominator degree.
[in]nDelayDelay value.
[in]nTresholdTreshold for estimator safety.
[in]dForgettingFactorForgetting factor.
void SLogic::ExtractPropertySubtree ( QString &  qsParentName,
const boost::property_tree::ptree &  p 
)

Helper method to call recursively when building property tree.

Parameters
[in]qsParentNameName of the parent node.
[in]pProperty tree to build gui tree from.

Here is the caller graph for this function:

void SLogic::GetLastIdentifiedDenominator ( std::vector< double > &  vDenom)
inline

Retrieves last identified denominator.

Parameters
[out]vNomVector with denominator values.
void SLogic::GetLastIdentifiedNominator ( std::vector< double > &  vNom)
inline

Retrieves last identified nominator.

Parameters
[out]vNomVector with nominator values.
bool SLogic::IsSimulatonChainReady ( )

Checks if simulation can be executed properly.

Returns
True if everything is set up properly (data loaded etc).

Here is the caller graph for this function:

bool SLogic::LoadSimChain ( const std::string  sFileName)

Tries to load the simulation chain from the .xml file.

Parameters
[in]sFileNameFilename to load data from.
Returns
True if successfully loaded.

Here is the call graph for this function:

Here is the caller graph for this function:

void SLogic::ObjectFocusChange ( std::string &  sObjName)

When user selects an object in GUI, this method is called. It searches object with the given name and builds its property tree.

Parameters
[in]sObjectNameObjects name.

Here is the call graph for this function:

void SLogic::RunSimulation ( int  nTime,
int  nPeriod 
)

Main simulation procedure. Takes time and period as milliseconds.

Parameters
[in]nTimeSimulation interval.
[in]nPeriodSimulation period.

Here is the call graph for this function:

bool SLogic::SaveObjectOutputToFile ( const std::string  sObjName,
std::string  sFileName = "" 
)

Sets object to save its output to specified file.

Parameters
[in]sObjNameObject name to search for.
[in]sFileNameFile to save output data to.
Returns
True if successfully set up the data transmission.

Here is the call graph for this function:

Here is the caller graph for this function:

bool SLogic::SaveSimChain ( const std::string  sFileName)

Commands to write the simualtion chain data into the specified file.

Parameters
[in]sFileNameFilename to save data into.
Returns
True if successfully saved.

Here is the caller graph for this function:

void SLogic::SelectedObjectEdited ( const std::string &  sObjName,
const std::string &  sKey,
const std::string &  sValue 
)

Called from GUI when the value is edited.

Parameters
[in]sObjNameName of the object edited.
[in]sKeyKey edited.
[in]sValueNew value of the key.

Here is the call graph for this function:

void SLogic::SetGUIInstance ( MainWindow MainWindowPtr)
inline

Set the GUI handle. This method has to be called as soon as possible after creation of the SLogic instance.

Parameters
[in]MainWindowPtrPointer to the GUI main window.

Here is the caller graph for this function:

void SLogic::SetSimulationParameters ( int  nTime,
int  nPeriod 
)
inline

Sets parameters. Accepts values in miliseconds.

Parameters
[in]nTimeSimulation interval.
[in]nPeriodSimulation period.
bool SLogic::StopSavingObjectOutputToFile ( const std::string  sObjName)

Disables the file output for a chosen object.

Parameters
[in]sObjNameObject name to search for.
Returns
True if successfully found the object.

Here is the call graph for this function:

bool SLogic::UpdateTreeValue ( boost::property_tree::ptree &  p,
const std::string &  sObjName,
const std::string &  sKey,
const std::string &  sNewValue 
)

Called from SelectedObjectEdited(). Helper method to update simulation tree.

Parameters
[in]pUpdated property tree.
[in]sObjNameName of the object edited.
[in]sKeyKey edited.
[in]sNewValueNew value of the key.

Here is the caller graph for this function:


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