helics  3.0.1
Public Member Functions | Protected Member Functions | Friends | List of all members
helics::CommonCore Class Referenceabstract

#include <CommonCore.hpp>

+ Inheritance diagram for helics::CommonCore:

Public Member Functions

 CommonCore () noexcept
 
 CommonCore (bool arg) noexcept
 
 CommonCore (const std::string &coreName)
 
virtual ~CommonCore () override
 
virtual void configure (const std::string &configureString) override final
 
virtual void configureFromArgs (int argc, char *argv[]) override final
 
virtual void configureFromVector (std::vector< std::string > args) override final
 
virtual bool isConfigured () const override final
 
virtual bool isOpenToNewFederates () const override final
 
virtual bool hasError () const override final
 
virtual void globalError (LocalFederateId federateID, int errorCode, const std::string &errorString) override final
 
virtual void localError (LocalFederateId federateID, int errorCode, const std::string &errorString) override final
 
virtual int getErrorCode () const override final
 
virtual std::string getErrorMessage () const override final
 
virtual void finalize (LocalFederateId federateID) override final
 
virtual void enterInitializingMode (LocalFederateId federateID) override final
 
virtual void setCoreReadyToInit () override final
 
virtual IterationResult enterExecutingMode (LocalFederateId federateID, IterationRequest iterate=NO_ITERATION) override final
 
virtual LocalFederateId registerFederate (const std::string &name, const CoreFederateInfo &info) override final
 
virtual const std::string & getFederateName (LocalFederateId federateID) const override final
 
virtual LocalFederateId getFederateId (const std::string &name) const override final
 
virtual int32_t getFederationSize () override final
 
virtual Time timeRequest (LocalFederateId federateID, Time next) override final
 
virtual iteration_time requestTimeIterative (LocalFederateId federateID, Time next, IterationRequest iterate) override final
 
virtual Time getCurrentTime (LocalFederateId federateID) const override final
 
virtual uint64_t getCurrentReiteration (LocalFederateId federateID) const override final
 
virtual void setTimeProperty (LocalFederateId federateID, int32_t property, Time time) override final
 
virtual void setIntegerProperty (LocalFederateId federateID, int32_t property, int16_t propertyValue) override final
 
virtual Time getTimeProperty (LocalFederateId federateID, int32_t property) const override final
 
virtual int16_t getIntegerProperty (LocalFederateId federateID, int32_t property) const override final
 
virtual void setFlagOption (LocalFederateId federateID, int32_t flag, bool flagValue=true) override final
 
virtual bool getFlagOption (LocalFederateId federateID, int32_t flag) const override final
 
virtual InterfaceHandle registerPublication (LocalFederateId federateID, const std::string &key, const std::string &type, const std::string &units) override final
 
virtual InterfaceHandle getPublication (LocalFederateId federateID, const std::string &key) const override final
 
virtual InterfaceHandle registerInput (LocalFederateId federateID, const std::string &key, const std::string &type, const std::string &units) override final
 
virtual InterfaceHandle getInput (LocalFederateId federateID, const std::string &key) const override final
 
virtual const std::string & getHandleName (InterfaceHandle handle) const override final
 
virtual void setHandleOption (InterfaceHandle handle, int32_t option, int32_t option_value) override final
 
virtual int32_t getHandleOption (InterfaceHandle handle, int32_t option) const override final
 
virtual void closeHandle (InterfaceHandle handle) override final
 
virtual void removeTarget (InterfaceHandle handle, std::string_view targetToRemove) override final
 
virtual void addDestinationTarget (InterfaceHandle handle, std::string_view dest, InterfaceType hint) override final
 
virtual void addSourceTarget (InterfaceHandle handle, std::string_view name, InterfaceType hint) override final
 
virtual const std::string & getDestinationTargets (InterfaceHandle handle) const override final
 
virtual const std::string & getSourceTargets (InterfaceHandle handle) const override final
 
virtual const std::string & getInjectionUnits (InterfaceHandle handle) const override final
 
virtual const std::string & getExtractionUnits (InterfaceHandle handle) const override final
 
virtual const std::string & getInjectionType (InterfaceHandle handle) const override final
 
virtual const std::string & getExtractionType (InterfaceHandle handle) const override final
 
virtual void setValue (InterfaceHandle handle, const char *data, uint64_t len) override final
 
virtual const std::shared_ptr< const SmallBuffer > & getValue (InterfaceHandle handle, uint32_t *inputIndex) override final
 
virtual const std::vector< std::shared_ptr< const SmallBuffer > > & getAllValues (InterfaceHandle handle) override final
 
virtual const std::vector< InterfaceHandle > & getValueUpdates (LocalFederateId federateID) override final
 
virtual InterfaceHandle registerEndpoint (LocalFederateId federateID, const std::string &name, const std::string &type) override final
 
virtual InterfaceHandle registerTargetedEndpoint (LocalFederateId federateID, const std::string &name, const std::string &type) override final
 
virtual InterfaceHandle getEndpoint (LocalFederateId federateID, const std::string &name) const override final
 
virtual InterfaceHandle registerFilter (const std::string &filterName, const std::string &type_in, const std::string &type_out) override final
 
virtual InterfaceHandle registerCloningFilter (const std::string &filterName, const std::string &type_in, const std::string &type_out) override final
 
virtual InterfaceHandle getFilter (const std::string &name) const override final
 
virtual void addDependency (LocalFederateId federateID, const std::string &federateName) override final
 
virtual void linkEndpoints (const std::string &source, const std::string &dest) override final
 
virtual void makeConnections (const std::string &file) override final
 
virtual void dataLink (const std::string &source, const std::string &target) override final
 
virtual void addSourceFilterToEndpoint (const std::string &filter, const std::string &endpoint) override final
 
virtual void addDestinationFilterToEndpoint (const std::string &filter, const std::string &endpoint) override final
 
virtual void send (InterfaceHandle sourceHandle, const void *data, uint64_t length) override final
 
virtual void sendAt (InterfaceHandle sourceHandle, const void *data, uint64_t length, Time time) override final
 
virtual void sendTo (InterfaceHandle sourceHandle, const void *data, uint64_t length, std::string_view destination) override final
 
virtual void sendToAt (InterfaceHandle sourceHandle, const void *data, uint64_t length, std::string_view destination, Time time) override final
 
virtual void sendMessage (InterfaceHandle sourceHandle, std::unique_ptr< Message > message) override final
 
virtual uint64_t receiveCount (InterfaceHandle destination) override final
 
virtual std::unique_ptr< Messagereceive (InterfaceHandle destination) override final
 
virtual std::unique_ptr< MessagereceiveAny (LocalFederateId federateID, InterfaceHandle &endpoint_id) override final
 
virtual uint64_t receiveCountAny (LocalFederateId federateID) override final
 
virtual void logMessage (LocalFederateId federateID, int logLevel, const std::string &messageToLog) override final
 
virtual void setFilterOperator (InterfaceHandle filter, std::shared_ptr< FilterOperator > callback) override final
 
void setIdentifier (const std::string &name)
 
virtual const std::string & getIdentifier () const override final
 
virtual const std::string & getAddress () const override final
 
const std::string & getFederateNameNoThrow (GlobalFederateId federateID) const noexcept
 
virtual void setLoggingLevel (int logLevel) override
 
virtual void setLoggingCallback (LocalFederateId federateID, std::function< void(int, std::string_view, std::string_view)> logFunction) override final
 
virtual void setLogFile (const std::string &lfile) override final
 
virtual std::string query (const std::string &target, const std::string &queryStr, HelicsSequencingModes mode) override
 
virtual void setQueryCallback (LocalFederateId federateID, std::function< std::string(std::string_view)> queryFunction) override
 
virtual void setGlobal (const std::string &valueName, const std::string &value) override
 
virtual void sendCommand (const std::string &target, const std::string &commandStr, const std::string &source, HelicsSequencingModes mode) override
 
virtual std::pair< std::string, std::string > getCommand (LocalFederateId federateID) override
 
virtual std::pair< std::string, std::string > waitCommand (LocalFederateId federateID) override
 
virtual bool connect () override final
 
virtual bool isConnected () const override final
 
virtual void disconnect () override final
 
virtual bool waitForDisconnect (std::chrono::milliseconds msToWait=std::chrono::milliseconds(0)) const override final
 
void unregister ()
 
virtual void processDisconnect (bool skipUnregister=false) override final
 
void checkInFlightQueriesForDisconnect ()
 
virtual void setInterfaceInfo (InterfaceHandle handle, std::string info) override final
 
virtual const std::string & getInterfaceInfo (InterfaceHandle handle) const override final
 
virtual void setInterfaceTag (InterfaceHandle handle, const std::string &tag, const std::string &value) override final
 
virtual const std::string & getInterfaceTag (InterfaceHandle handle, const std::string &tag) const override final
 
virtual void setFederateTag (LocalFederateId fid, const std::string &tag, const std::string &value) override final
 
virtual const std::string & getFederateTag (LocalFederateId fid, const std::string &tag) const override final
 
- Public Member Functions inherited from helics::Core
 Core ()=default
 
virtual ~Core ()=default
 
virtual void globalError (LocalFederateId federateID, int32_t errorCode, const std::string &errorString)=0
 
virtual void localError (LocalFederateId federateID, int32_t errorCode, const std::string &errorString)=0
 
- Public Member Functions inherited from helics::BrokerBase
 BrokerBase (bool DisableQueue=false) noexcept
 
 BrokerBase (const std::string &broker_name, bool DisableQueue=false)
 
int parseArgs (int argc, char *argv[])
 
int parseArgs (std::vector< std::string > args)
 
int parseArgs (const std::string &initializationString)
 
virtual void configureBase ()
 
void addActionMessage (const ActionMessage &m)
 
void addActionMessage (ActionMessage &&m)
 
void setLoggerFunction (std::function< void(int level, std::string_view identifier, std::string_view message)> logFunction)
 
void logFlush ()
 
bool isRunning () const
 
void setLogLevel (int32_t level)
 
void setLogLevels (int32_t consoleLevel, int32_t fileLevel)
 
GlobalBrokerId getGlobalId () const
 
std::function< void(int, const std::string &, const std::string &)> getLoggingCallback () const
 
void joinAllThreads ()
 
std::size_t currentMessageCounter () const
 

Protected Member Functions

virtual void processCommand (ActionMessage &&command) override final
 
virtual void processPriorityCommand (ActionMessage &&command) override final
 
virtual void transmit (route_id rid, const ActionMessage &command)=0
 
virtual void transmit (route_id rid, ActionMessage &&command)=0
 
virtual void addRoute (route_id rid, int interfaceId, const std::string &routeInfo)=0
 
virtual void removeRoute (route_id rid)=0
 
FederateStategetFederateAt (LocalFederateId federateID) const
 
FederateStategetFederate (const std::string &federateName) const
 
FederateStategetHandleFederate (InterfaceHandle handle)
 
const BasicHandleInfogetHandleInfo (InterfaceHandle handle) const
 
const BasicHandleInfogetLocalEndpoint (const std::string &name) const
 
bool allInitReady () const
 
bool allDisconnected () const
 
operation_state minFederateState () const
 
virtual double getSimulationTime () const override
 
- Protected Member Functions inherited from helics::BrokerBase
void setTickForwarding (TickForwardingReasons reason, bool value=true)
 
BrokerState getBrokerState () const
 
bool setBrokerState (BrokerState newState)
 
bool transitionBrokerState (BrokerState expectedState, BrokerState newState)
 
virtual bool tryReconnect ()=0
 
virtual bool sendToLogger (GlobalFederateId federateID, int logLevel, std::string_view name, std::string_view message) const
 
void saveProfilingData (std::string_view message)
 
void writeProfilingData ()
 
void generateNewIdentifier ()
 
virtual std::string generateLocalAddressString () const =0
 
virtual std::shared_ptr< helicsCLI11AppgenerateCLI ()
 
void setErrorState (int eCode, std::string_view estring)
 
void setLoggingFile (const std::string &lfile)
 
bool getFlagValue (int32_t flag) const
 

Friends

class TimeoutMonitor
 

Additional Inherited Members

- Protected Types inherited from helics::BrokerBase
enum  BrokerState : int16_t {
  BrokerState::created = -6, BrokerState::configuring = -5, BrokerState::configured = -4, BrokerState::connecting = -3,
  BrokerState::connected = -2, BrokerState::initializing = -1, BrokerState::operating = 0, BrokerState::terminating = 1,
  BrokerState::terminated = 3, BrokerState::errored = 7
}
 
enum  TickForwardingReasons : uint32_t { NONE = 0, NO_COMMS = 0x01, PING_RESPONSE = 0x02, QUERY_TIMEOUT = 0x04 }
 
- Static Protected Member Functions inherited from helics::BrokerBase
static bool isReasonForTick (std::uint32_t code, TickForwardingReasons reason)
 
- Protected Attributes inherited from helics::BrokerBase
std::atomic< GlobalBrokerIdglobal_id {parent_broker_id}
 
GlobalBrokerId global_broker_id_local {}
 
GlobalBrokerId higher_broker_id {0}
 the id code of the broker 1 level about this broker
 
std::atomic< int32_t > maxLogLevel {HELICS_LOG_LEVEL_WARNING}
 
int32_t consoleLogLevel {HELICS_LOG_LEVEL_WARNING}
 the logging level for console display
 
int32_t fileLogLevel {HELICS_LOG_LEVEL_WARNING}
 the logging level for logging to a file
 
int32_t minFederateCount {1}
 
int32_t minBrokerCount {0}
 
int32_t maxFederateCount {(std::numeric_limits<int32_t>::max)()}
 
int32_t maxBrokerCount {(std::numeric_limits<int32_t>::max)()}
 
int32_t minChildCount {0}
 
int32_t maxIterationCount {10000}
 the maximum number of iterative loops that are allowed
 
Time tickTimer {5.0}
 the length of each heartbeat tick
 
Time timeout {30.0}
 timeout to wait to establish a broker connection before giving up
 
Time networkTimeout {-1.0}
 timeout to establish a socket connection before giving up
 
Time queryTimeout {15.0}
 
Time errorDelay {10.0}
 time to delay before terminating after error state
 
Time grantTimeout {-1.0}
 timeout for triggering diagnostic action waiting for a time grant
 
std::string identifier
 an identifier for the broker
 
std::string brokerKey
 
std::string address
 network location of the broker
 
std::shared_ptr< spdlog::logger > consoleLogger
 default logging object to use if the logging callback is not specified
 
std::shared_ptr< spdlog::logger > fileLogger
 default logging object to use if the logging callback is not specified
 
std::thread queueProcessingThread
 thread for running the broker
 
std::function< void(int, std::string_view, std::string_view)> loggerFunction
 
std::atomic< bool > haltOperations {false}
 flag indicating that no further message should be processed
 
bool restrictive_time_policy {false}
 flag indicating the broker should use a conservative time policy
 
bool terminate_on_error {false}
 flag indicating that the federation should halt on any error
 
bool debugging {false}
 flag indicating operation in a user debugging mode
 
bool observer {false}
 flag indicating that the broker is an observer only
 
std::string logFile
 the file to log message to
 
std::unique_ptr< ForwardingTimeCoordinatortimeCoord
 object managing the time control
 
gmlc::containers::BlockingPriorityQueue< ActionMessageactionQueue
 primary routing queue
 
bool noAutomaticID {false}
 the broker should not automatically generate an ID
 
bool hasTimeDependency {false}
 set to true if the broker has Time dependencies
 
bool enteredExecutionMode
 flag indicating that the broker has entered execution mode More...
 
bool waitingForBrokerPingReply {false}
 flag indicating we are waiting for a ping reply
 
bool hasFilters {false}
 flag indicating filters come through the broker
 
bool no_ping {false}
 indicator that the broker is not very responsive to ping requests
 
bool uuid_like {false}
 will be set to true if the name looks like a uuid
 
bool useJsonSerialization {false}
 
bool enable_profiling {false}
 indicator that profiling is enabled
 
decltype(std::chrono::steady_clock::now()) errorTimeStart
 time when the error condition started related to the errorDelay
 
std::atomic< int > lastErrorCode {0}
 storage for last error code
 
std::string lastErrorString
 storage for last error string
 
- Static Protected Attributes inherited from helics::BrokerBase
static constexpr double mInvalidSimulationTime {-98763.2}
 

Detailed Description

base class implementing a standard interaction strategy between federates

the CommonCore is virtual class that manages local federates and handles most of the interaction between federate it is meant to be instantiated for specific inter-federate communication strategies

Constructor & Destructor Documentation

◆ CommonCore() [1/3]

helics::CommonCore::CommonCore ( )
noexcept

default constructor

◆ CommonCore() [2/3]

helics::CommonCore::CommonCore ( bool  arg)
explicitnoexcept

function mainly to match some other object constructors does the same thing as the default constructor

◆ CommonCore() [3/3]

helics::CommonCore::CommonCore ( const std::string &  coreName)
explicit

construct from a core name

◆ ~CommonCore()

helics::CommonCore::~CommonCore ( )
overridevirtual

virtual destructor

References helics::BrokerBase::joinAllThreads().

Member Function Documentation

◆ addDependency()

void helics::CommonCore::addDependency ( LocalFederateId  federateID,
const std::string &  federateName 
)
finaloverridevirtual

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

Implements helics::Core.

References helics::BrokerBase::addActionMessage(), getFederateAt(), helics::FederateState::global_id, helics::ActionMessage::name(), and helics::ActionMessage::source_id.

◆ addDestinationFilterToEndpoint()

void helics::CommonCore::addDestinationFilterToEndpoint ( const std::string &  filter,
const std::string &  target 
)
finaloverridevirtual

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

Implements helics::Core.

References helics::BrokerBase::addActionMessage(), destination_target, helics::ActionMessage::name(), and setActionFlag().

◆ addDestinationTarget()

void helics::CommonCore::addDestinationTarget ( InterfaceHandle  handle,
std::string_view  dest,
InterfaceType  hint 
)
finaloverridevirtual

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
hintthe interface type for the destination target

Implements helics::Core.

References helics::BrokerBase::addActionMessage(), checkActionFlag(), clone_flag, destination_target, helics::ENDPOINT, helics::FILTER, getHandleInfo(), helics::INPUT, helics::PUBLICATION, setActionFlag(), and helics::ActionMessage::setSource().

◆ addRoute()

virtual void helics::CommonCore::addRoute ( route_id  rid,
int  interfaceId,
const std::string &  routeInfo 
)
protectedpure virtual

add a route to whatever internal structure manages the routes

Parameters
ridthe identification of the route
interfaceIdan interface id code that can be used to identify the interface route should be added to, in most cases this should be zero since there is only one interface
routeInfoa string containing the information necessary to connect

◆ addSourceFilterToEndpoint()

void helics::CommonCore::addSourceFilterToEndpoint ( const std::string &  filter,
const std::string &  target 
)
finaloverridevirtual

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

Implements helics::Core.

References helics::BrokerBase::addActionMessage(), and helics::ActionMessage::name().

◆ addSourceTarget()

void helics::CommonCore::addSourceTarget ( InterfaceHandle  handle,
std::string_view  name,
InterfaceType  hint 
)
finaloverridevirtual

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
hintthe interface type for the source target

Implements helics::Core.

References helics::BrokerBase::addActionMessage(), checkActionFlag(), clone_flag, helics::ENDPOINT, helics::FILTER, getHandleInfo(), helics::INPUT, helics::PUBLICATION, setActionFlag(), and helics::ActionMessage::setSource().

◆ allDisconnected()

bool helics::CommonCore::allDisconnected ( ) const
protected

◆ allInitReady()

bool helics::CommonCore::allInitReady ( ) const
protected

check if all federates managed by the core are ready to enter initialization state

References helics::BrokerBase::minChildCount, and helics::BrokerBase::minFederateCount.

◆ checkInFlightQueriesForDisconnect()

void helics::CommonCore::checkInFlightQueriesForDisconnect ( )

check to make sure there are no inflight queries that need to be resolved before disconnect

References helics::BrokerBase::global_broker_id_local.

◆ closeHandle()

void helics::CommonCore::closeHandle ( InterfaceHandle  handle)
finaloverridevirtual

close a handle from further connections

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

Implements helics::Core.

References helics::BrokerBase::addActionMessage(), checkActionFlag(), disconnected_flag, getHandleInfo(), and setActionFlag().

◆ configure()

void helics::CommonCore::configure ( const std::string &  configureString)
finaloverridevirtual

Configure the core from a configuration string

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

Implements helics::Core.

References helics::BrokerBase::configureBase(), helics::BrokerBase::configuring, helics::BrokerBase::created, and helics::BrokerBase::parseArgs().

◆ configureFromArgs()

void helics::CommonCore::configureFromArgs ( int  argc,
char *  argv[] 
)
finaloverridevirtual

Configure the core from command line arguments.

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

Implements helics::Core.

References helics::BrokerBase::configureBase(), helics::BrokerBase::configuring, helics::BrokerBase::created, and helics::BrokerBase::parseArgs().

◆ configureFromVector()

void helics::CommonCore::configureFromVector ( std::vector< std::string >  args)
finaloverridevirtual

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

Implements helics::Core.

References helics::BrokerBase::configureBase(), helics::BrokerBase::configuring, helics::BrokerBase::created, and helics::BrokerBase::parseArgs().

◆ connect()

bool helics::CommonCore::connect ( )
finaloverridevirtual

◆ dataLink()

void helics::CommonCore::dataLink ( const std::string &  source,
const std::string &  target 
)
finaloverridevirtual

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

Parameters
sourcethe name of the publication
targetthe name of the input

Implements helics::Core.

References helics::BrokerBase::addActionMessage(), and helics::ActionMessage::name().

◆ disconnect()

void helics::CommonCore::disconnect ( )
finaloverridevirtual

disconnect the core from its broker

Implements helics::Core.

References helics::BrokerBase::addActionMessage(), and waitForDisconnect().

◆ enterExecutingMode()

IterationResult helics::CommonCore::enterExecutingMode ( LocalFederateId  federateID,
IterationRequest  iterate = NO_ITERATION 
)
finaloverridevirtual

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

Implements helics::Core.

References helics::FederateState::addAction(), helics::BrokerBase::addActionMessage(), helics::ActionMessage::dest_id, helics::FederateState::enterExecutingMode(), getFederateAt(), helics::FederateState::getState(), helics::FederateState::global_id, helics::HELICS_EXECUTING, helics::HELICS_INITIALIZING, indicator_flag, helics::NEXT_STEP, setActionFlag(), helics::setIterationFlags(), and helics::ActionMessage::source_id.

◆ enterInitializingMode()

void helics::CommonCore::enterInitializingMode ( LocalFederateId  federateID)
finaloverridevirtual

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

Implements helics::Core.

References helics::BrokerBase::addActionMessage(), helics::FederateState::enterInitializingMode(), getFederateAt(), helics::FederateState::getState(), helics::FederateState::global_id, helics::HALTED, helics::HELICS_INITIALIZING, helics::FederateState::init_requested, helics::NEXT_STEP, and helics::ActionMessage::source_id.

◆ finalize()

void helics::CommonCore::finalize ( LocalFederateId  federateID)
finaloverridevirtual

Federate has completed.

Should be invoked a single time to complete the simulation.

Implements helics::Core.

References helics::BrokerBase::addActionMessage(), helics::ActionMessage::dest_id, getFederateAt(), and helics::ActionMessage::source_id.

◆ getAddress()

const std::string & helics::CommonCore::getAddress ( ) const
finaloverridevirtual

get the connection network or connection address for the core

Implements helics::Core.

References helics::BrokerBase::address, helics::BrokerBase::connected, and helics::BrokerBase::generateLocalAddressString().

Referenced by connect().

◆ getAllValues()

const std::vector< std::shared_ptr< const SmallBuffer > > & helics::CommonCore::getAllValues ( InterfaceHandle  handle)
finaloverridevirtual

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

Implements helics::Core.

References helics::FederateState::getAllValues(), getFederateAt(), getHandleInfo(), and helics::INPUT.

◆ getCommand()

std::pair< std::string, std::string > helics::CommonCore::getCommand ( LocalFederateId  federateID)
overridevirtual

get a command for a specific federate

Implements helics::Core.

References helics::FederateState::getCommand(), and getFederateAt().

◆ getCurrentReiteration()

uint64_t helics::CommonCore::getCurrentReiteration ( LocalFederateId  federateID) const
finaloverridevirtual

Returns the current reiteration count for the specified federate.

Implements helics::Core.

References helics::FederateState::getCurrentIteration(), and getFederateAt().

◆ getCurrentTime()

Time helics::CommonCore::getCurrentTime ( LocalFederateId  federateID) const
finaloverridevirtual

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

Implements helics::Core.

References getFederateAt(), and helics::FederateState::grantedTime().

◆ getDestinationTargets()

const std::string & helics::CommonCore::getDestinationTargets ( InterfaceHandle  handle) const
finaloverridevirtual

get the destination targets for an interface

Parameters
handlean interface get the destination targets for

Implements helics::Core.

References helics::ENDPOINT, helics::FILTER, helics::EndpointInfo::getDestinationTargets(), getFederateAt(), getHandleInfo(), helics::INPUT, helics::FederateState::interfaces(), and helics::PUBLICATION.

◆ getEndpoint()

InterfaceHandle helics::CommonCore::getEndpoint ( LocalFederateId  federateID,
const std::string &  name 
) const
finaloverridevirtual

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

Implements helics::Core.

◆ getErrorCode()

int helics::CommonCore::getErrorCode ( ) const
finaloverridevirtual

get the last error code from a core

Implements helics::Core.

References helics::BrokerBase::lastErrorCode.

◆ getErrorMessage()

std::string helics::CommonCore::getErrorMessage ( ) const
finaloverridevirtual

get the last error message

Implements helics::Core.

References helics::BrokerBase::lastErrorCode, and helics::BrokerBase::lastErrorString.

◆ getExtractionType()

const std::string & helics::CommonCore::getExtractionType ( InterfaceHandle  handle) const
finaloverridevirtual

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

Implements helics::Core.

References helics::ENDPOINT, helics::FILTER, getHandleInfo(), helics::INPUT, and helics::PUBLICATION.

◆ getExtractionUnits()

const std::string & helics::CommonCore::getExtractionUnits ( InterfaceHandle  handle) const
finaloverridevirtual
Returns
the unit string for the specified handle.

Implements helics::Core.

References getHandleInfo(), helics::INPUT, and helics::PUBLICATION.

◆ getFederate()

FederateState * helics::CommonCore::getFederate ( const std::string &  federateName) const
protected

get the federate Information from the federateID

Referenced by sendCommand().

◆ getFederateAt()

FederateState * helics::CommonCore::getFederateAt ( LocalFederateId  federateID) const
protected

◆ getFederateId()

LocalFederateId helics::CommonCore::getFederateId ( const std::string &  name) const
finaloverridevirtual

Returns the federate Id.

Implements helics::Core.

References helics::FederateState::local_id.

◆ getFederateName()

const std::string & helics::CommonCore::getFederateName ( LocalFederateId  federateID) const
finaloverridevirtual

Returns the federate name.

Implements helics::Core.

References getFederateAt(), and helics::FederateState::getIdentifier().

◆ getFederateTag()

const std::string & helics::CommonCore::getFederateTag ( LocalFederateId  fid,
const std::string &  tag 
) const
finaloverridevirtual

getter for the federate tags

Parameters
fidthe identifier for the federate to get the tag data for
tagthe name of the tag to retrieve
Returns
a reference to a const std::string with the tag value.

Implements helics::Core.

References getFederateAt(), helics::gLocalCoreId(), HELICS_SEQUENCING_MODE_ORDERED, and query().

◆ getFederationSize()

int32_t helics::CommonCore::getFederationSize ( )
finaloverridevirtual

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

Implements helics::Core.

References helics::BrokerBase::operating.

◆ getFilter()

InterfaceHandle helics::CommonCore::getFilter ( const std::string &  name) const
finaloverridevirtual

get a 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

Implements helics::Core.

References helics::FILTER.

◆ getFlagOption()

bool helics::CommonCore::getFlagOption ( LocalFederateId  federateID,
int32_t  flag 
) const
finaloverridevirtual

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

Implements helics::Core.

References getFederateAt(), helics::BrokerBase::getFlagValue(), helics::FederateState::getOptionFlag(), and helics::gLocalCoreId().

◆ getHandleFederate()

FederateState * helics::CommonCore::getHandleFederate ( InterfaceHandle  handle)
protected

get the federate Information from a handle

Parameters
handlea handle identifier as generated by the one of the functions

Referenced by receive(), receiveCount(), and setHandleOption().

◆ getHandleInfo()

const BasicHandleInfo * helics::CommonCore::getHandleInfo ( InterfaceHandle  handle) const
protected

◆ getHandleName()

const std::string & helics::CommonCore::getHandleName ( InterfaceHandle  handle) const
finaloverridevirtual

Returns the name or identifier for a specified handle

Implements helics::Core.

References getHandleInfo().

◆ getHandleOption()

int32_t helics::CommonCore::getHandleOption ( InterfaceHandle  handle,
int32_t  option 
) const
finaloverridevirtual

get a handle option

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

Implements helics::Core.

References getHandleInfo().

◆ getIdentifier()

const std::string & helics::CommonCore::getIdentifier ( ) const
finaloverridevirtual

get the local identifier for the core

Implements helics::Core.

References helics::BrokerBase::identifier.

Referenced by connect(), processDisconnect(), query(), sendCommand(), and helics::TimeoutMonitor::tick().

◆ getInjectionType()

const std::string & helics::CommonCore::getInjectionType ( InterfaceHandle  handle) const
finaloverridevirtual

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

Implements helics::Core.

References helics::ENDPOINT, helics::FILTER, getFederateAt(), getHandleInfo(), helics::INPUT, and helics::FederateState::interfaces().

◆ getInjectionUnits()

const std::string & helics::CommonCore::getInjectionUnits ( InterfaceHandle  handle) const
finaloverridevirtual

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

Implements helics::Core.

References getFederateAt(), getHandleInfo(), helics::INPUT, helics::FederateState::interfaces(), and helics::PUBLICATION.

◆ getInput()

InterfaceHandle helics::CommonCore::getInput ( LocalFederateId  federateID,
const std::string &  key 
) const
finaloverridevirtual

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

Implements helics::Core.

◆ getIntegerProperty()

int16_t helics::CommonCore::getIntegerProperty ( LocalFederateId  federateID,
int32_t  property 
) const
finaloverridevirtual

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

Implements helics::Core.

References helics::BrokerBase::consoleLogLevel, helics::BrokerBase::fileLogLevel, getFederateAt(), helics::FederateState::getIntegerProperty(), helics::gLocalCoreId(), HELICS_PROPERTY_INT_CONSOLE_LOG_LEVEL, HELICS_PROPERTY_INT_FILE_LOG_LEVEL, and HELICS_PROPERTY_INT_LOG_LEVEL.

◆ getInterfaceInfo()

const std::string & helics::CommonCore::getInterfaceInfo ( InterfaceHandle  handle) const
finaloverridevirtual

get the local information field of the interface

Implements helics::Core.

References getHandleInfo().

◆ getInterfaceTag()

const std::string & helics::CommonCore::getInterfaceTag ( InterfaceHandle  handle,
const std::string &  tag 
) const
finaloverridevirtual

getter for the interface tags

Parameters
handlethe identifier for the interface to set the info data on
tagthe name of the tag to retrieve

Implements helics::Core.

References getHandleInfo().

◆ getLocalEndpoint()

const BasicHandleInfo * helics::CommonCore::getLocalEndpoint ( const std::string &  name) const
protected

get a localEndpoint from the name

◆ getPublication()

InterfaceHandle helics::CommonCore::getPublication ( LocalFederateId  federateID,
const std::string &  key 
) const
finaloverridevirtual

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

Implements helics::Core.

◆ getSimulationTime()

double helics::CommonCore::getSimulationTime ( ) const
overrideprotectedvirtual

virtual function to return the current simulation time

Reimplemented from helics::BrokerBase.

◆ getSourceTargets()

const std::string & helics::CommonCore::getSourceTargets ( InterfaceHandle  handle) const
finaloverridevirtual

get the source targets for an interface

Parameters
handlethe identifier of the interface

Implements helics::Core.

References helics::ENDPOINT, helics::FILTER, getFederateAt(), getHandleInfo(), helics::EndpointInfo::getSourceTargets(), helics::INPUT, helics::FederateState::interfaces(), and helics::PUBLICATION.

◆ getTimeProperty()

Time helics::CommonCore::getTimeProperty ( LocalFederateId  federateID,
int32_t  property 
) const
finaloverridevirtual

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

Implements helics::Core.

References getFederateAt(), and helics::FederateState::getTimeProperty().

◆ getValue()

const std::shared_ptr< const SmallBuffer > & helics::CommonCore::getValue ( InterfaceHandle  handle,
uint32_t *  inputIndex 
)
finaloverridevirtual

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)

Implements helics::Core.

References getFederateAt(), getHandleInfo(), helics::FederateState::getValue(), and helics::INPUT.

◆ getValueUpdates()

const std::vector< InterfaceHandle > & helics::CommonCore::getValueUpdates ( LocalFederateId  federateID)
finaloverridevirtual

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

Implements helics::Core.

References helics::FederateState::getEvents(), and getFederateAt().

◆ isConfigured()

bool helics::CommonCore::isConfigured ( ) const
finaloverridevirtual

Returns true if the core has been configured.

Implements helics::Core.

References helics::BrokerBase::configured.

◆ isConnected()

bool helics::CommonCore::isConnected ( ) const
finaloverridevirtual

check if the core is connected properly

Implements helics::Core.

References helics::BrokerBase::connected, and helics::BrokerBase::operating.

Referenced by helics::TimeoutMonitor::tick().

◆ isOpenToNewFederates()

bool helics::CommonCore::isOpenToNewFederates ( ) const
finaloverridevirtual

check if the core is ready to accept new federates

Implements helics::Core.

References helics::BrokerBase::created, and helics::BrokerBase::operating.

◆ linkEndpoints()

void helics::CommonCore::linkEndpoints ( const std::string &  source,
const std::string &  dest 
)
finaloverridevirtual

Register communicating source/destination endpoint targets.

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

Implements helics::Core.

References helics::BrokerBase::addActionMessage(), and helics::ActionMessage::name().

◆ logMessage()

void helics::CommonCore::logMessage ( LocalFederateId  federateID,
int  logLevel,
const std::string &  messageToLog 
)
finaloverridevirtual

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

Implements helics::Core.

References helics::BrokerBase::actionQueue, helics::ActionMessage::dest_id, getFederateAt(), helics::BrokerBase::global_id, helics::FederateState::global_id, helics::gLocalCoreId(), helics::ActionMessage::messageID, helics::ActionMessage::payload, and helics::ActionMessage::source_id.

◆ makeConnections()

void helics::CommonCore::makeConnections ( const std::string &  file)
finaloverridevirtual

load a file containing connection information

Parameters
filea JSON or TOML file containing connection information

Implements helics::Core.

◆ minFederateState()

operation_state helics::CommonCore::minFederateState ( ) const
protected

get the minimum operating state of the connected federates

Referenced by allDisconnected().

◆ processCommand()

void helics::CommonCore::processCommand ( ActionMessage &&  cmd)
finaloverrideprotectedvirtual

process a single command action

cmd may be modified by this function

Implements helics::BrokerBase.

Referenced by helics::TimeoutMonitor::tick().

◆ processDisconnect()

void helics::CommonCore::processDisconnect ( bool  skipUnregister = false)
finaloverridevirtual

◆ processPriorityCommand()

void helics::CommonCore::processPriorityCommand ( ActionMessage &&  command)
finaloverrideprotectedvirtual

function to process a priority command independent of the main queue

called when processing a priority command. The priority command has a response message which gets sent this mainly deals with some of the registration functions

Parameters
commandthe command to process

Implements helics::BrokerBase.

◆ query()

std::string helics::CommonCore::query ( const std::string &  target,
const std::string &  queryStr,
HelicsSequencingModes  mode 
)
overridevirtual

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_value" to query a global value stored in the broker, or "global" to get a json structure with the name and value

Parameters
targetthe specific target of the query
queryStrthe actual query
modethe sequencing mode for the query, fast or ordered
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

Implements helics::Core.

References helics::generateJsonErrorResponse(), getIdentifier(), and helics::BrokerBase::terminating.

Referenced by getFederateTag().

◆ receive()

std::unique_ptr< Message > helics::CommonCore::receive ( InterfaceHandle  destination)
finaloverridevirtual

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

Implements helics::Core.

References getHandleFederate(), helics::FederateState::getState(), helics::HELICS_EXECUTING, and helics::FederateState::receive().

◆ receiveAny()

std::unique_ptr< Message > helics::CommonCore::receiveAny ( LocalFederateId  federateID,
InterfaceHandle endpoint_id 
)
finaloverridevirtual

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

Implements helics::Core.

References getFederateAt(), helics::FederateState::getState(), and helics::FederateState::receiveAny().

◆ receiveCount()

uint64_t helics::CommonCore::receiveCount ( InterfaceHandle  destination)
finaloverridevirtual

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

Implements helics::Core.

References getHandleFederate(), and helics::FederateState::getQueueSize().

◆ receiveCountAny()

uint64_t helics::CommonCore::receiveCountAny ( LocalFederateId  federateID)
finaloverridevirtual

Returns number of messages for all destinations.

Implements helics::Core.

References getFederateAt(), helics::FederateState::getQueueSize(), and helics::FederateState::getState().

◆ registerCloningFilter()

InterfaceHandle helics::CommonCore::registerCloningFilter ( const std::string &  filterName,
const std::string &  type_in,
const std::string &  type_out 
)
finaloverridevirtual

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

Implements helics::Core.

References helics::BrokerBase::actionQueue, clone_flag, helics::FILTER, make_flags(), helics::ActionMessage::name(), setActionFlag(), helics::ActionMessage::source_handle, helics::ActionMessage::source_id, and helics::BrokerBase::terminating.

◆ registerEndpoint()

InterfaceHandle helics::CommonCore::registerEndpoint ( LocalFederateId  federateID,
const std::string &  name,
const std::string &  type 
)
finaloverridevirtual

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

Parameters
federateIDthe federate to associate the endpoint with
namethe name of the endpoint
typethe type of data the endpoint should accept or generate(can be left empty)

Implements helics::Core.

References helics::BrokerBase::actionQueue, helics::FederateState::createInterface(), helics::ENDPOINT, helics::ActionMessage::flags, getFederateAt(), helics::FederateState::getInterfaceFlags(), helics::FederateState::global_id, helics::FederateState::local_id, helics::ActionMessage::name(), helics::ActionMessage::source_handle, and helics::ActionMessage::source_id.

◆ registerFederate()

LocalFederateId helics::CommonCore::registerFederate ( const std::string &  name,
const CoreFederateInfo info 
)
finaloverridevirtual

◆ registerFilter()

InterfaceHandle helics::CommonCore::registerFilter ( const std::string &  filterName,
const std::string &  type_in,
const std::string &  type_out 
)
finaloverridevirtual

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

Implements helics::Core.

References helics::BrokerBase::actionQueue, helics::FILTER, helics::ActionMessage::name(), helics::ActionMessage::source_handle, helics::ActionMessage::source_id, and helics::BrokerBase::terminating.

◆ registerInput()

InterfaceHandle helics::CommonCore::registerInput ( LocalFederateId  federateID,
const std::string &  key,
const std::string &  type,
const std::string &  units 
)
finaloverridevirtual

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

Implements helics::Core.

References helics::FederateState::createInterface(), getFederateAt(), helics::FederateState::getInterfaceFlags(), helics::FederateState::global_id, helics::INPUT, and helics::FederateState::local_id.

◆ registerPublication()

InterfaceHandle helics::CommonCore::registerPublication ( LocalFederateId  federateID,
const std::string &  key,
const std::string &  type,
const std::string &  units 
)
finaloverridevirtual

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

Implements helics::Core.

References getFederateAt().

◆ registerTargetedEndpoint()

InterfaceHandle helics::CommonCore::registerTargetedEndpoint ( LocalFederateId  federateID,
const std::string &  name,
const std::string &  type 
)
finaloverridevirtual

Register an endpoint which can only send or receive to specific targets

Parameters
federateIDthe federate to associate the endpoint with
namethe name of the endpoint
typethe type of data the endpoint should accept or generate(can be left empty)

Implements helics::Core.

References helics::BrokerBase::actionQueue, helics::FederateState::createInterface(), helics::ENDPOINT, helics::ActionMessage::flags, getFederateAt(), helics::FederateState::getInterfaceFlags(), helics::FederateState::global_id, helics::FederateState::local_id, helics::ActionMessage::name(), helics::ActionMessage::source_handle, helics::ActionMessage::source_id, and targetted_flag.

◆ removeRoute()

virtual void helics::CommonCore::removeRoute ( route_id  rid)
protectedpure virtual

remove or disconnect a route from use

Parameters
ridthe identification of the route

◆ removeTarget()

void helics::CommonCore::removeTarget ( InterfaceHandle  handle,
std::string_view  targetToRemove 
)
finaloverridevirtual

remove a target from a handles operation

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

Implements helics::Core.

References helics::FederateState::addAction(), helics::BrokerBase::addActionMessage(), helics::ENDPOINT, helics::FILTER, getFederateAt(), getHandleInfo(), helics::FederateState::grantedTime(), helics::INPUT, helics::PUBLICATION, and helics::ActionMessage::setSource().

◆ requestTimeIterative()

iteration_time helics::CommonCore::requestTimeIterative ( LocalFederateId  federateID,
Time  next,
IterationRequest  iterate 
)
finaloverridevirtual

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

Implements helics::Core.

References helics::ActionMessage::actionTime, helics::BrokerBase::addActionMessage(), helics::ActionMessage::dest_id, helics::ERROR_RESULT, helics::FederateState::getCurrentIteration(), getFederateAt(), helics::FederateState::getState(), helics::FederateState::global_id, helics::HALTED, helics::HELICS_ERROR, helics::HELICS_EXECUTING, helics::HELICS_FINISHED, helics::HELICS_INITIALIZING, helics::HELICS_TERMINATING, helics::HELICS_UNKNOWN, indicator_flag, helics::ITERATE_IF_NEEDED, helics::BrokerBase::maxIterationCount, helics::NO_ITERATIONS, helics::FederateState::requestTime(), setActionFlag(), helics::setIterationFlags(), helics::ActionMessage::source_id, and helics::timeZero.

◆ send()

void helics::CommonCore::send ( InterfaceHandle  sourceHandle,
const void *  data,
uint64_t  length 
)
finaloverridevirtual

Send data from a source to its targets

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.

Implements helics::Core.

References helics::ActionMessage::actionTime, helics::SmallBuffer::assign(), helics::ENDPOINT, getFederateAt(), getHandleInfo(), helics::FederateState::getMessageDestinations(), helics::ActionMessage::messageID, helics::FederateState::nextAllowedSendTime(), helics::ActionMessage::payload, helics::ActionMessage::source_handle, and helics::ActionMessage::source_id.

◆ sendAt()

void helics::CommonCore::sendAt ( InterfaceHandle  sourceHandle,
const void *  data,
uint64_t  length,
Time  time 
)
finaloverridevirtual

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
sourceHandlethe source of the event
datathe raw data for the event
lengththe record length of the event
timethe time the event is scheduled for

Implements helics::Core.

References helics::ActionMessage::actionTime, helics::SmallBuffer::assign(), helics::ENDPOINT, getFederateAt(), getHandleInfo(), helics::FederateState::getMessageDestinations(), helics::ActionMessage::messageID, helics::FederateState::nextAllowedSendTime(), helics::ActionMessage::payload, helics::ActionMessage::source_handle, and helics::ActionMessage::source_id.

◆ sendCommand()

void helics::CommonCore::sendCommand ( const std::string &  target,
const std::string &  commandStr,
const std::string &  source,
HelicsSequencingModes  mode 
)
overridevirtual

send a command to a specific target

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

Parameters
targetthe specific target of the command
commandStrthe actual command
sourcethe designated source of the command, for return values or indication
modethe sequencing mode for the command, fast or ordered

Implements helics::Core.

References helics::BrokerBase::addActionMessage(), helics::ActionMessage::dest_id, getFederate(), helics::BrokerBase::getGlobalId(), getIdentifier(), HELICS_SEQUENCING_MODE_ORDERED, helics::parent_broker_id, helics::ActionMessage::payload, and helics::ActionMessage::source_id.

◆ sendMessage()

void helics::CommonCore::sendMessage ( InterfaceHandle  sourceHandle,
std::unique_ptr< Message message 
)
finaloverridevirtual

◆ sendTo()

void helics::CommonCore::sendTo ( InterfaceHandle  sourceHandle,
const void *  data,
uint64_t  length,
std::string_view  destination 
)
finaloverridevirtual

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.

Implements helics::Core.

References helics::ActionMessage::actionTime, helics::BrokerBase::addActionMessage(), helics::SmallBuffer::assign(), checkActionFlag(), helics::ENDPOINT, helics::ActionMessage::flags, getFederateAt(), getHandleInfo(), helics::ActionMessage::messageID, helics::FederateState::nextAllowedSendTime(), helics::ActionMessage::payload, helics::ActionMessage::source_handle, helics::ActionMessage::source_id, and targetted_flag.

◆ sendToAt()

void helics::CommonCore::sendToAt ( InterfaceHandle  sourceHandle,
const void *  data,
uint64_t  length,
std::string_view  destination,
Time  time 
)
finaloverridevirtual

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
sourceHandlethe source of the event
datathe raw data for the event
lengththe record length of the event
destinationthe target of the event
timethe time the event is scheduled for

Implements helics::Core.

References helics::ActionMessage::actionTime, helics::BrokerBase::addActionMessage(), helics::SmallBuffer::assign(), checkActionFlag(), helics::ENDPOINT, helics::ActionMessage::flags, getFederateAt(), getHandleInfo(), helics::ActionMessage::messageID, helics::FederateState::nextAllowedSendTime(), helics::ActionMessage::payload, helics::ActionMessage::source_handle, helics::ActionMessage::source_id, and targetted_flag.

◆ setCoreReadyToInit()

void helics::CommonCore::setCoreReadyToInit ( )
finaloverridevirtual

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

Implements helics::Core.

References helics::gLocalCoreId(), and setFlagOption().

◆ setFederateTag()

void helics::CommonCore::setFederateTag ( LocalFederateId  fid,
const std::string &  tag,
const std::string &  value 
)
finaloverridevirtual

setter for federate tags which are key-value pairs

Parameters
fidthe identifier for the federate to set the tag data on
taga string containing the name of the tag
valuea string containing the value for the tag

Implements helics::Core.

References helics::BrokerBase::addActionMessage(), helics::ActionMessage::dest_id, getFederateAt(), helics::BrokerBase::getGlobalId(), helics::gLocalCoreId(), and helics::ActionMessage::source_id.

◆ setFilterOperator()

void helics::CommonCore::setFilterOperator ( InterfaceHandle  filter,
std::shared_ptr< FilterOperator callback 
)
finaloverridevirtual

set the filter callback operator

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

Implements helics::Core.

References helics::BrokerBase::actionQueue, helics::ActionMessage::counter, helics::FILTER, getHandleInfo(), helics::ActionMessage::messageID, helics::ActionMessage::source_handle, and helics::ActionMessage::source_id.

◆ setFlagOption()

void helics::CommonCore::setFlagOption ( LocalFederateId  federateID,
int32_t  flag,
bool  flagValue = true 
)
finaloverridevirtual

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

Implements helics::Core.

References helics::BrokerBase::addActionMessage(), getFederateAt(), helics::gLocalCoreId(), indicator_flag, setActionFlag(), and helics::FederateState::setProperties().

Referenced by setCoreReadyToInit().

◆ setGlobal()

void helics::CommonCore::setGlobal ( const std::string &  valueName,
const std::string &  value 
)
overridevirtual

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

Implements helics::Core.

References helics::BrokerBase::addActionMessage(), helics::ActionMessage::dest_id, helics::direct_core_id, helics::ActionMessage::payload, helics::root_broker_id, and helics::ActionMessage::source_id.

◆ setHandleOption()

void helics::CommonCore::setHandleOption ( InterfaceHandle  handle,
int32_t  option,
int32_t  option_value 
)
finaloverridevirtual

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)

Implements helics::Core.

References helics::ActionMessage::counter, helics::ActionMessage::dest_handle, helics::ActionMessage::dest_id, helics::FILTER, getHandleFederate(), getHandleInfo(), helics::FederateState::global_id, indicator_flag, helics::ActionMessage::messageID, setActionFlag(), helics::ActionMessage::setExtraDestData(), and helics::FederateState::setProperties().

◆ setIdentifier()

void helics::CommonCore::setIdentifier ( const std::string &  name)

set the local identification for the core

References helics::BrokerBase::created, and helics::BrokerBase::identifier.

◆ setIntegerProperty()

void helics::CommonCore::setIntegerProperty ( LocalFederateId  federateID,
int32_t  property,
int16_t  propValue 
)
finaloverridevirtual

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

Implements helics::Core.

References helics::BrokerBase::addActionMessage(), getFederateAt(), helics::BrokerBase::global_id, helics::gLocalCoreId(), and helics::FederateState::setProperties().

◆ setInterfaceInfo()

void helics::CommonCore::setInterfaceInfo ( helics::InterfaceHandle  handle,
std::string  info 
)
finaloverridevirtual

set the local information field of the interface

Implements helics::Core.

References helics::InterfaceHandle::baseValue().

◆ setInterfaceTag()

void helics::CommonCore::setInterfaceTag ( InterfaceHandle  handle,
const std::string &  tag,
const std::string &  value 
)
finaloverridevirtual

setter for interface tags which are key-value pairs

Parameters
handlethe identifier for the interface to set the tag data on
taga string containing the name of the tag
valuea string containing the value for the tag

Implements helics::Core.

References helics::BrokerBase::addActionMessage(), helics::InterfaceHandle::baseValue(), getHandleInfo(), helics::ActionMessage::setDestination(), and helics::ActionMessage::setSource().

◆ setLogFile()

void helics::CommonCore::setLogFile ( const std::string &  lfile)
finaloverridevirtual

set the core logging file

Implements helics::Core.

References helics::BrokerBase::setLoggingFile().

◆ setLoggingCallback()

void helics::CommonCore::setLoggingCallback ( LocalFederateId  federateID,
std::function< void(int, std::string_view, std::string_view)>  logFunction 
)
finaloverridevirtual

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

Implements helics::Core.

References helics::BrokerBase::actionQueue, helics::ActionMessage::counter, helics::ActionMessage::dest_id, empty_flag, getFederateAt(), helics::BrokerBase::global_id, helics::gLocalCoreId(), helics::ActionMessage::messageID, setActionFlag(), helics::FederateState::setLogger(), and helics::ActionMessage::source_id.

◆ setLoggingLevel()

void helics::CommonCore::setLoggingLevel ( int  logLevel)
overridevirtual

set the core logging level

Implements helics::Core.

References helics::BrokerBase::global_id.

◆ setQueryCallback()

void helics::CommonCore::setQueryCallback ( LocalFederateId  federateID,
std::function< std::string(std::string_view)>  queryFunction 
)
overridevirtual

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

Implements helics::Core.

References getFederateAt(), and helics::FederateState::setQueryCallback().

◆ setTimeProperty()

void helics::CommonCore::setTimeProperty ( LocalFederateId  federateID,
int32_t  property,
Time  timeValue 
)
finaloverridevirtual

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

Implements helics::Core.

References getFederateAt(), helics::FederateState::setProperties(), and helics::timeZero.

◆ setValue()

void helics::CommonCore::setValue ( InterfaceHandle  handle,
const char *  data,
uint64_t  len 
)
finaloverridevirtual

◆ timeRequest()

Time helics::CommonCore::timeRequest ( LocalFederateId  federateID,
Time  next 
)
finaloverridevirtual

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

Implements helics::Core.

References helics::ActionMessage::actionTime, helics::BrokerBase::addActionMessage(), helics::ActionMessage::dest_id, helics::ERROR_RESULT, getFederateAt(), helics::FederateState::getState(), helics::FederateState::global_id, helics::HALTED, helics::HELICS_EXECUTING, helics::HELICS_FINISHED, indicator_flag, helics::FederateState::lastErrorString(), helics::NO_ITERATIONS, helics::FederateState::requestTime(), setActionFlag(), and helics::ActionMessage::source_id.

◆ transmit() [1/2]

virtual void helics::CommonCore::transmit ( route_id  rid,
ActionMessage &&  command 
)
protectedpure virtual

transit an ActionMessage to another core or broker

Parameters
ridthe identifier for the route information to send the message to
commandthe actionMessage to send

◆ transmit() [2/2]

virtual void helics::CommonCore::transmit ( route_id  rid,
const ActionMessage command 
)
protectedpure virtual

transit an ActionMessage to another core or broker

Parameters
ridthe identifier for the route information to send the message to
commandthe actionMessage to send

Referenced by connect(), processDisconnect(), and helics::TimeoutMonitor::tick().

◆ unregister()

void helics::CommonCore::unregister ( )

unregister the core from any process find functions

References helics::CoreFactory::findCore(), helics::BrokerBase::identifier, and helics::CoreFactory::unregisterCore().

Referenced by processDisconnect().

◆ waitCommand()

std::pair< std::string, std::string > helics::CommonCore::waitCommand ( LocalFederateId  federateID)
overridevirtual

get a command for a specific federate. block until a command is received

Implements helics::Core.

References getFederateAt(), and helics::FederateState::waitCommand().

◆ waitForDisconnect()

bool helics::CommonCore::waitForDisconnect ( std::chrono::milliseconds  msToWait = std::chrono::milliseconds(0)) const
finaloverridevirtual

waits in the current thread until the core is disconnected

Returns
true if the disconnect was successful

Implements helics::Core.

Referenced by disconnect().


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