helics
3.5.2
|
#include <Player.hpp>
Public Member Functions | |
Player ()=default | |
Player (std::vector< std::string > args) | |
Player (int argc, char *argv[]) | |
Player (std::string_view name, const FederateInfo &fi) | |
Player (std::string_view name, const std::shared_ptr< Core > &core, const FederateInfo &fi) | |
Player (std::string_view name, CoreApp &core, const FederateInfo &fi) | |
Player (std::string_view appName, const std::string &configString) | |
Player (Player &&other_player)=default | |
Player & | operator= (Player &&fed)=default |
virtual void | initialize () override |
virtual void | runTo (Time stopTime_input) override |
void | addPublication (std::string_view name, DataType type, std::string_view pubUnits=std::string_view()) |
template<class valType > | |
std::enable_if_t< helicsType< valType >) !=DataType::HELICS_CUSTOM > | addPublication (std::string_view key, std::string_view pubUnits=std::string_view()) |
void | addEndpoint (std::string_view endpointName, std::string_view endpointType=std::string_view()) |
template<class valType > | |
void | addPoint (Time pubTime, std::string_view key, const valType &val) |
template<class valType > | |
void | addPoint (Time pubTime, int iteration, std::string_view key, const valType &val) |
void | addMessage (Time sendTime, std::string_view src, std::string_view dest, std::string_view payload) |
void | addMessage (Time sendTime, Time actionTime, std::string_view src, std::string_view dest, std::string_view payload) |
auto | pointCount () const |
auto | messageCount () const |
auto | publicationCount () const |
auto | endpointCount () const |
const auto & | getPoint (int index) const |
const auto & | getMessage (int index) const |
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 | |
App & | operator= (App &&app)=default |
App & | operator= (const App &app)=delete |
void | loadFile (const std::string &filename, bool enableFederateInterfaceRegistration=true) |
virtual void | run () |
virtual void | finalize () |
bool | isActive () const |
const CombinationFederate & | accessUnderlyingFederate () const |
Additional Inherited Members | |
Protected Member Functions inherited from helics::apps::App | |
void | loadJsonFileConfiguration (const std::string &appName, const std::string &jsonString, bool enableFederateInterfaceRegistration) |
void | loadInputFiles () |
void | loadConfigOptions (AppTextParser &aparser) |
Protected Attributes inherited from helics::apps::App | |
std::shared_ptr< CombinationFederate > | fed |
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 |
class implementing a Player object, which is capable of reading a file and generating interfaces and sending signals at the appropriate times
the Player class is not thread-safe, don't try to use it from multiple threads without external protection, that will result in undefined behavior
|
default |
default constructor
|
explicit |
construct from command line arguments in a vector
args | the command line arguments to pass in a reverse vector |
helics::apps::Player::Player | ( | int | argc, |
char * | argv[] | ||
) |
construct from command line arguments
argc | the number of arguments |
argv | the strings in the input |
|
explicit |
construct from a federate info object
name | the name of the federate (can be empty to use defaults from fi) |
fi | a pointer info object containing information on the desired federate configuration |
helics::apps::Player::Player | ( | std::string_view | name, |
const std::shared_ptr< Core > & | core, | ||
const FederateInfo & | fi | ||
) |
constructor taking a federate information structure and using the given core
name | the name of the federate (can be empty to use defaults from fi) |
core | a pointer to core object which the federate can join |
fi | a federate information structure |
helics::apps::Player::Player | ( | std::string_view | name, |
CoreApp & | core, | ||
const FederateInfo & | fi | ||
) |
constructor taking a federate information structure and using the given core
name | the name of the federate (can be empty to use defaults from fi) |
core | a coreApp object that can be joined |
fi | a federate information structure |
helics::apps::Player::Player | ( | std::string_view | appName, |
const std::string & | configString | ||
) |
constructor taking a file with the required information
appName | the name of the app |
configString | JSON, TOML or text file or JSON string defining the federate information and other configuration |
|
default |
move construction
void helics::apps::Player::addEndpoint | ( | std::string_view | endpointName, |
std::string_view | endpointType = std::string_view() |
||
) |
add an endpoint to the Player
endpointName | the name of the endpoint |
endpointType | the named type of the endpoint |
void helics::apps::Player::addMessage | ( | Time | sendTime, |
std::string_view | src, | ||
std::string_view | dest, | ||
std::string_view | payload | ||
) |
add a message to a Player queue
sendTime | the time the message should be sent |
src | the source endpoint of the message |
dest | the destination endpoint of the message |
payload | the payload of the message |
void helics::apps::Player::addMessage | ( | Time | sendTime, |
Time | actionTime, | ||
std::string_view | src, | ||
std::string_view | dest, | ||
std::string_view | payload | ||
) |
add an event for a specific time to a Player queue
sendTime | the time the message should be sent |
actionTime | the eventTime listed for the message |
src | the source endpoint of the message |
dest | the destination endpoint of the message |
payload | the payload of the message |
|
inline |
add a data point to publish through a Player
pubTime | the time of the publication |
iteration | the iteration count on which the value should be published |
key | the key for the publication |
val | the value to publish |
|
inline |
add a data point to publish through a Player
pubTime | the time of the publication |
key | the key for the publication |
val | the value to publish |
|
inline |
add a publication to a Player
key | the key of the publication to add |
pubUnits | the units associated with the publication |
void helics::apps::Player::addPublication | ( | std::string_view | name, |
DataType | type, | ||
std::string_view | pubUnits = std::string_view() |
||
) |
add a publication to a Player
name | the identifier of the publication to add |
type | the type of the publication |
pubUnits | the units associated with the publication |
|
inline |
get the number of endpoints
|
inline |
get the messages from an index
|
inline |
get the point from an index
|
overridevirtual |
initialize the Player federate
generate all the publications and organize the points, the final publication count will be available after this time and the Player will enter the initialization mode, which means it will not be possible to add more publications calling run will automatically do this if necessary
Reimplemented from helics::apps::App.
References helics::apps::App::fed, and helics::Federate::STARTUP.
Referenced by runTo().
|
inline |
get the number of messages loaded
|
inline |
get the number of points loaded
|
inline |
get the number of publications
|
overridevirtual |
run the Player until the specified time
stopTime_input | the desired stop time |
Implements helics::apps::App.
References helics::Federate::EXECUTING, helics::apps::App::fed, helics::FORCE_ITERATION, initialize(), helics::isValidIndex(), helics::Federate::STARTUP, and helics::timeZero.