helics
3.5.2
|
#include <ValueFederateManager.hpp>
Public Member Functions | |
ValueFederateManager (Core *coreOb, ValueFederate *vfed, LocalFederateId id, bool singleThreaded) | |
Publication & | registerPublication (std::string_view key, std::string_view type, std::string_view units) |
Input & | registerInput (std::string_view key, std::string_view type, std::string_view units) |
void | addAlias (const Input &inp, std::string_view shortcutName) |
void | addAlias (const Publication &pub, std::string_view shortcutName) |
void | addTarget (const Publication &pub, std::string_view target) |
void | addTarget (const Input &inp, std::string_view target) |
void | removeTarget (const Publication &pub, std::string_view target) |
void | removeTarget (const Input &inp, std::string_view target) |
void | setDefaultValue (const Input &inp, const data_view &block) |
data_view | getValue (const Input &inp) |
void | publish (const Publication &pub, const data_view &block) |
void | updateTime (Time newTime, Time oldTime) |
void | startupToInitializeStateTransition () |
void | initializeToExecuteStateTransition (iteration_time result) |
std::string | localQuery (std::string_view queryStr) const |
std::vector< int > | queryUpdates () |
const std::string & | getTarget (const Input &inp) const |
Input & | getInput (std::string_view key) |
const Input & | getInput (std::string_view key) const |
Input & | getInput (int index) |
const Input & | getInput (int index) const |
const Input & | getInputByTarget (std::string_view key) const |
Input & | getInputByTarget (std::string_view key) |
Publication & | getPublication (std::string_view key) |
const Publication & | getPublication (std::string_view key) const |
Publication & | getPublication (int index) |
const Publication & | getPublication (int index) const |
void | setInputNotificationCallback (std::function< void(Input &, Time)> callback) |
void | disconnect () |
int | getPublicationCount () const |
int | getInputCount () const |
void | clearUpdates () |
bool | getUpdateFromCore (Input &inp) |
Static Public Member Functions | |
static bool | hasUpdate (const Input &inp) |
static Time | getLastUpdateTime (const Input &inp) |
static void | setInputNotificationCallback (const Input &inp, std::function< void(Input &, Time)> callback) |
static void | clearUpdate (const Input &inp) |
Public Attributes | |
bool | useJsonSerialization {false} |
all outgoing data should be serialized as JSON | |
class handling the implementation details of a value Federate
void helics::ValueFederateManager::addAlias | ( | const Input & | inp, |
std::string_view | shortcutName | ||
) |
add a shortcut for locating a subscription
primarily for use in looking up an id from a different location creates a local shortcut for referring to a subscription which may have a long actual name
inp | the subscription identifier |
shortcutName | the name of the shortcut |
References helics::Interface::getName(), helics::Interface::handle, and helics::Interface::isValid().
void helics::ValueFederateManager::addAlias | ( | const Publication & | pub, |
std::string_view | shortcutName | ||
) |
add a alias/shortcut for locating a publication
primarily for use in looking up an id from a different location creates a local shortcut for referring to a subscription which may have a long actual name
pub | the subscription identifier |
shortcutName | the name of the shortcut |
References helics::Interface::getName(), helics::Interface::handle, and helics::Interface::isValid().
void helics::ValueFederateManager::addTarget | ( | const Input & | inp, |
std::string_view | target | ||
) |
add a source target to an input/subscription
inp | the identifier of the publication |
target | the name of the input to send the data to |
References helics::Input::getDisplayName(), and helics::Interface::handle.
void helics::ValueFederateManager::addTarget | ( | const Publication & | pub, |
std::string_view | target | ||
) |
add a destination target to a publication
pub | the identifier of the input |
target | the name of the input to send the data to |
References helics::Interface::handle.
|
static |
clear an input value as updated without actually retrieving it
inp | the identifier for the subscription |
References helics::InputData::hasUpdate.
void helics::ValueFederateManager::clearUpdates | ( | ) |
clear all the updates
after this call isUpdated on all the internal objects will return false
References helics::Input::clearUpdate().
void helics::ValueFederateManager::disconnect | ( | ) |
disconnect from the coreObject
disconnect to an empty Core which does nothing
Input & helics::ValueFederateManager::getInput | ( | int | index | ) |
get an input by index
References helics::isValidIndex().
Input & helics::ValueFederateManager::getInput | ( | std::string_view | key | ) |
const Input & helics::ValueFederateManager::getInputByTarget | ( | std::string_view | key | ) | const |
get the id of an by the target name
key | the target of a input |
int helics::ValueFederateManager::getInputCount | ( | ) | const |
get a count of the number subscriptions registered
get a count of the number inputs registered
get the time of the last update
References helics::InputData::lastUpdate.
Publication & helics::ValueFederateManager::getPublication | ( | std::string_view | key | ) |
get a publication based on its key
key | the publication id |
int helics::ValueFederateManager::getPublicationCount | ( | ) | const |
get a count of the number publications registered
const std::string & helics::ValueFederateManager::getTarget | ( | const Input & | inp | ) | const |
get the target of a input
References helics::Interface::handle.
get a value as raw data block from the system
inp | the identifier for the subscription |
References helics::InputData::lastQuery.
|
static |
check if a given subscription has and update
References helics::InputData::hasUpdate.
void helics::ValueFederateManager::initializeToExecuteStateTransition | ( | iteration_time | result | ) |
transition from initialize to execution State
References helics::iteration_time::grantedTime, and helics::initializationTime.
std::string helics::ValueFederateManager::localQuery | ( | std::string_view | queryStr | ) | const |
generate results for a local query
References helics::fileops::JsonBuilder::addElement(), helics::Input::checkUpdate(), helics::fileops::JsonBuilder::generate(), helics::Input::getDisplayName(), helics::Input::getHelicsInjectionType(), helics::Input::getHelicsType(), and helics::Input::isUpdated().
void helics::ValueFederateManager::publish | ( | const Publication & | pub, |
const data_view & | block | ||
) |
publish a value
References helics::data_view::data(), helics::Interface::handle, and helics::data_view::size().
std::vector< int > helics::ValueFederateManager::queryUpdates | ( | ) |
get a list of all the values that have been updated since the last call
Input & helics::ValueFederateManager::registerInput | ( | std::string_view | key, |
std::string_view | type, | ||
std::string_view | units | ||
) |
void helics::ValueFederateManager::removeTarget | ( | const Input & | inp, |
std::string_view | target | ||
) |
remove a source target from an input/subscription
inp | the identifier of the publication |
target | the name of the publication to remove |
References helics::Interface::handle.
void helics::ValueFederateManager::removeTarget | ( | const Publication & | pub, |
std::string_view | target | ||
) |
remove a destination target from a publication
pub | the identifier of the input |
target | the name of the input to remove |
References helics::Interface::handle.
set the default value for a subscription
this is the value returned prior to any publications
inp | the subscription identifier |
block | the data block representing the default value |
copy the data first since we are not entirely sure of the lifetime of the data_view
References helics::data_view::data(), helics::Interface::isValid(), helics::InputData::lastData, and helics::data_view::size().
|
static |
register a callback function to call when the specified subscription is updated
inp | the id to register the callback for |
callback | the function to call |
References helics::InputData::callback.
void helics::ValueFederateManager::setInputNotificationCallback | ( | std::function< void(Input &, Time)> | callback | ) |
register a callback function to call when any subscribed value is updated
there can only be one generic callback
callback | the function to call |
void helics::ValueFederateManager::startupToInitializeStateTransition | ( | ) |
transition from Startup To the Initialize State
update the time from oldTime to newTime
newTime | the newTime of the federate |
oldTime | the oldTime of the federate |
find the id
References helics::InputData::lastUpdate.