helics  2.8.1
Public Member Functions | List of all members
helics::Core Class Referenceabstract

#include <Core.hpp>

+ Inheritance diagram for helics::Core:

Public Member Functions

 Core ()=default
 
virtual ~Core ()=default
 
void initialize (const std::string &configureString)
 
void initializeFromArgs (int argc, char *argv[])
 
virtual void configure (const std::string &configureString)=0
 
virtual void configureFromArgs (int argc, char *argv[])=0
 
virtual void configureFromVector (std::vector< std::string > args)=0
 
virtual bool isConfigured () const =0
 
bool isInitialized () const
 
virtual bool connect ()=0
 
virtual bool isConnected () const =0
 
virtual void disconnect ()=0
 
virtual bool hasError () const =0
 
virtual bool waitForDisconnect (std::chrono::milliseconds msToWait=std::chrono::milliseconds(0)) const =0
 
virtual bool isOpenToNewFederates () const =0
 
virtual const std::string & getIdentifier () const =0
 
virtual const std::string & getAddress () const =0
 
virtual void globalError (local_federate_id federateID, int32_t errorCode, const std::string &errorString)=0
 
virtual void localError (local_federate_id federateID, int32_t errorCode, const std::string &errorString)=0
 
void error (local_federate_id federateID, int32_t errorCode=-1)
 
virtual int getErrorCode () const =0
 
virtual std::string getErrorMessage () const =0
 
virtual void finalize (local_federate_id federateID)=0
 
virtual void enterInitializingMode (local_federate_id federateID)=0
 
virtual void setCoreReadyToInit ()=0
 
virtual iteration_result enterExecutingMode (local_federate_id federateID, iteration_request iterate=NO_ITERATION)=0
 
virtual local_federate_id registerFederate (const std::string &name, const CoreFederateInfo &info)=0
 
virtual const std::string & getFederateName (local_federate_id federateID) const =0
 
virtual local_federate_id getFederateId (const std::string &name) const =0
 
virtual int32_t getFederationSize ()=0
 
virtual Time timeRequest (local_federate_id federateID, Time next)=0
 
virtual iteration_time requestTimeIterative (local_federate_id federateID, Time next, iteration_request iterate)=0
 
virtual uint64_t getCurrentReiteration (local_federate_id federateID) const =0
 
virtual void setTimeProperty (local_federate_id federateID, int32_t property, Time timeValue)=0
 
virtual Time getTimeProperty (local_federate_id federateID, int32_t property) const =0
 
virtual void setIntegerProperty (local_federate_id federateID, int32_t property, int16_t propValue)=0
 
virtual int16_t getIntegerProperty (local_federate_id federateID, int32_t property) const =0
 
virtual Time getCurrentTime (local_federate_id federateID) const =0
 
virtual void setFlagOption (local_federate_id federateID, int32_t flag, bool flagValue)=0
 
virtual bool getFlagOption (local_federate_id federateID, int32_t flag) const =0
 
virtual interface_handle registerPublication (local_federate_id federateID, const std::string &key, const std::string &type, const std::string &units)=0
 
virtual interface_handle getPublication (local_federate_id federateID, const std::string &key) const =0
 
virtual interface_handle registerInput (local_federate_id federateID, const std::string &key, const std::string &type, const std::string &units)=0
 
virtual interface_handle getInput (local_federate_id federateID, const std::string &key) const =0
 
virtual const std::string & getHandleName (interface_handle handle) const =0
 
virtual void removeTarget (interface_handle handle, const std::string &targetToRemove)=0
 
virtual const std::string & getExtractionUnits (interface_handle handle) const =0
 
virtual const std::string & getInjectionUnits (interface_handle handle) const =0
 
const std::string & getUnits (interface_handle handle) const
 
virtual const std::string & getInjectionType (interface_handle handle) const =0
 
virtual const std::string & getExtractionType (interface_handle handle) const =0
 
virtual void setHandleOption (interface_handle handle, int32_t option, int32_t option_value)=0
 
virtual int32_t getHandleOption (interface_handle handle, int32_t option) const =0
 
virtual void closeHandle (interface_handle handle)=0
 
virtual void setValue (interface_handle handle, const char *data, uint64_t len)=0
 
virtual const std::shared_ptr< const data_block > & getValue (interface_handle handle, uint32_t *inputIndex=nullptr)=0
 
virtual const std::vector< std::shared_ptr< const data_block > > & getAllValues (interface_handle handle)=0
 
virtual const std::vector< interface_handle > & getValueUpdates (local_federate_id federateID)=0
 
virtual interface_handle registerEndpoint (local_federate_id federateID, const std::string &name, const std::string &type)=0
 
virtual interface_handle getEndpoint (local_federate_id federateID, const std::string &name) const =0
 
virtual interface_handle registerCloningFilter (const std::string &filterName, const std::string &type_in, const std::string &type_out)=0
 
virtual interface_handle registerFilter (const std::string &filterName, const std::string &type_in, const std::string &type_out)=0
 
virtual void addDestinationTarget (interface_handle handle, const std::string &dest)=0
 
virtual void addSourceTarget (interface_handle handle, const std::string &name)=0
 
virtual interface_handle getFilter (const std::string &name) const =0
 
virtual void addDependency (local_federate_id federateID, const std::string &federateName)=0
 
virtual void registerFrequentCommunicationsPair (const std::string &source, const std::string &dest)=0
 
virtual void makeConnections (const std::string &file)=0
 
virtual void dataLink (const std::string &source, const std::string &target)=0
 
virtual void addSourceFilterToEndpoint (const std::string &filter, const std::string &target)=0
 
virtual void addDestinationFilterToEndpoint (const std::string &filter, const std::string &target)=0
 
virtual void send (interface_handle sourceHandle, const std::string &destination, const char *data, uint64_t length)=0
 
virtual void sendEvent (Time time, interface_handle sourceHandle, const std::string &destination, const char *data, uint64_t length)=0
 
virtual void sendMessage (interface_handle sourceHandle, std::unique_ptr< Message > message)=0
 
virtual uint64_t receiveCount (interface_handle destination)=0
 
virtual std::unique_ptr< Messagereceive (interface_handle destination)=0
 
virtual std::unique_ptr< MessagereceiveAny (local_federate_id federateID, interface_handle &endpoint_id)=0
 
virtual uint64_t receiveCountAny (local_federate_id federateID)=0
 
virtual void logMessage (local_federate_id federateID, int logLevel, const std::string &messageToLog)=0
 
virtual void setFilterOperator (interface_handle filter, std::shared_ptr< FilterOperator > callback)=0
 
virtual void setLoggingCallback (local_federate_id federateID, std::function< void(int, const std::string &, const std::string &)> logFunction)=0
 
virtual void setLoggingLevel (int logLevel)=0
 
virtual void setLogFile (const std::string &lfile)=0
 
virtual void setGlobal (const std::string &valueName, const std::string &value)=0
 
virtual std::string query (const std::string &target, const std::string &queryStr, helics_sequencing_mode mode)=0
 
virtual void setQueryCallback (local_federate_id federateID, std::function< std::string(const std::string &)> queryFunction)=0
 
virtual void setInterfaceInfo (interface_handle handle, std::string info)=0
 
virtual const std::string & getInterfaceInfo (interface_handle handle) const =0
 

Detailed Description

the class defining the core interface through an abstract class

Constructor & Destructor Documentation

◆ Core()

helics::Core::Core ( )
default

default constructor

◆ ~Core()

virtual helics::Core::~Core ( )
virtualdefault

virtual destructor

Member Function Documentation

◆ addDependency()

virtual void helics::Core::addDependency ( local_federate_id  federateID,
const std::string &  federateName 
)
pure virtual

add a time dependency between federates

this function is primarily useful for Message federates which do not otherwise restrict the dependencies adding a dependency gives additional information to the core that the specified federate(given by id) will be sending Messages to the named Federate(by federateName)

Parameters
federateIDthe identifier for the federate
federateNamethe name of the dependent federate

Implemented in helics::CommonCore.

◆ addDestinationFilterToEndpoint()

virtual void helics::Core::addDestinationFilterToEndpoint ( const std::string &  filter,
const std::string &  target 
)
pure virtual

create a filter connection between a named filter and a named endpoint for destination processing

Parameters
filterthe name of the filter
targetthe name of the source target

Implemented in helics::CommonCore.

◆ addDestinationTarget()

virtual void helics::Core::addDestinationTarget ( interface_handle  handle,
const std::string &  dest 
)
pure virtual

add a destination target, the handle can be for a filter or a publication

a filter will create an additional processing step for messages before they get to a destination endpoint, for publications this will establish a linkage from the publication to the named input

Parameters
handlean interface to add the target to
destthe target endpoint for the filter

Implemented in helics::CommonCore.

Referenced by helics::MessageFederateManager::addDestinationFilter(), and helics::Filter::addDestinationTarget().

◆ addSourceFilterToEndpoint()

virtual void helics::Core::addSourceFilterToEndpoint ( const std::string &  filter,
const std::string &  target 
)
pure virtual

create a filter connection between a named filter and a named endpoint for messages coming from that endpoint

Parameters
filterthe name of the filter
targetthe name of the source target

Implemented in helics::CommonCore.

◆ addSourceTarget()

virtual void helics::Core::addSourceTarget ( interface_handle  handle,
const std::string &  name 
)
pure virtual

add a source target, the handle can be a subscription, input, filter or endpoint

for subscriptions and inputs this establishes a link from a publication, for endpoints this creates a linkage to a particular publication, for filters it add a source endpoint to filter

Parameters
handlethe identifier of the interface
namethe name of the filter or its target

Implemented in helics::CommonCore.

Referenced by helics::MessageFederateManager::addSourceFilter(), helics::Filter::addSourceTarget(), and helics::MessageFederateManager::subscribe().

◆ closeHandle()

virtual void helics::Core::closeHandle ( interface_handle  handle)
pure virtual

close a handle from further connections

Parameters
handlethe handle from the publication, input, endpoint or filter

Implemented in helics::CommonCore.

Referenced by helics::Filter::close(), and helics::FilterFederateManager::closeAllFilters().

◆ configure()

virtual void helics::Core::configure ( const std::string &  configureString)
pure virtual

Configure the core from a configuration string

Should be invoked a single time to initialize the co-simulation core.

Implemented in helics::CommonCore.

Referenced by initialize().

◆ configureFromArgs()

virtual void helics::Core::configureFromArgs ( int  argc,
char *  argv[] 
)
pure virtual

Configure the core from command line arguments.

Should be invoked a single time to configure the co-simulation core for operation

Implemented in helics::CommonCore.

Referenced by initializeFromArgs().

◆ configureFromVector()

virtual void helics::Core::configureFromVector ( std::vector< std::string >  args)
pure virtual

Configure the core from command line arguments contained in a vector in reverse order

Should be invoked a single time to configure the co-simulation core for operations

Implemented in helics::CommonCore.

◆ connect()

virtual bool helics::Core::connect ( )
pure virtual

connect the core to a broker if needed

Returns
true if the connection was successful

Implemented in helics::CommonCore.

◆ dataLink()

virtual void helics::Core::dataLink ( const std::string &  source,
const std::string &  target 
)
pure virtual

create a data connection between a named publication and a named input

Parameters
sourcethe name of the publication
targetthe name of the input

Implemented in helics::CommonCore.

◆ disconnect()

virtual void helics::Core::disconnect ( )
pure virtual

disconnect the core from its broker

Implemented in helics::CommonCore.

◆ enterExecutingMode()

virtual iteration_result helics::Core::enterExecutingMode ( local_federate_id  federateID,
iteration_request  iterate = NO_ITERATION 
)
pure virtual

Change the federate state to the Executing state.

May only be invoked in Initializing state.

Parameters
federateIDthe identifier of the federate
iteratethe requested iteration mode if nonconverged the federate requests an iterative update
Returns
an iteration result enumeration value indicating the current state of iterations

Implemented in helics::CommonCore.

◆ enterInitializingMode()

virtual void helics::Core::enterInitializingMode ( local_federate_id  federateID)
pure virtual

Federates may be in five Modes.

  1. Startup Configuration of the federate. State begins when registerFederate() is invoked and ends when enterInitializingMode() is invoked.
  2. Initializing Configure of the simulation state prior to the start of time stepping. State begins when enterInitializingMode() is invoked and ends when enterExecutingMode(true) is invoked.
  3. Executing State begins when enterExecutingMode() is invoked and ends when finalize() is invoked.
  4. Finalized state after finalize is invoked.
  5. Error state invoked after an error is called. Change the federate state to the Initializing state.

May only be invoked in Created state otherwise an error is thrown

Implemented in helics::CommonCore.

◆ error()

void helics::Core::error ( local_federate_id  federateID,
int32_t  errorCode = -1 
)
inline

Federate has encountered an unrecoverable error.

References globalError().

◆ finalize()

virtual void helics::Core::finalize ( local_federate_id  federateID)
pure virtual

Federate has completed.

Should be invoked a single time to complete the simulation.

Implemented in helics::CommonCore.

◆ getAddress()

virtual const std::string& helics::Core::getAddress ( ) const
pure virtual

get the connection network or connection address for the core

Implemented in helics::CommonCore.

◆ getAllValues()

virtual const std::vector<std::shared_ptr<const data_block> >& helics::Core::getAllValues ( interface_handle  handle)
pure virtual

Return all the available data for the specified handle or the latest input

Implemented in helics::CommonCore.

◆ getCurrentReiteration()

virtual uint64_t helics::Core::getCurrentReiteration ( local_federate_id  federateID) const
pure virtual

Returns the current reiteration count for the specified federate.

Implemented in helics::CommonCore.

◆ getCurrentTime()

virtual Time helics::Core::getCurrentTime ( local_federate_id  federateID) const
pure virtual

get the most recent granted Time

Parameters
federateIDthe identifier of the federate to get the time
Returns
the most recent granted time or the startup time

Implemented in helics::CommonCore.

◆ getEndpoint()

virtual interface_handle helics::Core::getEndpoint ( local_federate_id  federateID,
const std::string &  name 
) const
pure virtual

get an endpoint Handle from its name

Parameters
federateIDthe identifier for the federate
namethe name of the endpoint
Returns
a handle to identify the endpoint

Implemented in helics::CommonCore.

◆ getErrorCode()

virtual int helics::Core::getErrorCode ( ) const
pure virtual

get the last error code from a core

Implemented in helics::CommonCore.

◆ getErrorMessage()

virtual std::string helics::Core::getErrorMessage ( ) const
pure virtual

get the last error message

Implemented in helics::CommonCore.

◆ getExtractionType()

virtual const std::string& helics::Core::getExtractionType ( interface_handle  handle) const
pure virtual

get the type for which data comes out of an interface, this is the type for data coming into an interface

for filters this is the output type, for publications this is the specified type, for endpoints this is the specified type and for inputs this is the specified type

Parameters
handlethe interface handle to get the injection type for
Returns
a const ref to std::string

Implemented in helics::CommonCore.

Referenced by helics::Filter::getExtractionType().

◆ getExtractionUnits()

virtual const std::string& helics::Core::getExtractionUnits ( interface_handle  handle) const
pure virtual
Returns
the unit string for the specified handle.

Implemented in helics::CommonCore.

Referenced by getUnits().

◆ getFederateId()

virtual local_federate_id helics::Core::getFederateId ( const std::string &  name) const
pure virtual

Returns the federate Id.

Implemented in helics::CommonCore.

◆ getFederateName()

virtual const std::string& helics::Core::getFederateName ( local_federate_id  federateID) const
pure virtual

Returns the federate name.

Implemented in helics::CommonCore.

◆ getFederationSize()

virtual int32_t helics::Core::getFederationSize ( )
pure virtual

Returns the global number of federates that are registered only return accurately after the initialization state has been entered

Implemented in helics::CommonCore.

◆ getFilter()

virtual interface_handle helics::Core::getFilter ( const std::string &  name) const
pure virtual

get a destination filter Handle from its name or target(this may not be unique so it will only find the first one)

Parameters
namethe name of the filter or its target
Returns
a handle to identify the filter

Implemented in helics::CommonCore.

◆ getFlagOption()

virtual bool helics::Core::getFlagOption ( local_federate_id  federateID,
int32_t  flag 
) const
pure virtual

Set a flag in a a federate

Parameters
federateIDthe identifier for the federate
flagan index code for the flag to set
Returns
the value of the flag

Implemented in helics::CommonCore.

◆ getHandleName()

virtual const std::string& helics::Core::getHandleName ( interface_handle  handle) const
pure virtual

Returns the name or identifier for a specified handle

Implemented in helics::CommonCore.

Referenced by helics::Filter::getKey(), helics::FilterFederateManager::registerCloningFilter(), and helics::FilterFederateManager::registerFilter().

◆ getHandleOption()

virtual int32_t helics::Core::getHandleOption ( interface_handle  handle,
int32_t  option 
) const
pure virtual

get a handle option

Parameters
handlethe handle from the publication, input, endpoint or filter
optionthe option to set see /ref defs::options

Implemented in helics::CommonCore.

Referenced by helics::Filter::getOption().

◆ getIdentifier()

virtual const std::string& helics::Core::getIdentifier ( ) const
pure virtual

get an identifier string for the core

Implemented in helics::CommonCore.

◆ getInjectionType()

virtual const std::string& helics::Core::getInjectionType ( interface_handle  handle) const
pure virtual

get the injection type for an interface, this is the type for data coming into an interface

for filters this is the input type, for publications this is type used to transmit data, for endpoints this is the specified type and for inputs this is the type of the transmitting publication

Parameters
handlethe interface handle to get the injection type for
Returns
a const ref to std::string

Implemented in helics::CommonCore.

Referenced by helics::Filter::getInjectionType().

◆ getInjectionUnits()

virtual const std::string& helics::Core::getInjectionUnits ( interface_handle  handle) const
pure virtual

get the injection units for an interface, this is the type for data coming into an interface

for publications this is the units associated with the transmitted data, for inputs this is the units of the transmitting publication

Parameters
handlethe interface handle to get the injection type for
Returns
a const ref to std::string

Implemented in helics::CommonCore.

◆ getInput()

virtual interface_handle helics::Core::getInput ( local_federate_id  federateID,
const std::string &  key 
) const
pure virtual

get a subscription Handle from its key

Parameters
federateIDthe identifier for the federate
keythe tag of the named input
Returns
a handle to identify the input

Implemented in helics::CommonCore.

◆ getIntegerProperty()

virtual int16_t helics::Core::getIntegerProperty ( local_federate_id  federateID,
int32_t  property 
) const
pure virtual

get an integer property on a federate

Parameters
federateIDthe federate to set a time based property on
propertythe property to set see /ref defs::properties
Returns
the current value of the property

Implemented in helics::CommonCore.

◆ getInterfaceInfo()

virtual const std::string& helics::Core::getInterfaceInfo ( interface_handle  handle) const
pure virtual

getter for the interface information

Parameters
handlethe identifiers for the interface to query
Returns
a string containing the Info data stored in an interface

Implemented in helics::CommonCore.

Referenced by helics::Filter::getInfo().

◆ getPublication()

virtual interface_handle helics::Core::getPublication ( local_federate_id  federateID,
const std::string &  key 
) const
pure virtual

get a publication Handle from its key

Parameters
federateIDthe identifier for the federate
keythe name of the publication
Returns
a handle to identify the publication

Implemented in helics::CommonCore.

◆ getTimeProperty()

virtual Time helics::Core::getTimeProperty ( local_federate_id  federateID,
int32_t  property 
) const
pure virtual

get a timebased property on a federate

Parameters
federateIDthe federate to set a time based property on
propertythe property to set see /ref defs::properties
Returns
the current value of the requested property

Implemented in helics::CommonCore.

◆ getUnits()

const std::string& helics::Core::getUnits ( interface_handle  handle) const
inline

Returns units for specified handle.

References getExtractionUnits().

◆ getValue()

virtual const std::shared_ptr<const data_block>& helics::Core::getValue ( interface_handle  handle,
uint32_t *  inputIndex = nullptr 
)
pure virtual

Return the data for the specified handle or the latest input

Parameters
handlethe input handle from which to get the data
[out]inputIndexreturn the index of input (always 1 for inputs with only a single source)

Implemented in helics::CommonCore.

◆ getValueUpdates()

virtual const std::vector<interface_handle>& helics::Core::getValueUpdates ( local_federate_id  federateID)
pure virtual

Returns vector of input handles that received an update during the last time request. The data remains valid until the next call to getValueUpdates for the given federateID

Parameters
federateIDthe identification code of the federate to get which interfaces have been updated
Returns
a reference to the location of an array of handles that have been updated

Implemented in helics::CommonCore.

◆ globalError()

virtual void helics::Core::globalError ( local_federate_id  federateID,
int32_t  errorCode,
const std::string &  errorString 
)
pure virtual

Federate has encountered a global error and the federation should halt.

Parameters
federateIDthe federate

Referenced by error().

◆ initialize()

void helics::Core::initialize ( const std::string &  configureString)
inline

Simulator control. Configure the core.

Should be invoked a single time to configure the co-simulation core for operation

References configure().

◆ initializeFromArgs()

void helics::Core::initializeFromArgs ( int  argc,
char *  argv[] 
)
inline

Configure the core from command line arguments.

Should be invoked a single time to initialize the co-simulation core for operation

References configureFromArgs().

◆ isConfigured()

virtual bool helics::Core::isConfigured ( ) const
pure virtual

Returns true if the core has been configured.

Implemented in helics::CommonCore.

Referenced by isInitialized().

◆ isConnected()

virtual bool helics::Core::isConnected ( ) const
pure virtual

check if the core is connected properly

Implemented in helics::CommonCore.

◆ isInitialized()

bool helics::Core::isInitialized ( ) const
inline

Returns true if the core has been configured.

References isConfigured().

◆ isOpenToNewFederates()

virtual bool helics::Core::isOpenToNewFederates ( ) const
pure virtual

check if the core is ready to accept new federates

Implemented in helics::CommonCore.

◆ localError()

virtual void helics::Core::localError ( local_federate_id  federateID,
int32_t  errorCode,
const std::string &  errorString 
)
pure virtual

Federate has encountered a local error and should be disconnected.

◆ logMessage()

virtual void helics::Core::logMessage ( local_federate_id  federateID,
int  logLevel,
const std::string &  messageToLog 
)
pure virtual

send a log message to the Core for logging

Parameters
federateIDthe federate that is sending the log message
logLevelan integer for the log level /ref helics_log_levels
messageToLogthe string to send to a logger

Implemented in helics::CommonCore.

◆ makeConnections()

virtual void helics::Core::makeConnections ( const std::string &  file)
pure virtual

load a file containing connection information

Parameters
filea JSON or TOML file containing connection information

Implemented in helics::CommonCore.

◆ query()

virtual std::string helics::Core::query ( const std::string &  target,
const std::string &  queryStr,
helics_sequencing_mode  mode 
)
pure virtual

make a query for information from the co-simulation

the format is somewhat unspecified target is the name of an object typically one of "federation", "broker", "core", or the name of a specific object/core/broker target can also be "global" to query a global value stored in the broker

Parameters
targetthe specific target of the query
queryStrthe actual query
modethe synchronization mode for the query
Returns
a string containing the response to the query. Query is a blocking call and will not return until the query is answered so use with caution

Implemented in helics::CommonCore.

◆ receive()

virtual std::unique_ptr<Message> helics::Core::receive ( interface_handle  destination)
pure virtual

Returns the next buffered message the specified destination endpoint.

this is a non-blocking call and will return a nullptr if no message are available

Implemented in helics::CommonCore.

◆ receiveAny()

virtual std::unique_ptr<Message> helics::Core::receiveAny ( local_federate_id  federateID,
interface_handle endpoint_id 
)
pure virtual

Receives a message for any destination.

this is a non-blocking call and will return a nullptr if no messages are available

Parameters
federateIDthe identifier for the federate
[out]endpoint_idthe endpoint handle related to the message gets stored here

Implemented in helics::CommonCore.

Referenced by helics::MessageFederateManager::updateTime().

◆ receiveCount()

virtual uint64_t helics::Core::receiveCount ( interface_handle  destination)
pure virtual

Returns the number of pending receives for the specified destination endpoint.

Implemented in helics::CommonCore.

◆ receiveCountAny()

virtual uint64_t helics::Core::receiveCountAny ( local_federate_id  federateID)
pure virtual

Returns number of messages for all destinations.

Implemented in helics::CommonCore.

Referenced by helics::MessageFederateManager::updateTime().

◆ registerCloningFilter()

virtual interface_handle helics::Core::registerCloningFilter ( const std::string &  filterName,
const std::string &  type_in,
const std::string &  type_out 
)
pure virtual

Register a cloning filter, a cloning filter operates on a copy of the message vs the actual message

Parameters
filterNamethe name of the filter (may be left blank and one will be automatically assigned)
type_inthe input type of the filter
type_outthe output type of the filter (may be left blank if the filter doesn't change type)
Returns
the handle for the new filter

Implemented in helics::CommonCore.

Referenced by helics::CloningFilter::CloningFilter(), and helics::FilterFederateManager::registerCloningFilter().

◆ registerEndpoint()

virtual interface_handle helics::Core::registerEndpoint ( local_federate_id  federateID,
const std::string &  name,
const std::string &  type 
)
pure virtual

Message interface. Designed for point-to-point communication patterns. Register an endpoint.

May only be invoked in the Initialization state.

Implemented in helics::CommonCore.

Referenced by helics::MessageFederateManager::registerEndpoint().

◆ registerFederate()

virtual local_federate_id helics::Core::registerFederate ( const std::string &  name,
const CoreFederateInfo info 
)
pure virtual

Register a federate.

The returned FederateId is local to invoking process, FederateId's should not be used as a global identifier.

May only be invoked in initialize state otherwise throws an error

Implemented in helics::CommonCore.

◆ registerFilter()

virtual interface_handle helics::Core::registerFilter ( const std::string &  filterName,
const std::string &  type_in,
const std::string &  type_out 
)
pure virtual

Register source filter.

May only be invoked in the Initialization state.

Parameters
filterNamethe name of the filter (may be left blank and one will be automatically assigned)
type_inthe input type of the filter
type_outthe output type of the filter (may be left blank if the filter doesn't change type) this is important for ordering in filters with operators
Returns
the handle for the new filter

Implemented in helics::CommonCore.

Referenced by helics::Filter::Filter(), and helics::FilterFederateManager::registerFilter().

◆ registerFrequentCommunicationsPair()

virtual void helics::Core::registerFrequentCommunicationsPair ( const std::string &  source,
const std::string &  dest 
)
pure virtual

Register communicating source/destination endpoint targets.

Parameters
sourcethe endpoint that is sending data
destthe endpoint receiving the data

Implemented in helics::CommonCore.

Referenced by helics::MessageFederateManager::registerKnownCommunicationPath().

◆ registerInput()

virtual interface_handle helics::Core::registerInput ( local_federate_id  federateID,
const std::string &  key,
const std::string &  type,
const std::string &  units 
)
pure virtual

Register a control input for the specified federate.

May only be invoked in the initialize state.

Parameters
federateIDthe identifier for the federate to register an input interface on
keythe name of the control input
typea string describing the type of the federate
unitsa string naming the units of the federate

Implemented in helics::CommonCore.

◆ registerPublication()

virtual interface_handle helics::Core::registerPublication ( local_federate_id  federateID,
const std::string &  key,
const std::string &  type,
const std::string &  units 
)
pure virtual

Value interface. Register a publication.

May only be invoked in the initialize state.

Parameters
federateIDthe identifier for the federate
keythe tag for the publication
typethe type of data the publication produces
unitsthe units associated with the publication
Returns
a handle to identify the publication

Implemented in helics::CommonCore.

◆ removeTarget()

virtual void helics::Core::removeTarget ( interface_handle  handle,
const std::string &  targetToRemove 
)
pure virtual

remove a target from a handles operation

Parameters
handlethe handle from the publication, input, endpoint or filter
targetToRemovethe name of the target to remove

Implemented in helics::CommonCore.

Referenced by helics::Filter::removeTarget().

◆ requestTimeIterative()

virtual iteration_time helics::Core::requestTimeIterative ( local_federate_id  federateID,
Time  next,
iteration_request  iterate 
)
pure virtual

Request a new time advancement window for reiterative federates.

Reiterative federates block on requestTimeIterative() until all reiterative federates have invoked requestTimeIterative(). The bool returned a global AND of all localConverged values. If globalConverged is false, time returned is the previous granted time. Time should not advance and another iteration attempted. Federates should recompute state based on newly published values. Time is advanced only when all reiterative federates have converged. If globalConverged is True, grantedTime is the minimum of over all next times in both reiterative and non-reiterative federates.

If a federate determines it cannot converge it should invoke the error() method.

Federates only participate it in reiterations for times that are evenly divisible by the federates time delta.

May only be invoked in Executing state.

Non-reiterative federates may not invoke this method.

Parameters
federateIDthe identifier for the federate to process
nextthe requested time
iteratethe requested iteration mode /ref iteration_request
Returns
an /ref iteration_time object with two field grantedTime and a enumeration indicating the state of the iteration

Implemented in helics::CommonCore.

◆ send()

virtual void helics::Core::send ( interface_handle  sourceHandle,
const std::string &  destination,
const char *  data,
uint64_t  length 
)
pure virtual

Send data from source to destination.

Time is implicitly defined as the end of the current time advancement window (value returned by last call to nextTime().

This send version was designed to enable communication of data between federates with the possible introduction of source and destination filters to represent properties of a communication network. This enables simulations to be run with/without a communications model present.

Implemented in helics::CommonCore.

◆ sendEvent()

virtual void helics::Core::sendEvent ( Time  time,
interface_handle  sourceHandle,
const std::string &  destination,
const char *  data,
uint64_t  length 
)
pure virtual

Send data from source to destination with explicit expected delivery time.

Time supplied is the time that will be reported in the message in the receiving federate.

This send version was designed to enable communication of events between discrete event federates. For this use case the receiving federate can deserialize the data and schedule an event for the specified time.

Parameters
timethe time the event is scheduled for
sourceHandlethe source of the event
destinationthe target of the event
datathe raw data for the event
lengththe record length of the event

Implemented in helics::CommonCore.

◆ sendMessage()

virtual void helics::Core::sendMessage ( interface_handle  sourceHandle,
std::unique_ptr< Message message 
)
pure virtual

Send for filters.

Continues sending the message to the next filter or to final destination.

Implemented in helics::CommonCore.

◆ setCoreReadyToInit()

virtual void helics::Core::setCoreReadyToInit ( )
pure virtual

set the core to ready to enter init

this function only needs to be called for cores that don't have any federates but may have filters for cores with federates it won't do anything

Implemented in helics::CommonCore.

◆ setFilterOperator()

virtual void helics::Core::setFilterOperator ( interface_handle  filter,
std::shared_ptr< FilterOperator callback 
)
pure virtual

set the filter callback operator

Parameters
filterthe handle of the filter
callbackpointer to the operator class executing the filter

Implemented in helics::CommonCore.

Referenced by helics::Filter::setFilterOperations(), and helics::Filter::setOperator().

◆ setFlagOption()

virtual void helics::Core::setFlagOption ( local_federate_id  federateID,
int32_t  flag,
bool  flagValue 
)
pure virtual

Set a flag in a a federate

Parameters
federateIDthe identifier for the federate
flagan index code for the flag to set
flagValuethe value to set the flag to

Implemented in helics::CommonCore.

◆ setGlobal()

virtual void helics::Core::setGlobal ( const std::string &  valueName,
const std::string &  value 
)
pure virtual

set a federation global value

this overwrites any previous value for this name

Parameters
valueNamethe name of the global to set
valuethe value of the global

Implemented in helics::CommonCore.

◆ setHandleOption()

virtual void helics::Core::setHandleOption ( interface_handle  handle,
int32_t  option,
int32_t  option_value 
)
pure virtual

set a handle option

Parameters
handlethe handle from the publication, input, endpoint or filter
optionthe option to set
option_valuethe value to set the option (mostly 0 or 1)

Implemented in helics::CommonCore.

Referenced by helics::Filter::setOption().

◆ setIntegerProperty()

virtual void helics::Core::setIntegerProperty ( local_federate_id  federateID,
int32_t  property,
int16_t  propValue 
)
pure virtual

set an integer property on a federate

Parameters
federateIDthe federate to set a time based property on
propertythe property to set see /ref defs::properties
propValuethe requested value of the property

Implemented in helics::CommonCore.

◆ setInterfaceInfo()

virtual void helics::Core::setInterfaceInfo ( interface_handle  handle,
std::string  info 
)
pure virtual

setter for the interface information

Parameters
handlethe identifiers for the interface to set the info data on
infoa string containing the info data

Implemented in helics::CommonCore.

Referenced by helics::Filter::setInfo().

◆ setLogFile()

virtual void helics::Core::setLogFile ( const std::string &  lfile)
pure virtual

set the core logging file

Implemented in helics::CommonCore.

◆ setLoggingCallback()

virtual void helics::Core::setLoggingCallback ( local_federate_id  federateID,
std::function< void(int, const std::string &, const std::string &)>  logFunction 
)
pure virtual

define a logging function to use for logging message and notices from the federation and individual federate

Parameters
federateIDthe identifier for the individual federate or 0 for the Core Logger
logFunctionthe callback function for doing something with a log message it takes 3 inputs an integer for logLevel /ref helics_log_levels A string indicating the source of the message and another string with the actual message

Implemented in helics::CommonCore.

◆ setLoggingLevel()

virtual void helics::Core::setLoggingLevel ( int  logLevel)
pure virtual

set the core logging level

Implemented in helics::CommonCore.

◆ setQueryCallback()

virtual void helics::Core::setQueryCallback ( local_federate_id  federateID,
std::function< std::string(const std::string &)>  queryFunction 
)
pure virtual

supply a query callback function

the intention of the query callback is to allow federates to answer particular requests through the query interface this allows other federates to make requests or queries of other federates in an asynchronous fashion.

Parameters
federateIDthe identifier for the federate
queryFunctiona function object that returns a string as a result of a query in the form of const string ref. This callback will be called when a federate received a query that cannot be answered that directed at a particular federate

Implemented in helics::CommonCore.

◆ setTimeProperty()

virtual void helics::Core::setTimeProperty ( local_federate_id  federateID,
int32_t  property,
Time  timeValue 
)
pure virtual

set a timebased property on a federate

Parameters
federateIDthe federate to set a time based property on
propertythe property to set see /ref defs::properties
timeValuethe requested value of the property

Implemented in helics::CommonCore.

◆ setValue()

virtual void helics::Core::setValue ( interface_handle  handle,
const char *  data,
uint64_t  len 
)
pure virtual

Publish specified data to the specified key.

Parameters
handlethe handle from the publication, input, endpoint or filter
datathe raw data to send
lenthe size of the data

Implemented in helics::CommonCore.

◆ timeRequest()

virtual Time helics::Core::timeRequest ( local_federate_id  federateID,
Time  next 
)
pure virtual

Time management. Request a new time advancement window for non-reiterative federates.

RequestTime() blocks until all non-reiterative federates have invoked requestTime() and all reiterative federates have converged (called requestTimeIterative() with localConverged value of true). Return time is the minimum of all supplied times.

May only be invoked in Executing state.

Iterative federates may not invoke this method.

Parameters
federateIDthe identification of the federate requesting the time
nextthe next time that is requested from the federate

Implemented in helics::CommonCore.

◆ waitForDisconnect()

virtual bool helics::Core::waitForDisconnect ( std::chrono::milliseconds  msToWait = std::chrono::milliseconds(0)) const
pure virtual

waits in the current thread until the core is disconnected

Returns
true if the disconnect was successful

Implemented in helics::CommonCore.


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