![]() |
helics
2.8.1
|
#include <Inputs.hpp>
Public Member Functions | |
Input ()=default | |
Input (ValueFederate *valueFed, interface_handle id, const std::string &actName, const std::string &unitsOut=std::string{}) | |
Input (ValueFederate *valueFed, const std::string &key, const std::string &defaultType="def", const std::string &units=std::string{}) | |
template<class FedPtr > | |
Input (FedPtr &valueFed, const std::string &key, const std::string &defaultType="def", const std::string &units=std::string{}) | |
Input (interface_visibility locality, ValueFederate *valueFed, const std::string &key, const std::string &defaultType="def", const std::string &units=std::string{}) | |
template<class FedPtr > | |
Input (interface_visibility locality, FedPtr &valueFed, const std::string &name, const std::string &defaultType="def", const std::string &units=std::string{}) | |
Input (ValueFederate *valueFed, const std::string &name, data_type defType, const std::string &units=std::string{}) | |
template<class FedPtr > | |
Input (FedPtr &valueFed, const std::string &name, data_type defType, const std::string &units=std::string()) | |
Input (interface_visibility locality, ValueFederate *valueFed, const std::string &name, const std::string &units=std::string{}) | |
template<class FedPtr > | |
Input (interface_visibility locality, FedPtr &valueFed, const std::string &key, const std::string &units=std::string{}) | |
Input (interface_visibility locality, ValueFederate *valueFed, const std::string &name, data_type defType, const std::string &units=std::string{}) | |
template<class FedPtr > | |
Input (interface_visibility locality, FedPtr &valueFed, const std::string &name, data_type defType, const std::string &units=std::string{}) | |
Time | getLastUpdate () const |
interface_handle | getHandle () const |
operator interface_handle () const | |
bool | isValid () const |
bool | operator< (const Input &inp) const |
bool | operator> (const Input &inp) const |
void | registerNotificationCallback (std::function< void(Time)> callback) |
const std::string & | getName () const |
const std::string & | getKey () const |
const std::string & | getDisplayName () const |
const std::string & | getPublicationType () const |
const std::string & | getType () const |
const std::string & | getUnits () const |
const std::string & | getInjectionUnits () const |
const std::string & | getTarget () const |
void | addTarget (const std::string &newTarget) |
void | removeTarget (const std::string &targetToRemove) |
const std::string & | getInfo () const |
void | setInfo (const std::string &info) |
void | setOption (int32_t option, int32_t value=1) |
int32_t | getOption (int32_t option) const |
bool | checkUpdate (bool assumeUpdate=false) |
void | clearUpdate () |
bool | isUpdated () |
bool | isUpdated () const |
template<class X > | |
void | setInputNotificationCallback (std::function< void(const X &, Time)> callback) |
template<class X > | |
void | setDefault (X &&val) |
void | setMinimumChange (double deltaV) noexcept |
void | enableChangeDetection (bool enabled=true) noexcept |
int | getValue (double *data, int maxsize) |
int | getValue (char *str, int maxsize) |
template<class X > | |
void | getValue (X &out) |
template<class X > | |
auto | getValue () |
template<class X > | |
const X & | getValueRef () |
data_view | getRawValue () |
size_t | getRawSize () |
size_t | getStringSize () |
size_t | getVectorSize () |
void | close () |
data_type | getHelicsType () const |
data_type | getHelicsInjectionType () const |
multi_input_handling_method | getMultiInputMode () const |
bool | vectorDataProcess (const std::vector< std::shared_ptr< const data_block >> &dataV) |
Protected Attributes | |
ValueFederate * | fed = nullptr |
reference to the value federate | |
interface_handle | handle |
the id as generated by the Federate | |
Friends | |
class | ValueFederateManager |
base class for a input object
|
default |
Default constructor
helics::Input::Input | ( | ValueFederate * | valueFed, |
interface_handle | id, | ||
const std::string & | actName, | ||
const std::string & | unitsOut = std::string{} |
||
) |
construct from a federate and handle, mainly used by the valueFederateManager
|
inline |
subscribe to a named publication
References fed.
bool helics::Input::checkUpdate | ( | bool | assumeUpdate = false | ) |
check if the value has been updated
if changeDetection is Enabled this function also loads the value into the buffer
assumeUpdate | if set to true will assume there was a publication and not check it first, if set to false[default] it will check the federate first |
References fed, helics::ValueFederate::getValueRaw(), and helics::ValueFederate::isUpdated().
Referenced by isUpdated().
void helics::Input::clearUpdate | ( | ) |
clear the isUpdated flag
References helics::ValueFederate::clearUpdate(), and fed.
|
inline |
close a input during an active simulation
it is not necessary to call this function unless you are continuing the simulation after the close
References fed.
|
inlinenoexcept |
enable change detection
enabled | (optional) set to false to disable change detection true(default) to enable it |
|
inline |
get the display name for an input
the name is the given local name or if empty the name of the target
|
inline |
get the underlying handle that can be used to make direct calls to the Core API
|
inline |
get the HELICS data type for the publication
|
inline |
get the HELICS data type for the input
|
inline |
get the interface information field of the input
References fed.
|
inline |
get the units associated with a input
References fed.
|
inline |
get the Name/Key for the input
the name is the local name if given, key is the full key name
References fed.
|
inline |
|
inline |
get the Name/Key for the input
the name is the local name if given, key is the full key name
int32_t helics::Input::getOption | ( | int32_t | option | ) | const |
get the current value of a flag for the handle
References fed, helics::Federate::getInterfaceOption(), handle, and helics_handle_option_multi_input_handling_method.
|
inline |
get the type of the data coming from the publication
size_t helics::Input::getRawSize | ( | ) |
get the size of the raw data
References fed, helics::ValueFederate::getValueRaw(), and isUpdated().
data_view helics::Input::getRawValue | ( | ) |
get the raw binary data
References fed, and helics::ValueFederate::getValueRaw().
size_t helics::Input::getStringSize | ( | ) |
get the size of the data if it were a string
References isUpdated().
|
inline |
get an associated target
References fed.
|
inline |
get the type of the input
References fed.
|
inline |
get the units associated with a input
References fed.
|
inline |
get the most recent value
int helics::Input::getValue | ( | char * | str, |
int | maxsize | ||
) |
get string value functions to retrieve data by a C string
int helics::Input::getValue | ( | double * | data, |
int | maxsize | ||
) |
get double vector value functions to retrieve data by a C array of doubles
References data.
Referenced by helics::ValueFederate::getDouble().
|
inline |
get the latest value for the input
[out] | out | the location to store the value |
size_t helics::Input::getVectorSize | ( | ) |
get the number of elements in the data if it were a vector
References isUpdated().
bool helics::Input::isUpdated | ( | ) |
check if the value has been updated including interpretation of the change detection
References checkUpdate().
Referenced by getRawSize(), getStringSize(), and getVectorSize().
bool helics::Input::isUpdated | ( | ) | const |
check if the value has been updated,
the const version can in some circumstances return true even if the value would not be updated the circumstances in which this is true are a minimum change has been set, checkUpdate has not been call(meaning it is a standalone copy, not the one stored with the federate, and the value has been published but would not trigger the change detection. If this is to be avoided use the non-const version or call checkUpdate before calling this function.
|
inline |
check if the Publication links to a valid operation
Referenced by helics::ValueFederateManager::addAlias(), and helics::ValueFederateManager::setDefaultValue().
|
inline |
implicit conversion operator for extracting the handle
|
inline |
register a callback for an update notification
the callback is called in the just before the time request function returns
callback | a function with signature void( Time time) time is the time the value was updated This callback is a notification callback and doesn't return the value |
References fed.
|
inline |
remove a named publication from being a target
References fed.
|
inline |
set the default value to use before any update has been published
Referenced by helics::InputT< X >::setDefault().
|
inline |
set the interface information field of the input
References fed.
|
inline |
register a callback for the update
the callback is called in the just before the time request function returns
callback | a function with signature void(X val, Time time) val is the new value and time is the time the value was updated |
|
inlinenoexcept |
set the minimum delta for change detection
deltaV | a double with the change in a value in order to register a different value |
void helics::Input::setOption | ( | int32_t | option, |
int32_t | value = 1 |
||
) |
set a handle flag for the input
References fed, handle, helics_handle_option_multi_input_handling_method, and helics::Federate::setInterfaceOption().