AGX Dynamics 2.42.2.1
Loading...
Searching...
No Matches
agx::Clock Class Reference

Clock class keeps representation of virtual/simulated time. More...

#include <Clock.h>

+ Inheritance diagram for agx::Clock:

Classes

class  Frame
 Internal class. More...
 
class  FrameWrapper
 Internal class. More...
 

Public Types

typedef agx::observer_ptr< const EventEventConstObserver
 
typedef agx::ref_ptr< const EventEventConstRef
 
typedef agx::observer_ptr< EventEventObserver
 
typedef agx::Vector< EventObserverEventObserverVector
 
typedef agx::VectorPOD< Event * > EventPtrVector
 
typedef agx::ref_ptr< EventEventRef
 
typedef agx::Vector< EventRefEventRefVector
 
typedef agx::observer_ptr< const FrameWrapperFrameWrapperConstObserver
 
typedef agx::ref_ptr< const FrameWrapperFrameWrapperConstRef
 
typedef agx::observer_ptr< FrameWrapperFrameWrapperObserver
 
typedef agx::Vector< FrameWrapperObserverFrameWrapperObserverVector
 
typedef agx::VectorPOD< FrameWrapper * > FrameWrapperPtrVector
 
typedef agx::ref_ptr< FrameWrapperFrameWrapperRef
 
typedef agx::Vector< FrameWrapperRefFrameWrapperRefVector
 
typedef Event1< Clock * > TickEvent
 
- Public Types inherited from agx::Component
typedef Event2< Component *, Object * > ObjectEvent
 Event when adding removing child objects.
 
typedef Callback1< Object * > TraverseCallback
 
- Public Types inherited from agx::Object
typedef agx::observer_ptr< const EventEventConstObserver
 
typedef agx::ref_ptr< const EventEventConstRef
 
typedef agx::observer_ptr< EventEventObserver
 
typedef agx::Vector< EventObserverEventObserverVector
 
typedef agx::VectorPOD< Event * > EventPtrVector
 
typedef agx::ref_ptr< EventEventRef
 
typedef agx::Vector< EventRefEventRefVector
 
- Public Types inherited from agx::EventT< Callback >
typedef VectorPOD< const CallbackType * > CallbackPtrVector
 
typedef Callback CallbackType
 

Public Member Functions

 Clock (const agx::Name &name="clock", agx::Real frequency=60)
 
void addEvent (agx::Clock::Event *event)
 Add an event to the clock to be triggered as specified by the event.
 
void addFrameJob (agx::Job *job)
 Add a job to be executed on each tick.
 
void addFrameTask (agx::Task *task)
 Add a task to be executed on each tick.
 
void addSlave (agx::Clock *slave)
 Add a slave clock, to be driven by this clock.
 
void bind (const agx::Path &path)
 Bind the clock to a reference clock using a bindpath.
 
virtual void configure (TiXmlElement *eClock) override
 
virtual void configure (TiXmlElement *eEvent) override
 
 Event (const agx::Callback &callback, agx::Real startDelay, agx::Real interval=-1.0)
 
 Event (const agx::Name &name="Event")
 Constructor.
 
const agx::PathgetBindPath () const
 
agx::ClockgetClock ()
 
agx::UInt getFrame () const
 
agx::Real getFrequency () const
 
size_t getIndex () const
 
agx::Real getInterval () const
 Get the trigger interval.
 
bool getIsThreadTimelineResponsible () const
 
agx::ClockgetReference ()
 
const agx::ClockPtrVectorgetSlaves () const
 
agx::Real getStartDelay () const
 
agx::Real getTime () const
 
agx::Real getTimeModulation () const
 
agx::Real getTimeStep () const
 
agx::Bool isEnabled () const
 
bool isRepeating () const
 
virtual void rebind () override
 
void removeEvent (agx::Clock::Event *event)
 Remove an event from the clock.
 
void removeFrameJob (agx::Job *job)
 Remove a frame job.
 
void removeFrameTask (agx::Task *task)
 Remove a frame task.
 
void removeSlave (agx::Clock *slave)
 Remove a slave clock.
 
void reset ()
 Reset to frame zero (and time=0), remove all events.
 
void reset ()
 Reset event, with start delay.
 
virtual void save (TiXmlElement *eParent) const override
 
void setEnable (agx::Bool flag)
 Set to false to disable the clock, tick will be void operation.
 
void setEnable (bool flag)
 Pause/unpause.
 
void setFrame (UInt frame)
 Explicitly set the current frame index.
 
void setFrequency (agx::Real frequency)
 Set the clock frequency.
 
void setInterval (agx::Real interval)
 Set the trigger interval.
 
void setIsThreadTimelineResponsible (bool isResponsible)
 Control whether this Clock is the main clock for thread timeline generation.
 
void setRepeating (bool flag)
 Set if event trigger multiple times.
 
void setStartDelay (agx::Real time)
 Set the start delay when added to a clock or reset.
 
void setTime (agx::Real64 time)
 Set the time explicitly, without ticking.
 
void setTimeModulation (agx::Real modulation)
 Set the time modulation of the clock, default is 1.0.
 
bool setTimeStep (agx::Real dt)
 Set the time step of the clock, 1/frequency.
 
void start ()
 Same as setEnable(true)
 
void stepForward (agx::Real delta)
 Advance the clock a specified interval.
 
void stepTo (agx::Real time)
 Advance the clock to a specified time.
 
void stop ()
 Same as setEnable(false)
 
void tick (bool blocking=true)
 Advance the clock to the next time step.
 
- Public Member Functions inherited from agx::Component
 Component (const agx::Name &name=agx::Name(), agx::Model *model=agx::Component::ClassModel(), agx::Device *device=nullptr)
 
virtual void addObject (agx::Object *object, bool assignContext=true)
 Add an object to the component.
 
virtual String autoComplete (const String &partialName, StringVector &matchingNames) const
 
virtual void buildNavigationTree (agxJson::Value &eNode) const override
 
void configure (Model *model)
 
virtual void configure (TiXmlElement *eComponent) override
 
agx::DevicegetDevice ()
 
template<typename T >
T * getDevice ()
 
const agx::DevicegetDevice () const
 
template<typename T >
const T * getDevice () const
 
size_t getNumObjects (const agx::Name &name) const
 
agx::ObjectgetObject (const agx::Name &name, agx::Model *model, size_t index=0)
 
const agx::ObjectgetObject (const agx::Name &name, agx::Model *model, size_t index=0) const
 
agx::ObjectgetObject (const agx::Name &name, size_t index=0)
 
template<typename T >
T * getObject (const agx::Name &name, size_t index=0)
 
const agx::ObjectgetObject (const agx::Name &name, size_t index=0) const
 
template<typename T >
const T * getObject (const agx::Name &name, size_t index=0) const
 
const agx::ObjectRefVectorgetObjects () const
 
template<typename T >
void getObjects (agx::ObjectPtrVector &result, bool recursive=false) const
 Returns All child objects of a specified type in the result container.
 
void getObjects (agx::ObjectPtrVector &result, const agx::Model *model, bool recursive=false) const
 
virtual ObjectgetResourceImpl (const Path &path, agx::Model *model) override
 
virtual void printSubtree () const override
 
void printSubtree (std::ostream &stream, int depth=0) const
 
virtual void rebind () override
 
void removeAllObjects ()
 Remove all components.
 
virtual void removeObject (agx::Object *object)
 Remove an object from the component.
 
void removeObject (const agx::Name &name, size_t index=0)
 Remove an object with a specified name (and optional index) from the component.
 
virtual void snapshot (TiXmlNode *eParent, const String &directory) const override
 
void traverse (ComponentVisitor *)
 
void traverse (const TraverseCallback &callback)
 
- Public Member Functions inherited from agx::Object
 Object (const Name &name=Name(), Model *model=Object::ClassModel())
 
void addListener (EventListener *listener)
 
virtual void buildNavigationTree (agxJson::Value &eNode) const
 
virtual void configure (TiXmlElement *)
 
agx::String fullName () const
 
agx::String fullPath () const
 
agx::String fullPath (const agx::Object *root) const
 
template<typename T >
T * getAutoScopedResource (const agx::Path &path)
 
template<typename T >
const T * getAutoScopedResource (const agx::Path &path) const
 
agx::ObjectgetAutoScopedResource (const agx::Path &path, agx::Model *model=nullptr)
 
const agx::ObjectgetAutoScopedResource (const agx::Path &path, agx::Model *model=nullptr) const
 
agx::ObjectgetContext ()
 
template<typename T >
T * getContext ()
 
const agx::ObjectgetContext () const
 
template<typename T >
const T * getContext () const
 
agx::UInt32 getId () const
 
const agx::NamegetImplementationName () const
 
agx::ModelgetModel ()
 
const agx::ModelgetModel () const
 
const agx::NamegetName () const
 
agx::ObjectgetNextSibling ()
 
const agx::ObjectgetNextSibling () const
 
agx::Path getPath () const
 
agx::Path getPath (const agx::Object *root) const
 
template<typename T >
T * getResource (const agx::Path &path)
 
template<typename T >
const T * getResource (const agx::Path &path) const
 
agx::ObjectgetResource (const agx::Path &path, agx::Model *model=nullptr)
 
const agx::ObjectgetResource (const agx::Path &path, agx::Model *model=nullptr) const
 
virtual agx::ObjectgetResourceImpl (const agx::Path &path, agx::Model *model)
 
agx::ObjectgetRootContext ()
 
const agx::ObjectgetRootContext () const
 
bool hasListener (EventListener *listener)
 
bool hasParent (const agx::Object *node) const
 
bool isUnique () const
 
virtual void printSubtree () const
 
virtual void rebind ()
 
void removeListener (EventListener *listener)
 
virtual void save (TiXmlElement *) const
 
virtual void setContext (agx::Object *context)
 
void setId (UInt32 id)
 
void setModel (agx::Model *model)
 Set the object model (handled automatically).
 
void setName (const agx::Name &name)
 Set the name of the object.
 
virtual void snapshot (TiXmlNode *, const String &) const
 
- Public Member Functions inherited from agx::Referenced
 Referenced ()
 Default constructor.
 
 Referenced (const Referenced &)
 
template<typename T >
T * as ()
 Subclass casting.
 
template<typename T >
const T * as () const
 
template<typename T >
T * asSafe ()
 Safe subclass casting, return nullptr if template type does not match.
 
template<typename T >
const T * asSafe () const
 
int getReferenceCount () const
 
template<typename T >
bool is () const
 Subclass test.
 
Referencedoperator= (const Referenced &)
 Assignment operator. Will increment the number of references to the referenced object.
 
void reference (void *ptr=nullptr) const
 Explicitly increment the reference count by one, indicating that this object has another pointer which is referencing it.
 
void unreference (void *ptr=nullptr) const
 Decrement the reference count by one, indicating that a pointer to this object is referencing it.
 
void unreference_nodelete () const
 Decrement the reference count by one, indicating that a pointer to this object is referencing it.
 
- Public Member Functions inherited from agx::Event
 Event (const agx::Name &name=agx::Name())
 
void trigger ()
 Trigger the event.
 
- Public Member Functions inherited from agx::EventT< Callback >
 EventT (const agx::Name &name=agx::Name())
 
void addCallback (const Callback *callback)
 Add a callback to the event.
 
void addCallbackFirst (const Callback *callback)
 Add a callback to the front of the callback list.
 
bool containsCallback (const Callback *callback) const
 
const CallbackPtrVectorgetCallbacks () const
 
const agx::NamegetName () const
 
void removeAllCallbacks ()
 Remove all callbacks.
 
bool removeCallback (const Callback *callback)
 

Static Public Member Functions

static agx::ModelClassModel ()
 
static agx::ModelClassModel ()
 
static Clockload (TiXmlElement *eClock, Device *device)
 
static Clock::Eventload (TiXmlElement *eEvent, Device *device)
 
- Static Public Member Functions inherited from agx::Component
static Component_load (TiXmlElement *eComponent, Device *device)
 
static agx::ModelClassModel ()
 
static Componentload (const Path &path, const Name &implementation, Device *device, const Path &_namespace=Path())
 
static Componentload (const String &path, const Path &_namespace=Path())
 
static Componentload (const String &path, Device *device, const Path &_namespace=Path())
 
static Componentload (TiXmlElement *eComponent, Device *device)
 
- Static Public Member Functions inherited from agx::Object
static agx::ModelClassModel ()
 
static agx::String generateName (const agx::String &bindPath)
 
static const HashSet< Object * > & getActiveObjects ()
 
static bool getEnableRebind ()
 Should rebinding be allowed? Right now a global setting.
 
static Objectload (const String &path, Device *device, const String &type, const String &attribute, const String &value)
 
template<typename T >
static T * load (const String &path, Device *device, const String &type, const String &attribute, const String &value)
 
static Objectload (const String &path, Device *device, const String &type="", size_t instance=0)
 
template<typename T >
static T * load (const String &path, Device *device, const String &type="", size_t instance=0)
 
static void load (const String &path, Device *device, ObjectPtrVector &loadedObjects)
 
static Objectload (TiXmlElement *eObject, Device *device)
 
template<typename T >
static T * load (TiXmlElement *eObject, Device *device)
 
static TiXmlDocument openDocument (const String &path)
 
static void setEnableRebind (bool flag)
 Sets if rebinding of objects should be allowed (Right now a global setting).
 
- Static Public Member Functions inherited from agx::Referenced
template<typename T >
static bool ValidateCast (const Referenced *object)
 

Public Attributes

TickEvent postTick
 
TickEvent preTick
 
- Public Attributes inherited from agx::Component
ObjectEvent addObjectEvent
 
ObjectEvent removeObjectEvent
 

Protected Member Functions

virtual ~Clock ()
 
virtual ~Event ()
 
- Protected Member Functions inherited from agx::Component
virtual ~Component ()
 
String expandAutoCompletionMatch (const String &query, const StringVector &matchingNames) const
 
void setDevice (Device *device)
 
- Protected Member Functions inherited from agx::Object
virtual ~Object ()
 
- Protected Member Functions inherited from agx::Referenced
virtual ~Referenced ()
 Destructor.
 
void allocateObserverVector () const
 
void deleteUsingDeleteHandler () const
 

Additional Inherited Members

- Static Protected Member Functions inherited from agx::Referenced
static DeleteHandlergetDeleteHandler ()
 
static void setDeleteHandler (DeleteHandler *handler)
 Internal: Set a DeleteHandler to which deletion of all referenced counted objects will be delegated to.
 
- Protected Attributes inherited from agx::Referenced
Mutex m_mutex
 
ObserverContainer m_observers
 
AtomicValue m_refCount
 
- Protected Attributes inherited from agx::EventT< Callback >
Threadm_activeThread
 
CallbackPtrVector m_callbacks
 
agx::UInt32 m_iterationIndex
 
Name m_name
 

Detailed Description

Clock class keeps representation of virtual/simulated time.

An event to be triggered after a specified time.

Clocks can be connected in a hierarchy using different frequencies. Tasks can be triggered when the clock ticks. Events can be scheduled with specified interval.

Optionally repeating with a specified interval.

Definition at line 37 of file Clock.h.

Member Typedef Documentation

◆ EventConstObserver

Definition at line 50 of file Clock.h.

◆ EventConstRef

Definition at line 50 of file Clock.h.

◆ EventObserver

Definition at line 50 of file Clock.h.

◆ EventObserverVector

Definition at line 51 of file Clock.h.

◆ EventPtrVector

Definition at line 51 of file Clock.h.

◆ EventRef

Definition at line 50 of file Clock.h.

◆ EventRefVector

Definition at line 51 of file Clock.h.

◆ FrameWrapperConstObserver

Definition at line 47 of file Clock.h.

◆ FrameWrapperConstRef

Definition at line 47 of file Clock.h.

◆ FrameWrapperObserver

◆ FrameWrapperObserverVector

◆ FrameWrapperPtrVector

Definition at line 48 of file Clock.h.

◆ FrameWrapperRef

Definition at line 47 of file Clock.h.

◆ FrameWrapperRefVector

◆ TickEvent

Definition at line 54 of file Clock.h.

Constructor & Destructor Documentation

◆ Clock()

agx::Clock::Clock ( const agx::Name name = "clock",
agx::Real  frequency = 60 
)

◆ ~Clock()

virtual agx::Clock::~Clock ( )
protectedvirtual

◆ ~Event()

virtual agx::Clock::~Event ( )
protectedvirtual

Member Function Documentation

◆ addEvent()

void agx::Clock::addEvent ( agx::Clock::Event event)

Add an event to the clock to be triggered as specified by the event.

Parameters
eventThe event

◆ addFrameJob()

void agx::Clock::addFrameJob ( agx::Job job)

Add a job to be executed on each tick.

Parameters
jobThe job

◆ addFrameTask()

void agx::Clock::addFrameTask ( agx::Task task)

Add a task to be executed on each tick.

Parameters
taskThe task

◆ addSlave()

void agx::Clock::addSlave ( agx::Clock slave)

Add a slave clock, to be driven by this clock.

Parameters
slaveThe slave clock

◆ bind()

void agx::Clock::bind ( const agx::Path path)

Bind the clock to a reference clock using a bindpath.

◆ ClassModel() [1/2]

static agx::Model * agx::Clock::ClassModel ( )
static

◆ ClassModel() [2/2]

static agx::Model * agx::Clock::ClassModel ( )
static

◆ configure() [1/2]

virtual void agx::Clock::configure ( TiXmlElement *  eClock)
overridevirtual

Reimplemented from agx::Component.

◆ configure() [2/2]

virtual void agx::Clock::configure ( TiXmlElement *  eEvent)
overridevirtual

Reimplemented from agx::Component.

◆ Event() [1/2]

agx::Clock::Event ( const agx::Callback callback,
agx::Real  startDelay,
agx::Real  interval = -1.0 
)

◆ Event() [2/2]

agx::Clock::Event ( const agx::Name name = "Event")

Constructor.

◆ getBindPath()

const agx::Path & agx::Clock::getBindPath ( ) const
Returns
The bind path

◆ getClock()

agx::Clock * agx::Clock::getClock ( )
Returns
The clock which is responsible for triggering the event.

◆ getFrame()

agx::UInt agx::Clock::getFrame ( ) const
Returns
The current frame index.

◆ getFrequency()

agx::Real agx::Clock::getFrequency ( ) const
Returns
The frequency of the clock, 1/timeStep

◆ getIndex()

size_t agx::Clock::getIndex ( ) const

◆ getInterval()

agx::Real agx::Clock::getInterval ( ) const

Get the trigger interval.

Returns
the trigger interval

◆ getIsThreadTimelineResponsible()

bool agx::Clock::getIsThreadTimelineResponsible ( ) const
Returns
True if this clock is the main thread timeline clock. False otherwise.

◆ getReference()

agx::Clock * agx::Clock::getReference ( )
Returns
The reference clock to which this clock is a slave.

◆ getSlaves()

const agx::ClockPtrVector & agx::Clock::getSlaves ( ) const
Returns
The list of slaves.

◆ getStartDelay()

agx::Real agx::Clock::getStartDelay ( ) const
Returns
the start delay when added to a clock or reset.

◆ getTime()

agx::Real agx::Clock::getTime ( ) const
Returns
The current time.

Referenced by agxSDK::Simulation::getTimeStamp().

◆ getTimeModulation()

agx::Real agx::Clock::getTimeModulation ( ) const
Returns
The time modulation of the clock.

◆ getTimeStep()

agx::Real agx::Clock::getTimeStep ( ) const
Returns
The current time step.

◆ isEnabled()

agx::Bool agx::Clock::isEnabled ( ) const
Returns
true if the clock is enabled.

◆ isRepeating()

bool agx::Clock::isRepeating ( ) const
Returns
true if event trigger multiple times.

◆ load() [1/2]

static Clock * agx::Clock::load ( TiXmlElement *  eClock,
Device device 
)
static

◆ load() [2/2]

static Clock::Event * agx::Clock::load ( TiXmlElement *  eEvent,
Device device 
)
static

◆ rebind()

virtual void agx::Clock::rebind ( )
overridevirtual

Reimplemented from agx::Component.

◆ removeEvent()

void agx::Clock::removeEvent ( agx::Clock::Event event)

Remove an event from the clock.

Parameters
eventThe event

◆ removeFrameJob()

void agx::Clock::removeFrameJob ( agx::Job job)

Remove a frame job.

Parameters
jobThe job

◆ removeFrameTask()

void agx::Clock::removeFrameTask ( agx::Task task)

Remove a frame task.

Parameters
taskThe task

◆ removeSlave()

void agx::Clock::removeSlave ( agx::Clock slave)

Remove a slave clock.

Parameters
slaveThe slave clock

◆ reset() [1/2]

void agx::Clock::reset ( )

Reset to frame zero (and time=0), remove all events.

◆ reset() [2/2]

void agx::Clock::reset ( )

Reset event, with start delay.

◆ save()

virtual void agx::Clock::save ( TiXmlElement *  eParent) const
overridevirtual

Reimplemented from agx::Object.

◆ setEnable() [1/2]

void agx::Clock::setEnable ( agx::Bool  flag)

Set to false to disable the clock, tick will be void operation.

◆ setEnable() [2/2]

void agx::Clock::setEnable ( bool  flag)

Pause/unpause.

◆ setFrame()

void agx::Clock::setFrame ( UInt  frame)

Explicitly set the current frame index.

◆ setFrequency()

void agx::Clock::setFrequency ( agx::Real  frequency)

Set the clock frequency.

◆ setInterval()

void agx::Clock::setInterval ( agx::Real  interval)

Set the trigger interval.

◆ setIsThreadTimelineResponsible()

void agx::Clock::setIsThreadTimelineResponsible ( bool  isResponsible)

Control whether this Clock is the main clock for thread timeline generation.

Default is true. Set to false for example when using a sub-simulation that is stepped from within the main simulation.

◆ setRepeating()

void agx::Clock::setRepeating ( bool  flag)

Set if event trigger multiple times.

◆ setStartDelay()

void agx::Clock::setStartDelay ( agx::Real  time)

Set the start delay when added to a clock or reset.

Parameters
time- in seconds

◆ setTime()

void agx::Clock::setTime ( agx::Real64  time)

Set the time explicitly, without ticking.

◆ setTimeModulation()

void agx::Clock::setTimeModulation ( agx::Real  modulation)

Set the time modulation of the clock, default is 1.0.

◆ setTimeStep()

bool agx::Clock::setTimeStep ( agx::Real  dt)

Set the time step of the clock, 1/frequency.

◆ start()

void agx::Clock::start ( )

Same as setEnable(true)

◆ stepForward()

void agx::Clock::stepForward ( agx::Real  delta)

Advance the clock a specified interval.

Parameters
deltaThe interval

◆ stepTo()

void agx::Clock::stepTo ( agx::Real  time)

Advance the clock to a specified time.

Parameters
timeThe specified time

◆ stop()

void agx::Clock::stop ( )

Same as setEnable(false)

◆ tick()

void agx::Clock::tick ( bool  blocking = true)

Advance the clock to the next time step.

Parameters
blockingWill wait for all tick tasks if true

Member Data Documentation

◆ postTick

TickEvent agx::Clock::postTick

Definition at line 56 of file Clock.h.

◆ preTick

TickEvent agx::Clock::preTick

Definition at line 55 of file Clock.h.


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