helics
3.5.3
|
#include <Inputs.hpp>
Public Member Functions | |
Input ()=default | |
Input (ValueFederate *valueFed, InterfaceHandle id, std::string_view actName, std::string_view unitsOut={}) | |
Input (ValueFederate *valueFed, std::string_view key, std::string_view defaultType="def", std::string_view units={}) | |
template<class FedPtr > | |
Input (FedPtr &valueFed, std::string_view key, std::string_view defaultType="def", std::string_view units={}) | |
Input (InterfaceVisibility locality, ValueFederate *valueFed, std::string_view key, std::string_view defaultType="def", std::string_view units={}) | |
template<class FedPtr > | |
Input (InterfaceVisibility locality, FedPtr &valueFed, std::string_view key, std::string_view defaultType="def", std::string_view units={}) | |
Input (ValueFederate *valueFed, std::string_view key, DataType defType, std::string_view units={}) | |
template<class FedPtr > | |
Input (FedPtr &valueFed, std::string_view key, DataType defType, std::string_view units={}) | |
Input (InterfaceVisibility locality, ValueFederate *valueFed, std::string_view key, std::string_view units={}) | |
template<class FedPtr > | |
Input (InterfaceVisibility locality, FedPtr &valueFed, std::string_view key, std::string_view units={}) | |
Input (InterfaceVisibility locality, ValueFederate *valueFed, std::string_view key, DataType defType, std::string_view units={}) | |
template<class FedPtr > | |
Input (InterfaceVisibility locality, FedPtr &valueFed, std::string_view key, DataType defType, std::string_view units={}) | |
Time | getLastUpdate () const |
void | registerNotificationCallback (std::function< void(Time)> callback) |
const std::string & | getPublicationType () const |
const std::string & | getType () const |
const std::string & | getUnits () const |
void | addPublication (std::string_view target) |
void | addTarget (std::string_view target) |
bool | checkUpdate (bool assumeUpdate=false) |
void | clearUpdate () |
bool | isUpdated () |
bool | isUpdated () const |
virtual void | setOption (int32_t option, int32_t value=1) override |
virtual int32_t | getOption (int32_t option) const override |
template<class X > | |
void | setInputNotificationCallback (std::function< void(const X &, Time)> callback) |
template<class X > | |
void | setDefault (X &&val) |
void | setDefaultBytes (data_view val) |
void | setMinimumChange (double deltaV) noexcept |
void | enableChangeDetection (bool enabled=true) noexcept |
int | getValue (double *data, int maxsize) |
int | getComplexValue (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 () |
double | getDouble () |
const std::string & | getString () |
data_view | getBytes () |
size_t | getByteCount () |
size_t | getStringSize () |
size_t | getVectorSize () |
DataType | getHelicsType () const |
DataType | getHelicsInjectionType () const |
MultiInputHandlingMethod | getMultiInputMode () const |
bool | vectorDataProcess (const std::vector< std::shared_ptr< const SmallBuffer >> &dataV) |
const std::string & | getTarget () const |
virtual const std::string & | getDisplayName () const override |
Public Member Functions inherited from helics::Interface | |
Interface (Federate *federate, InterfaceHandle hid, std::string_view actName) | |
Interface (Core *core, InterfaceHandle hid, std::string_view actName) | |
InterfaceHandle | getHandle () const |
operator InterfaceHandle () const | |
bool | isValid () const |
bool | operator< (const Interface &inp) const |
bool | operator> (const Interface &inp) const |
bool | operator== (const Interface &inp) const |
bool | operator!= (const Interface &inp) const |
const std::string & | getLocalName () const |
const std::string & | getName () const |
const std::string & | getTarget () const |
void | addSourceTarget (std::string_view newTarget, InterfaceType hint=InterfaceType::UNKNOWN) |
void | addDestinationTarget (std::string_view newTarget, InterfaceType hint=InterfaceType::UNKNOWN) |
void | removeTarget (std::string_view targetToRemove) |
void | addAlias (std::string_view alias) |
const std::string & | getInfo () const |
void | setInfo (std::string_view info) |
void | setTag (std::string_view tag, std::string_view value) |
const std::string & | getTag (std::string_view tag) const |
const std::string & | getInjectionType () const |
const std::string & | getExtractionType () const |
const std::string & | getInjectionUnits () const |
const std::string & | getExtractionUnits () const |
const std::string & | getSourceTargets () const |
const std::string & | getDestinationTargets () const |
std::size_t | getSourceTargetCount () const |
std::size_t | getDestinationTargetCount () const |
void | close () |
void | disconnectFromCore () |
Protected Attributes | |
ValueFederate * | fed = nullptr |
reference to the value federate | |
Protected Attributes inherited from helics::Interface | |
Core * | mCore {nullptr} |
pointer to the core object | |
InterfaceHandle | handle {} |
the id as generated by the Federate | |
std::string | mName |
the name or key of the interface | |
Friends | |
class | ValueFederateManager |
base class for a input object
|
default |
Default constructor
helics::Input::Input | ( | ValueFederate * | valueFed, |
InterfaceHandle | id, | ||
std::string_view | actName, | ||
std::string_view | unitsOut = {} |
||
) |
construct from a federate and handle, mainly used by the valueFederateManager
void helics::Input::addPublication | ( | std::string_view | target | ) |
add a publication for the inputs information
References helics::ValueFederate::addTarget(), and fed.
|
inline |
add a target to the input
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::getBytes(), and helics::ValueFederate::isUpdated().
Referenced by isUpdated(), and helics::ValueFederateManager::localQuery().
void helics::Input::clearUpdate | ( | ) |
clear the isUpdated flag
References helics::ValueFederate::clearUpdate(), and fed.
Referenced by helics::ValueFederateManager::clearUpdates().
|
inlinenoexcept |
enable change detection
enabled | (optional) set to false to disable change detection true(default) to enable it |
size_t helics::Input::getByteCount | ( | ) |
get the size of the raw data
References fed, helics::ValueFederate::getBytes(), and isUpdated().
data_view helics::Input::getBytes | ( | ) |
get the raw binary data
References fed, and helics::ValueFederate::getBytes().
int helics::Input::getComplexValue | ( | double * | data, |
int | maxsize | ||
) |
get a complex double vector value functions to retrieve data by a C array of doubles
|
inlineoverridevirtual |
get the display name for an input
the name is the given local name or if empty the name of the target
Implements helics::Interface.
Referenced by helics::ValueFederateManager::addTarget(), and helics::ValueFederateManager::localQuery().
|
inline |
get the current value as a Double
|
inline |
get the HELICS data type for the publication
Referenced by helics::ValueFederateManager::localQuery().
|
inline |
get the HELICS data type for the input
Referenced by helics::ValueFederateManager::localQuery().
Time helics::Input::getLastUpdate | ( | ) | const |
get the time of the last update
References fed, and helics::ValueFederate::getLastUpdateTime().
|
overridevirtual |
get the current value of a flag for the handle
Reimplemented from helics::Interface.
References helics::Interface::getOption(), and HELICS_HANDLE_OPTION_MULTI_INPUT_HANDLING_METHOD.
|
inline |
get the type of the data coming from the publication
|
inline |
get the current value as a string
size_t helics::Input::getStringSize | ( | ) |
get the size of the data if it were a string
References isUpdated().
|
inline |
get the type of the input
|
inline |
get the units associated with a input
|
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
|
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 getByteCount(), getStringSize(), getVectorSize(), helics::ValueFederateManager::localQuery(), and registerNotificationCallback().
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.
References fed, and helics::ValueFederate::isUpdated().
void helics::Input::registerNotificationCallback | ( | std::function< void(Time)> | callback | ) |
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) where time is the time the value was updated. This callback is a notification callback and doesn't return the value |
References fed, isUpdated(), and helics::ValueFederate::setInputNotificationCallback().
|
inline |
set the default value to use before any update has been published
|
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 |
|
overridevirtual |
set a handle flag for the input
Reimplemented from helics::Interface.
References HELICS_HANDLE_OPTION_MULTI_INPUT_HANDLING_METHOD, and helics::Interface::setOption().