helics  2.8.1
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
helics::ValueFederateManager Class Reference

#include <ValueFederateManager.hpp>

Public Member Functions

 ValueFederateManager (Core *coreOb, ValueFederate *vfed, local_federate_id id)
 
PublicationregisterPublication (const std::string &key, std::string type, const std::string &units)
 
InputregisterInput (const std::string &key, std::string type, const std::string &units)
 
void addAlias (const Input &inp, const std::string &shortcutName)
 
void addAlias (const Publication &pub, const std::string &shortcutName)
 
void addTarget (const Publication &pub, const std::string &target)
 
void addTarget (const Input &inp, const std::string &target)
 
void removeTarget (const Publication &pub, const std::string &target)
 
void removeTarget (const Input &inp, const std::string &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_result result)
 
std::string localQuery (const std::string &queryStr) const
 
std::vector< int > queryUpdates ()
 
const std::string & getTarget (const Input &inp) const
 
InputgetInput (const std::string &key)
 
const InputgetInput (const std::string &key) const
 
InputgetInput (int index)
 
const InputgetInput (int index) const
 
const InputgetSubscription (const std::string &key) const
 
InputgetSubscription (const std::string &key)
 
PublicationgetPublication (const std::string &key)
 
const PublicationgetPublication (const std::string &key) const
 
PublicationgetPublication (int index)
 
const PublicationgetPublication (int index) const
 
void setInputNotificationCallback (std::function< void(Input &, Time)> callback)
 
void disconnect ()
 
int getPublicationCount () const
 
int getInputCount () const
 
void clearUpdates ()
 

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
 

Detailed Description

class handling the implementation details of a value Federate

Member Function Documentation

◆ addAlias() [1/2]

void helics::ValueFederateManager::addAlias ( const Input inp,
const std::string &  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

Parameters
inpthe subscription identifier
shortcutNamethe name of the shortcut

References helics::Input::handle, and helics::Input::isValid().

◆ addAlias() [2/2]

void helics::ValueFederateManager::addAlias ( const Publication pub,
const std::string &  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

Parameters
pubthe subscription identifier
shortcutNamethe name of the shortcut

References helics::Publication::handle, and helics::Publication::isValid().

◆ addTarget() [1/2]

void helics::ValueFederateManager::addTarget ( const Input inp,
const std::string &  target 
)

add a source target to an input/subscription

Parameters
inpthe identifier of the publication
targetthe name of the input to send the data to

References fed, and helics::Input::handle.

◆ addTarget() [2/2]

void helics::ValueFederateManager::addTarget ( const Publication pub,
const std::string &  target 
)

add a destination target to a publication

Parameters
pubthe identifier of the input
targetthe name of the input to send the data to

References helics::Publication::handle.

◆ clearUpdate()

void helics::ValueFederateManager::clearUpdate ( const Input inp)
static

clear an input value as updated without actually retrieving it

Parameters
inpthe identifier for the subscription

References helics::input_info::hasUpdate.

◆ clearUpdates()

void helics::ValueFederateManager::clearUpdates ( )

clear all the updates

after this call isUpdated on all the internal objects will return false

◆ disconnect()

void helics::ValueFederateManager::disconnect ( )

disconnect from the coreObject

◆ getInput() [1/2]

Input & helics::ValueFederateManager::getInput ( const std::string &  key)

get an Input from Its Name

Parameters
keythe identifier or shortcut of the input
Returns
ivalid_input_id if name is not a recognized

◆ getInput() [2/2]

Input & helics::ValueFederateManager::getInput ( int  index)

get an input by index

References helics::isValidIndex().

◆ getInputCount()

int helics::ValueFederateManager::getInputCount ( ) const

get a count of the number subscriptions registered

get a count of the number inputs registered

◆ getLastUpdateTime()

Time helics::ValueFederateManager::getLastUpdateTime ( const Input inp)
static

get the time of the last update

References helics::input_info::lastUpdate.

◆ getPublication()

Publication & helics::ValueFederateManager::getPublication ( const std::string &  key)

get a publication based on its key

Parameters
keythe publication id
Returns
ivalid_publication_id if name is not recognized otherwise returns the publication_id

◆ getPublicationCount()

int helics::ValueFederateManager::getPublicationCount ( ) const

get a count of the number publications registered

◆ getSubscription()

const Input & helics::ValueFederateManager::getSubscription ( const std::string &  key) const

get the id of a subscription

Parameters
keythe target of a subscription
Returns
ivalid_input_id if name is not a recognized

◆ getTarget()

const std::string & helics::ValueFederateManager::getTarget ( const Input inp) const

get the target of a input

References helics::Input::handle.

◆ getValue()

data_view helics::ValueFederateManager::getValue ( const Input inp)

get a value as raw data block from the system

Parameters
inpthe identifier for the subscription
Returns
a constant data block

References helics::input_info::lastQuery.

◆ hasUpdate()

bool helics::ValueFederateManager::hasUpdate ( const Input inp)
static

check if a given subscription has and update

References helics::input_info::hasUpdate.

◆ initializeToExecuteStateTransition()

void helics::ValueFederateManager::initializeToExecuteStateTransition ( iteration_result  result)

transition from initialize to execution State

References helics::initializationTime, and helics::timeZero.

◆ localQuery()

std::string helics::ValueFederateManager::localQuery ( const std::string &  queryStr) const

generate results for a local query

References helics::JsonBuilder::addElement(), and helics::JsonBuilder::generate().

◆ publish()

void helics::ValueFederateManager::publish ( const Publication pub,
const data_view block 
)

◆ queryUpdates()

std::vector< int > helics::ValueFederateManager::queryUpdates ( )

get a list of all the values that have been updated since the last call

Returns
a vector of subscription_ids with all the values that have not been retrieved since updated

◆ registerInput()

Input & helics::ValueFederateManager::registerInput ( const std::string &  key,
std::string  type,
const std::string &  units 
)

register a subscription

call is only valid in startup mode

References fed.

◆ removeTarget() [1/2]

void helics::ValueFederateManager::removeTarget ( const Input inp,
const std::string &  target 
)

remove a source target from an input/subscription

Parameters
inpthe identifier of the publication
targetthe name of the publication to remove

References helics::Input::handle.

◆ removeTarget() [2/2]

void helics::ValueFederateManager::removeTarget ( const Publication pub,
const std::string &  target 
)

remove a destination target from a publication

Parameters
pubthe identifier of the input
targetthe name of the input to remove

References helics::Publication::handle.

◆ setDefaultValue()

void helics::ValueFederateManager::setDefaultValue ( const Input inp,
const data_view block 
)

set the default value for a subscription

this is the value returned prior to any publications

Parameters
inpthe subscription identifier
blockthe 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::Input::isValid(), helics::input_info::lastData, and helics::data_view::size().

◆ setInputNotificationCallback() [1/2]

void helics::ValueFederateManager::setInputNotificationCallback ( const Input inp,
std::function< void(Input &, Time)>  callback 
)
static

register a callback function to call when the specified subscription is updated

Parameters
inpthe id to register the callback for
callbackthe function to call

References helics::input_info::callback.

◆ setInputNotificationCallback() [2/2]

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

Parameters
callbackthe function to call

◆ startupToInitializeStateTransition()

void helics::ValueFederateManager::startupToInitializeStateTransition ( )

transition from Startup To the Initialize State

◆ updateTime()

void helics::ValueFederateManager::updateTime ( Time  newTime,
Time  oldTime 
)

update the time from oldTime to newTime

Parameters
newTimethe newTime of the federate
oldTimethe oldTime of the federate

find the id

References data, and helics::input_info::lastUpdate.


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