helics  3.5.2
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 (std::string_view name, const FederateInfo &fi)
 
 Source (std::string_view name, const std::shared_ptr< Core > &core, const FederateInfo &fi)
 
 Source (std::string_view name, CoreApp &core, const FederateInfo &fi)
 
 Source (std::string_view 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 (std::string_view key, std::string_view generator, DataType type, Time period, std::string_view units=std::string_view())
 
void addPublication (std::string_view key, DataType type, Time period, std::string_view units=std::string_view())
 
int addSignalGenerator (std::string_view name, std::string_view type)
 
void setStartTime (std::string_view key, Time startTime)
 
void setPeriod (std::string_view key, Time period)
 
void linkPublicationToGenerator (std::string_view key, std::string_view generator)
 
void linkPublicationToGenerator (std::string_view key, int genIndex)
 
std::shared_ptr< SignalGeneratorgetGenerator (int index)
 
- Public Member Functions inherited from helics::apps::App
 App ()=default
 
 App (std::string_view defaultAppName, std::vector< std::string > args)
 
 App (std::string_view defaultAppName, int argc, char *argv[])
 
 App (std::string_view appName, const FederateInfo &fedInfo)
 
 App (std::string_view appName, const std::shared_ptr< Core > &core, const FederateInfo &fedInfo)
 
 App (std::string_view appName, CoreApp &core, const FederateInfo &fedInfo)
 
 App (std::string_view appName, const std::string &configString)
 
 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, bool enableFederateInterfaceRegistration=true)
 
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, bool enableFederateInterfaceRegistration)
 
virtual void loadTextFile (const std::string &textFile)
 
void loadInputFiles ()
 
void loadConfigOptions (AppTextParser &aparser)
 
- Protected Attributes inherited from helics::apps::App
std::shared_ptr< CombinationFederatefed
 the federate created for the App
 
Time stopTime = Time::maxVal()
 the time the App should stop
 
std::string configFileName
 name of the config file used for constructing the federate
 
std::string inputFileName
 the name of the app input file
 
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 ( std::string_view  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

◆ Source() [5/8]

helics::apps::Source::Source ( std::string_view  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

◆ Source() [6/8]

helics::apps::Source::Source ( std::string_view  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

◆ Source() [7/8]

helics::apps::Source::Source ( std::string_view  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

◆ Source() [8/8]

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

move construction

Member Function Documentation

◆ addPublication() [1/2]

void helics::apps::Source::addPublication ( std::string_view  key,
DataType  type,
Time  period,
std::string_view  units = std::string_view() 
)
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

◆ addPublication() [2/2]

void helics::apps::Source::addPublication ( std::string_view  key,
std::string_view  generator,
DataType  type,
Time  period,
std::string_view  units = std::string_view() 
)

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

◆ addSignalGenerator()

int helics::apps::Source::addSignalGenerator ( std::string_view  name,
std::string_view  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 ( std::string_view  key,
int  genIndex 
)

tie a publication to a signal generator

◆ linkPublicationToGenerator() [2/2]

void helics::apps::Source::linkPublicationToGenerator ( std::string_view  key,
std::string_view  generator 
)

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 ( std::string_view  key,
Time  period 
)

set the start time for a publication

◆ setStartTime()

void helics::apps::Source::setStartTime ( std::string_view  key,
Time  startTime 
)

set the start time for a publication


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