helics
3.5.2
|
#include <MessageFederate.hpp>
Public Member Functions | |
MessageFederate (std::string_view fedName, const FederateInfo &fedInfo) | |
MessageFederate (std::string_view fedName, const std::shared_ptr< Core > &core, const FederateInfo &fedInfo=FederateInfo{}) | |
MessageFederate (std::string_view fedName, CoreApp &core, const FederateInfo &fedInfo=FederateInfo{}) | |
MessageFederate (std::string_view name, const std::string &configString) | |
MessageFederate (const std::string &configString) | |
MessageFederate (const char *configString) | |
MessageFederate (MessageFederate &&mFed) noexcept | |
MessageFederate (const MessageFederate &mFed)=delete | |
MessageFederate () | |
MessageFederate (bool res) | |
virtual | ~MessageFederate () |
MessageFederate & | operator= (MessageFederate &&mFed) noexcept |
MessageFederate & | operator= (const MessageFederate &mFed)=delete |
Endpoint & | registerEndpoint (std::string_view eptName=std::string_view(), std::string_view type=std::string_view()) |
Endpoint & | registerTargetedEndpoint (std::string_view eptName=std::string_view(), std::string_view type=std::string_view()) |
Endpoint & | registerGlobalEndpoint (std::string_view eptName, std::string_view type=std::string_view()) |
Endpoint & | registerGlobalTargetedEndpoint (std::string_view eptName, std::string_view type=std::string_view()) |
Endpoint & | registerIndexedEndpoint (std::string_view eptName, int index1, std::string_view type=std::string_view()) |
Endpoint & | registerDataSink (std::string_view sinkName=std::string_view()) |
virtual void | registerInterfaces (const std::string &configString) override |
void | registerMessageInterfaces (const std::string &configString) |
void | subscribe (const Endpoint &ept, std::string_view key) |
bool | hasMessage () const |
bool | hasMessage (const Endpoint &ept) const |
uint64_t | pendingMessageCount (const Endpoint &ept) const |
uint64_t | pendingMessageCount () const |
std::unique_ptr< Message > | getMessage (const Endpoint &ept) |
std::unique_ptr< Message > | getMessage () |
Endpoint & | getEndpoint (std::string_view name) const |
Endpoint & | getEndpoint (int index) const |
Endpoint & | getDataSink (std::string_view name) const |
void | setMessageNotificationCallback (const std::function< void(Endpoint &, Time)> &callback) |
void | setMessageNotificationCallback (const Endpoint &ept, const std::function< void(Endpoint &, Time)> &callback) |
virtual void | disconnect () override |
int | getEndpointCount () const |
Public Member Functions inherited from helics::Federate | |
Federate (std::string_view fedname, const FederateInfo &fedInfo) | |
Federate (std::string_view fedname, const std::shared_ptr< Core > &core, const FederateInfo &fedInfo=FederateInfo{}) | |
Federate (std::string_view fedname, CoreApp &core, const FederateInfo &fedInfo=FederateInfo{}) | |
Federate (const std::string &configString) | |
Federate (std::string_view fedname, const std::string &configString) | |
Federate () noexcept | |
Federate (Federate &&fed) noexcept | |
Federate (const Federate &fed)=delete | |
virtual | ~Federate () |
Federate & | operator= (Federate &&fed) noexcept |
Federate & | operator= (const Federate &fed)=delete |
void | enterInitializingMode () |
void | enterInitializingModeAsync () |
bool | isAsyncOperationCompleted () const |
void | enterInitializingModeComplete () |
void | enterInitializingModeIterative () |
void | enterInitializingModeIterativeAsync () |
void | enterInitializingModeIterativeComplete () |
IterationResult | enterExecutingMode (IterationRequest iterate=IterationRequest::NO_ITERATIONS) |
void | enterExecutingModeAsync (IterationRequest iterate=IterationRequest::NO_ITERATIONS) |
IterationResult | enterExecutingModeComplete () |
void | finalize () |
void | finalizeAsync () |
void | finalizeComplete () |
void | processCommunication (std::chrono::milliseconds period=std::chrono::milliseconds(0)) |
void | localError (int errorcode, std::string_view message) |
void | globalError (int errorcode, std::string_view message) |
void | localError (int errorcode) |
void | globalError (int errorcode) |
void | setSeparator (char separator) |
Time | requestTime (Time nextInternalTimeStep) |
Time | requestNextStep () |
Time | requestTimeAdvance (Time timeDelta) |
iteration_time | requestTimeIterative (Time nextInternalTimeStep, IterationRequest iterate) |
void | requestTimeAsync (Time nextInternalTimeStep) |
void | requestTimeIterativeAsync (Time nextInternalTimeStep, IterationRequest iterate) |
Time | requestTimeComplete () |
iteration_time | requestTimeIterativeComplete () |
void | setTag (std::string_view tag, std::string_view value) |
const std::string & | getTag (std::string_view tag) const |
virtual void | setProperty (int32_t option, double timeValue) |
virtual void | setProperty (int32_t option, Time timeValue) |
virtual void | setFlagOption (int flag, bool flagValue=true) |
virtual void | setProperty (int32_t option, int32_t optionValue) |
virtual Time | getTimeProperty (int32_t option) const |
virtual bool | getFlagOption (int flag) const |
virtual int | getIntegerProperty (int32_t option) const |
void | setLoggingCallback (const std::function< void(int, std::string_view, std::string_view)> &logFunction) |
void | setInitializingEntryCallback (std::function< void(bool)> callback) |
void | setExecutingEntryCallback (std::function< void()> callback) |
void | setTimeRequestEntryCallback (std::function< void(Time, Time, bool)> callback) |
void | setTimeUpdateCallback (std::function< void(Time, bool)> callback) |
void | setModeUpdateCallback (std::function< void(Modes, Modes)> callback) |
void | setTimeRequestReturnCallback (std::function< void(Time, bool)> callback) |
void | setCosimulationTerminatedCallback (std::function< void()> callback) |
void | setErrorHandlerCallback (std::function< void(int, std::string_view)> errorHandlerCallback) |
std::string | query (std::string_view target, std::string_view queryStr, HelicsSequencingModes mode=HELICS_SEQUENCING_MODE_FAST) |
std::string | query (std::string_view queryStr, HelicsSequencingModes mode=HELICS_SEQUENCING_MODE_FAST) |
QueryId | queryAsync (std::string_view target, std::string_view queryStr, HelicsSequencingModes mode=HELICS_SEQUENCING_MODE_FAST) |
QueryId | queryAsync (std::string_view queryStr, HelicsSequencingModes mode=HELICS_SEQUENCING_MODE_FAST) |
std::string | queryComplete (QueryId queryIndex) |
bool | isQueryCompleted (QueryId queryIndex) const |
void | setQueryCallback (const std::function< std::string(std::string_view)> &queryFunction) |
void | setGlobal (std::string_view valueName, std::string_view value) |
void | addAlias (std::string_view interfaceName, std::string_view alias) |
void | sendCommand (std::string_view target, std::string_view commandStr, HelicsSequencingModes mode=HelicsSequencingModes::HELICS_SEQUENCING_MODE_FAST) |
std::pair< std::string, std::string > | getCommand () |
std::pair< std::string, std::string > | waitCommand () |
void | addDependency (std::string_view fedName) |
Filter & | registerGlobalFilter (std::string_view filterName, std::string_view inputType=std::string_view{}, std::string_view outputType=std::string_view{}) |
CloningFilter & | registerGlobalCloningFilter (std::string_view filterName, std::string_view inputType=std::string_view{}, std::string_view outputType=std::string_view{}) |
Filter & | registerFilter (std::string_view filterName, std::string_view inputType=std::string_view{}, std::string_view outputType=std::string_view{}) |
CloningFilter & | registerCloningFilter (std::string_view filterName, std::string_view inputType=std::string_view{}, std::string_view outputType=std::string_view{}) |
Filter & | registerFilter () |
Translator & | registerGlobalTranslator (std::int32_t translatorType, std::string_view translatorName, std::string_view endpointType=std::string_view{}, std::string_view units=std::string_view{}) |
Translator & | registerTranslator (std::int32_t translatorType, std::string_view translatorName, std::string_view endpointType=std::string_view{}, std::string_view units=std::string_view{}) |
Translator & | registerGlobalTranslator (std::string_view translatorName, std::string_view endpointType=std::string_view{}, std::string_view units=std::string_view{}) |
Translator & | registerTranslator (std::string_view translatorName, std::string_view endpointType=std::string_view{}, std::string_view units=std::string_view{}) |
Translator & | registerTranslator () |
CloningFilter & | registerCloningFilter () |
const Filter & | getFilter (std::string_view filterName) const |
const Filter & | getFilter (int index) const |
Filter & | getFilter (std::string_view filterName) |
Filter & | getFilter (int index) |
void | setFilterOperator (const Filter &filt, std::shared_ptr< FilterOperator > filtOp) |
register a operator for the specified filter More... | |
int | getFilterCount () const |
const Translator & | getTranslator (std::string_view translatorName) const |
const Translator & | getTranslator (int index) const |
Translator & | getTranslator (std::string_view translatorName) |
Translator & | getTranslator (int index) |
void | setTranslatorOperator (const Translator &trans, std::shared_ptr< TranslatorOperator > transOp) |
register an operator for the specified translator More... | |
int | getTranslatorCount () const |
const std::string & | getConfigFile () const |
void | registerConnectorInterfaces (const std::string &configString) |
void | registerFilterInterfaces (const std::string &configString) |
auto | getID () const noexcept |
Modes | getCurrentMode () const noexcept |
Time | getCurrentTime () const noexcept |
const std::string & | getName () const |
const std::shared_ptr< Core > & | getCorePointer () |
void | logMessage (int level, std::string_view message) const |
void | logErrorMessage (std::string_view message) const |
void | logWarningMessage (std::string_view message) const |
void | logInfoMessage (std::string_view message) const |
void | logDebugMessage (std::string_view message) const |
void | completeOperation () |
Protected Member Functions | |
virtual void | startupToInitializeStateTransition () override |
virtual void | initializeToExecuteStateTransition (iteration_time result) override |
virtual void | updateTime (Time newTime, Time oldTime) override |
virtual std::string | localQuery (std::string_view queryStr) const override |
Protected Member Functions inherited from helics::Federate | |
void | enteringInitializingMode (IterationResult iterating) |
void | enteringExecutingMode (iteration_time res) |
void | finalizeOperations () |
void | preTimeRequestOperations (Time nextStep, bool iterating) |
void | postTimeRequestOperations (Time newTime, bool iterating) |
virtual void | disconnectTransition () |
std::string | localNameGenerator (std::string_view addition) const |
void | handleError (int errorCode, std::string_view errorString, bool noThrow) |
void | setAsyncCheck (std::function< bool()> asyncCheck) |
Additional Inherited Members | |
Public Types inherited from helics::Federate | |
enum class | Modes : char { STARTUP = 0 , INITIALIZING = 1 , EXECUTING = 2 , FINALIZE = 3 , ERROR_STATE = 4 , PENDING_INIT = 5 , PENDING_EXEC = 6 , PENDING_TIME = 7 , PENDING_ITERATIVE_TIME = 8 , PENDING_FINALIZE = 9 , FINISHED = 10 , PENDING_ITERATIVE_INIT = 12 } |
Protected Attributes inherited from helics::Federate | |
std::atomic< Modes > | currentMode {Modes::STARTUP} |
the current state of the simulation | |
char | nameSegmentSeparator = '/' |
the separator between automatically prependend names | |
bool | strictConfigChecking {true} |
bool | useJsonSerialization {false} |
bool | observerMode {false} |
bool | retriggerTimeRequest {false} |
bool | singleThreadFederate {false} |
bool | hasPotentialInterfaces {false} |
std::shared_ptr< Core > | coreObject |
reference to the core simulation API | |
Time | mCurrentTime = Time::minVal() |
the current simulation time | |
Time | mStopTime = Time::maxVal() |
the stopping time for the federate | |
std::string | configFile |
any config file used | |
class defining the block communication based interface
helics::MessageFederate::MessageFederate | ( | std::string_view | fedName, |
const FederateInfo & | fedInfo | ||
) |
constructor taking a federate information structure and using the default core
fedName | the name of the messageFederate, can be left empty to use a default or one from fedInfo |
fedInfo | a federate information structure |
helics::MessageFederate::MessageFederate | ( | std::string_view | fedName, |
const std::shared_ptr< Core > & | core, | ||
const FederateInfo & | fedInfo = FederateInfo{} |
||
) |
constructor taking a core and a federate information structure, core information in fedInfo is ignored
fedName | the name of the messageFederate, can be left empty to use a default or one from fedInfo |
core | a shared ptr to a core to join |
fedInfo | a federate information structure |
helics::MessageFederate::MessageFederate | ( | std::string_view | fedName, |
CoreApp & | core, | ||
const FederateInfo & | fedInfo = FederateInfo{} |
||
) |
constructor taking a core and a federate information structure, core information in fedInfo is ignored
fedName | the name of the messageFederate, can be left empty to use a default or one from fedInfo |
core | a CoreApp object representing the core to connect to |
fedInfo | a federate information structure |
helics::MessageFederate::MessageFederate | ( | std::string_view | name, |
const std::string & | configString | ||
) |
constructor taking a string with the required information
name | the name of the federate, can be empty to get name from config |
configString | can be either a JSON file, TOML file or a string containing JSON code |
|
explicit |
constructor taking a string with the required information
configString | can be either a JSON file, TOML file or a string containing JSON code, or command line arguments it can also be just the federate name |
|
explicit |
constructor taking a string as const char * with the required information
; this constructor is to deconflict with the bool overload which can be triggered if a string literal is passed on some platforms
configString | can be either a JSON file, TOML file or a string containing JSON code, or command line arguments it can also be just the federate name |
|
defaultnoexcept |
move constructor
|
delete |
delete copy constructor
helics::MessageFederate::MessageFederate | ( | ) |
default constructor
|
explicit |
special constructor should only be used by child classes in constructor due to virtual inheritance
|
virtualdefault |
destructor
|
overridevirtual |
disconnect a simulation from the core (will also call finalize before disconnecting if necessary)
Reimplemented from helics::Federate.
Reimplemented in helics::CombinationFederate.
References helics::Federate::disconnect().
Referenced by helics::CombinationFederate::disconnect().
Endpoint & helics::MessageFederate::getDataSink | ( | std::string_view | name | ) | const |
get a data sink by its name
name | the Data Sink |
Endpoint & helics::MessageFederate::getEndpoint | ( | int | index | ) | const |
Endpoint & helics::MessageFederate::getEndpoint | ( | std::string_view | name | ) | const |
get an endpoint or data sink by its name
name | the Endpoint |
References helics::Interface::isValid(), and helics::Federate::localNameGenerator().
int helics::MessageFederate::getEndpointCount | ( | ) | const |
get the number of registered endpoints
get a count of the number endpoints registered
std::unique_ptr< Message > helics::MessageFederate::getMessage | ( | ) |
receive a communication message for any endpoint in the federate
the return order will be in order of endpoint creation then order of arrival all messages for the first endpoint, then all for the second, and so on
References helics::Federate::currentMode, and helics::Federate::INITIALIZING.
receive a packet from a particular endpoint
ept | the identifier for the endpoint |
References helics::Federate::currentMode, and helics::Federate::INITIALIZING.
bool helics::MessageFederate::hasMessage | ( | ) | const |
check if the federate has any outstanding messages
References helics::Federate::currentMode, and helics::Federate::INITIALIZING.
|
overrideprotectedvirtual |
function to deal with any operations that need to occur on the transition from startup to initialize
Reimplemented from helics::Federate.
Reimplemented in helics::CombinationFederate.
Referenced by helics::CombinationFederate::initializeToExecuteStateTransition().
|
overrideprotectedvirtual |
function to generate results for a local Query
should return an empty string if the query is not recognized
Reimplemented from helics::Federate.
Reimplemented in helics::CombinationFederate.
Referenced by helics::CombinationFederate::localQuery().
|
delete |
delete copy assignment
|
noexcept |
move assignment
References helics::Federate::operator=().
uint64_t helics::MessageFederate::pendingMessageCount | ( | ) | const |
Returns the number of pending receives for all endpoints.
References helics::Federate::currentMode, and helics::Federate::INITIALIZING.
uint64_t helics::MessageFederate::pendingMessageCount | ( | const Endpoint & | ept | ) | const |
Returns the number of pending receives for the specified destination endpoint.
References helics::Federate::currentMode, and helics::Federate::INITIALIZING.
Endpoint & helics::MessageFederate::registerDataSink | ( | std::string_view | sinkName = std::string_view() | ) |
register a dataSink
sinkName | the name of the endpoint |
Endpoint & helics::MessageFederate::registerEndpoint | ( | std::string_view | eptName = std::string_view() , |
std::string_view | type = std::string_view() |
||
) |
register an endpoint
eptName | the name of the endpoint |
type | the defined type of the interface for endpoint checking if requested |
References helics::Federate::localNameGenerator().
Referenced by helics::Endpoint::Endpoint().
Endpoint & helics::MessageFederate::registerGlobalEndpoint | ( | std::string_view | eptName, |
std::string_view | type = std::string_view() |
||
) |
register an endpoint directly without prepending the federate name
eptName | the name of the endpoint |
type | the defined type of the interface for endpoint checking if requested |
Referenced by helics::Endpoint::Endpoint().
Endpoint & helics::MessageFederate::registerGlobalTargetedEndpoint | ( | std::string_view | eptName, |
std::string_view | type = std::string_view() |
||
) |
register a targeted endpoint directly without prepending the federate name
eptName | the name of the endpoint |
type | the defined type of the interface for endpoint checking if requested |
|
inline |
register an indexed Endpoint
register a global endpoint as part of a 1D array of endpoints
eptName | the name of the endpoint array |
index1 | the index into a 1 dimensional array of endpoints |
type | the optional type on the endpoint |
|
overridevirtual |
register a set of interfaces defined in a file
call is only valid in startup mode
configString | the location of the file or config String to load to generate the interfaces |
Reimplemented from helics::Federate.
Reimplemented in helics::CombinationFederate.
References helics::Federate::registerConnectorInterfaces(), and registerMessageInterfaces().
void helics::MessageFederate::registerMessageInterfaces | ( | const std::string & | configString | ) |
register a set Message interfaces
call is only valid in startup mode it is a protected call to add an
configString | the location of the file(TOML or JSON) or JSON String to load to generate the interfaces |
Referenced by helics::CombinationFederate::registerInterfaces(), and registerInterfaces().
Endpoint & helics::MessageFederate::registerTargetedEndpoint | ( | std::string_view | eptName = std::string_view() , |
std::string_view | type = std::string_view() |
||
) |
register a targeted endpoint
this type of endpoint can can send messages to predefined targets
eptName | the name of the endpoint |
type | the defined type of the interface for endpoint checking if requested |
References helics::Federate::localNameGenerator().
void helics::MessageFederate::setMessageNotificationCallback | ( | const Endpoint & | ept, |
const std::function< void(Endpoint &, Time)> & | callback | ||
) |
register a callback for a specific endpoint
ept | the endpoint to associate with the specified callback |
callback | the function to execute upon receipt of a message for the given endpoint |
void helics::MessageFederate::setMessageNotificationCallback | ( | const std::function< void(Endpoint &, Time)> & | callback | ) |
register a callback for all endpoints
callback | the function to execute upon receipt of a message for any endpoint |
|
overrideprotectedvirtual |
function to deal with any operations that need to occur on the transition from startup to initialize
Reimplemented from helics::Federate.
Reimplemented in helics::CombinationFederate.
Referenced by helics::CombinationFederate::startupToInitializeStateTransition().
void helics::MessageFederate::subscribe | ( | const Endpoint & | ept, |
std::string_view | key | ||
) |
subscribe to valueFederate publication to be delivered as Messages to the given endpoint
ept | the specified endpoint to deliver the values |
key | the name of the publication to subscribe |
References helics::Federate::coreObject.
function to deal with any operations that need to occur on a time update
Reimplemented from helics::Federate.
Reimplemented in helics::CombinationFederate.
Referenced by helics::CombinationFederate::updateTime().