![]() |
helics
2.8.1
|
#include <FederateState.hpp>
Public Member Functions | |
FederateState (const std::string &fedName, const CoreFederateInfo &fedInfo) | |
FederateState (const FederateState &)=delete | |
FederateState & | operator= (const FederateState &)=delete |
~FederateState () | |
void | reset () |
void | reInit () |
const std::string & | getIdentifier () const |
federate_state | getState () const |
InterfaceInfo & | interfaces () |
const InterfaceInfo & | interfaces () const |
uint64_t | getQueueSize (interface_handle id) const |
uint64_t | getQueueSize () const |
int32_t | getCurrentIteration () const |
std::unique_ptr< Message > | receive (interface_handle id) |
std::unique_ptr< Message > | receiveAny (interface_handle &id) |
const std::shared_ptr< const data_block > & | getValue (interface_handle handle, uint32_t *inputIndex) |
const std::vector< std::shared_ptr< const data_block > > & | getAllValues (interface_handle handle) |
void | setParent (CommonCore *coreObject) |
void | setProperties (const ActionMessage &cmd) |
void | setInterfaceProperty (const ActionMessage &cmd) |
void | setProperty (int timeProperty, Time propertyVal) |
void | setProperty (int intProperty, int propertyVal) |
void | setOptionFlag (int optionFlag, bool value) |
Time | getTimeProperty (int timeProperty) const |
bool | getOptionFlag (int optionFlag) const |
int32_t | getHandleOption (interface_handle handle, char iType, int32_t option) const |
uint16_t | getInterfaceFlags () const |
int | getIntegerProperty (int intProperty) const |
int | publicationCount () const |
int | endpointCount () const |
int | inputCount () const |
void | spinlock () const |
void | sleeplock () const |
void | lock () |
bool | try_lock () const |
void | unlock () const |
int | loggingLevel () const |
Time | grantedTime () const |
Time | nextAllowedSendTime () const |
const std::vector< interface_handle > & | getEvents () const |
std::vector< global_federate_id > | getDependencies () const |
std::vector< global_federate_id > | getDependents () const |
const std::string & | lastErrorString () const |
int | lastErrorCode () const noexcept |
void | setCoreObject (CommonCore *parent) |
iteration_result | waitSetup () |
iteration_result | enterInitializingMode () |
iteration_result | enterExecutingMode (iteration_request iterate, bool sendRequest=false) |
iteration_time | requestTime (Time nextTime, iteration_request iterate, bool sendRequest=false) |
std::vector< global_handle > | getSubscribers (interface_handle handle) |
iteration_result | genericUnspecifiedQueueProcess () |
void | finalize () |
void | addAction (const ActionMessage &action) |
void | addAction (ActionMessage &&action) |
opt< ActionMessage > | processPostTerminationAction (const ActionMessage &action) |
void | logMessage (int level, const std::string &logMessageSource, const std::string &message) const |
void | setLogger (std::function< void(int, const std::string &, const std::string &)> logFunction) |
void | setQueryCallback (std::function< std::string(const std::string &)> queryCallbackFunction) |
std::string | processQuery (const std::string &query, bool force_ordering=false) const |
bool | checkAndSetValue (interface_handle pub_id, const char *data, uint64_t len) |
void | routeMessage (const ActionMessage &msg) |
void | createInterface (handle_type htype, interface_handle handle, const std::string &key, const std::string &type, const std::string &units) |
void | closeInterface (interface_handle handle, handle_type type) |
Public Attributes | |
local_federate_id | local_id |
id code for the local federate descriptor | |
std::atomic< global_federate_id > | global_id |
global id code, default to invalid | |
std::atomic< bool > | init_transmitted {false} |
the initialization request has been transmitted | |
std::atomic< bool > | init_requested |
this federate has requested entry to initialization More... | |
std::atomic< bool > | requestingMode {false} |
class managing the information about a single federate
helics::FederateState::FederateState | ( | const std::string & | fedName, |
const CoreFederateInfo & | fedInfo | ||
) |
constructor from name and information structure
References routeMessage().
|
delete |
DISABLE_COPY_AND_ASSIGN
|
default |
destructor
void helics::FederateState::addAction | ( | ActionMessage && | action | ) |
move a message to the queue
void helics::FederateState::addAction | ( | const ActionMessage & | action | ) |
add an action message to the queue
References helics::ActionMessage::action(), helics::ActionMessage::actionTime, helics::ActionMessage::dest_id, helics::ActionMessage::source_id, and helics::timeZero.
bool helics::FederateState::checkAndSetValue | ( | interface_handle | pub_id, |
const char * | data, | ||
uint64_t | len | ||
) |
check if a value should be published or not and if needed archive it as a changed value for future change detection
pub_id | the handle of the publication |
data | the raw data to check |
len | the length of the data |
References helics::PublicationInfo::CheckSetValue(), and data.
void helics::FederateState::closeInterface | ( | interface_handle | handle, |
handle_type | type | ||
) |
close an interface
References helics::ActionMessage::actionTime, helics::ActionMessage::setDestination(), and helics::ActionMessage::setSource().
void helics::FederateState::createInterface | ( | handle_type | htype, |
interface_handle | handle, | ||
const std::string & | key, | ||
const std::string & | type, | ||
const std::string & | units | ||
) |
create an interface
References checkActionFlag(), and required_flag.
int helics::FederateState::endpointCount | ( | ) | const |
get the number of endpoints
iteration_result helics::FederateState::enterExecutingMode | ( | iteration_request | iterate, |
bool | sendRequest = false |
||
) |
function to call when entering execution state
iterate | indicator of whether the fed should iterate if need be or not |
sendRequest | generates the local actionMessage inside the function leaving to false assumes the caller generated the message returns either converged or nonconverged depending on whether an iteration is needed |
References error, helics::HELICS_ERROR, helics::HELICS_FINISHED, indicator_flag, helics::initializationTime, setActionFlag(), helics::setIterationFlags(), helics::ActionMessage::source_id, and helics::timeZero.
iteration_result helics::FederateState::enterInitializingMode | ( | ) |
process until the initialization state has been entered or there is a failure
References error, helics::HELICS_ERROR, and helics::HELICS_FINISHED.
void helics::FederateState::finalize | ( | ) |
function to process the queue until a disconnect_fed_ack is received
References error, helics::HELICS_ERROR, and helics::HELICS_FINISHED.
iteration_result helics::FederateState::genericUnspecifiedQueueProcess | ( | ) |
function to process the queue in a generic fashion used to just process messages with no specific end in mind
const std::vector< std::shared_ptr< const data_block > > & helics::FederateState::getAllValues | ( | interface_handle | handle | ) |
Return all the available data for the specified handle or the latest input
References interfaces.
int32_t helics::FederateState::getCurrentIteration | ( | ) | const |
get the current iteration counter for an iterative call
this will work properly even when a federate is processing
std::vector< global_federate_id > helics::FederateState::getDependencies | ( | ) | const |
get a vector of the federates this one depends on
std::vector< global_federate_id > helics::FederateState::getDependents | ( | ) | const |
get a vector to the global ids of dependent federates
const std::vector< interface_handle > & helics::FederateState::getEvents | ( | ) | const |
get a reference to the handles of subscriptions with value updates
int32_t helics::FederateState::getHandleOption | ( | interface_handle | handle, |
char | iType, | ||
int32_t | option | ||
) | const |
get the currently active option for a handle
|
inline |
get the name of the federate
int helics::FederateState::getIntegerProperty | ( | int | intProperty | ) | const |
get an option flag value
|
inline |
get the currently active interface flags
bool helics::FederateState::getOptionFlag | ( | int | optionFlag | ) | const |
get an option flag value
uint64_t helics::FederateState::getQueueSize | ( | ) | const |
get the sum of all message queue sizes i.e. the total number of messages available in all endpoints
uint64_t helics::FederateState::getQueueSize | ( | interface_handle | id | ) | const |
get the size of a message queue for a specific endpoint or filter handle
References helics::EndpointInfo::availableMessages().
federate_state helics::FederateState::getState | ( | ) | const |
get the current state of the federate
std::vector< global_handle > helics::FederateState::getSubscribers | ( | interface_handle | handle | ) |
get a list of current subscribers to a publication
handle | the publication handle to use |
Time helics::FederateState::getTimeProperty | ( | int | timeProperty | ) | const |
get a time Property
const std::shared_ptr< const data_block > & helics::FederateState::getValue | ( | interface_handle | handle, |
uint32_t * | inputIndex | ||
) |
Return the data for the specified handle or the latest input
References interfaces.
|
inline |
get the granted time of a federate
int helics::FederateState::inputCount | ( | ) | const |
get the number of inputs
|
inline |
get the information that comes from the interface including timing information
|
inline |
const version of the interface info retrieval function
|
inlinenoexcept |
get the last error code
|
inline |
get the last error string
|
inline |
locks the processing so FederateState can be used with lock_guard
References sleeplock().
|
inline |
get the current logging level
void helics::FederateState::logMessage | ( | int | level, |
const std::string & | logMessageSource, | ||
const std::string & | message | ||
) | const |
log a message to the federate Logger
level | the logging level of the message |
logMessageSource | the name of the object that sent the message |
message | the message to log |
|
inline |
get allowable message time
Referenced by helics::CommonCore::sendEvent().
stx::optional< ActionMessage > helics::FederateState::processPostTerminationAction | ( | const ActionMessage & | action | ) |
sometime a message comes in after a federate has terminated and may require a response
std::string helics::FederateState::processQuery | ( | const std::string & | query, |
bool | force_ordering = false |
||
) | const |
generate the result of a query string
query | a query string |
force_ordering | true if the query should be processed in a force_ordering way |
int helics::FederateState::publicationCount | ( | ) | const |
get the number of publications
std::unique_ptr< Message > helics::FederateState::receive | ( | interface_handle | id | ) |
get the next available message for an endpoint
id | the handle of an endpoint or filter |
References helics::EndpointInfo::getMessage().
std::unique_ptr< Message > helics::FederateState::receiveAny | ( | interface_handle & | id | ) |
get any message ready for reception
[out] | id | the endpoint related to the message |
References helics::EndpointInfo::getMessage(), helics::global_handle::handle, and helics::EndpointInfo::id.
void helics::FederateState::reInit | ( | ) |
reset the federate to the initializing state
References helics::HELICS_INITIALIZING.
iteration_time helics::FederateState::requestTime | ( | Time | nextTime, |
iteration_request | iterate, | ||
bool | sendRequest = false |
||
) |
request a time advancement
nextTime | the time of the requested advancement |
iterate | the type of iteration requested |
sendRequest | generates the local actionMessage inside the function leaving to false assumes the caller generated the message |
void helics::FederateState::reset | ( | ) |
reset the federate to created state
References global_id, local_id, and helics::InterfaceInfo::setGlobalId().
void helics::FederateState::routeMessage | ( | const ActionMessage & | msg | ) |
route a message either forward to parent or add to queue
References helics::ActionMessage::action().
Referenced by FederateState().
void helics::FederateState::setCoreObject | ( | CommonCore * | parent | ) |
set the managing core object
void helics::FederateState::setInterfaceProperty | ( | const ActionMessage & | cmd | ) |
set a property on a specific interface
References checkActionFlag(), and indicator_flag.
|
inline |
set the logging function
function must have signature void(int level, const std::string &sourceName, const std::string &message)
void helics::FederateState::setOptionFlag | ( | int | optionFlag, |
bool | value | ||
) |
set an option Flag for a the coordinator
|
inline |
set the CommonCore object that is managing this Federate
void helics::FederateState::setProperties | ( | const ActionMessage & | cmd | ) |
update the info structure
public call so it also calls the federate lock before calling private update function the action Message should be CMD_FED_CONFIGURE
void helics::FederateState::setProperty | ( | int | intProperty, |
int | propertyVal | ||
) |
set a timeProperty for a the coordinator
void helics::FederateState::setProperty | ( | int | timeProperty, |
Time | propertyVal | ||
) |
set a timeProperty for a the coordinator
|
inline |
set the query callback function
function must have signature std::string(const std::string &query)
|
inline |
locks the processing with a sleep loop
Referenced by lock().
|
inline |
locks the processing with a busy loop
|
inline |
tries to lock the processing return true if successful and false if not
|
inline |
unlocks the processing
iteration_result helics::FederateState::waitSetup | ( | ) |
process until the federate has verified its membership and assigned a global id number
std::atomic<bool> helics::FederateState::init_requested |
this federate has requested entry to initialization