| helics 3.6.1

ForwardingTimeCoordinator.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 "ActionMessage.hpp"
10 #include "BaseTimeCoordinator.hpp"
11 #include "CoreFederateInfo.hpp"
12 #include "TimeDependencies.hpp"
13
14 #include <atomic>
15 #include <functional>
16 #include <nlohmann/json_fwd.hpp>
17 #include <string>
18 #include <utility>
19 #include <vector>
20
21 namespace helics {
22
27 class ForwardingTimeCoordinator: public BaseTimeCoordinator {
28 private:
29 // the variables for time coordination
30 DependencyInfo upstream;
31 DependencyInfo downstream;
32 static constexpr std::int32_t mSequenceIncrement{100};
33
34 protected:
35 bool iterating{false};
36 bool ignoreMinFed{false};
37 std::int32_t sequenceModifier{0};
38
39 public:
40 ForwardingTimeCoordinator() = default;
41
45 virtual bool updateTimeFactors() override;
46
47 private:
48 void transmitTimingMessagesUpstream(ActionMessage& msg) const;
49 void transmitTimingMessagesDownstream(ActionMessage& msg,
50 GlobalFederateId skipFed = GlobalFederateId{}) const;
51
52 public:
53 virtual TimeProcessingResult processTimeMessage(const ActionMessage& cmd) override;
55 virtual MessageProcessingResult
56 checkExecEntry(GlobalFederateId triggerFed = GlobalFederateId{}) override;
57
59 virtual std::string printTimeStatus() const override;
61 virtual void generateDebuggingTimeInfo(nlohmann::json& base) const override;
62
64 virtual Time getNextTime() const override { return downstream.next; }
65 };
66 } // namespace helics
helics::BaseTimeCoordinator
Definition: BaseTimeCoordinator.hpp:25
helics::DependencyInfo
Definition: TimeDependencies.hpp:98
helics::ForwardingTimeCoordinator
Definition: ForwardingTimeCoordinator.hpp:27
helics::ForwardingTimeCoordinator::checkExecEntry
virtual MessageProcessingResult checkExecEntry(GlobalFederateId triggerFed=GlobalFederateId{}) override
Definition: ForwardingTimeCoordinator.cpp:138
helics::ForwardingTimeCoordinator::updateTimeFactors
virtual bool updateTimeFactors() override
Definition: ForwardingTimeCoordinator.cpp:23
helics::ForwardingTimeCoordinator::ignoreMinFed
bool ignoreMinFed
flag indicating that minFed Controls should not be used
Definition: ForwardingTimeCoordinator.hpp:36
helics::ForwardingTimeCoordinator::iterating
bool iterating
flag indicating that the min dependency is iterating
Definition: ForwardingTimeCoordinator.hpp:35
helics::ForwardingTimeCoordinator::generateDebuggingTimeInfo
virtual void generateDebuggingTimeInfo(nlohmann::json &base) const override
Definition: ForwardingTimeCoordinator.cpp:104
helics::ForwardingTimeCoordinator::printTimeStatus
virtual std::string printTimeStatus() const override
Definition: ForwardingTimeCoordinator.cpp:117
helics::ForwardingTimeCoordinator::getNextTime
virtual Time getNextTime() const override
Definition: ForwardingTimeCoordinator.hpp:64
helics::ForwardingTimeCoordinator::processTimeMessage
virtual TimeProcessingResult processTimeMessage(const ActionMessage &cmd) override
Definition: ForwardingTimeCoordinator.cpp:125
helics::TimeData::next
Time next
next possible message or value
Definition: TimeDependencies.hpp:64
helics
the main namespace for the helics co-simulation library User functions will be in the helics namespac...
Definition: AsyncFedCallInfo.hpp:14
helics::MessageProcessingResult
MessageProcessingResult
Definition: CoreTypes.hpp:75
helics::TimeProcessingResult
TimeProcessingResult
Definition: TimeDependencies.hpp:42
helics::Time
TimeRepresentation< count_time< 9 > > Time
Definition: helicsTime.hpp:27