9 #include "basic_CoreTypes.hpp"
11 #include "json/forwards.h"
22 exec_requested_require_iteration = 1,
23 exec_requested_iterative = 2,
26 time_requested_require_iteration = 6,
27 time_requested_iterative = 7,
53 enum class GrantDelayMode : std::uint8_t { NONE = 0, INTERRUPTED = 1, WAITING = 2 };
57 return waiting ? GrantDelayMode::WAITING :
58 (interrupted ? GrantDelayMode::INTERRUPTED : GrantDelayMode::NONE);
71 TimeState mTimeState{TimeState::initialized};
89 TimeState startState = TimeState::initialized,
90 std::uint8_t resLevel = 0U):
121 template<
class... Args>
123 TimeData(start, std::forward<Args>(args)...)
131 std::vector<DependencyInfo> dependencies;
158 auto size()
const {
return dependencies.size(); }
160 auto begin() {
return dependencies.begin(); }
162 auto end() {
return dependencies.end(); }
164 auto begin()
const {
return dependencies.cbegin(); }
166 auto end()
const {
return dependencies.cend(); }
168 auto cbegin()
const {
return dependencies.cbegin(); }
170 auto cend()
const {
return dependencies.cend(); }
173 bool empty()
const {
return dependencies.empty(); }
190 Time desiredGrantTime,
209 void setDependencyVector(
const std::vector<DependencyInfo>& deps) { dependencies = deps; }
214 bool hasDelayedDependency()
const {
return mDelayedDependency.
isValid(); }
215 GlobalFederateId delayedDependency()
const {
return mDelayedDependency; }
218 inline bool checkSequenceCounter(
const DependencyInfo& dep,
Time tmin, std::int32_t sq)
220 return (!dep.dependency || !dep.dependent || dep.timingVersion <= 0 || dep.next > tmin ||
221 dep.next >=
cBigTime || dep.responseSequenceCounter == sq);
224 const DependencyInfo& getExecEntryMinFederate(
const TimeDependencies& dependencies,
225 GlobalFederateId
self,
227 GlobalFederateId ignore = GlobalFederateId{});
228 static constexpr GlobalFederateId NoIgnoredFederates{};
230 TimeData generateMinTimeUpstream(
const TimeDependencies& dependencies,
232 GlobalFederateId
self,
233 GlobalFederateId ignore,
234 std::int32_t responseCode);
236 TimeData generateMinTimeDownstream(
const TimeDependencies& dependencies,
238 GlobalFederateId
self,
239 GlobalFederateId ignore,
240 std::int32_t responseCode);
242 TimeData generateMinTimeTotal(
const TimeDependencies& dependencies,
244 GlobalFederateId
self,
245 GlobalFederateId ignore,
246 std::int32_t responseCode);
248 void generateJsonOutputTimeData(Json::Value& output,
250 bool includeAggregates =
true);
252 void addTimeState(Json::Value& output,
const TimeState state);
254 void generateJsonOutputDependency(Json::Value& output,
const DependencyInfo& dep);
Definition: ActionMessage.hpp:30
Definition: TimeDependencies.hpp:98
bool dependency
indicator that the dependency is an actual dependency
Definition: TimeDependencies.hpp:106
bool triggered
indicator that the dependency has been triggered in some way
Definition: TimeDependencies.hpp:109
bool nonGranting
indicator that the dependency is a non granting time coordinator
Definition: TimeDependencies.hpp:108
bool updateRequested
indicator that an update request is in process
Definition: TimeDependencies.hpp:110
GlobalFederateId fedID
identifier for the dependency
Definition: TimeDependencies.hpp:100
bool dependent
indicator the dependency is a dependent object
Definition: TimeDependencies.hpp:105
bool cyclic
Definition: TimeDependencies.hpp:102
DependencyInfo(GlobalFederateId id)
Definition: TimeDependencies.hpp:119
bool forwarding
indicator that the dependency is a forwarding time coordinator
Definition: TimeDependencies.hpp:107
Definition: GlobalFederateId.hpp:75
constexpr bool isValid() const
Definition: GlobalFederateId.hpp:112
Definition: TimeDependencies.hpp:62
std::int32_t responseSequenceCounter
Definition: TimeDependencies.hpp:80
Time Te
the next currently scheduled event
Definition: TimeDependencies.hpp:65
Time TeAlt
the second min event
Definition: TimeDependencies.hpp:67
std::int32_t grantedIteration
the iteration of the dependency when the local iteration was granted
Definition: TimeDependencies.hpp:82
std::uint8_t restrictionLevel
timing restriction level
Definition: TimeDependencies.hpp:76
bool update(const TimeData &update)
Definition: TimeDependencies.cpp:172
Time next
next possible message or value
Definition: TimeDependencies.hpp:64
bool interrupted
indicator that the federates next event is a timing interruption
Definition: TimeDependencies.hpp:73
std::int8_t timingVersion
version indicator
Definition: TimeDependencies.hpp:75
Time minDe
min dependency event time
Definition: TimeDependencies.hpp:66
std::int32_t timeoutCount
counter for timeout checking
Definition: TimeDependencies.hpp:78
Time lastGrant
storage for the previous grant time
Definition: TimeDependencies.hpp:68
bool hasData
indicator that data was sent in the current interval
Definition: TimeDependencies.hpp:72
GlobalFederateId minFedActual
the actual forwarded minimum federate object
Definition: TimeDependencies.hpp:70
bool delayedTiming
indicator that the dependency is using delayed timing
Definition: TimeDependencies.hpp:74
std::int32_t sequenceCounter
the sequence Counter of the request
Definition: TimeDependencies.hpp:79
GlobalFederateId minFed
identifier for the min dependency
Definition: TimeDependencies.hpp:69
Definition: TimeDependencies.hpp:129
bool checkIfReadyForExecEntry(bool iterating, bool waiting) const
Definition: TimeDependencies.cpp:502
void resetDependency(GlobalFederateId id)
Definition: TimeDependencies.cpp:432
bool addDependent(GlobalFederateId gid)
Definition: TimeDependencies.cpp:394
void resetDependentEvents(Time grantTime)
Definition: TimeDependencies.cpp:693
void resetIteratingExecRequests()
Definition: TimeDependencies.cpp:666
bool addDependency(GlobalFederateId gid)
Definition: TimeDependencies.cpp:350
bool verifySequenceCounter(Time tmin, std::int32_t sequenceCount)
Definition: TimeDependencies.cpp:636
TimeDependencies()=default
bool empty() const
Definition: TimeDependencies.hpp:173
auto begin() const
Definition: TimeDependencies.hpp:164
const DependencyInfo * getDependencyInfo(GlobalFederateId gid) const
Definition: TimeDependencies.cpp:330
TimeProcessingResult updateTime(const ActionMessage &cmd)
Definition: TimeDependencies.cpp:454
void removeInterdependence(GlobalFederateId gid)
Definition: TimeDependencies.cpp:444
std::pair< int, std::string > checkForIssues(bool waiting) const
Definition: TimeDependencies.cpp:703
auto cbegin() const
Definition: TimeDependencies.hpp:168
bool checkIfAllDependenciesArePastExec(bool iterating) const
Definition: TimeDependencies.cpp:463
auto begin()
Definition: TimeDependencies.hpp:160
int activeDependencyCount() const
Definition: TimeDependencies.cpp:644
bool hasActiveTimeDependencies() const
Definition: TimeDependencies.cpp:629
auto size() const
Definition: TimeDependencies.hpp:158
auto end() const
Definition: TimeDependencies.hpp:166
bool isDependency(GlobalFederateId ofed) const
Definition: TimeDependencies.cpp:312
bool checkIfReadyForTimeGrant(bool iterating, Time desiredGrantTime, GrantDelayMode delayMode) const
Definition: TimeDependencies.cpp:552
void resetIteratingTimeRequests(Time requestTime)
Definition: TimeDependencies.cpp:680
auto cend() const
Definition: TimeDependencies.hpp:170
auto end()
Definition: TimeDependencies.hpp:162
void removeDependent(GlobalFederateId gid)
Definition: TimeDependencies.cpp:419
void removeDependency(GlobalFederateId gid)
Definition: TimeDependencies.cpp:381
bool isDependent(GlobalFederateId ofed) const
Definition: TimeDependencies.cpp:321
GlobalFederateId getMinDependency() const
Definition: TimeDependencies.cpp:651
the main namespace for the helics co-simulation library User functions will be in the helics namespac...
Definition: AsyncFedCallInfo.hpp:14
constexpr Time cBigTime
Definition: helicsTime.hpp:37
constexpr Time timeZero
Definition: helicsTime.hpp:31
ConnectionType
Definition: TimeDependencies.hpp:33
GrantDelayMode
Definition: TimeDependencies.hpp:53
TimeProcessingResult
Definition: TimeDependencies.hpp:42
@ DELAY_PROCESSING
the message should be delayed and reprocessed later
@ PROCESSED_NEW_REQUEST
the message was used to update the current state and a new request was made
@ PROCESSED_AND_CHECK
the message was used to update the current state and additional checks should be made
@ NOT_PROCESSED
the message did not result in an update
TimeState
Definition: TimeDependencies.hpp:20
TimeRepresentation< count_time< 9 > > Time
Definition: helicsTime.hpp:27
constexpr Time negEpsilon
Definition: helicsTime.hpp:35