CANpie FD
CAN programming interface environment - Version 3.08
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Friends Macros Modules Pages
Public Member Functions | Static Public Member Functions
QCanTimeStamp Class Reference

Detailed Description

The QCanTimeStamp class provides the functionality for setting a time-stamp with a 1 ns (nano-seconds) resolution to a CAN frame (refer to QCanFrame::setTimeStamp). The time-stamp has two data fields:

The time-stamp covers a time-period of more than 49652 days (136 years). The value of a time-stamp can be set from a counter value by means of the functions fromMicroSeconds() or fromMilliSeconds().

Public Member Functions

 QCanTimeStamp (uint32_t ulSecondsV=0, uint32_t ulNanoSecondsV=0)
 
void clear (void)
 
void fromMicroSeconds (uint32_t ulMicroSecondsV)
 
void fromMilliSeconds (uint32_t ulMilliSecondsV)
 
bool isValid (void)
 
uint32_t nanoSeconds (void) const
 
uint32_t seconds (void) const
 
void setNanoSeconds (uint32_t ulNanoSecondsV)
 
void setSeconds (const uint32_t ulSecondsV)
 
QByteArray toByteArray (void) const
 
bool operator== (const QCanTimeStamp &clTimeStampR) const
 
bool operator!= (const QCanTimeStamp &clTimeStampR) const
 
bool operator< (const QCanTimeStamp &clTimeStampR) const
 
bool operator<= (const QCanTimeStamp &clTimeStampR) const
 
bool operator> (const QCanTimeStamp &clTimeStampR) const
 
bool operator>= (const QCanTimeStamp &clTimeStampR) const
 
QCanTimeStamp operator+ (const QCanTimeStamp &clTimeStampR) const
 
QCanTimeStampoperator+= (const QCanTimeStamp &clTimeStampR)
 
QCanTimeStamp operator- (const QCanTimeStamp &clTimeStampR) const
 
QCanTimeStampoperator-= (const QCanTimeStamp &clTimeStampR)
 

Static Public Member Functions

static QCanTimeStamp now (void)
 

Constructor & Destructor Documentation

◆ QCanTimeStamp()

QCanTimeStamp::QCanTimeStamp ( uint32_t  ulSecondsV = 0,
uint32_t  ulNanoSecondsV = 0 
)
Parameters
[in]ulSecondsV- Set the seconds field
[in]ulNanoSecondsV- Set the nano-seconds field

Construct a time-stamp with ulSecondsV and ulNanoSecondsV. If the valid value range for the parameters is violated the object will be constructed using maximum allowed values.

Member Function Documentation

◆ clear()

void QCanTimeStamp::clear ( void  )

Clear time-stamp by setting both data fields to 0.

◆ fromMicroSeconds()

void QCanTimeStamp::fromMicroSeconds ( uint32_t  ulMicroSecondsV)
Parameters
[in]ulMicroSecondsV- time-value in microseconds [µs]

Set the time-stamp value according to the parameter ulMicroSecondsV.

◆ fromMilliSeconds()

void QCanTimeStamp::fromMilliSeconds ( uint32_t  ulMilliSecondsV)
Parameters
[in]ulMilliSecondsV- time-value in milliseconds [msec]

Set the time-stamp value according to the parameter ulMilliSecondsV.

◆ isValid()

bool QCanTimeStamp::isValid ( void  )
Returns
true if time-stamp value is valid

Returns true if this time-stamp is within the valid value range. The limit for the data fields are defined by TIME_STAMP_SECS_LIMIT and TIME_STAMP_NSEC_LIMIT.

◆ nanoSeconds()

uint32_t QCanTimeStamp::nanoSeconds ( void  ) const
inline
Returns
Nanoseconds part of time-stamp value
See also
setNanoSeconds()

Returns the nanoseconds part of this time-stamp. A return value of TIME_STAMP_INVALID_VALUE marks the time-stamp value as invalid. The validity of a time-stamp can be tested with isValid().

◆ now()

static QCanTimeStamp QCanTimeStamp::now ( void  )
static
Returns
QCanTimeStamp object

Return a QCanTimeStamp object set to the current time point based on the High resolution clock. The method uses the high_resolution_clock::now() function of the std::chrono library.

◆ operator!=()

bool QCanTimeStamp::operator!= ( const QCanTimeStamp clTimeStampR) const
Parameters
clTimeStampR- Reference to other time-stamp
Returns
true on not equal time-stamps

Returns true if this time-stamp is not equal to time-stamp clTimeStampR, otherwise returns false.

◆ operator+()

QCanTimeStamp QCanTimeStamp::operator+ ( const QCanTimeStamp clTimeStampR) const
Parameters
clTimeStampR- Reference to other time-stamp
Returns
Sum of two time-stamp values

Add the time-stamp clTimeStampR to this time-stamp value and returns a reference to this time-stamp.

◆ operator+=()

QCanTimeStamp& QCanTimeStamp::operator+= ( const QCanTimeStamp clTimeStampR)
Parameters
clTimeStampR- Reference to other time-stamp
Returns
Sum of two time-stamp values

Add the time-stamp clTimeStampR to this time-stamp value and returns a reference to this time-stamp.

◆ operator-()

QCanTimeStamp QCanTimeStamp::operator- ( const QCanTimeStamp clTimeStampR) const
Parameters
clTimeStampR- Reference to other time-stamp
Returns
Difference between two time-stamp values

Subtract the time-stamp clTimeStampR from this time-stamp value and returns a reference to this time-stamp.

◆ operator-=()

QCanTimeStamp& QCanTimeStamp::operator-= ( const QCanTimeStamp clTimeStampR)
Parameters
clTimeStampR- Reference to other time-stamp
Returns
Difference between two time-stamp values

Subtract the time-stamp clTimeStampR from this time-stamp value and returns a reference to this time-stamp.

◆ operator<()

bool QCanTimeStamp::operator< ( const QCanTimeStamp clTimeStampR) const
Parameters
clTimeStampR- Reference to other time-stamp
Returns
true on smaller time-stamp

Returns true if this time-stamp is less than time-stamp clTimeStampR, otherwise returns false.

◆ operator<=()

bool QCanTimeStamp::operator<= ( const QCanTimeStamp clTimeStampR) const
Parameters
clTimeStampR- Reference to other time-stamp
Returns
true on smaller or equal time-stamp

Returns true if this time-stamp is less than or equal to time-stamp clTimeStampR, otherwise returns false.

◆ operator==()

bool QCanTimeStamp::operator== ( const QCanTimeStamp clTimeStampR) const
Parameters
clTimeStampR- Reference to other time-stamp
Returns
true on equal time-stamps

Returns true if this time-stamp is equal to time-stamp clTimeStampR, otherwise returns false.

◆ operator>()

bool QCanTimeStamp::operator> ( const QCanTimeStamp clTimeStampR) const
Parameters
clTimeStampR- Reference to other time-stamp
Returns
true on greater time-stamp

Returns true if this time-stamp is greater than time-stamp clTimeStampR, otherwise returns false.

◆ operator>=()

bool QCanTimeStamp::operator>= ( const QCanTimeStamp clTimeStampR) const
Parameters
clTimeStampR- Reference to other time-stamp
Returns
true on greater or equal time-stamp

Returns true if this time-stamp is greater or equal than time-stamp clTimeStampR, otherwise returns false.

◆ seconds()

uint32_t QCanTimeStamp::seconds ( void  ) const
inline
Returns
Seconds part of time-stamp value
See also
setSeconds()

Returns the seconds part of this time-stamp. A return value of TIME_STAMP_INVALID_VALUE marks the time-stamp value as invalid. The validity of a time-stamp can be tested with isValid().

◆ setNanoSeconds()

void QCanTimeStamp::setNanoSeconds ( uint32_t  ulNanoSecondsV)
Parameters
[in]ulNanoSecondsV- Nanosecond value
See also
nanoSeconds()

Set the nanoseconds part of this time-stamp. The value of ulNanoSecondsV must be in the range from 0 to TIME_STAMP_NSEC_LIMIT. If passing a value greater than TIME_STAMP_NSEC_LIMIT the value is limited to TIME_STAMP_NSEC_LIMIT.

◆ setSeconds()

void QCanTimeStamp::setSeconds ( const uint32_t  ulSecondsV)
Parameters
[in]ulSecondsV- Second value
See also
seconds()

Set the seconds part of this time-stamp. The value of ulSecondsV must be in the range from 0 to TIME_STAMP_SECS_LIMIT. If passing a value greater than TIME_STAMP_SECS_LIMIT the value is limited to TIME_STAMP_SECS_LIMIT.

◆ toByteArray()

QByteArray QCanTimeStamp::toByteArray ( void  ) const
Returns
QByteArray

The function converts a QCanTimeStamp object to a QByteArray.