C++ TargetRTS
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Attributes | Protected Types | Protected Member Functions | Friends | List of all members
Timing::Base Class Reference

Represents a timer port. More...

#include <RTTiming.h>

Inheritance diagram for Timing::Base:
RTProtocol

Public Types

enum  { rti_timeout = rtiLast_RTProtocol + 1 }
 

Public Member Functions

RTInSignal timeout (void)
 Return the object that represents the timeout event which is received by this port when the timer has expired.
 
RTTimespec currentTime (void) const
 Return the current time.
 
RTTimerNodeinformAt (const RTTimespec &when, const void *data, const RTObject_class *type, int prio=General)
 Start a timer which will expire at a particular absolute point in time.
 
RTTimerNodeinformAt (const RTTimespec &when, int prio=General)
 Start a timer which will expire at a particular absolute point in time.
 
RTTimerNodeinformAt (const RTTimespec &when, const RTDataObject &data, int prio=General)
 Start a timer which will expire at a particular absolute point in time.
 
RTTimerNodeinformAt (const RTTimespec &when, const RTTypedValue &info, int prio=General)
 Start a timer which will expire at a particular absolute point in time.
 
RTTimerNodeinformIn (const RTTimespec &delta, const void *data, const RTObject_class *type, int prio=General)
 Start a timer which will expire after a specified time interval.
 
RTTimerNodeinformIn (const RTTimespec &delta, int prio=General)
 Start a timer which will expire after a specified time interval.
 
RTTimerNodeinformIn (const RTTimespec &delta, const RTDataObject &data, int prio=General)
 Start a timer which will expire after a specified time interval.
 
RTTimerNodeinformIn (const RTTimespec &delta, const RTTypedValue &info, int prio=General)
 Start a timer which will expire after a specified time interval.
 
RTTimerNodeinformIn (unsigned long centiseconds, int prio=General)
 
RTTimerNodeinformIn (unsigned long centiseconds, const RTDataObject &data, int prio=General)
 
RTTimerNodeinformIn (unsigned long centiseconds, const RTTypedValue &info, int prio=General)
 
RTTimerNodeinformEvery (const RTTimespec &delta, const void *data, const RTObject_class *type, int prio=General)
 Start a periodic timer which will expire at regular intervals.
 
RTTimerNodeinformEvery (const RTTimespec &delta, const RTDataObject &data, int prio=General)
 Start a periodic timer which will expire at regular intervals.
 
RTTimerNodeinformEvery (const RTTimespec &delta, const RTTypedValue &info, int prio=General)
 Start a periodic timer which will expire at regular intervals.
 
RTTimerNodeinformEvery (const RTTimespec &delta)
 Start a periodic timer which will expire at regular intervals.
 
int timeouts (const RTTimerId &id)
 Get the number of timeout intervals that passed before the timeout of a periodic timer was actually processed.
 
int cancelTimer (RTTimerId &id)
 Cancel a timer.
 
void adjustTimeBegin (void)
 Begin adjustment of system time.
 
void adjustTimeEnd (const RTTimespec &delta)
 End adjustment of system time.
 
RTTimerNodeinformAt (const std::chrono::system_clock::time_point &when, const void *data, const RTObject_class *type, int prio=General)
 
RTTimerNodeinformAt (const std::chrono::system_clock::time_point &when, int prio=General)
 
RTTimerNodeinformAt (const std::chrono::system_clock::time_point &when, const RTDataObject &data, int prio=General)
 
RTTimerNodeinformAt (const std::chrono::system_clock::time_point &when, const RTTypedValue &info, int prio=General)
 
RTTimerNodeinformIn (const std::chrono::nanoseconds &delta_ns, const void *data, const RTObject_class *type, int prio=General)
 
RTTimerNodeinformIn (const std::chrono::nanoseconds &delta_ns, int prio=General)
 
RTTimerNodeinformIn (const std::chrono::nanoseconds &delta_ns, const RTDataObject &data, int prio=General)
 
RTTimerNodeinformIn (const std::chrono::nanoseconds &delta_ns, const RTTypedValue &info, int prio=General)
 
RTTimerNodeinformEvery (const std::chrono::nanoseconds &delta_ns, const void *data, const RTObject_class *type, int prio=General)
 
RTTimerNodeinformEvery (const std::chrono::nanoseconds &delta_ns, const RTDataObject &data, int prio=General)
 
RTTimerNodeinformEvery (const std::chrono::nanoseconds &delta_ns, const RTTypedValue &info, int prio=General)
 
RTTimerNodeinformEvery (const std::chrono::nanoseconds &delta_ns)
 
- Public Member Functions inherited from RTProtocol
RTControllercontext (void) const
 Get the context of the capsule that owns this port.
 
int getId (void) const
 Get the id of the port.
 
const RTPortDescriptorgetInfo (void) const
 Get information about a port.
 
const char * getName (void) const
 Get the name of the port.
 
RTActorgetOwner (void) const
 Get the owner capsule to which the port belongs.
 
int size (void) const
 Get the size of the port.
 
int resize (int new_size)
 Set a new size (i.e.
 
int registerSAP (const char *service)
 Register an unwired port (SAP) with the layer service (as a "client").
 
int deregisterSAP (void)
 Deregister an unwired port (SAP).
 
int registerSPP (const char *service)
 Register an unwired port (SPP) with the layer service (as the "provider").
 
int deregisterSPP (void)
 Deregister an unwired port (SPP).
 
const char * defaultLayerName (void) const
 Get the default registration name for the port.
 
int isRegistered (void) const
 Determine if the port is currently registered with the layer service or not.
 
const char * getRegisteredName (void) const
 Get the registration name of the port.
 
int registerAs (const char *service)
 Register an unwired port either as an SAP or SPP (depending on the "Publish" property of the port).
 
int deregister (void)
 Deregister an unwired port (either an SAP or SPP).
 
int isBoundAt (int index) const
 Determine if a port instance is currently connected to another port instance.
 
int isIndexTo (int index, RTActor *capsule) const
 Determine if a port instance is currently connected to a port instance owned by a certain capsule instance.
 
int indexTo (RTActor *capsule) const
 Determine if there exists a port instance currently connected to a port instance owned by a certain capsule instance.
 
int purge (void)
 Empty the defer queue of all port instances without recalling any deferred message.
 
int purgeAt (int index)
 Empty the defer queue of a specified port instance without recalling any deferred message.
 
int recall (void)
 Recall a message from the defer queue and insert it at the back of the controller's message queue (after other queued messages).
 
int recallFront (void)
 Recall a message from the defer queue and insert it at the front of the controller's message queue (before other queued messages).
 
int recallAt (int index, int front=0)
 Recall a message from the defer queue and insert it in the controller's message queue.
 
int recallAll (void)
 Recall all messages from the defer queue and insert them at the back of the controller's message queue (after other queued messages).
 
int recallAllFront (void)
 Recall all messages from the defer queue and insert them at the front of the controller's message queue (before other queued messages).
 
int recallAllAt (int index, int front=0)
 Recall all messages from the defer queue and insert them in the controller's message queue.
 
void bindingNotification (int on_off)
 Turn on or off binding notifications for this port.
 
int bindingNotificationRequested (void) const
 Determine if binding notifications are currently enabled for the port.
 
void sendTypeCheckEnable (int on_off)
 Turn on or off type checking when performing send(), invoke() or reply() on the port.
 
int sendTypeCheckEnabled (void) const
 Determine if type checking when sending events is enabled.
 
RTProtocolDescriptor::Status sendCheck (int signal, const RTObject_class *type) const
 Check if a particular event would be possible to send on this port.
 
void receiveTypeCheckEnable (int on_off)
 Turn on or off type checking when receiving an event on the port.
 
int receiveTypeCheckEnabled (void) const
 Determine if type checking when receiving events is enabled.
 
RTProtocolDescriptor::Status receiveCheck (int signal, const RTObject_class *type) const
 Check if a particular event would be possible to receive on this port.
 
int invoke (RTMessage *replyBuffer, int signal, const void *data, const RTObject_class *type, bool implicitReply)
 Invoke an event on the port.
 
int invokeAt (int index, RTMessage *replyBuffer, int signal, const void *data, const RTObject_class *type, bool implicitReply)
 Invoke an event on a replicated port at a specified index.
 
int reply (int signal, const void *data, const RTObject_class *type)
 Make a reply to respond to an invoke.
 
int send (int signal, const void *data, const RTObject_class *type, int priority, bool moveData=false)
 Send an event on the port.
 
int sendAt (int index, int signal, const void *data, const RTObject_class *type, int priority, bool moveData=false)
 Send an event on a replicated port at a specified index.
 

Static Public Attributes

static const RTProtocolDescriptor rt_class
 

Protected Types

enum  { rtiLast_Timing = rti_timeout }
 
- Protected Types inherited from RTProtocol
enum  {
  BindingNotification = 1 , RegisteredAsSAP = 2 , SendTypeCheck = 4 , ReceiveTypeCheck = 8 ,
  Resized = 16
}
 
enum  { rtiLast_RTProtocol = 0 }
 

Protected Member Functions

RTTimerNodeinformIn (const RTTimespec &when, const RTTimespec &repeatInterval, const void *data, const RTObject_class *type, int prio)
 
- Protected Member Functions inherited from RTProtocol
void init (const RTPortDescriptor *)
 
int getFlags (void) const
 
void setFlag (int)
 
void resetFlag (int)
 
void bindAt (int, RTBindingEnd &, RTController *)
 
int peerAt (int, RTBindingEnd &)
 
void unbindAt (int, RTController *)
 
void notifyInit (RTController *)
 
void notifyBoundAt (int, RTController *)
 

Friends

class RTTimerActor
 
class RTTimerNode
 

Detailed Description

Represents a timer port.

Member Function Documentation

◆ adjustTimeBegin()

void Timing::Base::adjustTimeBegin ( void  )

Begin adjustment of system time.

If ever the real-time clock needs to be adjusted it has to be done between calls to adjustTimeBegin() and adjustTimeEnd() so that the run-time system can be aware of it and make any necessary adjustments to its internal data structures so that relative timeouts (requested via informIn() or informEvery() calls) are not delayed nor advanced.

◆ adjustTimeEnd()

void Timing::Base::adjustTimeEnd ( const RTTimespec delta)

End adjustment of system time.

If ever the real-time clock needs to be adjusted it has to be done between calls to adjustTimeBegin() and adjustTimeEnd() so that the run-time system can be aware of it and make any necessary adjustments to its internal data structures so that relative timeouts (requested via informIn() or informEvery() calls) are not delayed nor advanced.

Parameters
[in]deltaSpecifies how the real-time clock was changed

◆ cancelTimer()

int Timing::Base::cancelTimer ( RTTimerId id)

Cancel a timer.

The function ensures that the timeout event of the specified timer will not be delivered to this timer port. This is true even if the timer already have expired at the time when this function is called, but the timeout event is waiting to be dispatched.

Parameters
[in]idTimer identifier for the timer to be cancelled.
Returns
1 if a pending timeout request was cancelled, 0 otherwise.

◆ currentTime()

RTTimespec Timing::Base::currentTime ( void  ) const

Return the current time.

It is recommended, for performance reasons, to instead use RTTimespec::getclock().

◆ informAt() [1/4]

RTTimerNode * Timing::Base::informAt ( const RTTimespec when,
const RTDataObject data,
int  prio = General 
)

Start a timer which will expire at a particular absolute point in time.

Parameters
[in]whenThe desired absolute time when the timer is to expire.
[in]dataData object to put in the timeout event. The data is copied by the TargetRTS using the copy function of the type descriptor for the data object.
[in]prioThe priority at which the timeout event should be sent. A message priority is interpreted as its relative importance with respect to all other unprocessed messages on a thread. The priority evaluates to one of the defined global priority values.
Returns
A timer handle which can be used to construct a timer identifier represented by an RTTimerId. This object can be used to cancel the timer prior to its expiry. NULL is returned in case the timer request fails.

◆ informAt() [2/4]

RTTimerNode * Timing::Base::informAt ( const RTTimespec when,
const RTTypedValue info,
int  prio = General 
)

Start a timer which will expire at a particular absolute point in time.

Parameters
[in]whenThe desired absolute time when the timer is to expire.
[in]infoAn RTTypedValue object which encapsules the data object to put in the timeout event and its type descriptor. The data is copied by the TargetRTS using the copy function of the type descriptor.
[in]prioThe priority at which the timeout event should be sent. A message priority is interpreted as its relative importance with respect to all other unprocessed messages on a thread. The priority evaluates to one of the defined global priority values.
Returns
A timer handle which can be used to construct a timer identifier represented by an RTTimerId. This object can be used to cancel the timer prior to its expiry. NULL is returned in case the timer request fails.

◆ informAt() [3/4]

RTTimerNode * Timing::Base::informAt ( const RTTimespec when,
const void *  data,
const RTObject_class type,
int  prio = General 
)

Start a timer which will expire at a particular absolute point in time.

Parameters
[in]whenThe desired absolute time when the timer is to expire.
[in]dataData object to put in the timeout event. The data is copied by the TargetRTS using the copy function of the type descriptor.
[in]typeType descriptor for the data object.
[in]prioThe priority at which the timeout event should be sent. A message priority is interpreted as its relative importance with respect to all other unprocessed messages on a thread. The priority evaluates to one of the defined global priority values.
Returns
A timer handle which can be used to construct a timer identifier represented by an RTTimerId. This object can be used to cancel the timer prior to its expiry. NULL is returned in case the timer request fails.

◆ informAt() [4/4]

RTTimerNode * Timing::Base::informAt ( const RTTimespec when,
int  prio = General 
)

Start a timer which will expire at a particular absolute point in time.

Parameters
[in]whenThe desired absolute time when the timer is to expire.
[in]prioThe priority at which the timeout event should be sent. A message priority is interpreted as its relative importance with respect to all other unprocessed messages on a thread. The priority evaluates to one of the defined global priority values.
Returns
A timer handle which can be used to construct a timer identifier represented by an RTTimerId. This object can be used to cancel the timer prior to its expiry. NULL is returned in case the timer request fails.

◆ informEvery() [1/4]

RTTimerNode * Timing::Base::informEvery ( const RTTimespec delta)

Start a periodic timer which will expire at regular intervals.

Parameters
[in]deltaThe desired time interval specifying how frequently the timer should expire. If the interval is less than or equal to the current time or equal to zero, the timer will expire immediately.
Returns
A timer handle which can be used to construct a timer identifier represented by an RTTimerId. This object can be used to cancel the timer prior to its expiry. NULL is returned in case the timer request fails.

◆ informEvery() [2/4]

RTTimerNode * Timing::Base::informEvery ( const RTTimespec delta,
const RTDataObject data,
int  prio = General 
)

Start a periodic timer which will expire at regular intervals.

Parameters
[in]deltaThe desired time interval specifying how frequently the timer should expire. If the interval is less than or equal to the current time or equal to zero, the timer will expire immediately.
[in]dataData object to put in the timeout event. The data is copied by the TargetRTS using the copy function of the type descriptor for the data object.
[in]prioThe priority at which the timeout event should be sent. A message priority is interpreted as its relative importance with respect to all other unprocessed messages on a thread. The priority evaluates to one of the defined global priority values.
Returns
A timer handle which can be used to construct a timer identifier represented by an RTTimerId. This object can be used to cancel the timer prior to its expiry. NULL is returned in case the timer request fails.

◆ informEvery() [3/4]

RTTimerNode * Timing::Base::informEvery ( const RTTimespec delta,
const RTTypedValue info,
int  prio = General 
)

Start a periodic timer which will expire at regular intervals.

Parameters
[in]deltaThe desired time interval specifying how frequently the timer should expire. If the interval is less than or equal to the current time or equal to zero, the timer will expire immediately.
[in]infoAn RTTypedValue object which encapsules the data object to put in the timeout event and its type descriptor. The data is copied by the TargetRTS using the copy function of the type descriptor.
[in]prioThe priority at which the timeout event should be sent. A message priority is interpreted as its relative importance with respect to all other unprocessed messages on a thread. The priority evaluates to one of the defined global priority values.
Returns
A timer handle which can be used to construct a timer identifier represented by an RTTimerId. This object can be used to cancel the timer prior to its expiry. NULL is returned in case the timer request fails.

◆ informEvery() [4/4]

RTTimerNode * Timing::Base::informEvery ( const RTTimespec delta,
const void *  data,
const RTObject_class type,
int  prio = General 
)

Start a periodic timer which will expire at regular intervals.

Parameters
[in]deltaThe desired time interval specifying how frequently the timer should expire. If the interval is less than or equal to the current time or equal to zero, the timer will expire immediately.
[in]dataData object to put in the timeout event. The data is copied by the TargetRTS using the copy function of the type descriptor.
[in]typeType descriptor for the data object.
[in]prioThe priority at which the timeout event should be sent. A message priority is interpreted as its relative importance with respect to all other unprocessed messages on a thread. The priority evaluates to one of the defined global priority values.
Returns
A timer handle which can be used to construct a timer identifier represented by an RTTimerId. This object can be used to cancel the timer prior to its expiry. NULL is returned in case the timer request fails.

◆ informIn() [1/4]

RTTimerNode * Timing::Base::informIn ( const RTTimespec delta,
const RTDataObject data,
int  prio = General 
)

Start a timer which will expire after a specified time interval.

Parameters
[in]deltaThe desired time interval (expressed as a time relative from now) when the timer is to expire. If the interval is less than or equal to the current time or equal to zero, the timer will expire immediately.
[in]dataData object to put in the timeout event. The data is copied by the TargetRTS using the copy function of the type descriptor for the data object.
[in]prioThe priority at which the timeout event should be sent. A message priority is interpreted as its relative importance with respect to all other unprocessed messages on a thread. The priority evaluates to one of the defined global priority values.
Returns
A timer handle which can be used to construct a timer identifier represented by an RTTimerId. This object can be used to cancel the timer prior to its expiry. NULL is returned in case the timer request fails.

◆ informIn() [2/4]

RTTimerNode * Timing::Base::informIn ( const RTTimespec delta,
const RTTypedValue info,
int  prio = General 
)

Start a timer which will expire after a specified time interval.

Parameters
[in]deltaThe desired time interval (expressed as a time relative from now) when the timer is to expire. If the interval is less than or equal to the current time or equal to zero, the timer will expire immediately.
[in]infoAn RTTypedValue object which encapsules the data object to put in the timeout event and its type descriptor. The data is copied by the TargetRTS using the copy function of the type descriptor.
[in]prioThe priority at which the timeout event should be sent. A message priority is interpreted as its relative importance with respect to all other unprocessed messages on a thread. The priority evaluates to one of the defined global priority values.
Returns
A timer handle which can be used to construct a timer identifier represented by an RTTimerId. This object can be used to cancel the timer prior to its expiry. NULL is returned in case the timer request fails.

◆ informIn() [3/4]

RTTimerNode * Timing::Base::informIn ( const RTTimespec delta,
const void *  data,
const RTObject_class type,
int  prio = General 
)

Start a timer which will expire after a specified time interval.

Parameters
[in]deltaThe desired time interval (expressed as a time relative from now) when the timer is to expire. If the interval is less than or equal to the current time or equal to zero, the timer will expire immediately.
[in]dataData object to put in the timeout event. The data is copied by the TargetRTS using the copy function of the type descriptor.
[in]typeType descriptor for the data object.
[in]prioThe priority at which the timeout event should be sent. A message priority is interpreted as its relative importance with respect to all other unprocessed messages on a thread. The priority evaluates to one of the defined global priority values.
Returns
A timer handle which can be used to construct a timer identifier represented by an RTTimerId. This object can be used to cancel the timer prior to its expiry. NULL is returned in case the timer request fails.

◆ informIn() [4/4]

RTTimerNode * Timing::Base::informIn ( const RTTimespec delta,
int  prio = General 
)

Start a timer which will expire after a specified time interval.

Parameters
[in]deltaThe desired time interval (expressed as a time relative from now) when the timer is to expire. If the interval is less than or equal to the current time or equal to zero, the timer will expire immediately.
[in]prioThe priority at which the timeout event should be sent. A message priority is interpreted as its relative importance with respect to all other unprocessed messages on a thread. The priority evaluates to one of the defined global priority values.
Returns
A timer handle which can be used to construct a timer identifier represented by an RTTimerId. This object can be used to cancel the timer prior to its expiry. NULL is returned in case the timer request fails.

◆ timeouts()

int Timing::Base::timeouts ( const RTTimerId id)

Get the number of timeout intervals that passed before the timeout of a periodic timer was actually processed.

Calling this function is a way to measure the accuracy of a periodic timer. The precision of a periodic timer depends on the underlying operating system. If you set a periodic timer with a timeout interval that is small, you may miss certain timeouts simply because the underlying operating system cannot process the timeouts fast enough. This function returns how many timeout intervals that have been missed since the last time a periodic timer expired. NOTE: Setting a timeout frequency higher than the granularity of the operating system means that the memory usage will grow since timeout messages then are produced at a higher pace than what they are consumed. If this goes on for long enough the application will run out of memory.

Parameters
[in]idTimer identifier for a periodic timer to measure the accuracy of.
Returns
A measurement of the number of missed timeout intervals since the last time the timer expired. If the timer never has expired 0 is returned. If no interval is missed (i.e. the timer expired at the specified time) 1 is returned. The higher number returned, the less accurate is the timer.

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