![]() |
helics
2.8.1
|
#include <CommonCore.hpp>
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 (local_federate_id federateID, int errorCode, const std::string &errorString) override final |
virtual void | localError (local_federate_id 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 (local_federate_id federateID) override final |
virtual void | enterInitializingMode (local_federate_id federateID) override final |
virtual void | setCoreReadyToInit () override final |
virtual iteration_result | enterExecutingMode (local_federate_id federateID, iteration_request iterate=NO_ITERATION) override final |
virtual local_federate_id | registerFederate (const std::string &name, const CoreFederateInfo &info) override final |
virtual const std::string & | getFederateName (local_federate_id federateID) const override final |
virtual local_federate_id | getFederateId (const std::string &name) const override final |
virtual int32_t | getFederationSize () override final |
virtual Time | timeRequest (local_federate_id federateID, Time next) override final |
virtual iteration_time | requestTimeIterative (local_federate_id federateID, Time next, iteration_request iterate) override final |
virtual Time | getCurrentTime (local_federate_id federateID) const override final |
virtual uint64_t | getCurrentReiteration (local_federate_id federateID) const override final |
virtual void | setTimeProperty (local_federate_id federateID, int32_t property, Time time) override final |
virtual void | setIntegerProperty (local_federate_id federateID, int32_t property, int16_t propertyValue) override final |
virtual Time | getTimeProperty (local_federate_id federateID, int32_t property) const override final |
virtual int16_t | getIntegerProperty (local_federate_id federateID, int32_t property) const override final |
virtual void | setFlagOption (local_federate_id federateID, int32_t flag, bool flagValue=true) override final |
virtual bool | getFlagOption (local_federate_id federateID, int32_t flag) const override final |
virtual interface_handle | registerPublication (local_federate_id federateID, const std::string &key, const std::string &type, const std::string &units) override final |
virtual interface_handle | getPublication (local_federate_id federateID, const std::string &key) const override final |
virtual interface_handle | registerInput (local_federate_id federateID, const std::string &key, const std::string &type, const std::string &units) override final |
virtual interface_handle | getInput (local_federate_id federateID, const std::string &key) const override final |
virtual const std::string & | getHandleName (interface_handle handle) const override final |
virtual void | setHandleOption (interface_handle handle, int32_t option, int32_t option_value) override final |
virtual int32_t | getHandleOption (interface_handle handle, int32_t option) const override final |
virtual void | closeHandle (interface_handle handle) override final |
virtual void | removeTarget (interface_handle handle, const std::string &targetToRemove) override final |
virtual void | addDestinationTarget (interface_handle handle, const std::string &dest) override final |
virtual void | addSourceTarget (interface_handle handle, const std::string &name) override final |
virtual const std::string & | getInjectionUnits (interface_handle handle) const override final |
virtual const std::string & | getExtractionUnits (interface_handle handle) const override final |
virtual const std::string & | getInjectionType (interface_handle handle) const override final |
virtual const std::string & | getExtractionType (interface_handle handle) const override final |
virtual void | setValue (interface_handle handle, const char *data, uint64_t len) override final |
virtual const std::shared_ptr< const data_block > & | getValue (interface_handle handle, uint32_t *inputIndex) override final |
virtual const std::vector< std::shared_ptr< const data_block > > & | getAllValues (interface_handle handle) override final |
virtual const std::vector< interface_handle > & | getValueUpdates (local_federate_id federateID) override final |
virtual interface_handle | registerEndpoint (local_federate_id federateID, const std::string &name, const std::string &type) override final |
virtual interface_handle | getEndpoint (local_federate_id federateID, const std::string &name) const override final |
virtual interface_handle | registerFilter (const std::string &filterName, const std::string &type_in, const std::string &type_out) override final |
virtual interface_handle | registerCloningFilter (const std::string &filterName, const std::string &type_in, const std::string &type_out) override final |
virtual interface_handle | getFilter (const std::string &name) const override final |
virtual void | addDependency (local_federate_id federateID, const std::string &federateName) override final |
virtual void | registerFrequentCommunicationsPair (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 (interface_handle sourceHandle, const std::string &destination, const char *data, uint64_t length) override final |
virtual void | sendEvent (Time time, interface_handle sourceHandle, const std::string &destination, const char *data, uint64_t length) override final |
virtual void | sendMessage (interface_handle sourceHandle, std::unique_ptr< Message > message) override final |
virtual uint64_t | receiveCount (interface_handle destination) override final |
virtual std::unique_ptr< Message > | receive (interface_handle destination) override final |
virtual std::unique_ptr< Message > | receiveAny (local_federate_id federateID, interface_handle &endpoint_id) override final |
virtual uint64_t | receiveCountAny (local_federate_id federateID) override final |
virtual void | logMessage (local_federate_id federateID, int logLevel, const std::string &messageToLog) override final |
virtual void | setFilterOperator (interface_handle 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 (global_federate_id federateID) const noexcept |
virtual void | setLoggingLevel (int logLevel) override |
virtual void | setLoggingCallback (local_federate_id federateID, std::function< void(int, const std::string &, const std::string &)> logFunction) override final |
virtual void | setLogFile (const std::string &lfile) override final |
virtual std::string | query (const std::string &target, const std::string &queryStr, helics_sequencing_mode mode) override |
virtual void | setQueryCallback (local_federate_id federateID, std::function< std::string(const std::string &)> queryFunction) override |
virtual void | setGlobal (const std::string &valueName, const std::string &value) 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 (interface_handle handle, std::string info) override final |
virtual const std::string & | getInterfaceInfo (interface_handle handle) const override final |
![]() | |
Core ()=default | |
virtual | ~Core ()=default |
void | initialize (const std::string &configureString) |
void | initializeFromArgs (int argc, char *argv[]) |
bool | isInitialized () const |
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) |
const std::string & | getUnits (interface_handle handle) const |
![]() | |
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, const std::string &, const std::string &)> logFunction) |
void | logFlush () |
bool | isRunning () const |
void | setLogLevel (int32_t level) |
void | setLogLevels (int32_t consoleLevel, int32_t fileLevel) |
global_broker_id | 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 |
FederateState * | getFederateAt (local_federate_id federateID) const |
FederateState * | getFederate (const std::string &federateName) const |
FederateState * | getHandleFederate (interface_handle handle) |
const BasicHandleInfo * | getHandleInfo (interface_handle handle) const |
const BasicHandleInfo * | getLocalEndpoint (const std::string &name) const |
bool | allInitReady () const |
bool | allDisconnected () const |
operation_state | minFederateState () const |
![]() | |
void | setTickForwarding (TickForwardingReasons reason, bool value=true) |
broker_state_t | getBrokerState () const |
bool | setBrokerState (broker_state_t newState) |
bool | transitionBrokerState (broker_state_t expectedState, broker_state_t newState) |
virtual bool | tryReconnect ()=0 |
virtual bool | sendToLogger (global_federate_id federateID, int logLevel, const std::string &name, const std::string &message) const |
void | saveProfilingData (const std::string &message) |
void | writeProfilingData () |
void | generateNewIdentifier () |
virtual std::string | generateLocalAddressString () const =0 |
virtual std::shared_ptr< helicsCLI11App > | generateCLI () |
void | setErrorState (int eCode, const std::string &estring) |
void | setLoggingFile (const std::string &lfile) |
bool | getFlagValue (int32_t flag) const |
Friends | |
class | TimeoutMonitor |
Additional Inherited Members | |
![]() | |
enum | broker_state_t : int16_t { broker_state_t::created = -6, broker_state_t::configuring = -5, broker_state_t::configured = -4, broker_state_t::connecting = -3, broker_state_t::connected = -2, broker_state_t::initializing = -1, broker_state_t::operating = 0, broker_state_t::terminating = 1, broker_state_t::terminated = 3, broker_state_t::errored = 7 } |
enum | TickForwardingReasons : uint32_t { none = 0, no_comms = 0x01, ping_response = 0x02, query_timeout = 0x04 } |
![]() | |
static bool | isReasonForTick (std::uint32_t code, TickForwardingReasons reason) |
![]() | |
std::atomic< global_broker_id > | global_id |
the unique identifier for the broker(core or broker) More... | |
global_broker_id | global_broker_id_local {} |
global_broker_id | higher_broker_id {0} |
the id code of the broker 1 level about this broker | |
std::atomic< int32_t > | maxLogLevel |
the logging level to use levels >=this will be ignored More... | |
int32_t | consoleLogLevel {1} |
the logging level for console display | |
int32_t | fileLogLevel {1} |
the logging level for logging to a file | |
int32_t | minFederateCount |
the minimum number of federates that must connect before entering init mode More... | |
int32_t | minBrokerCount |
the minimum number of brokers that must connect before entering init mode More... | |
int32_t | maxFederateCount {(std::numeric_limits<int32_t>::max)()} |
int32_t | maxBrokerCount {(std::numeric_limits<int32_t>::max)()} |
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 | |
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, const std::string &, const std::string &)> | loggerFunction |
std::atomic< bool > | haltOperations |
flag indicating that no further message should be processed More... | |
bool | restrictive_time_policy |
flag indicating the broker should use a conservative time policy More... | |
bool | terminate_on_error |
flag indicating that the federation should halt on any error More... | |
bool | debugging {false} |
flag indicating operation in a user debugging mode | |
std::string | logFile |
the file to log message to | |
std::unique_ptr< ForwardingTimeCoordinator > | timeCoord |
object managing the time control | |
gmlc::containers::BlockingPriorityQueue< ActionMessage > | actionQueue |
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 | |
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
|
noexcept |
default constructor
|
explicitnoexcept |
function mainly to match some other object constructors does the same thing as the default constructor
|
explicit |
construct from a core name
|
overridevirtual |
virtual destructor
References helics::BrokerBase::joinAllThreads().
|
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)
federateID | the identifier for the federate |
federateName | the name of the dependent federate |
Implements helics::Core.
References helics::BrokerBase::addActionMessage(), fed, getFederateAt(), helics::ActionMessage::name, and helics::ActionMessage::source_id.
|
finaloverridevirtual |
create a filter connection between a named filter and a named endpoint for destination processing
filter | the name of the filter |
target | the name of the source target |
Implements helics::Core.
References helics::BrokerBase::addActionMessage(), destination_target, helics::ActionMessage::name, and setActionFlag().
|
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
handle | an interface to add the target to |
dest | the target endpoint for the filter |
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().
|
protectedpure virtual |
add a route to whatever internal structure manages the routes
rid | the identification of the route |
interfaceId | an 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 |
routeInfo | a string containing the information necessary to connect |
|
finaloverridevirtual |
create a filter connection between a named filter and a named endpoint for messages coming from that endpoint
filter | the name of the filter |
target | the name of the source target |
Implements helics::Core.
References helics::BrokerBase::addActionMessage(), and helics::ActionMessage::name.
|
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
handle | the identifier of the interface |
name | the name of the filter or its 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().
|
protected |
check if all connections are disconnected (feds and time dependencies)
References helics::FilterFederate::hasActiveTimeDependencies(), helics::BrokerBase::hasFilters, helics::BrokerBase::hasTimeDependency, minFederateState(), and helics::BrokerBase::timeCoord.
|
protected |
check if all federates managed by the core are ready to enter initialization state
References fed, and helics::BrokerBase::minFederateCount.
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.
|
finaloverridevirtual |
close a handle from further connections
handle | the handle from the publication, input, endpoint or filter |
Implements helics::Core.
References helics::BrokerBase::addActionMessage(), checkActionFlag(), disconnected_flag, getHandleInfo(), and setActionFlag().
|
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().
|
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().
|
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().
|
finaloverridevirtual |
connect the core to a broker if needed
Implements helics::Core.
References helics::BrokerBase::brokerKey, helics::BrokerBase::configured, helics::BrokerBase::connected, helics::BrokerBase::connecting, core_flag, helics::BrokerBase::errored, getAddress(), getIdentifier(), helics::ActionMessage::name, helics::BrokerBase::no_ping, setActionFlag(), slow_responding_flag, helics::ActionMessage::source_id, helics::BrokerBase::timeout, transmit(), use_json_serialization_flag, and helics::BrokerBase::useJsonSerialization.
|
finaloverridevirtual |
create a data connection between a named publication and a named input
source | the name of the publication |
target | the name of the input |
Implements helics::Core.
References helics::BrokerBase::addActionMessage(), and helics::ActionMessage::name.
|
finaloverridevirtual |
disconnect the core from its broker
Implements helics::Core.
References helics::BrokerBase::addActionMessage(), and waitForDisconnect().
|
finaloverridevirtual |
Change the federate state to the Executing state.
May only be invoked in Initializing state.
federateID | the identifier of the federate |
iterate | the requested iteration mode if nonconverged the federate requests an iterative update |
Implements helics::Core.
References helics::BrokerBase::addActionMessage(), helics::ActionMessage::dest_id, fed, getFederateAt(), helics::HELICS_EXECUTING, helics::HELICS_INITIALIZING, indicator_flag, helics::next_step, setActionFlag(), helics::setIterationFlags(), and helics::ActionMessage::source_id.
|
finaloverridevirtual |
Federates may be in five Modes.
May only be invoked in Created state otherwise an error is thrown
Implements helics::Core.
References helics::BrokerBase::addActionMessage(), fed, getFederateAt(), helics::halted, helics::HELICS_INITIALIZING, helics::next_step, and helics::ActionMessage::source_id.
|
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, fed, getFederateAt(), and helics::ActionMessage::source_id.
|
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().
|
finaloverridevirtual |
Return all the available data for the specified handle or the latest input
Implements helics::Core.
References fed, getFederateAt(), getHandleInfo(), and helics::input.
|
finaloverridevirtual |
Returns the current reiteration count for the specified federate.
Implements helics::Core.
References fed, and getFederateAt().
|
finaloverridevirtual |
get the most recent granted Time
federateID | the identifier of the federate to get the time |
Implements helics::Core.
References fed, and getFederateAt().
|
finaloverridevirtual |
get an endpoint Handle from its name
federateID | the identifier for the federate |
name | the name of the endpoint |
Implements helics::Core.
|
finaloverridevirtual |
get the last error code from a core
Implements helics::Core.
References helics::BrokerBase::lastErrorCode.
|
finaloverridevirtual |
get the last error message
Implements helics::Core.
References helics::BrokerBase::lastErrorCode, and helics::BrokerBase::lastErrorString.
|
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
handle | the interface handle to get the injection type for |
Implements helics::Core.
References helics::endpoint, helics::filter, getHandleInfo(), helics::input, and helics::publication.
|
finaloverridevirtual |
Implements helics::Core.
References getHandleInfo(), helics::input, and helics::publication.
|
protected |
get the federate Information from the federateID
Referenced by query().
|
protected |
get the federate Information from the federateID
References helics::local_federate_id::baseValue().
Referenced by addDependency(), enterExecutingMode(), enterInitializingMode(), finalize(), getAllValues(), getCurrentReiteration(), getCurrentTime(), getFederateName(), getFlagOption(), getInjectionType(), getInjectionUnits(), getIntegerProperty(), getTimeProperty(), getValue(), getValueUpdates(), logMessage(), query(), receiveAny(), receiveCountAny(), registerEndpoint(), registerInput(), registerPublication(), removeTarget(), requestTimeIterative(), send(), sendEvent(), sendMessage(), setFlagOption(), setIntegerProperty(), setLoggingCallback(), setQueryCallback(), setTimeProperty(), setValue(), and timeRequest().
|
finaloverridevirtual |
|
finaloverridevirtual |
|
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.
|
finaloverridevirtual |
get a destination filter Handle from its name or target(this may not be unique so it will only find the first one)
name | the name of the filter or its target |
Implements helics::Core.
References helics::filter.
|
finaloverridevirtual |
Set a flag in a a federate
federateID | the identifier for the federate |
flag | an index code for the flag to set |
Implements helics::Core.
References fed, getFederateAt(), helics::BrokerBase::getFlagValue(), and helics::local_core_id().
|
protected |
get the federate Information from a handle
handle | a handle identifier as generated by the one of the functions |
Referenced by receive(), receiveCount(), and setHandleOption().
|
protected |
get the basic handle information
References helics::interface_handle::baseValue().
Referenced by addDestinationTarget(), addSourceTarget(), closeHandle(), getAllValues(), getExtractionType(), getExtractionUnits(), getHandleName(), getHandleOption(), getInjectionType(), getInjectionUnits(), getInterfaceInfo(), getValue(), removeTarget(), send(), sendEvent(), sendMessage(), setFilterOperator(), setHandleOption(), and setValue().
|
finaloverridevirtual |
Returns the name or identifier for a specified handle
Implements helics::Core.
References getHandleInfo().
|
finaloverridevirtual |
get a handle option
handle | the handle from the publication, input, endpoint or filter |
option | the option to set see /ref defs::options |
Implements helics::Core.
References getHandleInfo().
|
inlinefinaloverridevirtual |
get the local identifier for the core
Implements helics::Core.
References helics::BrokerBase::identifier.
Referenced by connect(), processDisconnect(), query(), and helics::TimeoutMonitor::tick().
|
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
handle | the interface handle to get the injection type for |
Implements helics::Core.
References helics::endpoint, fed, helics::filter, getFederateAt(), getHandleInfo(), and helics::input.
|
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
handle | the interface handle to get the injection type for |
Implements helics::Core.
References fed, getFederateAt(), getHandleInfo(), helics::input, and helics::publication.
|
finaloverridevirtual |
get a subscription Handle from its key
federateID | the identifier for the federate |
key | the tag of the named input |
Implements helics::Core.
|
finaloverridevirtual |
get an integer property on a federate
federateID | the federate to set a time based property on |
property | the property to set see /ref defs::properties |
Implements helics::Core.
References helics::BrokerBase::consoleLogLevel, fed, helics::BrokerBase::fileLogLevel, getFederateAt(), helics_property_int_console_log_level, helics_property_int_file_log_level, helics_property_int_log_level, and helics::local_core_id().
|
finaloverridevirtual |
getter for the interface information
handle | the identifiers for the interface to query |
Implements helics::Core.
References getHandleInfo().
|
protected |
get a localEndpoint from the name
|
finaloverridevirtual |
get a publication Handle from its key
federateID | the identifier for the federate |
key | the name of the publication |
Implements helics::Core.
|
finaloverridevirtual |
get a timebased property on a federate
federateID | the federate to set a time based property on |
property | the property to set see /ref defs::properties |
Implements helics::Core.
References fed, and getFederateAt().
|
finaloverridevirtual |
Return the data for the specified handle or the latest input
handle | the input handle from which to get the data | |
[out] | inputIndex | return the index of input (always 1 for inputs with only a single source) |
Implements helics::Core.
References fed, getFederateAt(), getHandleInfo(), and helics::input.
|
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
federateID | the identification code of the federate to get which interfaces have been updated |
Implements helics::Core.
References fed, and getFederateAt().
|
finaloverridevirtual |
Returns true if the core has been configured.
Implements helics::Core.
References helics::BrokerBase::configured.
|
finaloverridevirtual |
check if the core is connected properly
Implements helics::Core.
References helics::BrokerBase::connected, and helics::BrokerBase::operating.
Referenced by helics::TimeoutMonitor::tick().
|
finaloverridevirtual |
check if the core is ready to accept new federates
Implements helics::Core.
References helics::BrokerBase::created, and helics::BrokerBase::operating.
|
finaloverridevirtual |
send a log message to the Core for logging
federateID | the federate that is sending the log message |
logLevel | an integer for the log level /ref helics_log_levels |
messageToLog | the string to send to a logger |
Implements helics::Core.
References helics::BrokerBase::actionQueue, helics::ActionMessage::dest_id, fed, getFederateAt(), helics::BrokerBase::global_id, helics::local_core_id(), helics::ActionMessage::messageID, helics::ActionMessage::payload, and helics::ActionMessage::source_id.
|
finaloverridevirtual |
load a file containing connection information
file | a JSON or TOML file containing connection information |
Implements helics::Core.
|
protected |
get the minimum operating state of the connected federates
References fed.
Referenced by allDisconnected().
|
finaloverrideprotectedvirtual |
process a single command action
cmd may be modified by this function
Implements helics::BrokerBase.
Referenced by helics::TimeoutMonitor::tick().
|
finaloverridevirtual |
TODO(PT): figure out how to make this non-public, it needs to be called in a lambda function, may need a helper class of some sort
Implements helics::BrokerBase.
References helics::BrokerBase::addActionMessage(), helics::BrokerBase::configured, getIdentifier(), helics::BrokerBase::global_broker_id_local, helics::parent_broker_id, helics::ActionMessage::payload, helics::ActionMessage::source_id, helics::BrokerBase::terminated, helics::BrokerBase::terminating, transmit(), and unregister().
Referenced by helics::TimeoutMonitor::tick().
|
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
command | the command to process |
Implements helics::BrokerBase.
|
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" to query a global value stored in the broker
target | the specific target of the query |
queryStr | the actual query |
mode | the synchronization mode for the query |
Implements helics::Core.
References helics::BrokerBase::addActionMessage(), helics::ActionMessage::dest_id, helics::direct_core_id, fed, getAddress(), getFederate(), getFederateAt(), getIdentifier(), helics_sequencing_mode_fast, helics_sequencing_mode_ordered, helics::ActionMessage::messageID, helics::parent_broker_id, helics::ActionMessage::payload, helics::ActionMessage::setAction(), helics::ActionMessage::source_id, and helics::BrokerBase::terminating.
|
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 fed, getHandleFederate(), and helics::HELICS_EXECUTING.
|
finaloverridevirtual |
Receives a message for any destination.
this is a non-blocking call and will return a nullptr if no messages are available
federateID | the identifier for the federate | |
[out] | endpoint_id | the endpoint handle related to the message gets stored here |
Implements helics::Core.
References fed, and getFederateAt().
|
finaloverridevirtual |
Returns the number of pending receives for the specified destination endpoint.
Implements helics::Core.
References fed, and getHandleFederate().
|
finaloverridevirtual |
Returns number of messages for all destinations.
Implements helics::Core.
References fed, and getFederateAt().
|
finaloverridevirtual |
Register a cloning filter, a cloning filter operates on a copy of the message vs the actual message
filterName | the name of the filter (may be left blank and one will be automatically assigned) |
type_in | the input type of the filter |
type_out | the output type of the filter (may be left blank if the filter doesn't change type) |
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.
|
finaloverridevirtual |
Message interface. Designed for point-to-point communication patterns. Register an endpoint.
May only be invoked in the Initialization state.
Implements helics::Core.
References helics::BrokerBase::actionQueue, helics::endpoint, fed, helics::ActionMessage::flags, getFederateAt(), helics::ActionMessage::name, helics::ActionMessage::source_handle, and helics::ActionMessage::source_id.
|
finaloverridevirtual |
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
Implements helics::Core.
References helics::BrokerBase::addActionMessage(), helics::BrokerBase::enable_profiling, helics::BrokerBase::errored, fed, helics::CoreFederateInfo::intProps, helics::BrokerBase::lastErrorString, helics::ActionMessage::name, helics::BrokerBase::operating, helics::parent_broker_id, and helics::BrokerBase::sendToLogger().
|
finaloverridevirtual |
Register source filter.
May only be invoked in the Initialization state.
filterName | the name of the filter (may be left blank and one will be automatically assigned) |
type_in | the input type of the filter |
type_out | the 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 |
Implements helics::Core.
References helics::BrokerBase::actionQueue, helics::filter, helics::ActionMessage::name, helics::ActionMessage::source_handle, helics::ActionMessage::source_id, and helics::BrokerBase::terminating.
|
finaloverridevirtual |
Register communicating source/destination endpoint targets.
source | the endpoint that is sending data |
dest | the endpoint receiving the data |
Implements helics::Core.
|
finaloverridevirtual |
Register a control input for the specified federate.
May only be invoked in the initialize state.
federateID | the identifier for the federate to register an input interface on |
key | the name of the control input |
type | a string describing the type of the federate |
units | a string naming the units of the federate |
Implements helics::Core.
References fed, getFederateAt(), and helics::input.
|
finaloverridevirtual |
Value interface. Register a publication.
May only be invoked in the initialize state.
federateID | the identifier for the federate |
key | the tag for the publication |
type | the type of data the publication produces |
units | the units associated with the publication |
Implements helics::Core.
References fed, and getFederateAt().
|
protectedpure virtual |
remove or disconnect a route from use
rid | the identification of the route |
|
finaloverridevirtual |
remove a target from a handles operation
handle | the handle from the publication, input, endpoint or filter |
targetToRemove | the name of the target to remove |
Implements helics::Core.
References helics::BrokerBase::addActionMessage(), helics::endpoint, fed, helics::filter, getFederateAt(), getHandleInfo(), helics::input, helics::publication, and helics::ActionMessage::setSource().
|
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.
federateID | the identifier for the federate to process |
next | the requested time |
iterate | the requested iteration mode /ref iteration_request |
Implements helics::Core.
References helics::ActionMessage::actionTime, helics::BrokerBase::addActionMessage(), helics::ActionMessage::dest_id, helics::error, fed, getFederateAt(), 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, setActionFlag(), helics::setIterationFlags(), helics::ActionMessage::source_id, and helics::timeZero.
|
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(), data, helics::endpoint, fed, helics::ActionMessage::flags, getFederateAt(), getHandleInfo(), helics::ActionMessage::messageID, helics::ActionMessage::payload, helics::ActionMessage::source_handle, and helics::ActionMessage::source_id.
|
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.
time | the time the event is scheduled for |
sourceHandle | the source of the event |
destination | the target of the event |
data | the raw data for the event |
length | the record length of the event |
Implements helics::Core.
References helics::ActionMessage::actionTime, helics::BrokerBase::addActionMessage(), data, helics::endpoint, helics::ActionMessage::flags, getFederateAt(), getHandleInfo(), helics::ActionMessage::messageID, helics::FederateState::nextAllowedSendTime(), helics::ActionMessage::payload, helics::ActionMessage::source_handle, and helics::ActionMessage::source_id.
|
finaloverridevirtual |
Send for filters.
Continues sending the message to the next filter or to final destination.
Implements helics::Core.
References helics::ActionMessage::actionTime, helics::BrokerBase::addActionMessage(), helics::direct_send_handle, helics::endpoint, fed, getFederateAt(), getHandleInfo(), helics::BrokerBase::global_id, helics_log_level_data, helics::ActionMessage::messageID, helics::prettyPrintString(), helics::ActionMessage::source_handle, and helics::ActionMessage::source_id.
|
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::local_core_id(), and setFlagOption().
|
finaloverridevirtual |
set the filter callback operator
filter | the handle of the filter |
callback | pointer 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.
|
finaloverridevirtual |
Set a flag in a a federate
federateID | the identifier for the federate |
flag | an index code for the flag to set |
flagValue | the value to set the flag to |
Implements helics::Core.
References helics::BrokerBase::addActionMessage(), fed, getFederateAt(), indicator_flag, helics::local_core_id(), and setActionFlag().
Referenced by setCoreReadyToInit().
|
overridevirtual |
set a federation global value
this overwrites any previous value for this name
valueName | the name of the global to set |
value | the 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.
|
finaloverridevirtual |
set a handle option
handle | the handle from the publication, input, endpoint or filter |
option | the option to set |
option_value | the value to set the option (mostly 0 or 1) |
Implements helics::Core.
References helics::ActionMessage::counter, helics::ActionMessage::dest_handle, helics::ActionMessage::dest_id, fed, helics::filter, getHandleFederate(), getHandleInfo(), indicator_flag, helics::ActionMessage::messageID, setActionFlag(), and helics::ActionMessage::setExtraDestData().
void helics::CommonCore::setIdentifier | ( | const std::string & | name | ) |
set the local identification for the core
References helics::BrokerBase::created, and helics::BrokerBase::identifier.
|
finaloverridevirtual |
set an integer property on a federate
federateID | the federate to set a time based property on |
property | the property to set see /ref defs::properties |
propValue | the requested value of the property |
Implements helics::Core.
References helics::BrokerBase::addActionMessage(), fed, getFederateAt(), helics::BrokerBase::global_id, and helics::local_core_id().
|
finaloverridevirtual |
setter for the interface information
handle | the identifiers for the interface to set the info data on |
info | a string containing the info data |
Implements helics::Core.
References helics::interface_handle::baseValue().
|
finaloverridevirtual |
|
finaloverridevirtual |
define a logging function to use for logging message and notices from the federation and individual federate
federateID | the identifier for the individual federate or 0 for the Core Logger |
logFunction | the 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, fed, getFederateAt(), helics::BrokerBase::global_id, helics::local_core_id(), helics::ActionMessage::messageID, setActionFlag(), and helics::ActionMessage::source_id.
|
overridevirtual |
set the core logging level
Implements helics::Core.
References helics::BrokerBase::addActionMessage(), and helics::BrokerBase::global_id.
|
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.
federateID | the identifier for the federate |
queryFunction | a 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 fed, and getFederateAt().
|
finaloverridevirtual |
set a timebased property on a federate
federateID | the federate to set a time based property on |
property | the property to set see /ref defs::properties |
timeValue | the requested value of the property |
Implements helics::Core.
References fed, getFederateAt(), and helics::timeZero.
|
finaloverridevirtual |
Publish specified data to the specified key.
handle | the handle from the publication, input, endpoint or filter |
data | the raw data to send |
len | the size of the data |
Implements helics::Core.
References helics::BrokerBase::actionQueue, helics::ActionMessage::actionTime, helics::appendMessage(), checkActionFlag(), helics::ActionMessage::counter, data, disconnected_flag, fed, getFederateAt(), getHandleInfo(), helics_log_level_data, helics::ActionMessage::payload, helics::publication, helics::ActionMessage::setDestination(), helics::ActionMessage::source_handle, and helics::ActionMessage::source_id.
|
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.
federateID | the identification of the federate requesting the time |
next | the next time that is requested from the federate |
Implements helics::Core.
References helics::ActionMessage::actionTime, helics::BrokerBase::addActionMessage(), helics::ActionMessage::dest_id, helics::error, fed, getFederateAt(), helics::halted, helics::HELICS_EXECUTING, helics::HELICS_FINISHED, indicator_flag, helics::no_iterations, setActionFlag(), and helics::ActionMessage::source_id.
|
protectedpure virtual |
transit an ActionMessage to another core or broker
rid | the identifier for the route information to send the message to |
command | the actionMessage to send |
|
protectedpure virtual |
transit an ActionMessage to another core or broker
rid | the identifier for the route information to send the message to |
command | the actionMessage to send |
Referenced by connect(), processDisconnect(), and helics::TimeoutMonitor::tick().
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().
|
finaloverridevirtual |
waits in the current thread until the core is disconnected
Implements helics::Core.
Referenced by disconnect().