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

#include <TimeCoordinator.hpp>

Public Member Functions

 TimeCoordinator ()
 
 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)
 
Time getTimeProperty (int timeProperty) const
 
bool getOptionFlag (int optionFlag) const
 
int getIntegerProperty (int intProperty) const
 
void setMessageSender (std::function< void(const ActionMessage &)> userSendMessageFunction)
 
Time getGrantedTime () const
 
Time allowedSendTime () const
 
std::vector< global_federate_idgetDependencies () const
 
std::vector< global_federate_idgetDependents () const
 
int32_t getCurrentIteration () const
 
bool updateTimeFactors ()
 
void updateValueTime (Time valueUpdateTime, bool allowRequestSend)
 
void updateMessageTime (Time messageUpdateTime, bool allowRequestSend)
 
void specifyNonGranting (bool value=true)
 
message_process_result processTimeMessage (const ActionMessage &cmd)
 
void processConfigUpdateMessage (const ActionMessage &cmd)
 
void processDependencyUpdateMessage (const ActionMessage &cmd)
 
bool addDependency (global_federate_id fedID)
 
bool addDependent (global_federate_id fedID)
 
void removeDependency (global_federate_id fedID)
 
void removeDependent (global_federate_id fedID)
 
void setAsChild (global_federate_id fedID)
 
void setAsParent (global_federate_id fedID)
 
message_processing_result checkExecEntry ()
 
void timeRequest (Time nextTime, iteration_request iterate, Time newValueTime, Time newMessageTime)
 
void enteringExecMode (iteration_request mode)
 
message_processing_result checkTimeGrant ()
 
void disconnect ()
 
void localError ()
 
std::string printTimeStatus () const
 
bool hasActiveTimeDependencies () const
 
void generateConfig (Json::Value &base) const
 
void generateDebuggingTimeInfo (Json::Value &base) const
 
int dependencyCount () const
 
global_federate_id getMinDependency () const
 

Public Attributes

global_federate_id source_id
 the identifier for inserting into the source id field of any generated messages; More...
 
iteration_request iterating
 
bool checkingExec
 flag indicating that the coordinator is trying to enter the exec mode More...
 
bool executionMode {false}
 flag that the coordinator has entered the execution Mode
 
bool hasInitUpdates {false}
 

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()
 
shared_guarded_m< std::vector< global_federate_id > > dependent_federates
 these are to maintain an accessible record of dependent federates
 
shared_guarded_m< std::vector< global_federate_id > > dependency_federates
 these are to maintain an accessible record of dependency federates
 
TimeDependencies dependencies
 
std::vector< std::pair< Time, int32_t > > timeBlocks
 blocks for a particular timeblocking link
 
tcoptions info
 basic time control information
 
std::function< void(const ActionMessage &)> sendMessageFunction
 callback used to send the messages
 
std::atomic< int32_t > iteration {0}
 iteration counter
 
bool disconnected {false}
 
bool nonGranting {false}
 

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 constructor

◆ TimeCoordinator() [2/2]

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

construct from a federate info and message send function

References sendMessageFunction.

Member Function Documentation

◆ addDependency()

bool helics::TimeCoordinator::addDependency ( global_federate_id  fedID)

add a federate dependency

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

References helics::TimeDependencies::addDependency(), dependencies, helics::TimeDependencies::getDependencyInfo(), and source_id.

Referenced by processDependencyUpdateMessage().

◆ addDependent()

bool helics::TimeCoordinator::addDependent ( global_federate_id  fedID)

add a dependent federate

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

References helics::TimeDependencies::addDependent(), dependencies, and dependent_federates.

Referenced by processDependencyUpdateMessage().

◆ allowedSendTime()

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

get the current granted time

References info, and time_granted.

◆ checkExecEntry()

message_processing_result helics::TimeCoordinator::checkExecEntry ( )

◆ checkTimeGrant()

message_processing_result helics::TimeCoordinator::checkTimeGrant ( )

◆ dependencyCount()

int helics::TimeCoordinator::dependencyCount ( ) const

get a count of the active dependencies

References helics::TimeDependencies::activeDependencyCount(), and dependencies.

◆ disconnect()

void helics::TimeCoordinator::disconnect ( )

◆ enteringExecMode()

void helics::TimeCoordinator::enteringExecMode ( iteration_request  mode)

function to enter the exec Mode

Parameters
modethe mode of iteration_request (no_iteration, force_iteration, iterate_if_needed)

References checkingExec, delayed_timing_flag, executionMode, info, iterating, helics::no_iterations, setActionFlag(), helics::setIterationFlags(), helics::ActionMessage::source_id, and source_id.

◆ generateConfig()

void helics::TimeCoordinator::generateConfig ( Json::Value &  base) const

generate a configuration string(JSON)

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

Referenced by generateDebuggingTimeInfo().

◆ generateDebuggingTimeInfo()

void helics::TimeCoordinator::generateDebuggingTimeInfo ( Json::Value &  base) const

◆ 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< global_federate_id > helics::TimeCoordinator::getDependencies ( ) const

get a list of actual dependencies

References dependency_federates.

◆ getDependents()

std::vector<global_federate_id> 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.

◆ getIntegerProperty()

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

get an option flag value

get a time Property

◆ getMinDependency()

global_federate_id helics::TimeCoordinator::getMinDependency ( ) const

get a count of the active dependencies

References dependencies, and helics::TimeDependencies::getMinDependency().

◆ getOptionFlag()

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

get an option flag value

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

◆ getTimeProperty()

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

get a time Property

◆ hasActiveTimeDependencies()

bool helics::TimeCoordinator::hasActiveTimeDependencies ( ) const

return true if there are active dependencies

References dependencies, and helics::TimeDependencies::hasActiveTimeDependencies().

Referenced by helics::FilterFederate::hasActiveTimeDependencies().

◆ localError()

void helics::TimeCoordinator::localError ( )

◆ printTimeStatus()

std::string helics::TimeCoordinator::printTimeStatus ( ) const

generate a string with the current time status

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
cmdthe update command

References checkActionFlag(), indicator_flag, setOptionFlag(), and setProperty().

◆ processDependencyUpdateMessage()

void helics::TimeCoordinator::processDependencyUpdateMessage ( const ActionMessage cmd)

◆ processTimeMessage()

message_process_result helics::TimeCoordinator::processTimeMessage ( const ActionMessage cmd)

◆ removeDependency()

void helics::TimeCoordinator::removeDependency ( global_federate_id  fedID)

remove a dependency

Parameters
fedIDthe identifier of the federate to remove

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

Referenced by processDependencyUpdateMessage().

◆ removeDependent()

void helics::TimeCoordinator::removeDependent ( global_federate_id  fedID)

remove a dependent

Parameters
fedIDthe identifier of the federate to remove

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

Referenced by processDependencyUpdateMessage(), and processTimeMessage().

◆ setMessageSender()

void helics::TimeCoordinator::setMessageSender ( std::function< void(const ActionMessage &)>  userSendMessageFunction)

set the callback function used for the sending messages

References sendMessageFunction.

◆ 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,
iteration_request  iterate,
Time  newValueTime,
Time  newMessageTime 
)

request a time

Parameters
nextTimethe new requested time
iteratethe mode of iteration to use (no_iteration, force_iteration, iterate_if_needed)
newValueTimethe time of the next value
newMessageTimethe time of the next message

References dependencies, helics::TimeDependencies::empty(), helics::force_iteration, info, iterating, helics::no_iterations, helics::TimeDependencies::resetDependentEvents(), 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 executionMode, hasInitUpdates, iterating, helics::no_iterations, time_granted, time_message, and helics::timeZero.

◆ updateTimeFactors()

bool helics::TimeCoordinator::updateTimeFactors ( )

compute updates to time values

Returns
true if they have been modified

References dependencies, helics::tcoptions::event_triggered, info, helics::TimeData::minDe, helics::TimeData::next, helics::TimeData::Te, time_allow, time_minDe, time_minminDe, time_next, 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 executionMode, hasInitUpdates, iterating, helics::no_iterations, time_granted, time_value, and helics::timeZero.

Member Data Documentation

◆ checkingExec

bool helics::TimeCoordinator::checkingExec
Initial value:
{
false}

flag indicating that the coordinator is trying to enter the exec mode

Referenced by enteringExecMode().

◆ dependencies

TimeDependencies helics::TimeCoordinator::dependencies
protected

◆ hasInitUpdates

bool helics::TimeCoordinator::hasInitUpdates {false}

flag indicating that a value or message was received during initialization stage

Referenced by checkExecEntry(), updateMessageTime(), and updateValueTime().

◆ iterating

iteration_request helics::TimeCoordinator::iterating
Initial value:

indicator that the coordinator should be iterating if need be

Referenced by checkExecEntry(), checkTimeGrant(), enteringExecMode(), timeRequest(), updateMessageTime(), and updateValueTime().

◆ source_id

global_federate_id helics::TimeCoordinator::source_id
Initial value:
{
0}

the identifier for inserting into the source id field of any generated messages;

Referenced by addDependency(), checkExecEntry(), disconnect(), enteringExecMode(), localError(), and processTimeMessage().

◆ time_block

Time helics::TimeCoordinator::time_block = Time::maxVal()
protected

a blocking time to not grant time >= the specified time

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 checkExecEntry(), checkTimeGrant(), localError(), and processTimeMessage().


The documentation for this class was generated from the following files:
helics::iteration_request::no_iterations
@ no_iterations
indicator that the iterations have completed