 |
helics
2.8.1
|
9 #include "../common/GuardedTypes.hpp"
10 #include "ActionMessage.hpp"
11 #include "TimeDependencies.hpp"
13 #include "json/forwards.h"
32 Time timeDelta = Time::epsilon();
42 bool wait_for_current_time_updates =
false;
43 bool uninterruptible =
false;
44 bool restrictive_time_policy =
false;
48 int maxIterations = 50;
80 std::vector<std::pair<Time, int32_t>>
timeBlocks;
99 bool disconnected{
false};
100 bool nonGranting{
false};
106 explicit TimeCoordinator(std::function<
void(
const ActionMessage&)> userSendMessageFunction);
111 void setProperty(
int intProperty,
int propertyVal);
121 void setMessageSender(std::function<
void(
const ActionMessage&)> userSendMessageFunction);
151 void specifyNonGranting(
bool value =
true) { nonGranting = value; }
157 DependencyInfo* getDependencyInfo(global_federate_id ofed);
159 bool isDependency(global_federate_id ofed)
const;
163 bool updateNextExecutionTime();
166 void updateNextPossibleEventTime();
168 Time getNextPossibleTime()
const;
169 Time generateAllowedTime(
Time testTime)
const;
171 bool checkAndSendTimeRequest(ActionMessage& upd, global_federate_id skip)
const;
173 void sendTimeRequest()
const;
174 void updateTimeGrant();
176 bool transmitTimingMessages(ActionMessage& msg,
177 global_federate_id skipFed = global_federate_id{})
const;
181 Time updateTimeBlocks(int32_t blockId,
Time newTime);
210 void setAsChild(global_federate_id fedID);
212 void setAsParent(global_federate_id fedID);
224 Time newMessageTime);
constexpr Time timeZero
Definition: helics-time.hpp:31
void processConfigUpdateMessage(const ActionMessage &cmd)
Definition: TimeCoordinator.cpp:1101
global_federate_id source_id
12 – for federate_id or route_id
Definition: ActionMessage.hpp:36
void removeDependency(global_federate_id id)
Definition: TimeDependencies.cpp:264
bool isDependency(global_federate_id ofed) const
Definition: TimeDependencies.cpp:201
@ processed
the message was used to update the current state
void resetIteratingTimeRequests(Time requestTime)
Definition: TimeDependencies.cpp:421
constexpr uint16_t delayed_timing_flag
overload of extra_flag2 to indicate the request is from federate with delayed timing
Definition: flagOperations.hpp:55
Time getGrantedTime() const
Definition: TimeCoordinator.hpp:124
bool hasInitUpdates
Definition: TimeCoordinator.hpp:95
void removeDependent(global_federate_id fedID)
Definition: TimeCoordinator.cpp:726
@ delay_processing
the message should be delayed and reprocessed later
iteration_request
Definition: core-types.hpp:90
global_federate_id getMinDependency() const
Definition: TimeDependencies.cpp:362
void processDependencyUpdateMessage(const ActionMessage &cmd)
Definition: TimeCoordinator.cpp:958
bool addDependency(global_federate_id id)
Definition: TimeDependencies.cpp:239
void setMessageSender(std::function< void(const ActionMessage &)> userSendMessageFunction)
Definition: TimeCoordinator.cpp:33
bool executionMode
flag that the coordinator has entered the execution Mode
Definition: TimeCoordinator.hpp:94
message_processing_result checkExecEntry()
Definition: TimeCoordinator.cpp:763
Definition: TimeDependencies.hpp:75
base helics enumerations for C++ API's, a namespace wrapper for the definitions defined in helics_enu...
Definition: global_federate_id.hpp:68
void setIterationFlags(ActionMessage &command, iteration_request iterate)
Definition: ActionMessage.cpp:950
global_federate_id source_id
the identifier for inserting into the source id field of any generated messages;
Definition: TimeCoordinator.hpp:87
void resetDependentEvents(Time grantTime)
Definition: TimeDependencies.cpp:434
std::vector< std::pair< Time, int32_t > > timeBlocks
blocks for a particular timeblocking link
Definition: TimeCoordinator.hpp:81
std::string printTimeStatus() const
Definition: TimeCoordinator.cpp:649
constexpr global_broker_id parent_broker_id
Definition: global_federate_id.hpp:60
Definition: TimeDependencies.hpp:36
Time time_minminDe
the minimum of the minimum dependency event Time
Definition: TimeCoordinator.hpp:65
TimeRepresentation< count_time< 9 > > Time
Definition: helics-time.hpp:27
Time time_next
the next possible internal event time
Definition: TimeCoordinator.hpp:64
Time Te
the next currently scheduled event
Definition: TimeDependencies.hpp:39
Time time_block
Definition: TimeCoordinator.hpp:74
void enteringExecMode(iteration_request mode)
Definition: TimeCoordinator.cpp:42
Definition: ActionMessage.hpp:29
shared_guarded_m< std::vector< global_federate_id > > dependent_federates
these are to maintain an accessible record of dependent federates
Definition: TimeCoordinator.hpp:76
@ error
indicator that an error has occurred
message_process_result
Definition: TimeCoordinator.hpp:23
@ force_iteration
force an iteration whether it is needed or not
message_process_result processTimeMessage(const ActionMessage &cmd)
Definition: TimeCoordinator.cpp:844
void resetIteratingExecRequests()
Definition: TimeDependencies.cpp:377
@ iteration_requested_flag
indicator that an iteration has been requested
Definition: flagOperations.hpp:16
bool checkIfReadyForTimeGrant(bool iterating, Time desiredGrantTime) const
Definition: TimeDependencies.cpp:386
int appendMessage(ActionMessage &m, const ActionMessage &newMessage)
Definition: ActionMessage.cpp:939
uint16_t counter
26 counter for filter tracking or message counter
Definition: ActionMessage.hpp:40
Time time_granted
the most recent time granted
Definition: TimeCoordinator.hpp:62
bool checkActionFlag(uint16_t flags, FlagIndex flag)
Definition: flagOperations.hpp:75
message_processing_result
Definition: core-types.hpp:65
auto size() const
Definition: TimeDependencies.hpp:100
bool isValid() const
Definition: global_federate_id.hpp:108
Time time_value
the time of the earliest value event
Definition: TimeCoordinator.hpp:70
@ halted
indicator that the simulation has been halted
@ continue_processing
the current loop should continue
void disconnect()
Definition: TimeCoordinator.cpp:60
bool getOptionFlag(int optionFlag) const
Definition: TimeCoordinator.cpp:1083
constexpr uint16_t child_flag
overload of extra_flag4 indicating a message is from a child object
Definition: flagOperations.hpp:46
@ iterate_if_needed
indicator that the iterations need to continue
Time next
next possible message or value
Definition: TimeDependencies.hpp:38
Time TeAlt
the second min event
Definition: TimeDependencies.hpp:41
void removeDependency(global_federate_id fedID)
Definition: TimeCoordinator.cpp:715
@ no_iterations
indicator that the iterations have completed
int activeDependencyCount() const
Definition: TimeDependencies.cpp:355
bool event_triggered
Definition: TimeCoordinator.hpp:47
std::string payload
Definition: ActionMessage.hpp:44
bool addDependency(global_federate_id fedID)
Definition: TimeCoordinator.cpp:668
constexpr base_type baseValue() const
Definition: global_federate_id.hpp:83
bool updateTime(const ActionMessage &m)
Definition: TimeDependencies.cpp:325
Definition: TimeCoordinator.hpp:30
void updateMessageTime(Time messageUpdateTime, bool allowRequestSend)
Definition: TimeCoordinator.cpp:411
void setOptionFlag(int optionFlag, bool value)
Definition: TimeCoordinator.cpp:1033
Time time_allow
the current allowable time
Definition: TimeCoordinator.hpp:67
int32_t messageID
8 – message ID for a variety of purposes
Definition: ActionMessage.hpp:35
std::atomic< int32_t > iteration
iteration counter
Definition: TimeCoordinator.hpp:98
bool hasActiveTimeDependencies() const
Definition: TimeCoordinator.cpp:348
void setExtraData(int32_t data)
Definition: ActionMessage.hpp:157
auto begin()
Definition: TimeDependencies.hpp:102
@ indicator_flag
flag used for setting values
Definition: flagOperations.hpp:21
bool updateTimeFactors()
Definition: TimeCoordinator.cpp:443
constexpr uint16_t non_granting_flag
overload of extra_flag1 to indicate the request is from a non-granting federate
Definition: flagOperations.hpp:52
TimeDependencies dependencies
Definition: TimeCoordinator.hpp:79
void setActionFlag(FlagContainer &M, FlagIndex flag)
Definition: flagOperations.hpp:67
Time time_minDe
the minimum event time of the dependencies
Definition: TimeCoordinator.hpp:66
void updateValueTime(Time valueUpdateTime, bool allowRequestSend)
Definition: TimeCoordinator.cpp:246
TimeCoordinator()
Definition: TimeCoordinator.cpp:23
Time Te
48 event time
Definition: ActionMessage.hpp:47
bool addDependent(global_federate_id id)
Definition: TimeDependencies.cpp:277
Definition: TimeDependencies.hpp:53
int dependencyCount() const
Definition: TimeCoordinator.cpp:353
Definition: TimeCoordinator.hpp:55
Time time_exec
the time of the next targeted execution
Definition: TimeCoordinator.hpp:68
Time getTimeProperty(int timeProperty) const
Definition: TimeCoordinator.cpp:1053
global_federate_id getMinDependency() const
Definition: TimeCoordinator.cpp:359
bool checkingExec
flag indicating that the coordinator is trying to enter the exec mode
Definition: TimeCoordinator.hpp:92
constexpr uint16_t parent_flag
overload of extra_flag3 indicating the message is from a parent object
Definition: flagOperations.hpp:43
int32_t getExtraData() const
Definition: ActionMessage.hpp:159
Time time_message
the time of the earliest message event
Definition: TimeCoordinator.hpp:69
void setProperty(int timeProperty, Time propertyVal)
Definition: TimeCoordinator.cpp:996
Time time_grantBase
Definition: TimeCoordinator.hpp:73
Time Tdemin
56 min dependent event time
Definition: ActionMessage.hpp:48
Time actionTime
40 the time an action took place or will take place //32
Definition: ActionMessage.hpp:43
bool addDependent(global_federate_id fedID)
Definition: TimeCoordinator.cpp:684
@ no_effect
the message did not result in an update
bool checkIfReadyForExecEntry(bool iterating) const
Definition: TimeDependencies.cpp:336
the main namespace for the helics co-simulation library User functions will be in the helics namespac...
Definition: AsyncFedCallInfo.hpp:14
shared_guarded_m< std::vector< global_federate_id > > dependency_federates
these are to maintain an accessible record of dependency federates
Definition: TimeCoordinator.hpp:78
int getIntegerProperty(int intProperty) const
Definition: TimeCoordinator.cpp:1072
bool hasActiveTimeDependencies() const
Definition: TimeDependencies.cpp:348
iteration_request iterating
Definition: TimeCoordinator.hpp:89
void generateDebuggingTimeInfo(Json::Value &base) const
Definition: TimeCoordinator.cpp:302
Time minDe
min dependency event time
Definition: TimeDependencies.hpp:40
Time time_requested
the most recent time requested
Definition: TimeCoordinator.hpp:63
std::vector< global_federate_id > getDependencies() const
Definition: TimeCoordinator.cpp:742
TimeData upstream
the variables for time coordination
Definition: TimeCoordinator.hpp:58
Definition: application_api/Federate.hpp:26
constexpr Time timeEpsilon
Definition: helics-time.hpp:33
global_federate_id dest_id
20 fed_id for a targeted message
Definition: ActionMessage.hpp:38
std::vector< global_federate_id > getDependents() const
Definition: TimeCoordinator.hpp:130
tcoptions info
basic time control information
Definition: TimeCoordinator.hpp:82
bool empty() const
Definition: TimeDependencies.hpp:115
std::function< void(const ActionMessage &)> sendMessageFunction
callback used to send the messages
Definition: TimeCoordinator.hpp:84
int32_t getCurrentIteration() const
Definition: TimeCoordinator.hpp:137
@ next_step
indicator that the iterations have completed
message_processing_result checkTimeGrant()
Definition: TimeCoordinator.cpp:481
global_federate_id minFed
identifier for the min dependency
Definition: TimeDependencies.hpp:42
const DependencyInfo * getDependencyInfo(global_federate_id id) const
Definition: TimeDependencies.cpp:219
void generateConfig(Json::Value &base) const
Definition: TimeCoordinator.cpp:277
@ iterating
indicator that the iterations need to continue
void localError()
Definition: TimeCoordinator.cpp:97
void timeRequest(Time nextTime, iteration_request iterate, Time newValueTime, Time newMessageTime)
Definition: TimeCoordinator.cpp:140
const int HELICS_INVALID_PROPERTY_VALUE
Definition: helics_enums.h:246
Time allowedSendTime() const
Definition: TimeCoordinator.hpp:126
void removeDependent(global_federate_id id)
Definition: TimeDependencies.cpp:302