| helics 3.6.1

AsyncTimeCoordinator.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 #include "nlohmann/json_fwd.hpp"
14
15 #include <atomic>
16 #include <functional>
17 #include <string>
18 #include <utility>
19 #include <vector>
20
21 namespace helics {
22
32 class AsyncTimeCoordinator: public BaseTimeCoordinator {
33 private:
34 // the variables for time coordination
35 Time currentMinTime{Time::minVal()};
36 TimeState currentTimeState{TimeState::initialized};
37 Time nextEvent{Time::maxVal()};
38
39 protected:
40 bool iterating{false};
41
42 public:
43 AsyncTimeCoordinator() = default;
44
48 virtual bool updateTimeFactors() override;
49
50 private:
51 void transmitTimingMessagesUpstream(ActionMessage& msg) const;
52 void transmitTimingMessagesDownstream(ActionMessage& msg,
53 GlobalFederateId skipFed = GlobalFederateId{}) const;
54
55 public:
57 virtual MessageProcessingResult
58 checkExecEntry(GlobalFederateId triggerFed = GlobalFederateId{}) override;
59
61 virtual std::string printTimeStatus() const override;
63 virtual void generateDebuggingTimeInfo(nlohmann::json& base) const override;
64
66 virtual Time getNextTime() const override { return currentMinTime; }
67 };
68 } // namespace helics
helics::ActionMessage
Definition: ActionMessage.hpp:30
helics::AsyncTimeCoordinator
Definition: AsyncTimeCoordinator.hpp:32
helics::AsyncTimeCoordinator::iterating
bool iterating
flag indicating that the min dependency is iterating
Definition: AsyncTimeCoordinator.hpp:40
helics::AsyncTimeCoordinator::getNextTime
virtual Time getNextTime() const override
Definition: AsyncTimeCoordinator.hpp:66
helics::AsyncTimeCoordinator::checkExecEntry
virtual MessageProcessingResult checkExecEntry(GlobalFederateId triggerFed=GlobalFederateId{}) override
Definition: AsyncTimeCoordinator.cpp:48
helics::AsyncTimeCoordinator::updateTimeFactors
virtual bool updateTimeFactors() override
Definition: AsyncTimeCoordinator.cpp:23
helics::AsyncTimeCoordinator::generateDebuggingTimeInfo
virtual void generateDebuggingTimeInfo(nlohmann::json &base) const override
Definition: AsyncTimeCoordinator.cpp:32
helics::AsyncTimeCoordinator::printTimeStatus
virtual std::string printTimeStatus() const override
Definition: AsyncTimeCoordinator.cpp:41
helics::BaseTimeCoordinator
Definition: BaseTimeCoordinator.hpp:25
helics::GlobalFederateId
Definition: GlobalFederateId.hpp:75
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::TimeState
TimeState
Definition: TimeDependencies.hpp:20
helics::Time
TimeRepresentation< count_time< 9 > > Time
Definition: helicsTime.hpp:27