| helics 3.6.1

Echo.hpp
1 /*
2 Copyright (c) 2017-2025,
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
9 #include "../application_api/MessageFederate.hpp"
10 #include "helicsApp.hpp"
11
12 #include <deque>
13 #include <memory>
14 #include <mutex>
15 #include <string>
16 #include <vector>
17
18 namespace helics {
19 namespace apps {
27 class HELICS_CXX_EXPORT Echo: public App {
28 public:
30 Echo() = default;
34 explicit Echo(std::vector<std::string> args);
39 Echo(int argc, char* argv[]);
45 explicit Echo(std::string_view name, const FederateInfo& fedInfo);
51 Echo(std::string_view name, const std::shared_ptr<Core>& core, const FederateInfo& fedInfo);
57 Echo(std::string_view name, CoreApp& core, const FederateInfo& fedInfo);
62 Echo(std::string_view name, const std::string& jsonString);
63
65 Echo(Echo&& other_echo) noexcept;
67 Echo& operator=(Echo&& other_echo) noexcept;
68
72 virtual void runTo(Time stopTime_input) override;
73
78 void addEndpoint(std::string_view endpointName, std::string_view endpointType = "");
79
81 auto echoCount() const { return echoCounter; }
85 void setEchoDelay(Time delay);
86
88 auto endpointCount() const { return endpoints.size(); }
89
90 private:
92 virtual void loadJsonFile(const std::string& jsonFile,
93 bool enableFederateInterfaceRegistration) override;
95 void echoMessage(const Endpoint& ept, Time currentTime);
96
97 private:
99 void initialSetup();
101 void processArgs();
102 std::deque<Endpoint> endpoints;
103 Time delayTime = timeZero;
104 size_t echoCounter = 0;
105 std::mutex delayTimeLock; // mutex protecting delayTime
106 };
107 } // namespace apps
108 } // namespace helics
helics::Endpoint
Definition: Endpoints.hpp:21
helics::FederateInfo
Definition: FederateInfo.hpp:28
helics::apps::App
Definition: helicsApp.hpp:32
helics::apps::Echo
Definition: Echo.hpp:27
helics::apps::Echo::endpointCount
auto endpointCount() const
Definition: Echo.hpp:88
helics::apps::Echo::echoCount
auto echoCount() const
Definition: Echo.hpp:81
helics::apps::Echo::Echo
Echo()=default
helics
the main namespace for the helics co-simulation library User functions will be in the helics namespac...
Definition: AsyncFedCallInfo.hpp:14
helics::timeZero
constexpr Time timeZero
Definition: helicsTime.hpp:31
helics::Time
TimeRepresentation< count_time< 9 > > Time
Definition: helicsTime.hpp:27