helics  3.3.0
application_api/Federate.hpp
1 /*
2 Copyright (c) 2017-2022,
3 Battelle Memorial Institute; Lawrence Livermore National Security, LLC; Alliance for Sustainable
4 Energy, LLC. See the top-level NOTICE for additional details. All rights reserved.
5 SPDX-License-Identifier: BSD-3-Clause
6 */
7 #pragma once
8 #include "../core/LocalFederateId.hpp"
9 #include "../core/helicsTime.hpp"
10 #include "../helics_enums.h"
11 #include "FederateInfo.hpp"
12 #include "helics/helics-config.h"
13 #include "helicsTypes.hpp"
14 #include "helics_cxx_export.h"
15 
16 #include <atomic>
17 #include <functional>
18 #include <memory>
19 #include <mutex>
20 #include <optional>
21 #include <stdexcept>
22 #include <string>
23 #include <utility>
24 
25 namespace gmlc {
26 namespace libguarded {
27  template<class T, class M>
29 } // namespace libguarded
30 } // namespace gmlc
31 
35 namespace helics {
36 class Core;
37 class CoreApp;
38 class AsyncFedCallInfo;
39 class MessageOperator;
40 class ConnectorFederateManager;
41 class Filter;
42 class Translator;
43 class CloningFilter;
44 class Federate;
45 
48 class HELICS_CXX_EXPORT Federate {
49  public:
51  enum class Modes : char {
53  STARTUP = 0,
55  INITIALIZING = 1,
57  EXECUTING = 2,
59  FINALIZE = 3,
61  ERROR_STATE = 4,
62  // the following states are for asynchronous operations
64  PENDING_INIT = 5,
66  PENDING_EXEC = 6,
68  PENDING_TIME = 7,
70  PENDING_ITERATIVE_TIME = 8,
72  PENDING_FINALIZE = 9,
74  FINISHED = 10
75  };
76 
77  protected:
78  std::atomic<Modes> currentMode{Modes::STARTUP};
79  char nameSegmentSeparator = '/';
80 
81  bool strictConfigChecking{true};
83  bool useJsonSerialization{false};
85  bool observerMode{false};
86 
87  private:
88  LocalFederateId fedID;
89  protected:
90  std::shared_ptr<Core> coreObject;
91  Time currentTime = Time::minVal();
92  private:
93  std::unique_ptr<gmlc::libguarded::shared_guarded<AsyncFedCallInfo, std::mutex>>
94  asyncCallInfo;
95  std::unique_ptr<ConnectorFederateManager> cManager;
96  std::string mName;
97  std::function<void(Time, Time, bool)> timeRequestEntryCallback;
98  std::function<void(Time, bool)> timeUpdateCallback;
99  std::function<void(Modes, Modes)> modeUpdateCallback;
100  std::function<void(Time, bool)> timeRequestReturnCallback;
101 
102  public:
107  Federate(std::string_view fedname, const FederateInfo& fi);
113  Federate(std::string_view fedname,
114  const std::shared_ptr<Core>& core,
115  const FederateInfo& fi = FederateInfo{});
116 
122  Federate(std::string_view fedname, CoreApp& core, const FederateInfo& fi = FederateInfo{});
126  explicit Federate(const std::string& configString);
132  Federate(std::string_view fedname, const std::string& configString);
134  Federate() noexcept;
136  Federate(Federate&& fed) noexcept;
138  Federate(const Federate& fed) = delete;
140  virtual ~Federate();
142  Federate& operator=(Federate&& fed) noexcept;
144  Federate& operator=(const Federate& fed) = delete;
148  void enterInitializingMode();
149 
154  void enterInitializingModeAsync();
159  bool isAsyncOperationCompleted() const;
163  void enterInitializingModeComplete();
168  IterationResult enterExecutingMode(IterationRequest iterate = IterationRequest::NO_ITERATIONS);
174  void enterExecutingModeAsync(IterationRequest iterate = IterationRequest::NO_ITERATIONS);
179  IterationResult enterExecutingModeComplete();
183  void finalize();
186  void finalizeAsync();
188  void finalizeComplete();
192  void processCommunication(std::chrono::milliseconds period = std::chrono::milliseconds(0));
195  virtual void disconnect();
196 
201  void localError(int errorcode, std::string_view message);
202 
208  void globalError(int errorcode, std::string_view message);
209 
213  void localError(int errorcode);
214 
218  void globalError(int errorcode);
219 
227  void setSeparator(char separator) { nameSegmentSeparator = separator; }
231  Time requestTime(Time nextInternalTimeStep);
232 
235  Time requestNextStep() { return requestTime(timeZero); }
236 
240  Time requestTimeAdvance(Time timeDelta) { return requestTime(currentTime + timeDelta); }
241 
246  iteration_time requestTimeIterative(Time nextInternalTimeStep, IterationRequest iterate);
247 
252  void requestTimeAsync(Time nextInternalTimeStep);
253 
260  void requestTimeIterativeAsync(Time nextInternalTimeStep, IterationRequest iterate);
261 
264  Time requestTimeComplete();
265 
269  iteration_time requestTimeIterativeComplete();
270 
276  void setTag(std::string_view tag, std::string_view value);
283  const std::string& getTag(std::string_view tag) const;
284 
289  void setProperty(int32_t option, double timeValue);
290 
295  void setProperty(int32_t option, Time timeValue);
296 
301  virtual void setFlagOption(int flag, bool flagValue = true);
306  void setProperty(int32_t option, int32_t optionValue);
307 
311  Time getTimeProperty(int32_t option) const;
312 
316  virtual bool getFlagOption(int flag) const;
320  int getIntegerProperty(int32_t option) const;
321 
328  void setLoggingCallback(
329  const std::function<void(int, std::string_view, std::string_view)>& logFunction);
330 
338  void setTimeRequestEntryCallback(std::function<void(Time, Time, bool)> callback);
339 
348  void setTimeUpdateCallback(std::function<void(Time, bool)> callback);
349 
358  void setModeUpdateCallback(std::function<void(Modes, Modes)> callback);
359 
367  void setTimeRequestReturnCallback(std::function<void(Time, bool)> callback);
368 
382  std::string query(std::string_view target,
383  std::string_view queryStr,
385 
398  std::string query(std::string_view queryStr,
400 
412  QueryId queryAsync(std::string_view target,
413  std::string_view queryStr,
415 
425  QueryId queryAsync(std::string_view queryStr,
427 
437  std::string queryComplete(QueryId queryIndex);
438 
442  bool isQueryCompleted(QueryId queryIndex) const;
443 
452  void setQueryCallback(const std::function<std::string(std::string_view)>& queryFunction);
453 
459  void setGlobal(std::string_view valueName, std::string_view value);
461  void addAlias(std::string_view interfaceName, std::string_view alias);
470  void sendCommand(
471  std::string_view target,
472  std::string_view commandStr,
474 
479  std::pair<std::string, std::string> getCommand();
480 
485  std::pair<std::string, std::string> waitCommand();
486 
491  void addDependency(std::string_view fedName);
492 
498  Filter& registerGlobalFilter(std::string_view filterName,
499  std::string_view inputType = std::string_view{},
500  std::string_view outputType = std::string_view{});
501 
508  CloningFilter& registerGlobalCloningFilter(std::string_view filterName,
509  std::string_view inputType = std::string_view{},
510  std::string_view outputType = std::string_view{});
511 
518  Filter& registerFilter(std::string_view filterName,
519  std::string_view inputType = std::string_view{},
520  std::string_view outputType = std::string_view{});
521 
530  CloningFilter& registerCloningFilter(std::string_view filterName,
531  std::string_view inputType = std::string_view{},
532  std::string_view outputType = std::string_view{});
533 
537  {
538  return registerGlobalFilter(std::string(), std::string_view{}, std::string_view{});
539  }
540 
547  Translator& registerGlobalTranslator(std::int32_t translatorType,
548  std::string_view translatorName,
549  std::string_view endpointType = std::string_view{},
550  std::string_view units = std::string_view{});
551 
559  Translator& registerTranslator(std::int32_t translatorType,
560  std::string_view translatorName,
561  std::string_view endpointType = std::string_view{},
562  std::string_view units = std::string_view{});
563 
569  Translator& registerGlobalTranslator(std::string_view translatorName,
570  std::string_view endpointType = std::string_view{},
571  std::string_view units = std::string_view{})
572  {
573  return registerGlobalTranslator(0, translatorName, endpointType, units);
574  }
575 
582  Translator& registerTranslator(std::string_view translatorName,
583  std::string_view endpointType = std::string_view{},
584  std::string_view units = std::string_view{})
585  {
586  return registerTranslator(0, translatorName, endpointType, units);
587  }
588 
591  Translator& registerTranslator() { return registerGlobalTranslator(""); }
595  {
596  return registerGlobalCloningFilter(std::string(), std::string(), std::string());
597  }
598 
602  const Filter& getFilter(std::string_view filterName) const;
603 
607  const Filter& getFilter(int index) const;
608 
612  Filter& getFilter(std::string_view filterName);
613 
617  Filter& getFilter(int index);
618 
626  void setFilterOperator(const Filter& filt, std::shared_ptr<FilterOperator> op);
627 
629  int getFilterCount() const;
630 
631  // translator retrieval
636  const Translator& getTranslator(std::string_view translatorName) const;
637 
642  const Translator& getTranslator(int index) const;
643 
648  Translator& getTranslator(std::string_view translatorName);
649 
654  Translator& getTranslator(int index);
655 
663  void setTranslatorOperator(const Translator& trans, std::shared_ptr<TranslatorOperator> op);
664 
666  int getTranslatorCount() const;
667 
668  protected:
670  virtual void updateTime(Time newTime, Time oldTime);
673  virtual void startupToInitializeStateTransition();
676  virtual void initializeToExecuteStateTransition(IterationResult iterate);
678  virtual void disconnectTransition();
681  virtual std::string localQuery(std::string_view queryStr) const;
684  std::string localNameGenerator(std::string_view addition) const;
685 
686  public:
692  virtual void registerInterfaces(const std::string& configString);
698  void registerFilterInterfaces(const std::string& configString);
699 
701  auto getID() const noexcept { return fedID; }
703  Modes getCurrentMode() const noexcept { return currentMode.load(); }
706  Time getCurrentTime() const { return currentTime; }
708  const std::string& getName() const { return mName; }
710  const std::shared_ptr<Core>& getCorePointer() { return coreObject; }
711 
716  void logMessage(int level, std::string_view message) const;
717 
721  void logErrorMessage(std::string_view message) const
722  {
723  logMessage(HELICS_LOG_LEVEL_ERROR, message);
724  }
728  void logWarningMessage(std::string_view message) const
729  {
730  logMessage(HELICS_LOG_LEVEL_WARNING, message);
731  }
735  void logInfoMessage(std::string_view message) const
736  {
737  logMessage(HELICS_LOG_LEVEL_SUMMARY, message);
738  }
742  void logDebugMessage(std::string_view message) const
743  {
744  logMessage(HELICS_LOG_LEVEL_DEBUG, message);
745  }
747  void completeOperation();
748 
749  private:
751  void updateFederateMode(Modes newMode);
753  void updateSimulationTime(Time newTime, Time oldTime, bool iterating);
758  void registerConnectorInterfacesJson(const std::string& jsonString);
763  void registerConnectorInterfacesToml(const std::string& tomlString);
764 };
765 
767 class HELICS_CXX_EXPORT Interface {
768  protected:
769  Core* cr{nullptr};
770  InterfaceHandle handle{};
771  std::string mName;
772  public:
773  Interface() = default;
774  Interface(Federate* federate, InterfaceHandle id, std::string_view actName);
775  Interface(Core* core, InterfaceHandle id, std::string_view actName):
776  cr(core), handle(id), mName(actName)
777  {
778  }
779  virtual ~Interface() = default;
782  InterfaceHandle getHandle() const { return handle; }
784  operator InterfaceHandle() const { return handle; }
786  bool isValid() const { return handle.isValid(); }
787  bool operator<(const Interface& inp) const { return (handle < inp.handle); }
788  bool operator>(const Interface& inp) const { return (handle > inp.handle); }
789  bool operator==(const Interface& inp) const { return (handle == inp.handle); }
790  bool operator!=(const Interface& inp) const { return (handle != inp.handle); }
793  const std::string& getLocalName() const { return mName; }
796  const std::string& getName() const;
798  const std::string& getTarget() const;
800  void addSourceTarget(std::string_view newTarget, InterfaceType hint = InterfaceType::UNKNOWN);
802  void addDestinationTarget(std::string_view newTarget,
803  InterfaceType hint = InterfaceType::UNKNOWN);
805  void removeTarget(std::string_view targetToRemove);
807  void addAlias(std::string_view alias);
809  const std::string& getInfo() const;
811  void setInfo(std::string_view info);
817  void setTag(std::string_view tag, std::string_view value);
824  const std::string& getTag(std::string_view tag) const;
826  virtual void setOption(int32_t option, int32_t value = 1);
827 
829  virtual int32_t getOption(int32_t option) const;
830 
836  const std::string& getInjectionType() const;
837 
843  const std::string& getExtractionType() const;
844 
850  const std::string& getInjectionUnits() const;
851 
856  const std::string& getExtractionUnits() const;
859  virtual const std::string& getDisplayName() const = 0;
862  const std::string& getSourceTargets() const;
865  const std::string& getDestinationTargets() const;
867  void close();
869  void disconnectFromCore();
870 };
871 
875 HELICS_CXX_EXPORT void cleanupHelicsLibrary();
876 } // namespace helics
helics::Interface::cr
Core * cr
pointer to the core object
Definition: application_api/Federate.hpp:769
helics::timeZero
constexpr Time timeZero
Definition: helicsTime.hpp:31
helics::Federate::completeOperation
void completeOperation()
Definition: Federate.cpp:662
helics::Interface::getDisplayName
virtual const std::string & getDisplayName() const =0
Definition: Federate.cpp:1670
helicsGetBuildFlags
const char * helicsGetBuildFlags(void)
Definition: helicsExport.cpp:36
helicsTypes.hpp
helics::Federate::Modes
Modes
Definition: application_api/Federate.hpp:51
helics::CloningFilter
Definition: Filters.hpp:97
helics::initializationTime
constexpr Time initializationTime
Definition: helicsTime.hpp:40
helics::IterationResult::HALTED
@ HALTED
indicator that the simulation has been halted
helics::Federate::setTimeRequestReturnCallback
void setTimeRequestReturnCallback(std::function< void(Time, bool)> callback)
Definition: Federate.cpp:535
helics::Federate::registerGlobalCloningFilter
CloningFilter & registerGlobalCloningFilter(std::string_view filterName, std::string_view inputType=std::string_view{}, std::string_view outputType=std::string_view{})
Definition: Federate.cpp:1473
helics::Core::setInterfaceTag
virtual void setInterfaceTag(InterfaceHandle handle, std::string_view tag, std::string_view value)=0
helics::IdentifierId< IdentifierType, Identifiers::QUERY, invalid_id_value >
helics::Federate::isQueryCompleted
bool isQueryCompleted(QueryId queryIndex) const
Definition: Federate.cpp:1400
helics::Federate::logMessage
void logMessage(int level, std::string_view message) const
Definition: Federate.cpp:1558
helics::Federate::getName
const std::string & getName() const
Definition: application_api/Federate.hpp:708
helics::make_cloning_filter
CloningFilter & make_cloning_filter(FilterTypes type, Federate *mFed, std::string_view delivery, std::string_view name)
Definition: Filters.cpp:252
helics::Federate::getFilterCount
int getFilterCount() const
Definition: Federate.cpp:1519
helics::loadFederateInfo
FederateInfo loadFederateInfo(const std::string &configString)
Definition: FederateInfo.cpp:711
helics::Interface::getLocalName
const std::string & getLocalName() const
Definition: application_api/Federate.hpp:793
helics::Interface::disconnectFromCore
void disconnectFromCore()
Definition: Federate.cpp:1681
helicsErrorClear
void helicsErrorClear(HelicsError *err)
Definition: helicsExport.cpp:66
helics::IdentifierId::value
BaseType value() const noexcept
Definition: helicsTypes.hpp:75
helics::Federate::logDebugMessage
void logDebugMessage(std::string_view message) const
Definition: application_api/Federate.hpp:742
helics::Core::closeHandle
virtual void closeHandle(InterfaceHandle handle)=0
helics::Federate::registerFilterInterfaces
void registerFilterInterfaces(const std::string &configString)
Definition: Federate.cpp:951
helics::Federate::startupToInitializeStateTransition
virtual void startupToInitializeStateTransition()
Definition: Federate.cpp:930
helics::Core::getHandleOption
virtual int32_t getHandleOption(InterfaceHandle handle, int32_t option) const =0
helics::Federate::setProperty
void setProperty(int32_t option, double timeValue)
Definition: Federate.cpp:475
helics::Federate::Modes::FINALIZE
@ FINALIZE
helics::Core::getSourceTargets
virtual const std::string & getSourceTargets(InterfaceHandle handle) const =0
helics::FederateInfo::forceNewCore
bool forceNewCore
indicator that the federate should not use an existing core
Definition: FederateInfo.hpp:37
helics::Federate::registerCloningFilter
CloningFilter & registerCloningFilter(std::string_view filterName, std::string_view inputType=std::string_view{}, std::string_view outputType=std::string_view{})
Definition: Federate.cpp:1459
helics::CoreFactory::findJoinableCoreOfType
std::shared_ptr< Core > findJoinableCoreOfType(CoreType type)
Definition: CoreFactory.cpp:309
helics::filterTypeFromString
FilterTypes filterTypeFromString(std::string_view filterType) noexcept
Definition: Filters.cpp:32
helics::InterfaceType
InterfaceType
Definition: CoreTypes.hpp:99
helics::Federate::finalizeAsync
void finalizeAsync()
Definition: Federate.cpp:607
helics::Interface::addAlias
void addAlias(std::string_view alias)
Definition: Federate.cpp:1605
helics::IterationResult::ERROR_RESULT
@ ERROR_RESULT
indicator that an error has occurred
HELICS_LOG_LEVEL_WARNING
@ HELICS_LOG_LEVEL_WARNING
Definition: helics_enums.h:192
helics::Interface::getTag
const std::string & getTag(std::string_view tag) const
Definition: Federate.cpp:1620
helics::Federate::localNameGenerator
std::string localNameGenerator(std::string_view addition) const
Definition: Federate.cpp:1441
helics::Federate::enterInitializingModeComplete
void enterInitializingModeComplete()
Definition: Federate.cpp:290
helics::InterfaceHandle
Definition: LocalFederateId.hpp:65
helics::Federate::getTag
const std::string & getTag(std::string_view tag) const
Definition: Federate.cpp:470
helics::Federate::getCommand
std::pair< std::string, std::string > getCommand()
Definition: Federate.cpp:1427
helics::Federate::currentMode
std::atomic< Modes > currentMode
the current state of the simulation
Definition: application_api/Federate.hpp:78
helics::BrokerFactory::cleanUpBrokers
size_t cleanUpBrokers()
Definition: BrokerFactory.cpp:266
helics::Federate::setLoggingCallback
void setLoggingCallback(const std::function< void(int, std::string_view, std::string_view)> &logFunction)
Definition: Federate.cpp:500
helics::Federate::enterInitializingModeAsync
void enterInitializingModeAsync()
Definition: Federate.cpp:250
HELICS_FLAG_STRICT_CONFIG_CHECKING
@ HELICS_FLAG_STRICT_CONFIG_CHECKING
Definition: helics_enums.h:135
helics::Federate::getFlagOption
virtual bool getFlagOption(int flag) const
Definition: Federate.cpp:552
helics::Time
TimeRepresentation< count_time< 9 > > Time
Definition: helicsTime.hpp:27
helics::Federate::registerInterfaces
virtual void registerInterfaces(const std::string &configString)
Definition: Federate.cpp:946
helics::Core::addSourceTarget
virtual void addSourceTarget(InterfaceHandle handle, std::string_view name, InterfaceType hint=InterfaceType::UNKNOWN)=0
helics::Interface::addSourceTarget
void addSourceTarget(std::string_view newTarget, InterfaceType hint=InterfaceType::UNKNOWN)
Definition: Federate.cpp:1590
helics::Interface::getInjectionType
const std::string & getInjectionType() const
Definition: Federate.cpp:1640
helics::Federate::processCommunication
void processCommunication(std::chrono::milliseconds period=std::chrono::milliseconds(0))
Definition: Federate.cpp:648
helics::Federate::logWarningMessage
void logWarningMessage(std::string_view message) const
Definition: application_api/Federate.hpp:728
helics::Federate::getTranslator
const Translator & getTranslator(std::string_view translatorName) const
Definition: Federate.cpp:1529
helics::Federate::Modes::PENDING_EXEC
@ PENDING_EXEC
helics::Filter
Definition: Filters.hpp:39
helics::Federate::setTag
void setTag(std::string_view tag, std::string_view value)
Definition: Federate.cpp:465
helics::Federate::currentTime
Time currentTime
the current simulation time
Definition: application_api/Federate.hpp:91
helics::Federate::requestTimeIterative
iteration_time requestTimeIterative(Time nextInternalTimeStep, IterationRequest iterate)
Definition: Federate.cpp:743
helics::Federate::Modes::PENDING_TIME
@ PENDING_TIME
helics::Federate::nameSegmentSeparator
char nameSegmentSeparator
the separator between automatically prependend names
Definition: application_api/Federate.hpp:79
helics::Federate::enterExecutingMode
IterationResult enterExecutingMode(IterationRequest iterate=IterationRequest::NO_ITERATIONS)
Definition: Federate.cpp:318
HELICS_FLAG_OBSERVER
@ HELICS_FLAG_OBSERVER
Definition: helics_enums.h:101
helics::getOptionIndex
int getOptionIndex(std::string val)
Definition: FederateInfo.cpp:408
helics::Federate::setTranslatorOperator
void setTranslatorOperator(const Translator &trans, std::shared_ptr< TranslatorOperator > op)
register an operator for the specified translator
Definition: Federate.cpp:1547
helics::Federate::addAlias
void addAlias(std::string_view interfaceName, std::string_view alias)
Definition: Federate.cpp:1415
helics::Federate::setFlagOption
virtual void setFlagOption(int flag, bool flagValue=true)
Definition: Federate.cpp:544
helics::Federate::disconnectTransition
virtual void disconnectTransition()
Definition: Federate.cpp:939
helics::Federate::registerFilter
Filter & registerFilter()
Definition: application_api/Federate.hpp:536
helics::FederateInfo::coreType
CoreType coreType
the type of the core
Definition: FederateInfo.hpp:34
helics::Federate::updateTime
virtual void updateTime(Time newTime, Time oldTime)
Definition: Federate.cpp:925
helics::getOptionValue
int getOptionValue(std::string val)
Definition: FederateInfo.cpp:427
HELICS_LOG_LEVEL_DEBUG
@ HELICS_LOG_LEVEL_DEBUG
Definition: helics_enums.h:205
helics::InvalidFunctionCall
Definition: core-exceptions.hpp:67
helics::Federate::getTimeProperty
Time getTimeProperty(int32_t option) const
Definition: Federate.cpp:490
helicsErrorInitialize
HelicsError helicsErrorInitialize(void)
Definition: helicsExport.cpp:57
helics::InvalidParameter
Definition: core-exceptions.hpp:48
helics::Interface::getTarget
const std::string & getTarget() const
Definition: Federate.cpp:1585
helics::Interface::getInjectionUnits
const std::string & getInjectionUnits() const
Definition: Federate.cpp:1650
helics::Interface
Definition: application_api/Federate.hpp:767
helics::Core
Definition: core/Core.hpp:41
helics::Federate::sendCommand
void sendCommand(std::string_view target, std::string_view commandStr, HelicsSequencingModes mode=HelicsSequencingModes::HELICS_SEQUENCING_MODE_FAST)
Definition: Federate.cpp:1420
helics::RegistrationFailure
Definition: core-exceptions.hpp:85
helics::Translator
Definition: application_api/Translator.hpp:35
helics::Interface::getOption
virtual int32_t getOption(int32_t option) const
Definition: Federate.cpp:1635
helics::CoreApp
Definition: application_api/CoreApp.hpp:25
helics::Federate::enterExecutingModeAsync
void enterExecutingModeAsync(IterationRequest iterate=IterationRequest::NO_ITERATIONS)
Definition: Federate.cpp:378
helics::fileops::isMember
bool isMember(const toml::value &element, const std::string &key)
Definition: TomlProcessingFunctions.hpp:155
helics::Interface::removeTarget
void removeTarget(std::string_view targetToRemove)
Definition: Federate.cpp:1600
helics::Federate::registerFilter
Filter & registerFilter(std::string_view filterName, std::string_view inputType=std::string_view{}, std::string_view outputType=std::string_view{})
Definition: Federate.cpp:1452
helics::Core::getDestinationTargets
virtual const std::string & getDestinationTargets(InterfaceHandle handle) const =0
helics::Core::getExtractionType
virtual const std::string & getExtractionType(InterfaceHandle handle) const =0
helics::Translator::setTranslatorType
void setTranslatorType(std::int32_t type)
Definition: Translator.cpp:105
helics::Federate::registerGlobalFilter
Filter & registerGlobalFilter(std::string_view filterName, std::string_view inputType=std::string_view{}, std::string_view outputType=std::string_view{})
Definition: Federate.cpp:1466
helics::Interface::isValid
bool isValid() const
Definition: application_api/Federate.hpp:786
helics::FederateInfo
Definition: FederateInfo.hpp:24
helics::CoreFactory::FindOrCreate
std::shared_ptr< Core > FindOrCreate(CoreType type, std::string_view coreName, std::vector< std::string > args)
Definition: CoreFactory.cpp:219
helics::Interface::handle
InterfaceHandle handle
the id as generated by the Federate
Definition: application_api/Federate.hpp:770
helics::IterationRequest
IterationRequest
Definition: CoreTypes.hpp:92
helics::Federate::isAsyncOperationCompleted
bool isAsyncOperationCompleted() const
Definition: Federate.cpp:268
helics::Federate::operator=
Federate & operator=(Federate &&fed) noexcept
Definition: Federate.cpp:192
helics::Federate::useJsonSerialization
bool useJsonSerialization
Definition: application_api/Federate.hpp:83
helics::Interface::addDestinationTarget
void addDestinationTarget(std::string_view newTarget, InterfaceType hint=InterfaceType::UNKNOWN)
Definition: Federate.cpp:1595
helics::Federate::Modes::ERROR_STATE
@ ERROR_STATE
helics::FederateInfo::useJsonSerialization
bool useJsonSerialization
Definition: FederateInfo.hpp:39
helics::Federate::getID
auto getID() const noexcept
Definition: application_api/Federate.hpp:701
helics::Federate::Modes::INITIALIZING
@ INITIALIZING
helics::Federate::enterExecutingModeComplete
IterationResult enterExecutingModeComplete()
Definition: Federate.cpp:415
helics::Interface::getName
const std::string & getName() const
Definition: Federate.cpp:1580
helics::Federate::getCurrentTime
Time getCurrentTime() const
Definition: application_api/Federate.hpp:706
helics::Core::getInjectionType
virtual const std::string & getInjectionType(InterfaceHandle handle) const =0
helics::Federate::~Federate
virtual ~Federate()
Definition: Federate.cpp:210
helics::Interface::getExtractionType
const std::string & getExtractionType() const
Definition: Federate.cpp:1645
helics::Interface::getSourceTargets
const std::string & getSourceTargets() const
Definition: Federate.cpp:1660
helics::Federate::registerTranslator
Translator & registerTranslator()
Definition: application_api/Federate.hpp:591
helics::Federate::localQuery
virtual std::string localQuery(std::string_view queryStr) const
Definition: Federate.cpp:1325
helics::IterationResult
IterationResult
Definition: CoreTypes.hpp:83
helicsGetSystemInfo
const char * helicsGetSystemInfo(void)
Definition: helicsExport.cpp:46
helics::FederateStates::INITIALIZING
@ INITIALIZING
helics::Federate::globalError
void globalError(int errorcode, std::string_view message)
Definition: Federate.cpp:704
helics::Interface::getExtractionUnits
const std::string & getExtractionUnits() const
Definition: Federate.cpp:1655
helics::Federate::query
std::string query(std::string_view target, std::string_view queryStr, HelicsSequencingModes mode=HELICS_SEQUENCING_MODE_FAST)
Definition: Federate.cpp:1348
helics::Core::getInjectionUnits
virtual const std::string & getInjectionUnits(InterfaceHandle handle) const =0
helics::Federate::queryAsync
QueryId queryAsync(std::string_view target, std::string_view queryStr, HelicsSequencingModes mode=HELICS_SEQUENCING_MODE_FAST)
Definition: Federate.cpp:1359
helics::Federate::setTimeUpdateCallback
void setTimeUpdateCallback(std::function< void(Time, bool)> callback)
Definition: Federate.cpp:515
HelicsSequencingModes
HelicsSequencingModes
Definition: helics_enums.h:395
helics::Federate::Modes::PENDING_FINALIZE
@ PENDING_FINALIZE
helics::cleanupHelicsLibrary
void cleanupHelicsLibrary()
Definition: Federate.cpp:38
helics::Core::getInterfaceInfo
virtual const std::string & getInterfaceInfo(InterfaceHandle handle) const =0
helics::Federate::enterInitializingMode
void enterInitializingMode()
Definition: Federate.cpp:224
helics::Federate::registerCloningFilter
CloningFilter & registerCloningFilter()
Definition: application_api/Federate.hpp:594
helics::Federate::registerGlobalTranslator
Translator & registerGlobalTranslator(std::string_view translatorName, std::string_view endpointType=std::string_view{}, std::string_view units=std::string_view{})
Definition: application_api/Federate.hpp:569
helics::Interface::setTag
void setTag(std::string_view tag, std::string_view value)
Definition: Federate.cpp:1625
helics::Core::addDestinationTarget
virtual void addDestinationTarget(InterfaceHandle handle, std::string_view dest, InterfaceType hint=InterfaceType::UNKNOWN)=0
HELICS_FLAG_USE_JSON_SERIALIZATION
@ HELICS_FLAG_USE_JSON_SERIALIZATION
Definition: helics_enums.h:137
helics::Federate::logInfoMessage
void logInfoMessage(std::string_view message) const
Definition: application_api/Federate.hpp:735
helics::Federate::initializeToExecuteStateTransition
virtual void initializeToExecuteStateTransition(IterationResult iterate)
Definition: Federate.cpp:934
helics::Federate::setGlobal
void setGlobal(std::string_view valueName, std::string_view value)
Definition: Federate.cpp:1410
helics::Federate::setModeUpdateCallback
void setModeUpdateCallback(std::function< void(Modes, Modes)> callback)
Definition: Federate.cpp:524
helics::Federate::waitCommand
std::pair< std::string, std::string > waitCommand()
Definition: Federate.cpp:1432
helics::operator==
bool operator==(const SmallBuffer &sb1, const SmallBuffer &sb2)
Definition: SmallBuffer.hpp:390
helics::Interface::getHandle
InterfaceHandle getHandle() const
Definition: application_api/Federate.hpp:782
helics::Interface::getInfo
const std::string & getInfo() const
Definition: Federate.cpp:1610
helics::FederateInfo::coreName
std::string coreName
the name of the core
Definition: FederateInfo.hpp:47
helics::Core::addAlias
virtual void addAlias(std::string_view interfaceKey, std::string_view alias)=0
helics::Interface::getDestinationTargets
const std::string & getDestinationTargets() const
Definition: Federate.cpp:1665
helics::operator!=
bool operator!=(const SmallBuffer &sb1, const SmallBuffer &sb2)
Definition: SmallBuffer.hpp:396
helics
the main namespace for the helics co-simulation library User functions will be in the helics namespac...
Definition: AsyncFedCallInfo.hpp:14
helics::Core::setInterfaceInfo
virtual void setInterfaceInfo(InterfaceHandle handle, std::string_view info)=0
helics::Core::getHandleName
virtual const std::string & getHandleName(InterfaceHandle handle) const =0
helics::Core::setHandleOption
virtual void setHandleOption(InterfaceHandle handle, int32_t option, int32_t option_value)=0
helics::Federate::requestTimeIterativeAsync
void requestTimeIterativeAsync(Time nextInternalTimeStep, IterationRequest iterate)
Definition: Federate.cpp:800
helics::FederateInfo::separator
char separator
separator for global name of localFederates
Definition: FederateInfo.hpp:27
helics::CoreFactory::cleanUpCores
size_t cleanUpCores()
Definition: CoreFactory.cpp:349
helics::iteration_time
Definition: helicsTime.hpp:49
HELICS_LOG_LEVEL_SUMMARY
@ HELICS_LOG_LEVEL_SUMMARY
Definition: helics_enums.h:194
helics::IterationResult::NEXT_STEP
@ NEXT_STEP
HELICS_SEQUENCING_MODE_FAST
@ HELICS_SEQUENCING_MODE_FAST
Definition: helics_enums.h:397
helics::CoreFactory::getEmptyCore
std::shared_ptr< Core > getEmptyCore()
Definition: CoreFactory.cpp:119
helics::Federate::requestTimeAdvance
Time requestTimeAdvance(Time timeDelta)
Definition: application_api/Federate.hpp:240
helicsAbort
void helicsAbort(int errorCode, const char *errorString)
Definition: helicsExport.cpp:983
helics::FunctionExecutionFailure
Definition: core-exceptions.hpp:29
helics::Interface::mName
std::string mName
the name or key of the interface
Definition: application_api/Federate.hpp:771
helics::Federate::localError
void localError(int errorcode, std::string_view message)
Definition: Federate.cpp:697
helics::Federate::registerTranslator
Translator & registerTranslator(std::string_view translatorName, std::string_view endpointType=std::string_view{}, std::string_view units=std::string_view{})
Definition: application_api/Federate.hpp:582
helics::Federate::Modes::PENDING_ITERATIVE_TIME
@ PENDING_ITERATIVE_TIME
helics::Federate::requestTimeIterativeComplete
iteration_time requestTimeIterativeComplete()
Definition: Federate.cpp:838
HELICS_LOG_LEVEL_ERROR
@ HELICS_LOG_LEVEL_ERROR
Definition: helics_enums.h:188
helics::FederateStates::EXECUTING
@ EXECUTING
the federation has entered execution state and it now advancing in time
helics::IterationResult::ITERATING
@ ITERATING
indicator that the iterations need to continue
helics::Federate::getCurrentMode
Modes getCurrentMode() const noexcept
Definition: application_api/Federate.hpp:703
helics::LocalFederateId
Definition: LocalFederateId.hpp:22
helics::make_filter
Filter & make_filter(FilterTypes type, Federate *mFed, std::string_view name)
Definition: Filters.cpp:202
helics::generateFullCoreInitString
std::string generateFullCoreInitString(const FederateInfo &fi)
Definition: FederateInfo.cpp:859
helics::Federate::finalize
void finalize()
Definition: Federate.cpp:559
helics::FederateStates::FINISHED
@ FINISHED
the federation has finished its execution
helics::Interface::setInfo
void setInfo(std::string_view info)
Definition: Federate.cpp:1615
helics::Federate::getFilter
const Filter & getFilter(std::string_view filterName) const
Definition: Federate.cpp:1501
helics::Federate
Definition: application_api/Federate.hpp:48
helics::Federate::getCorePointer
const std::shared_ptr< Core > & getCorePointer()
Definition: application_api/Federate.hpp:710
helics::Core::getExtractionUnits
virtual const std::string & getExtractionUnits(InterfaceHandle handle) const =0
helicsGetDataType
int helicsGetDataType(const char *val)
Definition: FederateExport.cpp:361
helics::Federate::requestNextStep
Time requestNextStep()
Definition: application_api/Federate.hpp:235
helics::Federate::setFilterOperator
void setFilterOperator(const Filter &filt, std::shared_ptr< FilterOperator > op)
register a operator for the specified filter
Definition: Federate.cpp:1524
gmlc::libguarded::shared_guarded
Definition: application_api/Federate.hpp:28
helics::Federate::Modes::FINISHED
@ FINISHED
helics::Federate::Modes::PENDING_INIT
@ PENDING_INIT
helics::Federate::finalizeComplete
void finalizeComplete()
Definition: Federate.cpp:637
helics::Federate::requestTime
Time requestTime(Time nextInternalTimeStep)
Definition: Federate.cpp:711
helics::loadCores
bool loadCores()
Definition: loadCores.cpp:149
helics::Federate::strictConfigChecking
bool strictConfigChecking
Definition: application_api/Federate.hpp:81
helics::Core::getInterfaceTag
virtual const std::string & getInterfaceTag(InterfaceHandle handle, std::string_view tag) const =0
helics::Federate::observerMode
bool observerMode
Definition: application_api/Federate.hpp:85
helics::Federate::logErrorMessage
void logErrorMessage(std::string_view message) const
Definition: application_api/Federate.hpp:721
helics::Federate::setQueryCallback
void setQueryCallback(const std::function< std::string(std::string_view)> &queryFunction)
Definition: Federate.cpp:1395
helics::Federate::Modes::STARTUP
@ STARTUP
helics::IterationRequest::NO_ITERATIONS
@ NO_ITERATIONS
indicator that the iterations have completed
helics::Interface::setOption
virtual void setOption(int32_t option, int32_t value=1)
Definition: Federate.cpp:1630
helics::CoreFactory::getEmptyCorePtr
Core * getEmptyCorePtr()
Definition: CoreFactory.cpp:124
helics::Interface::close
void close()
Definition: Federate.cpp:1675
helics::Federate::coreObject
std::shared_ptr< Core > coreObject
reference to the core simulation API
Definition: application_api/Federate.hpp:90
helics::Federate::addDependency
void addDependency(std::string_view fedName)
Definition: Federate.cpp:1437
helics::Core::removeTarget
virtual void removeTarget(InterfaceHandle handle, std::string_view targetToRemove)=0
helics::Federate::getIntegerProperty
int getIntegerProperty(int32_t option) const
Definition: Federate.cpp:495
helics::Federate::Federate
Federate() noexcept
Definition: Federate.cpp:169
helics::Federate::queryComplete
std::string queryComplete(QueryId queryIndex)
Definition: Federate.cpp:1384
helics::Federate::requestTimeComplete
Time requestTimeComplete()
Definition: Federate.cpp:819
helics::HelicsException
Definition: core-exceptions.hpp:18
helics::Federate::getTranslatorCount
int getTranslatorCount() const
Definition: Federate.cpp:1553
helics::Federate::registerGlobalTranslator
Translator & registerGlobalTranslator(std::int32_t translatorType, std::string_view translatorName, std::string_view endpointType=std::string_view{}, std::string_view units=std::string_view{})
Definition: Federate.cpp:1480
helics::Federate::requestTimeAsync
void requestTimeAsync(Time nextInternalTimeStep)
Definition: Federate.cpp:783
helics::Federate::Modes::EXECUTING
@ EXECUTING
helics::FederateInfo::defName
std::string defName
a default name to use for a federate
Definition: FederateInfo.hpp:46
helics::Federate::setTimeRequestEntryCallback
void setTimeRequestEntryCallback(std::function< void(Time, Time, bool)> callback)
Definition: Federate.cpp:506
helics::Federate::disconnect
virtual void disconnect()
Definition: Federate.cpp:653
helics::FilterTypes
FilterTypes
Definition: Filters.hpp:21
helics::generateJsonErrorResponse
std::string generateJsonErrorResponse(JsonErrorCodes code, const std::string &message)
Definition: JsonGeneration.hpp:36