Skip to main content
Skip table of contents

LJM Interval Configs

See the StartInterval function for information on interval timing.

LJM_INTERVAL_CLOCK_TYPE

Requires LJM 1.2100 or later.

Sets which type of clock LJM_StartInterval initializes for a given IntervalHandle. LJM_WaitForNextInterval will then use the given clock type for that IntervalHandle.

LJM_INTERVAL_CLOCK_TYPE_STEADY = 1 (default)

  • The time between ticks of the steady clock is constant.

  • Steady clock is not affected by Network Time Protocol (NTP) updates or updates the system clock.

  • This clock is appropriate for consistent timing performed on a single computer.

  • LJM_INTERVAL_CLOCK_TYPE_STEADY is implemented in C++ via std::chrono::steady_clock, or via std::chrono::high_resolution_clock if high_resolution_clock is a steady clock.

LJM_INTERVAL_CLOCK_TYPE_SYSTEM = 2

  • The system clock is also known as the wall clock.

  • It can jump forward or backward. This can happen due to NTP updates or due to manually setting the system clock.

  • This clock can be appropriate for a shared interval across multiple computers over long times. Because NTP prevents clock drift (relative to the NTP time), multiple computers getting NTP updates to the system time will perform the same number of iterations when performing intervals based on the system clock.

  • LJM_INTERVAL_CLOCK_TYPE_SYSTEM is implemented in C++ via std::chrono::system_clock, or via std::chrono::high_resolution_clock if high_resolution_clock is not a steady clock.

The constant LJM_INTERVAL_CLOCK_TYPE can be used interchangeably with the string "LJM_INTERVAL_CLOCK_TYPE".

Remarks

LJM_INTERVAL_CLOCK_TYPE does not affect any previously initialized IntervalHandle.

Relevant Functions

To read LJM_INTERVAL_CLOCK_TYPE, use LJM_ReadLibraryConfigS.

To write LJM_INTERVAL_CLOCK_TYPE, use LJM_WriteLibraryConfigS or LJM_LoadConfigurationFile.

Example

Set the LJM_INTERVAL_CLOCK_TYPE mode to LJM_INTERVAL_CLOCK_TYPE_SYSTEM

C
int LJMError = 0;
LJMError = LJM_WriteLibraryConfigS(
     LJM_INTERVAL_CLOCK_TYPE,
     LJM_INTERVAL_CLOCK_TYPE_SYSTEM
);
ErrorCheck(LJMError, "LJM_WriteLibraryConfigS");

int SkippedIntervals;
const int INTERVAL_HANDLE = 1;
const int ONE_SECOND = 1000 * 1000; // One second in microseconds
LJMError = LJM_StartInterval(INTERVAL_HANDLE, ONE_SECOND);
ErrorCheck(LJMError, "LJM_StartInterval");

for (int loop = 0; loop < 100; loop++) {
    ReadAndOutput(handle, "AIN0");

    LJMError = LJM_WaitForNextInterval(INTERVAL_HANDLE, &SkippedIntervals);
    ErrorCheck(LJMError, "LJM_WaitForNextInterval");
    if (SkippedIntervals > 0) {
        printf("SkippedIntervals: %d\n", SkippedIntervals);
    }
}

For more LJM configurations, see Library Configuration Functions.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.