helics  2.8.1
Functions
ValueFederate.h File Reference

Functions related to value federates for the C api. More...

#include "helics.h"

Go to the source code of this file.

Functions

helics_input helicsFederateRegisterSubscription (helics_federate fed, const char *key, const char *units, helics_error *err)
 
helics_publication helicsFederateRegisterPublication (helics_federate fed, const char *key, helics_data_type type, const char *units, helics_error *err)
 
helics_publication helicsFederateRegisterTypePublication (helics_federate fed, const char *key, const char *type, const char *units, helics_error *err)
 
helics_publication helicsFederateRegisterGlobalPublication (helics_federate fed, const char *key, helics_data_type type, const char *units, helics_error *err)
 
helics_publication helicsFederateRegisterGlobalTypePublication (helics_federate fed, const char *key, const char *type, const char *units, helics_error *err)
 
helics_input helicsFederateRegisterInput (helics_federate fed, const char *key, helics_data_type type, const char *units, helics_error *err)
 
helics_input helicsFederateRegisterTypeInput (helics_federate fed, const char *key, const char *type, const char *units, helics_error *err)
 
helics_publication helicsFederateRegisterGlobalInput (helics_federate fed, const char *key, helics_data_type type, const char *units, helics_error *err)
 
helics_publication helicsFederateRegisterGlobalTypeInput (helics_federate fed, const char *key, const char *type, const char *units, helics_error *err)
 
helics_publication helicsFederateGetPublication (helics_federate fed, const char *key, helics_error *err)
 
helics_publication helicsFederateGetPublicationByIndex (helics_federate fed, int index, helics_error *err)
 
helics_input helicsFederateGetInput (helics_federate fed, const char *key, helics_error *err)
 
helics_input helicsFederateGetInputByIndex (helics_federate fed, int index, helics_error *err)
 
helics_input helicsFederateGetSubscription (helics_federate fed, const char *key, helics_error *err)
 
void helicsFederateClearUpdates (helics_federate fed)
 
void helicsFederateRegisterFromPublicationJSON (helics_federate fed, const char *json, helics_error *err)
 
void helicsFederatePublishJSON (helics_federate fed, const char *json, helics_error *err)
 
helics_bool helicsPublicationIsValid (helics_publication pub)
 
void helicsPublicationPublishRaw (helics_publication pub, const void *data, int inputDataLength, helics_error *err)
 
void helicsPublicationPublishString (helics_publication pub, const char *str, helics_error *err)
 
void helicsPublicationPublishInteger (helics_publication pub, int64_t val, helics_error *err)
 
void helicsPublicationPublishBoolean (helics_publication pub, helics_bool val, helics_error *err)
 
void helicsPublicationPublishDouble (helics_publication pub, double val, helics_error *err)
 
void helicsPublicationPublishTime (helics_publication pub, helics_time val, helics_error *err)
 
void helicsPublicationPublishChar (helics_publication pub, char val, helics_error *err)
 
void helicsPublicationPublishComplex (helics_publication pub, double real, double imag, helics_error *err)
 
void helicsPublicationPublishVector (helics_publication pub, const double *vectorInput, int vectorLength, helics_error *err)
 
void helicsPublicationPublishNamedPoint (helics_publication pub, const char *str, double val, helics_error *err)
 
void helicsPublicationAddTarget (helics_publication pub, const char *target, helics_error *err)
 
helics_bool helicsInputIsValid (helics_input ipt)
 
void helicsInputAddTarget (helics_input ipt, const char *target, helics_error *err)
 
int helicsInputGetRawValueSize (helics_input ipt)
 
void helicsInputGetRawValue (helics_input ipt, void *data, int maxDataLength, int *actualSize, helics_error *err)
 
int helicsInputGetStringSize (helics_input ipt)
 
void helicsInputGetString (helics_input ipt, char *outputString, int maxStringLength, int *actualLength, helics_error *err)
 
int64_t helicsInputGetInteger (helics_input ipt, helics_error *err)
 
helics_bool helicsInputGetBoolean (helics_input ipt, helics_error *err)
 
double helicsInputGetDouble (helics_input ipt, helics_error *err)
 
helics_time helicsInputGetTime (helics_input ipt, helics_error *err)
 
char helicsInputGetChar (helics_input ipt, helics_error *err)
 
helics_complex helicsInputGetComplexObject (helics_input ipt, helics_error *err)
 
void helicsInputGetComplex (helics_input ipt, double *real, double *imag, helics_error *err)
 
int helicsInputGetVectorSize (helics_input ipt)
 
void helicsInputGetVector (helics_input ipt, double data[], int maxLength, int *actualSize, helics_error *err)
 
void helicsInputGetNamedPoint (helics_input ipt, char *outputString, int maxStringLength, int *actualLength, double *val, helics_error *err)
 
void helicsInputSetDefaultRaw (helics_input ipt, const void *data, int inputDataLength, helics_error *err)
 
void helicsInputSetDefaultString (helics_input ipt, const char *str, helics_error *err)
 
void helicsInputSetDefaultInteger (helics_input ipt, int64_t val, helics_error *err)
 
void helicsInputSetDefaultBoolean (helics_input ipt, helics_bool val, helics_error *err)
 
void helicsInputSetDefaultTime (helics_input ipt, helics_time val, helics_error *err)
 
void helicsInputSetDefaultChar (helics_input ipt, char val, helics_error *err)
 
void helicsInputSetDefaultDouble (helics_input ipt, double val, helics_error *err)
 
void helicsInputSetDefaultComplex (helics_input ipt, double real, double imag, helics_error *err)
 
void helicsInputSetDefaultVector (helics_input ipt, const double *vectorInput, int vectorLength, helics_error *err)
 
void helicsInputSetDefaultNamedPoint (helics_input ipt, const char *str, double val, helics_error *err)
 
const char * helicsInputGetType (helics_input ipt)
 
const char * helicsInputGetPublicationType (helics_input ipt)
 
const char * helicsPublicationGetType (helics_publication pub)
 
const char * helicsInputGetKey (helics_input ipt)
 
const char * helicsSubscriptionGetKey (helics_input ipt)
 
const char * helicsPublicationGetKey (helics_publication pub)
 
const char * helicsInputGetUnits (helics_input ipt)
 
const char * helicsInputGetInjectionUnits (helics_input ipt)
 
const char * helicsInputGetExtractionUnits (helics_input ipt)
 
const char * helicsPublicationGetUnits (helics_publication pub)
 
const char * helicsInputGetInfo (helics_input inp)
 
void helicsInputSetInfo (helics_input inp, const char *info, helics_error *err)
 
const char * helicsPublicationGetInfo (helics_publication pub)
 
void helicsPublicationSetInfo (helics_publication pub, const char *info, helics_error *err)
 
int helicsInputGetOption (helics_input inp, int option)
 
void helicsInputSetOption (helics_input inp, int option, int value, helics_error *err)
 
int helicsPublicationGetOption (helics_publication pub, int option)
 
void helicsPublicationSetOption (helics_publication pub, int option, int val, helics_error *err)
 
void helicsPublicationSetMinimumChange (helics_publication pub, double tolerance, helics_error *err)
 
void helicsInputSetMinimumChange (helics_input inp, double tolerance, helics_error *err)
 
helics_bool helicsInputIsUpdated (helics_input ipt)
 
helics_time helicsInputLastUpdateTime (helics_input ipt)
 
void helicsInputClearUpdate (helics_input ipt)
 
int helicsFederateGetPublicationCount (helics_federate fed)
 
int helicsFederateGetInputCount (helics_federate fed)
 

Detailed Description

Functions related to value federates for the C api.

Function Documentation

◆ helicsFederateClearUpdates()

void helicsFederateClearUpdates ( helics_federate  fed)

Clear all the update flags from a federates inputs.

Parameters
fedThe value federate object for which to clear update flags.

References fed.

Referenced by helicscpp::ValueFederate::clearUpdates().

◆ helicsFederateGetInput()

helics_input helicsFederateGetInput ( helics_federate  fed,
const char *  key,
helics_error err 
)

Get an input object from a key.

Parameters
fedThe value federate object to use to get the publication.
keyThe name of the input. @forcpponly
[in,out]errThe error object to complete if there is an error. @endforcpponly
Returns
A helics_input object, the object will not be valid and err will contain an error code if no input with the specified key exists.

References fed, and helics_error_invalid_argument.

Referenced by helicscpp::ValueFederate::getInput().

◆ helicsFederateGetInputByIndex()

helics_input helicsFederateGetInputByIndex ( helics_federate  fed,
int  index,
helics_error err 
)

Get an input by its index, typically already created via registerInterfaces file or something of that nature.

Parameters
fedThe federate object in which to create a publication.
indexThe index of the publication to get. @forcpponly
[in,out]errA pointer to an error object for catching errors. @endforcpponly
Returns
A helics_input, which will be NULL if an invalid index.

References fed, and helics_error_invalid_argument.

Referenced by helicscpp::ValueFederate::getSubscription().

◆ helicsFederateGetInputCount()

int helicsFederateGetInputCount ( helics_federate  fed)

Get the number of subscriptions in a federate.

Returns
(-1) if fed was not a valid federate otherwise returns the number of subscriptions.

References fed.

Referenced by helicscpp::ValueFederate::getInputCount().

◆ helicsFederateGetPublication()

helics_publication helicsFederateGetPublication ( helics_federate  fed,
const char *  key,
helics_error err 
)

Get a publication object from a key.

Parameters
fedThe value federate object to use to get the publication.
keyThe name of the publication. @forcpponly
[in,out]errThe error object to complete if there is an error. @endforcpponly
Returns
A helics_publication object, the object will not be valid and err will contain an error code if no publication with the specified key exists.

References fed, and helics_error_invalid_argument.

Referenced by helicscpp::ValueFederate::getPublication().

◆ helicsFederateGetPublicationByIndex()

helics_publication helicsFederateGetPublicationByIndex ( helics_federate  fed,
int  index,
helics_error err 
)

Get a publication by its index, typically already created via registerInterfaces file or something of that nature.

Parameters
fedThe federate object in which to create a publication.
indexThe index of the publication to get. @forcpponly
[in,out]errA pointer to an error object for catching errors. @endforcpponly
Returns
A helics_publication.

References fed, and helics_error_invalid_argument.

Referenced by helicscpp::ValueFederate::getPublication().

◆ helicsFederateGetPublicationCount()

int helicsFederateGetPublicationCount ( helics_federate  fed)

Get the number of publications in a federate.

Returns
(-1) if fed was not a valid federate otherwise returns the number of publications.

References fed.

Referenced by helicscpp::ValueFederate::getPublicationCount().

◆ helicsFederateGetSubscription()

helics_input helicsFederateGetSubscription ( helics_federate  fed,
const char *  key,
helics_error err 
)

Get an input object from a subscription target.

Parameters
fedThe value federate object to use to get the publication.
keyThe name of the publication that a subscription is targeting. @forcpponly
[in,out]errThe error object to complete if there is an error. @endforcpponly
Returns
A helics_input object, the object will not be valid and err will contain an error code if no input with the specified key exists.

References fed, and helics_error_invalid_argument.

◆ helicsFederatePublishJSON()

void helicsFederatePublishJSON ( helics_federate  fed,
const char *  json,
helics_error err 
)

Publish data contained in a JSON file or string.

Parameters
fedThe value federate object through which to publish the data.
jsonThe publication file name or literal JSON data string. @forcpponly
[in,out]errThe error object to complete if there is an error. @endforcpponly

References fed.

Referenced by helicscpp::ValueFederate::publishJSON().

◆ helicsFederateRegisterFromPublicationJSON()

void helicsFederateRegisterFromPublicationJSON ( helics_federate  fed,
const char *  json,
helics_error err 
)

Register the publications via JSON publication string.

Parameters
fedThe value federate object to use to register the publications.
jsonThe JSON publication string. @forcpponly
[in,out]errThe error object to complete if there is an error. @endforcpponly

This would be the same JSON that would be used to publish data.

References fed.

Referenced by helicscpp::ValueFederate::registerFromPublicationJSON().

◆ helicsFederateRegisterGlobalInput()

helics_publication helicsFederateRegisterGlobalInput ( helics_federate  fed,
const char *  key,
helics_data_type  type,
const char *  units,
helics_error err 
)

Register a global named input.

The publication becomes part of the federate and is destroyed when the federate is freed so there are no separate free functions for subscriptions and publications.

Parameters
fedThe federate object in which to create a publication.
keyThe identifier for the publication.
typeA code identifying the type of the input see /ref helics_data_type for available options.
unitsA string listing the units of the subscription maybe NULL. @forcpponly
[in,out]errA pointer to an error object for catching errors. @endforcpponly
Returns
An object containing the publication.

References fed, helics_data_type_any, helics_data_type_raw, helics_data_type_string, helics_data_type_time, helics_error_invalid_argument, helicsFederateRegisterGlobalTypeInput(), and helics::typeNameStringRef().

Referenced by helicscpp::ValueFederate::registerGlobalInput().

◆ helicsFederateRegisterGlobalPublication()

helics_publication helicsFederateRegisterGlobalPublication ( helics_federate  fed,
const char *  key,
helics_data_type  type,
const char *  units,
helics_error err 
)

Register a global named publication with an arbitrary type.

The publication becomes part of the federate and is destroyed when the federate is freed so there are no separate free functions for subscriptions and publications.

Parameters
fedThe federate object in which to create a publication.
keyThe identifier for the publication.
typeA code identifying the type of the input see /ref helics_data_type for available options.
unitsA string listing the units of the subscription (may be NULL). @forcpponly
[in,out]errA pointer to an error object for catching errors. @endforcpponly
Returns
An object containing the publication.

References fed, helics_data_type_raw, helics_data_type_time, helics_error_invalid_argument, helicsFederateRegisterGlobalTypePublication(), and helics::typeNameStringRef().

Referenced by helicscpp::ValueFederate::registerGlobalPublication().

◆ helicsFederateRegisterGlobalTypeInput()

helics_publication helicsFederateRegisterGlobalTypeInput ( helics_federate  fed,
const char *  key,
const char *  type,
const char *  units,
helics_error err 
)

Register a global publication with an arbitrary type.

The publication becomes part of the federate and is destroyed when the federate is freed so there are no separate free functions for subscriptions and publications.

Parameters
fedThe federate object in which to create a publication.
keyThe identifier for the publication.
typeA string defining the type of the input.
unitsA string listing the units of the subscription maybe NULL. @forcpponly
[in,out]errA pointer to an error object for catching errors. @endforcpponly
Returns
An object containing the publication.

References fed.

Referenced by helicsFederateRegisterGlobalInput(), and helicscpp::ValueFederate::registerGlobalInput().

◆ helicsFederateRegisterGlobalTypePublication()

helics_publication helicsFederateRegisterGlobalTypePublication ( helics_federate  fed,
const char *  key,
const char *  type,
const char *  units,
helics_error err 
)

Register a global publication with a defined type.

The publication becomes part of the federate and is destroyed when the federate is freed so there are no separate free functions for subscriptions and publications.

Parameters
fedThe federate object in which to create a publication.
keyThe identifier for the publication.
typeA string describing the expected type of the publication.
unitsA string listing the units of the subscription (may be NULL). @forcpponly
[in,out]errA pointer to an error object for catching errors. @endforcpponly
Returns
An object containing the publication.

References fed.

Referenced by helicsFederateRegisterGlobalPublication(), and helicscpp::ValueFederate::registerGlobalPublication().

◆ helicsFederateRegisterInput()

helics_input helicsFederateRegisterInput ( helics_federate  fed,
const char *  key,
helics_data_type  type,
const char *  units,
helics_error err 
)

Register a named input.

The input becomes part of the federate and is destroyed when the federate is freed so there are no separate free functions for subscriptions, inputs, and publications.

Parameters
fedThe federate object in which to create an input.
keyThe identifier for the publication the global input key will be prepended with the federate name.
typeA code identifying the type of the input see /ref helics_data_type for available options.
unitsA string listing the units of the input (may be NULL). @forcpponly
[in,out]errA pointer to an error object for catching errors. @endforcpponly
Returns
An object containing the input.

References fed, helics_data_type_any, helics_data_type_raw, helics_data_type_string, helics_data_type_time, helics_error_invalid_argument, helicsFederateRegisterTypeInput(), and helics::typeNameStringRef().

◆ helicsFederateRegisterPublication()

helics_publication helicsFederateRegisterPublication ( helics_federate  fed,
const char *  key,
helics_data_type  type,
const char *  units,
helics_error err 
)

Register a publication with a known type.

The publication becomes part of the federate and is destroyed when the federate is freed so there are no separate free functions for subscriptions and publications.

Parameters
fedThe federate object in which to create a publication.
keyThe identifier for the publication the global publication key will be prepended with the federate name.
typeA code identifying the type of the input see /ref helics_data_type for available options.
unitsA string listing the units of the subscription (may be NULL). @forcpponly
[in,out]errA pointer to an error object for catching errors. @endforcpponly
Returns
An object containing the publication.

References fed, helics_data_type_raw, helics_data_type_string, helics_data_type_time, helics_error_invalid_argument, helicsFederateRegisterTypePublication(), and helics::typeNameStringRef().

Referenced by helicscpp::ValueFederate::registerInput(), and helicscpp::ValueFederate::registerPublication().

◆ helicsFederateRegisterSubscription()

helics_input helicsFederateRegisterSubscription ( helics_federate  fed,
const char *  key,
const char *  units,
helics_error err 
)

sub/pub registration Create a subscription.

The subscription becomes part of the federate and is destroyed when the federate is freed so there are no separate free functions for subscriptions and publications.

Parameters
fedThe federate object in which to create a subscription, must have been created with /ref helicsCreateValueFederate or /ref helicsCreateCombinationFederate.
keyThe identifier matching a publication to get a subscription for.
unitsA string listing the units of the subscription (may be NULL). @forcpponly
[in,out]errA pointer to an error object for catching errors. @endforcpponly
Returns
An object containing the subscription.

References fed.

Referenced by helicscpp::ValueFederate::registerSubscription().

◆ helicsFederateRegisterTypeInput()

helics_input helicsFederateRegisterTypeInput ( helics_federate  fed,
const char *  key,
const char *  type,
const char *  units,
helics_error err 
)

Register an input with a defined type.

The input becomes part of the federate and is destroyed when the federate is freed so there are no separate free functions for subscriptions, inputs, and publications.

Parameters
fedThe federate object in which to create an input.
keyThe identifier for the input.
typeA string describing the expected type of the input.
unitsA string listing the units of the input maybe NULL. @forcpponly
[in,out]errA pointer to an error object for catching errors. @endforcpponly
Returns
An object containing the publication.

References fed.

Referenced by helicsFederateRegisterInput(), and helicscpp::ValueFederate::registerInput().

◆ helicsFederateRegisterTypePublication()

helics_publication helicsFederateRegisterTypePublication ( helics_federate  fed,
const char *  key,
const char *  type,
const char *  units,
helics_error err 
)

Register a publication with a defined type.

The publication becomes part of the federate and is destroyed when the federate is freed so there are no separate free functions for subscriptions and publications.

Parameters
fedThe federate object in which to create a publication.
keyThe identifier for the publication.
typeA string labeling the type of the publication.
unitsA string listing the units of the subscription (may be NULL). @forcpponly
[in,out]errA pointer to an error object for catching errors. @endforcpponly
Returns
An object containing the publication.

References fed.

Referenced by helicsFederateRegisterPublication(), and helicscpp::ValueFederate::registerPublication().

◆ helicsInputClearUpdate()

void helicsInputClearUpdate ( helics_input  ipt)

Clear the updated flag from an input.

Referenced by helicscpp::Input::clearUpdate().

◆ helicsInputIsUpdated()

helics_bool helicsInputIsUpdated ( helics_input  ipt)

Check if a particular subscription was updated.

Returns
helics_true if it has been updated since the last value retrieval.

References helics_false, and helics_true.

Referenced by helicscpp::Input::isUpdated().

◆ helicsInputLastUpdateTime()

helics_time helicsInputLastUpdateTime ( helics_input  ipt)

Get the last time a subscription was updated.

References helics_time_invalid.

Referenced by helicscpp::Input::getLastUpdateTime().