| helics 3.6.1

Public Member Functions | Public Attributes | Protected Attributes | List of all members
helics::TimeCoordinator Class Reference

`#include <TimeCoordinator.hpp>`

Inheritance diagram for helics::TimeCoordinator:

## Public Member Functions
| TimeCoordinator ()=default
| TimeCoordinator (std::function< void(const ActionMessage &)> userSendMessageFunction)
void | setProperty (int timeProperty, Time propertyVal)
void | setProperty (int intProperty, int propertyVal)
void | setOptionFlag (int optionFlag, bool value)
void | setDynamicJoining ()
Time | getTimeProperty (int timeProperty) const
bool | getOptionFlag (int optionFlag) const
int | getIntegerProperty (int intProperty) const
Time | getGrantedTime () const
Time | getRequestedTime () const
Time | allowedSendTime () const
std::vector< GlobalFederateId > | getDependencies () const
std::vector< GlobalFederateId > | getDependents () const
const auto & | getBarriers () const
int32_t | getCurrentIteration () const
virtual bool | updateTimeFactors () override
void | updateValueTime (Time valueUpdateTime, bool allowRequestSend)
void | updateMessageTime (Time messageUpdateTime, bool allowRequestSend)
void | specifyNonGranting (bool value=true)
virtual TimeProcessingResult | processTimeMessage (const ActionMessage &cmd) override
void | processConfigUpdateMessage (const ActionMessage &cmd)
virtual bool | addDependency (GlobalFederateId fedID) override
virtual bool | addDependent (GlobalFederateId fedID) override
virtual void | removeDependency (GlobalFederateId fedID) override
virtual void | removeDependent (GlobalFederateId fedID) override
virtual MessageProcessingResult | checkExecEntry (GlobalFederateId triggerFed=GlobalFederateId{}) override
void | sendUpdatedExecRequest (GlobalFederateId target=GlobalFederateId{}, GlobalFederateId minFed=GlobalFederateId{}, std::int32_t responseSequenceCounter=0)
void | timeRequest (Time nextTime, IterationRequest iterate, Time newValueTime, Time newMessageTime)
virtual void | enteringExecMode (IterationRequest mode) override
MessageProcessingResult | checkTimeGrant (GlobalFederateId triggerFed=GlobalFederateId{})
void | localError ()
virtual std::string | printTimeStatus () const override
void | generateConfig (nlohmann::json &base) const
virtual void | generateDebuggingTimeInfo (nlohmann::json &base) const override
std::pair< GlobalFederateId, Time > | getMinGrantedDependency () const
void | enterInitialization ()
void | requestTimeCheck ()
virtual Time | getNextTime () const override
Public Member Functions inherited from helics::BaseTimeCoordinator
| BaseTimeCoordinator (std::function< void(const ActionMessage &)> userSendMessageFunction)
void | setMessageSender (std::function< void(const ActionMessage &)> userSendMessageFunction)
void | setRestrictivePolicy (bool policy)
std::vector< GlobalFederateId > | getDependencies () const
std::vector< GlobalFederateId > | getDependents () const
Time | getLastGrant (GlobalFederateId fedId) const
void | setSourceId (GlobalFederateId sourceId)
GlobalFederateId | sourceId () const
const DependencyInfo * | getDependencyInfo (GlobalFederateId ofed) const
bool | isDependency (GlobalFederateId ofed) const
bool | empty () const
void | processDependencyUpdateMessage (const ActionMessage &cmd)
virtual void | resetDependency (GlobalFederateId fedID)
void | setAsChild (GlobalFederateId fedID)
void | setAsParent (GlobalFederateId fedID)
void | setVersion (GlobalFederateId fedID, std::int8_t version)
GlobalFederateId | getParent () const
void | disconnect ()
bool | hasActiveTimeDependencies () const
int | dependencyCount () const
GlobalFederateId | getMinDependency () const
nlohmann::json | grantTimeoutCheck (const ActionMessage &cmd)

## Public Attributes
IterationRequest | iterating {IterationRequest::NO_ITERATIONS}
| indicator that the coordinator should be iteratingif need be
bool | hasInitUpdates {false}
| flag indicating that a value or message was received during initialization stage
bool | hasIterationData {false}
| flag indicating that a value or message was received during iteration
bool | needSendAll {false}
bool | triggered {false}
| indicator the federate was triggered recently
bool | globalTime {false}
| true if using a global time manager parent

## Protected Attributes
TimeData | upstream
| the variables for time coordination
TimeData | total
TimeData | lastSend
Time | time_granted {Time::minVal()}
| the most recent time granted
Time | time_requested {Time::maxVal()}
| the most recent time requested
Time | time_next {timeZero}
| the next possible internal event time
Time | time_minminDe {timeZero}
| the minimum of the minimum dependency event Time
Time | time_minDe {timeZero}
| the minimum event time of the dependencies
Time | time_allow {Time::minVal()}
| the current allowable time
Time | time_exec {Time::maxVal()}
| the time of the next targeted execution
Time | time_message {Time::maxVal()}
| the time of the earliest message event
Time | time_value {Time::maxVal()}
| the time of the earliest value event
Time | time_grantBase {Time::minVal()}
Time | time_block {Time::maxVal()}
| a blocking time to not grant time >= the specified time
Time | maxTime {Time::maxVal()}
shared_guarded_m< std::vector< GlobalFederateId > > | dependent_federates
| these are to maintain an accessible record of dependent federates
shared_guarded_m< std::vector< GlobalFederateId > > | dependency_federates
| these are to maintain an accessible record of dependency federates
std::vector< std::pair< Time, int32_t > > | timeBlocks
| blocks for a particular timeblocking link
tcoptions | info
| basic time control information
std::uint8_t | currentRestrictionLevel {0}
bool | dynamicJoining {false}
| if set to true the time coordinator is joining an ongoing co-simulation
std::atomic< int32_t > | iteration {0}
| current number of iterations
Protected Attributes inherited from helics::BaseTimeCoordinator
TimeDependencies | dependencies
std::function< void(const ActionMessage &)> | sendMessageFunction
| callback used to send the messages
GlobalFederateId | mSourceId {0}
| the identifier for inserting into the source id field of any generated messages;
std::int32_t | sequenceCounter {0}
| storage for sequence counter
bool | noParent {true}
| indicator that the coordinator does not have parents
bool | federatesOnly {false}
| indicator that the forwarder only operates with federates
bool | checkingExec {false}
bool | executionMode {false}
bool | restrictive_time_policy {false}
| flag indicating that a restrictive time policy should be used
bool | nonGranting {false}
bool | delayedTiming {false}
bool | disconnected {false}

## Additional Inherited Members
Static Public Attributes inherited from helics::BaseTimeCoordinator
static constexpr std::int32_t | TIME_COORDINATOR_VERSION {1}
Protected Member Functions inherited from helics::BaseTimeCoordinator
ActionMessage | generateTimeRequest (const TimeData &dep, GlobalFederateId fed, std::int32_t responseCode) const
void | sendTimingInfo ()

## Detailed Description

class managing the coordination of time in HELICS the time coordinator manages dependencies and computes whether time can advance or enter execution mode

## Constructor & Destructor Documentation

## ◆ TimeCoordinator() [1/2]

helics::TimeCoordinator::TimeCoordinator | ( |  | ) |
| default

default constructor

## ◆ TimeCoordinator() [2/2]

helics::TimeCoordinator::TimeCoordinator | ( | std::function< void(const ActionMessage &)> | userSendMessageFunction | ) |
| inline explicit

construct from a federate info and message send function

## Member Function Documentation

## ◆ addDependency()

bool helics::TimeCoordinator::addDependency | ( | GlobalFederateId | fedID | ) |
| override virtual

add a federate dependency

Returns
  true if it was actually added, false if the federate was already present

Reimplemented from helics::BaseTimeCoordinator.

References helics::BaseTimeCoordinator::addDependency(), and dependency_federates.

## ◆ addDependent()

bool helics::TimeCoordinator::addDependent | ( | GlobalFederateId | fedID | ) |
| override virtual

add a dependent federate

Returns
  true if it was actually added, false if the federate was already present

Reimplemented from helics::BaseTimeCoordinator.

References helics::BaseTimeCoordinator::addDependent(), and dependent_federates.

## ◆ allowedSendTime()

Time helics::TimeCoordinator::allowedSendTime | ( |  | ) | const
| inline

get the current granted time

References info, and time_granted.

## ◆ checkExecEntry()

MessageProcessingResult helics::TimeCoordinator::checkExecEntry | ( | GlobalFederateId | triggerFed = `GlobalFederateId{}` | ) |
| override virtual

check if entry to the executing state can be granted

Implements helics::BaseTimeCoordinator.

References helics::TimeDependencies::checkIfAllDependenciesArePastExec(), helics::TimeDependencies::checkIfReadyForExecEntry(), helics::CONTINUE_PROCESSING, helics::BaseTimeCoordinator::dependencies, helics::FORCE_ITERATION, helics::TimeDependencies::getDependencyInfo(), globalTime, hasInitUpdates, info, helics::GlobalFederateId::isValid(), helics::ITERATE_IF_NEEDED, helics::ITERATING, iterating, iteration, helics::BaseTimeCoordinator::mSourceId, needSendAll, helics::TimeData::next, helics::NEXT_STEP, helics::NO_ITERATIONS, sendUpdatedExecRequest(), helics::BaseTimeCoordinator::sequenceCounter, time_block, and helics::timeZero.

## ◆ checkTimeGrant()

MessageProcessingResult helics::TimeCoordinator::checkTimeGrant | ( | GlobalFederateId | triggerFed = `GlobalFederateId{}` | ) |

check if it is valid to grant a time

References helics::TimeDependencies::checkIfReadyForTimeGrant(), helics::CONTINUE_PROCESSING, helics::BaseTimeCoordinator::dependencies, helics::BaseTimeCoordinator::disconnect(), helics::FORCE_ITERATION, helics::HALTED, hasIterationData, info, helics::GlobalFederateId::isValid(), helics::ITERATE_IF_NEEDED, helics::ITERATING, iterating, iteration, helics::BaseTimeCoordinator::mSourceId, needSendAll, helics::NEXT_STEP, helics::NO_ITERATIONS, helics::BaseTimeCoordinator::nonGranting, helics::BaseTimeCoordinator::sequenceCounter, time_allow, time_block, time_exec, time_grantBase, time_granted, time_requested, and updateTimeFactors().

## ◆ enteringExecMode()

void helics::TimeCoordinator::enteringExecMode | ( | IterationRequest | mode | ) |
| override virtual

function to enter the exec Mode

Parameters

  mode | the mode of iteration_request (NO_ITERATIONS, FORCE_ITERATION, ITERATE_IF_NEEDED)

Reimplemented from helics::BaseTimeCoordinator.

References helics::TimeDependencies::checkForIssues(), helics::ActionMessage::counter, helics::delayed_timing_flag, helics::BaseTimeCoordinator::dependencies, helics::ActionMessage::dest_id, helics::BaseTimeCoordinator::executionMode, hasInitUpdates, info, iterating, helics::ActionMessage::messageID, helics::BaseTimeCoordinator::mSourceId, helics::NO_ITERATIONS, helics::parent_broker_id, helics::ActionMessage::payload, helics::BaseTimeCoordinator::sendMessageFunction, helics::BaseTimeCoordinator::sendTimingInfo(), helics::BaseTimeCoordinator::sequenceCounter, helics::setActionFlag(), helics::ActionMessage::setExtraData(), helics::setIterationFlags(), and helics::ActionMessage::source_id.

## ◆ enterInitialization()

void helics::TimeCoordinator::enterInitialization | ( |  | ) |

enter initialization

References helics::BaseTimeCoordinator::dependencies, helics::ActionMessage::dest_id, dynamicJoining, helics::BaseTimeCoordinator::mSourceId, helics::BaseTimeCoordinator::sendMessageFunction, and helics::ActionMessage::source_id.

## ◆ generateConfig()

void helics::TimeCoordinator::generateConfig | ( | nlohmann::json & | base | ) | const

generate a configuration string(JSON)

References helics::tcoptions::event_triggered, info, and helics::timeZero.

Referenced by generateDebuggingTimeInfo().

## ◆ generateDebuggingTimeInfo()

void helics::TimeCoordinator::generateDebuggingTimeInfo | ( | nlohmann::json & | base | ) | const
| override virtual

generate debugging time information

Reimplemented from helics::BaseTimeCoordinator.

References generateConfig(), helics::BaseTimeCoordinator::generateDebuggingTimeInfo(), time_allow, time_exec, time_granted, time_message, time_minDe, time_minminDe, time_requested, time_value, timeBlocks, and upstream.

## ◆ getCurrentIteration()

int32_t helics::TimeCoordinator::getCurrentIteration | ( |  | ) | const
| inline

get the current iteration counter for an iterative call

this will work properly even when a federate is processing

References iteration.

## ◆ getDependencies()

std::vector< GlobalFederateId > helics::TimeCoordinator::getDependencies | ( |  | ) | const

get a list of actual dependencies

References dependency_federates.

## ◆ getDependents()

std::vector<GlobalFederateId> helics::TimeCoordinator::getDependents | ( |  | ) | const
| inline

get a reference to the dependents vector

References dependent_federates.

## ◆ getGrantedTime()

Time helics::TimeCoordinator::getGrantedTime | ( |  | ) | const
| inline

get the current granted time

References time_granted.

Referenced by getNextTime().

## ◆ getIntegerProperty()

int helics::TimeCoordinator::getIntegerProperty | ( | int | intProperty | ) | const

get an option flag value

## ◆ getMinGrantedDependency()

std::pair< GlobalFederateId, Time > helics::TimeCoordinator::getMinGrantedDependency | ( |  | ) | const

get a count of the active dependencies

References helics::BaseTimeCoordinator::dependencies.

## ◆ getNextTime()

Time helics::TimeCoordinator::getNextTime | ( |  | ) | const
| override virtual

get the current next time

Implements helics::BaseTimeCoordinator.

References getGrantedTime().

## ◆ getOptionFlag()

bool helics::TimeCoordinator::getOptionFlag | ( | int | optionFlag | ) | const

get an option flag value

References helics::tcoptions::event_triggered, and info.

## ◆ getRequestedTime()

Time helics::TimeCoordinator::getRequestedTime | ( |  | ) | const
| inline

get the current granted time

References time_requested.

## ◆ getTimeProperty()

Time helics::TimeCoordinator::getTimeProperty | ( | int | timeProperty | ) | const

get a time Property

## ◆ localError()

void helics::TimeCoordinator::localError | ( |  | ) |

generate a local Error

References helics::appendMessage(), helics::TimeDependencies::begin(), helics::BaseTimeCoordinator::dependencies, helics::ActionMessage::dest_id, helics::TimeDependencies::empty(), helics::BaseTimeCoordinator::mSourceId, processTimeMessage(), helics::BaseTimeCoordinator::sendMessageFunction, helics::TimeDependencies::size(), helics::ActionMessage::source_id, time_grantBase, and time_granted.

## ◆ printTimeStatus()

std::string helics::TimeCoordinator::printTimeStatus | ( |  | ) | const
| override virtual

generate a string with the current time status

Implements helics::BaseTimeCoordinator.

References time_allow, time_exec, time_granted, time_message, time_minDe, time_minminDe, time_requested, and time_value.

## ◆ processConfigUpdateMessage()

void helics::TimeCoordinator::processConfigUpdateMessage | ( | const ActionMessage & | cmd | ) |

process a message related to configuration

Parameters

  cmd | the update command

References helics::ActionMessage::action(), helics::ActionMessage::actionTime, helics::checkActionFlag(), helics::ActionMessage::counter, helics::indicator_flag, helics::ActionMessage::messageID, setOptionFlag(), and setProperty().

## ◆ processTimeMessage()

TimeProcessingResult helics::TimeCoordinator::processTimeMessage | ( | const ActionMessage & | cmd | ) |
| override virtual

process a message related to time

Returns
  a TimeProcessingResult if it did anything

Reimplemented from helics::BaseTimeCoordinator.

References helics::ActionMessage::action(), helics::ActionMessage::actionTime, helics::TimeData::minDe, helics::BaseTimeCoordinator::mSourceId, helics::TimeData::next, helics::NOT_PROCESSED, helics::PROCESSED, removeDependent(), helics::ActionMessage::source_id, helics::TimeData::Te, time_grantBase, and time_granted.

Referenced by localError().

## ◆ removeDependency()

void helics::TimeCoordinator::removeDependency | ( | GlobalFederateId | fedID | ) |
| override virtual

remove a dependency

Parameters

  fedID | the identifier of the federate to remove

Reimplemented from helics::BaseTimeCoordinator.

References helics::BaseTimeCoordinator::dependencies, dependency_federates, and helics::TimeDependencies::removeDependency().

## ◆ removeDependent()

void helics::TimeCoordinator::removeDependent | ( | GlobalFederateId | fedID | ) |
| override virtual

remove a dependent

Parameters

  fedID | the identifier of the federate to remove

Reimplemented from helics::BaseTimeCoordinator.

References helics::BaseTimeCoordinator::dependencies, dependent_federates, and helics::TimeDependencies::removeDependent().

Referenced by processTimeMessage().

## ◆ requestTimeCheck()

void helics::TimeCoordinator::requestTimeCheck | ( |  | ) |

request a resend of the time message for certain federates currently blocking

References helics::BaseTimeCoordinator::dependencies, helics::ActionMessage::dest_id, dynamicJoining, helics::BaseTimeCoordinator::mSourceId, helics::BaseTimeCoordinator::sendMessageFunction, helics::ActionMessage::source_id, and time_exec.

## ◆ sendUpdatedExecRequest()

void helics::TimeCoordinator::sendUpdatedExecRequest | ( | GlobalFederateId | target = `GlobalFederateId{}`,
|  | GlobalFederateId | minFed = `GlobalFederateId{}`,
|  | std::int32_t | responseSequenceCounter = `0`
| ) |  |

send updated exec request to target or everyone if target is invalid

References helics::GlobalFederateId::baseValue(), helics::ActionMessage::counter, helics::delayed_timing_flag, helics::BaseTimeCoordinator::dependencies, helics::ActionMessage::dest_id, info, helics::GlobalFederateId::isValid(), iterating, helics::ActionMessage::messageID, helics::BaseTimeCoordinator::mSourceId, helics::BaseTimeCoordinator::sendMessageFunction, helics::BaseTimeCoordinator::sequenceCounter, helics::setActionFlag(), helics::ActionMessage::setExtraData(), helics::ActionMessage::setExtraDestData(), helics::setIterationFlags(), and helics::ActionMessage::source_id.

Referenced by checkExecEntry().

## ◆ setDynamicJoining()

void helics::TimeCoordinator::setDynamicJoining | ( |  | ) |
| inline

set dynamic joining flag to true

References dynamicJoining.

## ◆ setOptionFlag()

void helics::TimeCoordinator::setOptionFlag | ( | int | optionFlag,
|  | bool | value
| ) |  |

set an option Flag for a the coordinator

References helics::tcoptions::event_triggered, and info.

Referenced by processConfigUpdateMessage().

## ◆ setProperty() [1/2]

void helics::TimeCoordinator::setProperty | ( | int | intProperty,
|  | int | propertyVal
| ) |  |

set a timeProperty for a the coordinator

## ◆ setProperty() [2/2]

void helics::TimeCoordinator::setProperty | ( | int | timeProperty,
|  | Time | propertyVal
| ) |  |

set a timeProperty for a the coordinator

Referenced by processConfigUpdateMessage().

## ◆ timeRequest()

void helics::TimeCoordinator::timeRequest | ( | Time | nextTime,
|  | IterationRequest | iterate,
|  | Time | newValueTime,
|  | Time | newMessageTime
| ) |  |

request a time

Parameters

  nextTime | the new requested time
  iterate | the mode of iteration to use (no_iteration, FORCE_ITERATION, ITERATE_IF_NEEDED)
  newValueTime | the time of the next value
  newMessageTime | the time of the next message

References helics::BaseTimeCoordinator::dependencies, helics::TimeDependencies::empty(), helics::FORCE_ITERATION, info, iterating, helics::NO_ITERATIONS, helics::TimeDependencies::resetDependentEvents(), helics::BaseTimeCoordinator::sequenceCounter, time_exec, time_granted, time_message, time_next, time_requested, time_value, and updateTimeFactors().

## ◆ updateMessageTime()

void helics::TimeCoordinator::updateMessageTime | ( | Time | messageUpdateTime,
|  | bool | allowRequestSend
| ) |  |

update the time_message variable with a new value if needed if allowed it will send an updated time request message

References helics::BaseTimeCoordinator::executionMode, hasInitUpdates, hasIterationData, iterating, helics::NO_ITERATIONS, time_granted, time_message, and helics::timeZero.

## ◆ updateTimeFactors()

bool helics::TimeCoordinator::updateTimeFactors | ( |  | ) |
| override virtual

compute updates to time values

Returns
  true if they have been modified

Implements helics::BaseTimeCoordinator.

References helics::cBigTime, helics::BaseTimeCoordinator::dependencies, helics::tcoptions::event_triggered, globalTime, info, helics::TimeData::minDe, helics::TimeData::minFed, helics::TimeData::next, helics::BaseTimeCoordinator::sequenceCounter, helics::TimeDependencies::size(), helics::TimeData::Te, time_allow, time_minDe, time_minminDe, time_next, time_requested, and upstream.

Referenced by checkTimeGrant(), and timeRequest().

## ◆ updateValueTime()

void helics::TimeCoordinator::updateValueTime | ( | Time | valueUpdateTime,
|  | bool | allowRequestSend
| ) |  |

update the time_value variable with a new value if needed if allowed it will send an updated time request message

References helics::BaseTimeCoordinator::executionMode, hasInitUpdates, hasIterationData, iterating, helics::NO_ITERATIONS, time_granted, time_value, and helics::timeZero.

## Member Data Documentation

## ◆ needSendAll

bool helics::TimeCoordinator::needSendAll {false}

flag indicating that we need to send updates to all dependencies on receipt of addition request

Referenced by checkExecEntry(), and checkTimeGrant().

## ◆ time_grantBase

Time helics::TimeCoordinator::time_grantBase {Time::minVal()}
| protected

time to use as a basis for calculating the next grantable time(usually time granted unless values are changing)

Referenced by checkTimeGrant(), localError(), and processTimeMessage().

The documentation for this class was generated from the following files:

- TimeCoordinator.hpp
- TimeCoordinator.cpp