Examples User Manual#

This manual explains the examples included in the examples/time/ subdirectory and how they can be used as patterns for building applications with the SCORE time library.

Overview#

The examples/time/ directory contains four working examples that demonstrate how to use different SCORE time sources:

  • Basic Clock Examples (system_time, steady_time, high_res_steady_time): Simple periodic time printers showing the common pattern for reading time from SCORE clocks

  • Vehicle Time Example (vehicle_time): More complex example showing PTP-synchronized time with initialization, status monitoring, and dual time sources

All examples follow consistent patterns and can be used as starting points for real applications.

Building and Running Examples#

All examples use Bazel:

# Build all examples
bazel build //examples/...

# Run specific example
bazel run //examples/time/system_time

# Run tests
bazel test //examples/time/system_time/src:system_time_handler_test

Common Patterns#

All examples share these implementation patterns:

  • Handler wrapper classes providing clean APIs over SCORE Clock<Tag> types

  • TimeReport structs containing time data with consistent field naming

  • Signal handling for graceful shutdown on SIGINT/SIGTERM

  • Unit test patterns using ScopedClockOverride for dependency injection

  • Nanosecond precision throughout all time calculations