NRP Core  1.4.1
FunctionManager Class Reference

Manages all types of Python functions that can be run as part of NRP Core. More...

#include <function_manager.h>

Public Types

using function_datas_t = std::multimap< std::string, FunctionData >
 
using linked_functions_t = std::pair< FunctionManager::function_datas_t::iterator, FunctionManager::function_datas_t::iterator >
 
using status_function_results_t = std::tuple< bool, datapacks_vector_t >
 

Public Member Functions

 FunctionManager ()
 
 FunctionManager (const boost::python::dict &tfGlobals)
 
datapack_identifiers_set_t getRequestedDataPackIDs () const
 Get DataPack IDs requested by TFs. More...
 
DataPackPassingPolicy getDataPackPassingPolicy () const
 
void setDataPackPassingPolicy (DataPackPassingPolicy method)
 
void setSimulationTime (SimulationTime simulationTime)
 Sets simulation time that will be accessible by all Python Functions. More...
 
const SimulationTimegetSimulationTime () const
 Returns simulation time stored by the manager. More...
 
void setSimulationIteration (unsigned long simulationIteration)
 Sets simulation iteration that will be accessible by all Python Functions. More...
 
unsigned long getSimulationIteration () const
 Returns simulation iteration number stored by the manager. More...
 
void loadDataPackFunction (const std::string &dataPackFunctionName, const std::string &dataPackFunctionFilename)
 Loads given DataPack Processing Function. More...
 
void loadStatusFunction (const std::string &statusFunctionName, const std::string &statusFunctionFilename)
 Loads given status funtion. More...
 
datapacks_vector_t executePreprocessingFunctions (const std::string &engineName, datapacks_set_t dataPacks)
 Executes all Preprocessing Functions linked to an engine. More...
 
datapacks_vector_t executeTransceiverFunctions (const std::string &engineName, datapacks_set_t dataPacks)
 Executes all Transceiver Functions linked to an engine. More...
 
status_function_results_t executeStatusFunction (datapacks_set_t dataPacks)
 Executes Status Function registered loaded by the manager. More...
 

Friends

class TransceiverFunction
 
class PreprocessingFunction
 
class StatusFunction
 

Detailed Description

Manages all types of Python functions that can be run as part of NRP Core.

This class is responsible for loading and running all Python functions that are supported by NRP Core. The following function types are supported:

  • Preprocessing Functions
  • Transceiver Functions
  • Status Functions Preprocessing and Transceiver Functions will be also refered to as DataPack (Processing) Functions, to distinguish them from Status Functions, which have a slightly different purpose.

Member Typedef Documentation

◆ function_datas_t

using FunctionManager::function_datas_t = std::multimap<std::string, FunctionData>

◆ linked_functions_t

using FunctionManager::linked_functions_t = std::pair<FunctionManager::function_datas_t::iterator, FunctionManager::function_datas_t::iterator>

◆ status_function_results_t

Constructor & Destructor Documentation

◆ FunctionManager() [1/2]

FunctionManager::FunctionManager ( )

◆ FunctionManager() [2/2]

FunctionManager::FunctionManager ( const boost::python::dict &  tfGlobals)

Member Function Documentation

◆ executePreprocessingFunctions()

datapacks_vector_t FunctionManager::executePreprocessingFunctions ( const std::string &  engineName,
datapacks_set_t  dataPacks 
)

Executes all Preprocessing Functions linked to an engine.

Parameters
engineNameName of engine
Returns
Returns results of executed Preprocessing Functions

◆ executeStatusFunction()

FunctionManager::status_function_results_t FunctionManager::executeStatusFunction ( datapacks_set_t  dataPacks)

Executes Status Function registered loaded by the manager.

Returns
Results of the Status Function execution as JSON object

This method will run the Status Function that was loaded using loadStatusFunction method.

◆ executeTransceiverFunctions()

datapacks_vector_t FunctionManager::executeTransceiverFunctions ( const std::string &  engineName,
datapacks_set_t  dataPacks 
)

Executes all Transceiver Functions linked to an engine.

Parameters
engineNameName of engine
Returns
Returns results of executed Preprocessing Functions

◆ getDataPackPassingPolicy()

DataPackPassingPolicy FunctionManager::getDataPackPassingPolicy ( ) const

◆ getRequestedDataPackIDs()

datapack_identifiers_set_t FunctionManager::getRequestedDataPackIDs ( ) const

Get DataPack IDs requested by TFs.

Returns

◆ getSimulationIteration()

unsigned long FunctionManager::getSimulationIteration ( ) const

Returns simulation iteration number stored by the manager.

◆ getSimulationTime()

const SimulationTime & FunctionManager::getSimulationTime ( ) const

Returns simulation time stored by the manager.

◆ loadDataPackFunction()

void FunctionManager::loadDataPackFunction ( const std::string &  dataPackFunctionName,
const std::string &  dataPackFunctionFilename 
)

Loads given DataPack Processing Function.

Parameters
dataPackFunctionNameName of the function, used as function's ID. The name doesn't have to match the actual name of the python function.
dataPackFunctionFilenameName of the file where the function is located.

The function runs python code from the given file, executes all decorators found in the function definition, and stores the function with some metadata for future use.

DataPack Processing Functions are Transceiver Functions and Preprocessing Functions.

◆ loadStatusFunction()

void FunctionManager::loadStatusFunction ( const std::string &  statusFunctionName,
const std::string &  statusFunctionFilename 
)

Loads given status funtion.

Parameters
statusFunctionNameName of the function, used as function's ID. The name doesn't have to match the actual name of the python function.
statusFunctionFilenameName of the file where the function is located.

The function runs python code from the given file, executes all decorators found in the definition of the function, and stores the function with some metadata for future use.

◆ setDataPackPassingPolicy()

void FunctionManager::setDataPackPassingPolicy ( DataPackPassingPolicy  method)

◆ setSimulationIteration()

void FunctionManager::setSimulationIteration ( unsigned long  simulationIteration)

Sets simulation iteration that will be accessible by all Python Functions.

Parameters
simulationIterationCurrent simulation iteration from the simulation manager

◆ setSimulationTime()

void FunctionManager::setSimulationTime ( SimulationTime  simulationTime)

Sets simulation time that will be accessible by all Python Functions.

Parameters
simulationTimeCurrent simulation time from the simulation manager

Friends And Related Function Documentation

◆ PreprocessingFunction

friend class PreprocessingFunction
friend

◆ StatusFunction

friend class StatusFunction
friend

◆ TransceiverFunction

friend class TransceiverFunction
friend

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