S2OPC OPCUA Toolkit
Loading...
Searching...
No Matches
p_sopc_zephyr_time.h File Reference
#include <stdbool.h>
#include <stdint.h>
#include "sopc_time_reference.h"

Go to the source code of this file.

Enumerations

enum  SOPC_Time_TimeSource { SOPC_TIME_TIMESOURCE_INTERNAL , SOPC_TIME_TIMESOURCE_PTP_SLAVE , SOPC_TIME_TIMESOURCE_PTP_MASTER }
 This file provides time related ZEPHYR-specific implementations which are defined in "sopc_time_reference.h". More...
 

Functions

SOPC_Time_TimeSource SOPC_Time_GetTimeSource (void)
 returns the current time source used for time-related operations (including timestamping)
 
float SOPC_Time_GetClockPrecision (void)
 returns an evaluation of the system clock precision (relatively to a remote PtP MASTER) This value can be used to check that PtP clock is sufficiently synchronized before allowing some time-related events, typically like sending Publisher messages with PublishOffset constraints. The threshold value may clearly be determined experimentally depending on expected precision.
 
float SOPC_Time_GetClockCorrection (void)
 Provides the information about clock discrepancy towards a PtP master.
 

Enumeration Type Documentation

◆ SOPC_Time_TimeSource

This file provides time related ZEPHYR-specific implementations which are defined in "sopc_time_reference.h".

Note
The ZEPHYR PtP time correction is realized while processing specific time events (SOPC_Time_GetCurrentTimeUTC). Natively, in S2OPC core, this function may not be called as long as no PubSub is started. As a consequence, in the case an application waits for a PtP synchronization before activating this service, it is mandatory to firstly force this synchronization by calling this functions explicitly until synchronization is good enough. A simple way to do that could be calling SOPC_Time_GetCurrentTimeUTC function as long as SOPC_HighRes_TimeReference_GetClockPrecision does not return sufficient precision.

Possible time sources

Enumerator
SOPC_TIME_TIMESOURCE_INTERNAL 

Local system time, non-ptp synchronized

SOPC_TIME_TIMESOURCE_PTP_SLAVE 

PtP time (acting as SLAVE device)

SOPC_TIME_TIMESOURCE_PTP_MASTER 

PtP time (acting as MASTER device)

Function Documentation

◆ SOPC_Time_GetTimeSource()

SOPC_Time_TimeSource SOPC_Time_GetTimeSource ( void )

returns the current time source used for time-related operations (including timestamping)

◆ SOPC_Time_GetClockPrecision()

float SOPC_Time_GetClockPrecision ( void )

returns an evaluation of the system clock precision (relatively to a remote PtP MASTER) This value can be used to check that PtP clock is sufficiently synchronized before allowing some time-related events, typically like sending Publisher messages with PublishOffset constraints. The threshold value may clearly be determined experimentally depending on expected precision.

Returns
A value between 0.0 and 1.0:
  • 1.0 for a perfectly synchronized PtP SLAVE (typically, current time source is SOPC_TIME_TIMESOURCE_PTP_SLAVE and remote PtP time is perfectly synchronized and stable with S2OPC internal clock)
  • 0.0 if there is no PtP synchronization (not PtP SLAVE or SLAVE but with clock failed to stabilize)

◆ SOPC_Time_GetClockCorrection()

float SOPC_Time_GetClockCorrection ( void )

Provides the information about clock discrepancy towards a PtP master.

Returns
clock ratio discrepancy: < 1.0 when local clock is faster than actual (PtP) time

‍1.0 when local clock is slower than actual (PtP) time