helics  3.3.0
ForwardingTimeCoordinator.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 
9 #include "ActionMessage.hpp"
10 #include "BaseTimeCoordinator.hpp"
11 #include "CoreFederateInfo.hpp"
12 #include "TimeDependencies.hpp"
13 
14 #include "json/forwards.h"
15 #include <atomic>
16 #include <functional>
17 #include <string>
18 #include <utility>
19 #include <vector>
20 
21 namespace helics {
22 
28  private:
29  // the variables for time coordination
30  DependencyInfo upstream;
31  DependencyInfo downstream;
32 
33  protected:
34  bool iterating{false};
35  bool ignoreMinFed{false};
36 
37  public:
38  ForwardingTimeCoordinator() = default;
39 
43  virtual bool updateTimeFactors() override;
44 
45  private:
46  void transmitTimingMessagesUpstream(ActionMessage& msg) const;
47  void transmitTimingMessagesDownstream(ActionMessage& msg,
48  GlobalFederateId skipFed = GlobalFederateId{}) const;
49 
50  public:
53  checkExecEntry(GlobalFederateId triggerFed = GlobalFederateId{}) override;
54 
56  virtual std::string printTimeStatus() const override;
58  virtual void generateDebuggingTimeInfo(Json::Value& base) const override;
59 
61  virtual Time getNextTime() const override { return downstream.next; }
62 };
63 } // namespace helics
helics::timeZero
constexpr Time timeZero
Definition: helicsTime.hpp:31
helics::ForwardingTimeCoordinator::getNextTime
virtual Time getNextTime() const override
Definition: ForwardingTimeCoordinator.hpp:61
helics::ActionMessage::setExtraDestData
void setExtraDestData(int32_t data)
Definition: ActionMessage.hpp:161
helics::BaseTimeCoordinator::dependencies
TimeDependencies dependencies
Definition: BaseTimeCoordinator.hpp:27
helics::BaseTimeCoordinator::sendMessageFunction
std::function< void(const ActionMessage &)> sendMessageFunction
callback used to send the messages
Definition: BaseTimeCoordinator.hpp:29
helics::TimeData::responseSequenceCounter
std::int32_t responseSequenceCounter
Definition: TimeDependencies.hpp:74
helics::BaseTimeCoordinator::mSourceId
GlobalFederateId mSourceId
the identifier for inserting into the source id field of any generated messages;
Definition: BaseTimeCoordinator.hpp:32
helics_definitions.hpp
base helics enumerations for C++ API's, a namespace wrapper for the definitions defined in helics_enu...
helics::Time
TimeRepresentation< count_time< 9 > > Time
Definition: helicsTime.hpp:27
helics::cBigTime
constexpr Time cBigTime
Definition: helicsTime.hpp:37
helics::TimeData::Te
Time Te
the next currently scheduled event
Definition: TimeDependencies.hpp:60
helics::GlobalFederateId
Definition: GlobalFederateId.hpp:72
helics::ActionMessage
Definition: ActionMessage.hpp:30
helics::BaseTimeCoordinator::sequenceCounter
std::int32_t sequenceCounter
storage for sequence counter
Definition: BaseTimeCoordinator.hpp:33
helics::ForwardingTimeCoordinator::ignoreMinFed
bool ignoreMinFed
flag indicating that minFed Controls should not be used
Definition: ForwardingTimeCoordinator.hpp:35
helics::ForwardingTimeCoordinator
Definition: ForwardingTimeCoordinator.hpp:27
helics::TimeData::sequenceCounter
std::int32_t sequenceCounter
the sequence Counter of the request
Definition: TimeDependencies.hpp:73
helics::TimeData::next
Time next
next possible message or value
Definition: TimeDependencies.hpp:59
helics::BaseTimeCoordinator::executionMode
bool executionMode
Definition: BaseTimeCoordinator.hpp:37
helics::BaseTimeCoordinator::restrictive_time_policy
bool restrictive_time_policy
flag indicating that a restrictive time policy should be used
Definition: BaseTimeCoordinator.hpp:39
helics::ForwardingTimeCoordinator::checkExecEntry
virtual MessageProcessingResult checkExecEntry(GlobalFederateId triggerFed=GlobalFederateId{}) override
Definition: ForwardingTimeCoordinator.cpp:123
helics::ActionMessage::dest_id
GlobalFederateId dest_id
20 fed_id for a targeted message
Definition: ActionMessage.hpp:39
helics::BaseTimeCoordinator::noParent
bool noParent
indicator that the coordinator does not have parents
Definition: BaseTimeCoordinator.hpp:34
helics::DependencyInfo
Definition: TimeDependencies.hpp:93
helics::MessageProcessingResult::CONTINUE_PROCESSING
@ CONTINUE_PROCESSING
the current loop should continue
helics::MessageProcessingResult
MessageProcessingResult
Definition: CoreTypes.hpp:64
helics::ForwardingTimeCoordinator::printTimeStatus
virtual std::string printTimeStatus() const override
Definition: ForwardingTimeCoordinator.cpp:115
helics::BaseTimeCoordinator
Definition: BaseTimeCoordinator.hpp:25
helics
the main namespace for the helics co-simulation library User functions will be in the helics namespac...
Definition: AsyncFedCallInfo.hpp:14
helics::ForwardingTimeCoordinator::iterating
bool iterating
flag indicating that the min dependency is iterating
Definition: ForwardingTimeCoordinator.hpp:34
helics::TimeData::update
bool update(const TimeData &update)
Definition: TimeDependencies.cpp:168
helics::ForwardingTimeCoordinator::updateTimeFactors
virtual bool updateTimeFactors() override
Definition: ForwardingTimeCoordinator.cpp:23
helics::MessageProcessingResult::NEXT_STEP
@ NEXT_STEP
indicator that the iterations have completed
helics::BaseTimeCoordinator::generateTimeRequest
ActionMessage generateTimeRequest(const TimeData &dep, GlobalFederateId fed, std::int32_t responseCode) const
Definition: BaseTimeCoordinator.cpp:288
helics::BaseTimeCoordinator::generateDebuggingTimeInfo
virtual void generateDebuggingTimeInfo(Json::Value &base) const
Definition: BaseTimeCoordinator.cpp:118
helics::TimeData::minDe
Time minDe
min dependency event time
Definition: TimeDependencies.hpp:61
helics::ActionMessage::action
action_message_def::action_t action() const noexcept
Definition: ActionMessage.hpp:88
helics::TimeData::minFed
GlobalFederateId minFed
identifier for the min dependency
Definition: TimeDependencies.hpp:63
flagOperations.hpp
helics::TimeDependencies::checkIfReadyForExecEntry
bool checkIfReadyForExecEntry(bool iterating, bool waiting) const
Definition: TimeDependencies.cpp:454
helics::ForwardingTimeCoordinator::generateDebuggingTimeInfo
virtual void generateDebuggingTimeInfo(Json::Value &base) const override
Definition: ForwardingTimeCoordinator.cpp:102
helics::ActionMessage::source_id
GlobalFederateId source_id
12 – for federate_id or route_id
Definition: ActionMessage.hpp:37