helics  2.8.1
Public Member Functions | List of all members
helics::apps::Source Class Reference

#include <Source.hpp>

+ Inheritance diagram for helics::apps::Source:

Public Member Functions

 Source ()=default
 
 Source (std::vector< std::string > args)
 
 Source (int argc, char *argv[])
 
 Source (const std::string &name, const FederateInfo &fi)
 
 Source (const std::string &name, const std::shared_ptr< Core > &core, const FederateInfo &fi)
 
 Source (const std::string &name, CoreApp &core, const FederateInfo &fi)
 
 Source (const std::string &name, const std::string &configString)
 
 Source (Source &&other_source)=default
 
Sourceoperator= (Source &&fed)=default
 
virtual void initialize () override
 
virtual void runTo (Time stopTime_input) override
 
void addPublication (const std::string &key, const std::string &generator, data_type type, Time period, const std::string &units=std::string())
 
void addPublication (const std::string &key, data_type type, Time period, const std::string &units=std::string())
 
int addSignalGenerator (const std::string &name, const std::string &type)
 
void setStartTime (const std::string &key, Time startTime)
 
void setPeriod (const std::string &key, Time period)
 
void linkPublicationToGenerator (const std::string &key, const std::string &generator)
 
void linkPublicationToGenerator (const std::string &key, int genIndex)
 
std::shared_ptr< SignalGeneratorgetGenerator (int index)
 
- Public Member Functions inherited from helics::apps::App
 App ()=default
 
 App (const std::string &defaultAppName, std::vector< std::string > args)
 
 App (const std::string &defaultAppName, int argc, char *argv[])
 
 App (const std::string &appName, const FederateInfo &fi)
 
 App (const std::string &appName, const std::shared_ptr< Core > &core, const FederateInfo &fi)
 
 App (const std::string &appName, CoreApp &core, const FederateInfo &fi)
 
 App (const std::string &appName, const std::string &jsonString)
 
 App (App &&other_app)=default
 
 App (const App &other_app)=delete
 
Appoperator= (App &&app)=default
 
Appoperator= (const App &app)=delete
 
void loadFile (const std::string &filename)
 
virtual void run ()
 
virtual void finalize ()
 
bool isActive () const
 
const CombinationFederateaccessUnderlyingFederate () const
 

Additional Inherited Members

- Protected Member Functions inherited from helics::apps::App
void loadJsonFileConfiguration (const std::string &appName, const std::string &jsonString)
 
virtual void loadTextFile (const std::string &textFile)
 
- Protected Attributes inherited from helics::apps::App
std::shared_ptr< CombinationFederatefed
 the federate created for the Player
 
Time stopTime = Time::maxVal()
 the time the Player should stop
 
std::string masterFileName
 the name of the master file used to do the construction
 
bool useLocal {false}
 
bool fileLoaded {false}
 
bool deactivated {false}
 
bool quietMode {false}
 
bool helpMode {false}
 
std::vector< std::string > remArgs
 

Detailed Description

class implementing a source federate, which is capable of generating signals of various kinds and sending signals at the appropriate times

the source class is NOT threadsafe, don't try to use it from multiple threads without external protection, that will result in undefined behavior

Constructor & Destructor Documentation

◆ Source() [1/8]

helics::apps::Source::Source ( )
default

default constructor

◆ Source() [2/8]

helics::apps::Source::Source ( std::vector< std::string >  args)
explicit

construct from command line arguments in a vector

Parameters
argsThe vector of string, the remaining arguments are returned in the args

◆ Source() [3/8]

helics::apps::Source::Source ( int  argc,
char *  argv[] 
)

construct from command line arguments

Parameters
argcthe number of arguments
argvthe strings in the input

◆ Source() [4/8]

helics::apps::Source::Source ( const std::string &  name,
const FederateInfo fi 
)

construct from a federate info object

Parameters
namethe name of the source object (can be empty to use defaults from fi)
fia pointer info object containing information on the desired federate configuration

References helics::apps::App::fed, and helics_flag_source_only.

◆ Source() [5/8]

helics::apps::Source::Source ( const std::string &  name,
const std::shared_ptr< Core > &  core,
const FederateInfo fi 
)

constructor taking a federate information structure and using the given core

Parameters
namethe name of the source object (can be empty to use defaults from fi)
corea pointer to core object which the federate can join
fia federate information structure

References helics::apps::App::fed, and helics_flag_source_only.

◆ Source() [6/8]

helics::apps::Source::Source ( const std::string &  name,
CoreApp &  core,
const FederateInfo fi 
)

constructor taking a federate information structure and using the given core

Parameters
namethe name of the federate (can be empty to use defaults from fi)
corea coreApp object that can be joined
fia federate information structure

References helics::apps::App::fed, and helics_flag_source_only.

◆ Source() [7/8]

helics::apps::Source::Source ( const std::string &  name,
const std::string &  configString 
)

constructor taking a file with the required information

Parameters
namethe name of the source object (can be empty to use defaults from fi)
configStringfile a JSON or TOML file or string containing configuration informatino

References helics::apps::App::fed, and helics_flag_source_only.

◆ Source() [8/8]

helics::apps::Source::Source ( Source &&  other_source)
default

move construction

Member Function Documentation

◆ addPublication() [1/2]

void helics::apps::Source::addPublication ( const std::string &  key,
const std::string &  generator,
data_type  type,
Time  period,
const std::string &  units = std::string() 
)

add a publication to a source

Parameters
keythe key of the publication to add
generatorthe name of the generator to link with
typethe type of the publication
periodthe period of the publication
unitsthe units associated with the publication

◆ addPublication() [2/2]

void helics::apps::Source::addPublication ( const std::string &  key,
data_type  type,
Time  period,
const std::string &  units = std::string() 
)
inline

add a publication to a source

Parameters
keythe key of the publication to add
typethe type of the publication
periodthe period of the publication
unitsthe units associated with the publication

◆ addSignalGenerator()

int helics::apps::Source::addSignalGenerator ( const std::string &  name,
const std::string &  type 
)

add a signal generator to the source object

Returns
an index for later reference of the signal generator

◆ getGenerator()

std::shared_ptr< SignalGenerator > helics::apps::Source::getGenerator ( int  index)

get a pointer to the signal generator

◆ initialize()

void helics::apps::Source::initialize ( )
overridevirtual

initialize the source federate

connect all sources with a generator

Reimplemented from helics::apps::App.

References helics::apps::App::fed, and helics::Federate::startup.

Referenced by runTo().

◆ linkPublicationToGenerator() [1/2]

void helics::apps::Source::linkPublicationToGenerator ( const std::string &  key,
const std::string &  generator 
)

tie a publication to a signal generator

◆ linkPublicationToGenerator() [2/2]

void helics::apps::Source::linkPublicationToGenerator ( const std::string &  key,
int  genIndex 
)

tie a publication to a signal generator

◆ operator=()

Source& helics::apps::Source::operator= ( Source &&  fed)
default

move assignment

◆ runTo()

void helics::apps::Source::runTo ( Time  stopTime_input)
overridevirtual

run the source until the specified time

Parameters
stopTime_inputthe desired stop time

Implements helics::apps::App.

References helics::Federate::executing, helics::apps::App::fed, initialize(), helics::Federate::startup, helics::timeEpsilon, and helics::timeZero.

◆ setPeriod()

void helics::apps::Source::setPeriod ( const std::string &  key,
Time  period 
)

set the start time for a publication

◆ setStartTime()

void helics::apps::Source::setStartTime ( const std::string &  key,
Time  startTime 
)

set the start time for a publication


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