VMX-pi C++ HAL Library for Raspberry Pi
VMX-pi Robotics Controller & Vision/Motion Processor
Public Types | Public Member Functions | Friends | List of all members
VMXTime Class Reference

The VMXTime class provides time management functions, including system timestamps, VMX Real-time Clock access, timer notifications and current thread time-delay. More...

#include <VMXTime.h>

Public Types

enum  DaylightSavingsAdjustment { DSAdjustmentNone = 0, DSAdjustmentAddOneHour = 1, DSAdjustmentSubtractOneHour = 2 }
 Real-Time Clock Daylight Savings Adjustment Setting. More...
 

Public Member Functions

uint64_t GetCurrentOSTimeMicroseconds ()
 Returns the current linux operating system (OS) time in microseconds Note that this value is similar to but not exactly synchronized with the CurrentMicroseconds value. More...
 
uint32_t GetCurrentMicroseconds ()
 Returns the low 32 bit portion of the current system Hardware Timer value in microseconds. More...
 
uint64_t GetCurrentTotalMicroseconds ()
 Returns the full 64 bit current system Hardware Timer value in microseconds. More...
 
uint32_t GetCurrentMicrosecondsHighPortion ()
 Returns the high 32 bit portion of the current system Hardware Timer value in microseconds. More...
 
uint32_t DelayMicroseconds (uint32_t delay_us)
 Blocks the current thread for the specified amount of time in microseconds. More...
 
uint32_t DelayMilliseconds (uint32_t delay_ms)
 Blocks the current thread for the specified amount of time in milliseconds. More...
 
uint32_t DelaySeconds (uint32_t delay_sec)
 Blocks the current thread for the specified amount of time in seconds. More...
 
bool RegisterTimerNotificationAbsolute (VMXNotifyHandler timer_notify_handler, uint64_t trigger_timestamp_us, void *param)
 Register a VMXNotifyHandler which is invoked when the system timestamp reaches the specified trigger_timestamp. More...
 
bool RegisterTimerNotificationRelative (VMXNotifyHandler timer_notify_handler, uint64_t time_from_now_us, void *param, bool repeat)
 Register a VMXNotifyHandler which is invoked within a time period relative to now, which option to create a repeating notification. More...
 
bool DeregisterTimerNotification (VMXNotifyHandler timer_notify_handler)
 Deregisters a previously-registered VMXNotifyHandler. More...
 
bool IsTimerNotificationExpired (VMXNotifyHandler timer_notify_handler, bool &expired)
 Indicates whether the provided previously-registered timer_notify_handler has expired. More...
 
bool GetRTCTime (uint8_t &hours, uint8_t &minutes, uint8_t &seconds, uint32_t &milliseconds, VMXErrorCode *errcode)
 Retrieves the current VMX Real-time clock value. More...
 
bool GetRTCDate (uint8_t &weekday, uint8_t &day, uint8_t &month, uint8_t &years, VMXErrorCode *errcode)
 Retrieves the current VMX Real-time date value. More...
 
bool GetRTCDaylightSavingsAdjustment (DaylightSavingsAdjustment &dsa, VMXErrorCode *errcode)
 Retrieves the current VMX Real-time clock daylight savings adjustment setting. More...
 
bool SetRTCTime (uint8_t hours, uint8_t minutes, uint8_t seconds, VMXErrorCode *errcode)
 Sets the current VMX Real-time clock value. More...
 
bool SetRTCDate (uint8_t weekday, uint8_t day, uint8_t month, uint8_t years, VMXErrorCode *errcode)
 Sets the current VMX Real-time date value. More...
 
bool SetRTCDaylightSavingsAdjustment (DaylightSavingsAdjustment dsa, VMXErrorCode *errcode)
 Sets the current VMX Real-time clock daylight savings adjustment setting. More...
 

Friends

class VMXPi
 
class VMXZero
 
class VMXIO
 

Detailed Description

The VMXTime class provides time management functions, including system timestamps, VMX Real-time Clock access, timer notifications and current thread time-delay.

Member Enumeration Documentation

◆ DaylightSavingsAdjustment

Real-Time Clock Daylight Savings Adjustment Setting.

Enumerator
DSAdjustmentNone 

The Real-time Clock hour is not adjusted during daylight savings time periods.

DSAdjustmentAddOneHour 

The Real-time Clock hour has one hour added to it during daylight savings time periods.

DSAdjustmentSubtractOneHour 

The Real-time Clock hours has one hour substracted from it during daylight savings time periods.

Member Function Documentation

◆ DelayMicroseconds()

uint32_t VMXTime::DelayMicroseconds ( uint32_t  delay_us)

Blocks the current thread for the specified amount of time in microseconds.

NOTE: Busy-waiting is used when the requested delay is less than 100 microseconds; otherwise, the delay occurs by suspending the current thread.

Parameters
delay_usThe amount of time to delay the current thread, in microseconds
Returns
the actual amount of time this thread was delayed, in microseconds

◆ DelayMilliseconds()

uint32_t VMXTime::DelayMilliseconds ( uint32_t  delay_ms)

Blocks the current thread for the specified amount of time in milliseconds.

The delay occurs by suspending the current thread.

Parameters
delay_msThe amount of time to delay the current thread, in milliseconds
Returns
the actual amount of time this thread was delayed, in millieconds

◆ DelaySeconds()

uint32_t VMXTime::DelaySeconds ( uint32_t  delay_sec)

Blocks the current thread for the specified amount of time in seconds.

The delay occurs by suspending the current thread.

Parameters
delay_secThe amount of time to delay the current thread, in seconds
Returns
the actual amount of time this thread was delayed, in seconds

◆ DeregisterTimerNotification()

bool VMXTime::DeregisterTimerNotification ( VMXNotifyHandler  timer_notify_handler)

Deregisters a previously-registered VMXNotifyHandler.

Parameters
timer_notify_handlerThe VMXNotifyHandler to be cancelled
Returns
true if the specified time_notify_handler was sucessfully cancelled

◆ GetCurrentMicroseconds()

uint32_t VMXTime::GetCurrentMicroseconds ( )

Returns the low 32 bit portion of the current system Hardware Timer value in microseconds.

This value is clock-monotonic, meaning that it is reset to each time the host is powered on.

◆ GetCurrentMicrosecondsHighPortion()

uint32_t VMXTime::GetCurrentMicrosecondsHighPortion ( )

Returns the high 32 bit portion of the current system Hardware Timer value in microseconds.

This value is clock-monotonic, meaning that it is reset to each time the host is powered on.

◆ GetCurrentOSTimeMicroseconds()

uint64_t VMXTime::GetCurrentOSTimeMicroseconds ( )

Returns the current linux operating system (OS) time in microseconds Note that this value is similar to but not exactly synchronized with the CurrentMicroseconds value.

This value is clock-monotonic, meaning that it is reset to 0 each time the host is powered on.

◆ GetCurrentTotalMicroseconds()

uint64_t VMXTime::GetCurrentTotalMicroseconds ( )

Returns the full 64 bit current system Hardware Timer value in microseconds.

This value is clock-monotonic, meaning that it is reset to each time the host is powered on.

◆ GetRTCDate()

bool VMXTime::GetRTCDate ( uint8_t &  weekday,
uint8_t &  day,
uint8_t &  month,
uint8_t &  years,
VMXErrorCode *  errcode 
)

Retrieves the current VMX Real-time date value.

Parameters
weekdayCurrent weekday (1-7; 1 = Monday)
dayCurrent day (0-31)
monthCurrent month (1-12; 1 = January)
yearsCurrent year (0-99; 0 = 2000)
[out]errcodePointer to the VMXErrorCode to be returned in case of error; may be null
Returns
Returns true if the current VMX Real-time Clock time was retrieved. If false, the error code will be returned via the errcode parameter.

◆ GetRTCDaylightSavingsAdjustment()

bool VMXTime::GetRTCDaylightSavingsAdjustment ( DaylightSavingsAdjustment dsa,
VMXErrorCode *  errcode 
)

Retrieves the current VMX Real-time clock daylight savings adjustment setting.

Parameters
dsaCurrent DaylightSavingsAdjustment value
[out]errcodePointer to the VMXErrorCode to be returned in case of error; may be null
Returns
Returns true if the current VMX Real-time Clock DaylightSavingsAdjustment was retrieved

◆ GetRTCTime()

bool VMXTime::GetRTCTime ( uint8_t &  hours,
uint8_t &  minutes,
uint8_t &  seconds,
uint32_t &  milliseconds,
VMXErrorCode *  errcode 
)

Retrieves the current VMX Real-time clock value.

Parameters
hoursCurrent hours (0-23; 0 = midnight)
minutesCurrent minutes (0-59)
secondsCurrent seconds (0-59)
millisecondscurrent milliseconds (0-999)
[out]errcodePointer to the VMXErrorCode to be returned in case of error; may be null
Returns
Returns true if the current VMX Real-time Clock time was retrieved. If false, the error code will be returned via the errcode parameter.

◆ IsTimerNotificationExpired()

bool VMXTime::IsTimerNotificationExpired ( VMXNotifyHandler  timer_notify_handler,
bool &  expired 
)

Indicates whether the provided previously-registered timer_notify_handler has expired.

Parameters
timer_notify_handlerThe VMXNotifyHandler to check
[out]expiredSet to true if the requested timer_notify_handler is expired
Returns
true if the specified timer_notify_handler is currently registered

◆ RegisterTimerNotificationAbsolute()

bool VMXTime::RegisterTimerNotificationAbsolute ( VMXNotifyHandler  timer_notify_handler,
uint64_t  trigger_timestamp_us,
void *  p_param 
)

Register a VMXNotifyHandler which is invoked when the system timestamp reaches the specified trigger_timestamp.

Parameters
timer_notify_handlerThe VMXNotifyHandler to be invoked upon timer expiry
trigger_timestamp_usThe absolute 64-bit system timestamp value in microseconds at which the notification should be triggered
p_paramThe parameter to pass to the timer_notify_handler; may be null

◆ RegisterTimerNotificationRelative()

bool VMXTime::RegisterTimerNotificationRelative ( VMXNotifyHandler  timer_notify_handler,
uint64_t  time_from_now_us,
void *  p_param,
bool  repeat 
)

Register a VMXNotifyHandler which is invoked within a time period relative to now, which option to create a repeating notification.

Parameters
timer_notify_handlerThe VMXNotifyHandler to be invoked upon timer expiry
time_from_now_usThe relative amount of time (from now) when the notification should be triggered
p_paramThe parameter to pass to the timer_notify_handler; may be null
repeatIf true, the VMXNotifyHandler will be repeatedly invoked every time_from_now_use period

◆ SetRTCDate()

bool VMXTime::SetRTCDate ( uint8_t  weekday,
uint8_t  day,
uint8_t  month,
uint8_t  years,
VMXErrorCode *  errcode 
)

Sets the current VMX Real-time date value.

Parameters
weekdayCurrent weekday (1-7; 1 = Monday)
dayCurrent day (0-31)
monthCurrent month (1-12; 1 = January)
yearscurrent years (0-99; 0 = 2000)
[out]errcodePointer to the VMXErrorCode to be returned in case of error; may be null
Returns
Returns true if the current VMX Real-time Clock time was set. If false, the error code will be returned via the errcode parameter.

◆ SetRTCDaylightSavingsAdjustment()

bool VMXTime::SetRTCDaylightSavingsAdjustment ( DaylightSavingsAdjustment  dsa,
VMXErrorCode *  errcode 
)

Sets the current VMX Real-time clock daylight savings adjustment setting.

Parameters
dsaCurrent DaylightSavingsAdjustment value
[out]errcodePointer to the VMXErrorCode to be returned in case of error; may be null
Returns
Returns true if the current VMX Real-time Clock DaylightSavingsAdjustment was set

◆ SetRTCTime()

bool VMXTime::SetRTCTime ( uint8_t  hours,
uint8_t  minutes,
uint8_t  seconds,
VMXErrorCode *  errcode 
)

Sets the current VMX Real-time clock value.

Parameters
hoursCurrent hours (0-23; 0 = midnight)
minutesCurrent minutes (0-59)
secondsCurrent seconds (0-59)
[out]errcodePointer to the VMXErrorCode to be returned in case of error; may be null
Returns
Returns true if the current VMX Real-time Clock time was set. If false, the error code will be returned via the errcode parameter.

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