diff --git a/docs/features/index.rst b/docs/features/index.rst new file mode 100644 index 00000000..a4bf7db2 --- /dev/null +++ b/docs/features/index.rst @@ -0,0 +1,24 @@ +.. + # ******************************************************************************* + # Copyright (c) 2024 Contributors to the Eclipse Foundation + # + # See the NOTICE file(s) distributed with this work for additional + # information regarding copyright ownership. + # + # This program and the accompanying materials are made available under the + # terms of the Apache License Version 2.0 which is available at + # https://www.apache.org/licenses/LICENSE-2.0 + # + # SPDX-License-Identifier: Apache-2.0 + # ******************************************************************************* + +Features +======== + +.. toctree:: + :maxdepth: 2 + :caption: Features: + + time_daemon/index + time_slave/index + test_cases diff --git a/docs/features/test_cases.rst b/docs/features/test_cases.rst new file mode 100644 index 00000000..66594f13 --- /dev/null +++ b/docs/features/test_cases.rst @@ -0,0 +1,967 @@ +.. + # ******************************************************************************* + # Copyright (c) 2026 Contributors to the Eclipse Foundation + # + # See the NOTICE file(s) distributed with this work for additional + # information regarding copyright ownership. + # + # This program and the accompanying materials are made available under the + # terms of the Apache License Version 2.0 which is available at + # https://www.apache.org/licenses/LICENSE-2.0 + # + # SPDX-License-Identifier: Apache-2.0 + # ******************************************************************************* + +Test Cases +========== + +This page lists verification test cases for the ``score::time`` module, organized by functional requirement. + + +FR-1 Vehicle Time Synchronization +--------------------------------- + + +TC-FR1-001 — gPTP Synchronization Establishment Verification +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +:Type: System Function +:Method: Log + Packet Capture +:Priority: High + +**Preconditions** + +1. Test device is powered on and started +2. A gPTP Time Master is available in the network +3. Wireshark/tcpdump is deployed on test PC or mirror port +4. Device logs are accessible + +**Test Steps** + +1. Start Wireshark on test PC, filter: eth.type == 0x88F7 +2. Start score::time service on target device +3. Wait 60s +4. Check captured gPTP packets in Wireshark +5. Execute log view command on device +6. Record AccuracyQualifier status in logs + +**Expected Result** + +**Packet Capture** + +- ✓ Pdelay_Req packets sent by this device are visible +- ✓ Pdelay_Resp, Sync, Follow_Up packets received by this device are visible +- ✓ No Sync packets sent by this device (device is Slave) + + +**Log Verification** + +- ✓ Log shows AccuracyQualifier changed to kSynchronized +- ✓ No persistent ERROR-level logs + + +TC-FR1-002 — gPTP Master Disconnection State Degradation +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +:Type: System Function +:Method: Log Verification +:Priority: High + +**Preconditions** + +1. FR-1-001 completed, device is in kSynchronized state +2. Device logs accessible +3. Network connectivity of gPTP Master can be controlled (unplug cable or shut down Master service) + +**Test Steps** + +1. Confirm AccuracyQualifier == kSynchronized in log, record timestamp +2. Disconnect gPTP Master network +3. Wait 60s (exceeds syncLossTimeout configuration) +4. Check latest AccuracyQualifier status in device log +5. Reconnect Master network +6. Wait 60s +7. Check AccuracyQualifier status in log again + +**Expected Result** + +**Disconnection Phase** + +- ✓ Log shows AccuracyQualifier degraded from kSynchronized to kUnstable or kNoTime +- ✓ Sync loss warning/error present in log + + +**Recovery Phase** + +- ✓ Log shows kSynchronized state restored +- ✓ No service crash during entire recovery process + + +TC-FR1-003 — Startup Behavior Without gPTP Master +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +:Type: System Function +:Method: Log Verification +:Priority: High + +**Preconditions** + +1. No gPTP Time Master in network (or Master is shut down) +2. Device logs accessible + +**Test Steps** + +1. Confirm no gPTP Master in network +2. Restart score::time service on target device +3. Wait 60s +4. Check AccuracyQualifier status in log +5. Verify service process is still running + +**Expected Result** + +**Log Verification** + +- ✓ AccuracyQualifier remains kNoTime +- ✓ Log contains clear sync failure or waiting-for-Master records + + +**Service Stability** + +- ✓ Service process not crashed, running normally +- ✓ No segfault or core dump + + +TC-FR1-004 — Device Does Not Send gPTP Sync Packets (Slave Role) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +:Type: System Function +:Method: Packet Capture +:Priority: Medium + +**Preconditions** + +1. gPTP Time Master available in network +2. Wireshark deployed + +**Test Steps** + +1. Start Wireshark, filter: eth.type == 0x88F7 +2. Start score::time service, wait 120s +3. Filter: source MAC is this device, gPTP messageType == Sync (0x0) +4. Count number of such packets + +**Expected Result** + +**Packet Capture** + +- ✓ 0 Sync packets actively sent by this device +- ✓ Pdelay_Req packets sent by this device visible (messageType == 0x2) +- ✓ Sync and Follow_Up packets received by this device visible + +FR-2 Vehicle Time Sync Precision +-------------------------------- + + +TC-FR2-001 — AVB Node Synchronization Accuracy Verification (≤1 μs) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +:Type: Performance +:Method: Clock Comparison +:Priority: Medium + +**Preconditions** + +1. Device is AVB node, gPTP sync completed +2. Reference clock source (GPS or high-precision Master) available +3. Accuracy measurement tool ready + +**Test Steps** + +1. Wait for AccuracyQualifier == kSynchronized then wait 5 more minutes to stabilize +2. Continuously sample for 10 minutes, record each offset +3. Calculate: max offset, average offset, standard deviation + +**Expected Result** + +- ✓ All sample offsets within 10 minutes have absolute value ≤ 1 μs +- ✓ No abnormal jumps (single offset change ≤ 500 ns) +- ✗ Fail if any sample offset > 1 μs + + +TC-FR2-002 — Non-AVB Node Synchronization Accuracy Verification (≤500 μs) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +:Type: Performance +:Method: Clock Comparison +:Priority: Medium + +**Preconditions** + +1. Device is non-AVB node, gPTP sync completed +2. Reference clock available + +**Test Steps** + +1. Wait for sync to stabilize (AccuracyQualifier == kSynchronized, then wait 2 more minutes) +2. Continuously sample for 5 minutes, record each offset +3. Calculate max offset + +**Expected Result** + +- ✓ All sample offsets have absolute value ≤ 500 μs +- ✓ Most samples ≤ 200 μs (target range 200–500 μs) +- ✗ Fail if offset > 500 μs + +FR-3 Vehicle Time Base API +-------------------------- + + +TC-FR3-001 — Vehicle Time Now() Can Be Read Normally +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +:Type: System Function +:Method: Test Tool +:Priority: High + +**Preconditions** + +1. gPTP sync completed (AccuracyQualifier == kSynchronized) +2. Test client tool deployed + +**Test Steps** + +1. Call IVehicleTime::Now(), record return value T1 +2. Wait 1s +3. Call Now() again, record T2 +4. Calculate T2 - T1 +5. Execute 10 consecutive times + +**Expected Result** + +- ✓ Each call succeeds without error code +- ✓ T2 > T1 (monotonically increasing) +- ✓ T2 - T1 in range [950ms, 1050ms] (error ≤5%) +- ✓ No crash or exception in all 10 calls + + +TC-FR3-002 — Vehicle Time Has Nanosecond Resolution +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +:Type: System Function +:Method: Test Tool +:Priority: High + +**Preconditions** + +1. gPTP sync completed +2. Test client tool available + +**Test Steps** + +1. Rapidly call Now() 10 consecutive times +2. Record complete time value returned each time (including nanosecond portion) +3. Check difference between adjacent return values + +**Expected Result** + +- ✓ Return value contains non-zero nanosecond field +- ✓ Difference between adjacent calls > 0 (time is advancing) +- ✓ Difference value consistent with actual call interval, precision at microsecond level + + +TC-FR3-003 — Vehicle Time Aligned with gPTP Master Clock +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +:Type: System Function +:Method: Test Tool + Clock Comparison +:Priority: High + +**Preconditions** + +1. gPTP sync completed +2. Current gPTP Master time is known +3. Test tool available + +**Test Steps** + +1. Read current time T_master from gPTP Master device +2. Immediately read IVehicleTime::Now() from local device to get T_local +3. Calculate ``abs(T_local - T_master)`` +4. Repeat 5 times + +**Expected Result** + +- ✓ ``abs(T_local - T_master)`` is within acceptable range (accounting for read operation latency) +- ✓ 5 results are stable, no random jumps + +FR-4 Vehicle Time Base Accuracy Qualifier +----------------------------------------- + + +TC-FR4-001 — AccuracyQualifier State: kNoTime +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +:Type: System Function +:Method: Test Tool + Log Verification +:Priority: High + +**Preconditions** + +1. No gPTP Master in network +2. score::time service just started (first run, never synced) +3. Test tool available + +**Test Steps** + +1. Start score::time service in environment without Master +2. Wait 10s +3. Query GetAccuracyQualifier() return value +4. Simultaneously check state record in log + +**Expected Result** + +- ✓ GetAccuracyQualifier() returns kNoTime +- ✓ Corresponding kNoTime state record present in log +- ✓ Now() can still be called in this state (no crash) + + +TC-FR4-002 — AccuracyQualifier State: kSynchronized +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +:Type: System Function +:Method: Test Tool + Log Verification +:Priority: High + +**Preconditions** + +1. Stable gPTP Master available in network +2. Test tool available + +**Test Steps** + +1. Start score::time service, connect to gPTP Master +2. After 60s query GetAccuracyQualifier() +3. View log to confirm state transition (kNoTime → kUnstable → kSynchronized) + +**Expected Result** + +- ✓ GetAccuracyQualifier() returns kSynchronized after 60s +- ✓ State transition process visible in log +- ✓ State transition order is reasonable + + +TC-FR4-003 — AccuracyQualifier State: kTimeJumpDetected +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +:Type: System Function +:Method: Test Tool + Log Verification +:Priority: Medium + +**Preconditions** + +1. Device is in kSynchronized state +2. Large clock jump can be injected (> threshold) + +**Test Steps** + +1. Confirm current state is kSynchronized +2. Inject large time jump (local clock offset from Master > jump detection threshold, e.g., > 1ms) +3. Immediately query GetAccuracyQualifier() +4. Query again after 30s + +**Expected Result** + +- ✓ GetAccuracyQualifier() returns kTimeJumpDetected after jump injection +- ✓ Clock jump detection record present in log +- ✓ System recovers from kTimeJumpDetected after 30s + + +TC-FR4-004 — AccuracyQualifier State: kUnstable +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +:Type: System Function +:Method: Test Tool + Log Verification +:Priority: Medium + +**Preconditions** + +1. gPTP Master signal quality can be degraded (e.g., via network emulator to introduce jitter) +2. Test tool available + +**Test Steps** + +1. Device is in kSynchronized state +2. Introduce persistent high jitter or intermittent packet loss to gPTP network +3. Wait 20s, query GetAccuracyQualifier() +4. Restore network quality, wait 60s, query again + +**Expected Result** + +- ✓ GetAccuracyQualifier() returns kUnstable during degradation period +- ✓ Log contains accuracy instability records +- ✓ State returns to kSynchronized after network recovery + +FR-5 Vehicle Time Base Time Point Qualifier +------------------------------------------- + + +TC-FR5-001 — TimePointQualifier ASIL Safety Level Query +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +:Type: System Function +:Method: Test Tool +:Priority: Medium + +**Preconditions** + +1. score::time service running +2. ASIL-B safety clock source configured +3. Test tool available + +**Test Steps** + +1. Query GetTimePointQualifier() when safety clock source is normal +2. Simulate safety clock source failure (or degrade to QM source) +3. Query GetTimePointQualifier() again + +**Expected Result** + +- ✓ Returns kASIL_B when safety clock source is normal +- ✓ Degrades to kQM after safety clock source failure +- ✓ State changes are logged + +FR-6 Vehicle Time Control Flow +------------------------------ + + +TC-FR6-001 — Now() Call Performance (Low Latency) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +:Type: Performance +:Method: Test Tool +:Priority: Medium + +**Preconditions** + +1. score::time service running +2. Test tool supports high-frequency calls and timing statistics + +**Test Steps** + +1. Continuously call IVehicleTime::Now() 1000 times +2. Record each call latency +3. Calculate: average latency, P99 latency, max latency + +**Expected Result** + +- ✓ Average call latency < 1 μs +- ✓ P99 latency < 5 μs +- ✓ No single call exceeds 100 μs (no kernel syscall blocking) + + +Note: If latency is significantly high (>10 μs average), shared memory mechanism may not be working + +FR-7 Vehicle Time Synchronization Logging +----------------------------------------- + + +TC-FR7-001 — Sync State Change Log Recording +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +:Type: Manual Acceptance +:Method: Log Verification +:Priority: High + +**Preconditions** + +1. Device logs accessible +2. Network environment controllable (can disconnect/restore gPTP Master) + +**Test Steps** + +1. Clear or mark current log position +2. Disconnect gPTP Master network, wait 30s +3. Restore Master network, wait 60s +4. View log, search keywords: AccuracyQualifier, sync, kSynchronized, kNoTime, kUnstable + +**Expected Result** + +- ✓ Log contains AccuracyQualifier state change records (with timestamp) +- ✓ Degradation log present when Master disconnects +- ✓ Re-sync log present when Master restores +- ✓ Log timestamp format is correct + + +TC-FR7-002 — Sync Statistics Log (Offset/Frequency) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +:Type: Manual Acceptance +:Method: Log Verification +:Priority: Medium + +**Preconditions** + +1. Device in sync state, logs accessible + +**Test Steps** + +1. Run for 10 minutes, view periodic sync statistics in log +2. Search keywords: offset, rate, correction, pDelay + +**Expected Result** + +- ✓ Log contains periodically recorded clock offset values +- ✓ Rate correction (rateCorrection) or path delay (pDelay) logs present +- ✓ Values within reasonable range, no abnormal values + + +TC-FR7-003 — Logging Does Not Block Sync Main Process +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +:Type: Manual Acceptance +:Method: Log Verification + Clock Comparison +:Priority: Low + +**Preconditions** + +1. Device in sync state + +**Test Steps** + +1. Monitor both log output and sync accuracy (offset) simultaneously +2. Measure sync accuracy during high-frequency log output (debug level) +3. Disable verbose logging, measure accuracy again +4. Compare accuracy difference between the two modes + +**Expected Result** + +- ✓ Sync accuracy not significantly degraded with verbose logging enabled (offset increase < 50 μs) +- ✓ Log thread does not affect real-time performance of sync main thread + +FR-8 score::time External Synchronization +----------------------------------------- + + +TC-FR8-001 — NTP Sync Source Configuration and Connection +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +:Type: System Function +:Method: Log Verification +:Priority: Medium + +**Preconditions** + +1. NTP Server accessible in network +2. score::time NTP function configuration enabled +3. Logs accessible + +**Test Steps** + +1. Configure NTP Server address +2. Restart score::time service +3. Wait 120s +4. Check NTP sync status in log (search: NTP, AbsoluteTime, synchronized) + +**Expected Result** + +- ✓ Log shows NTP sync success record +- ✓ No persistent NTP connection failure errors in log +- ✓ AbsoluteTime-related log has state update records + + +TC-FR8-002 — Fallback Behavior When NTP Server Unreachable +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +:Type: System Function +:Method: Log Verification +:Priority: Medium + +**Preconditions** + +1. NTP function enabled +2. NTP Server address configured as unreachable + +**Test Steps** + +1. Configure NTP Server to unreachable address (e.g., 192.0.2.1) +2. Restart service, wait 120s +3. Check AbsoluteTime AccuracyQualifier status in log + +**Expected Result** + +- ✓ Log contains NTP connection failure record +- ✓ IAbsoluteTime AccuracyQualifier does not enter synchronized state +- ✓ Service does not crash, continues providing other functions + +FR-9 Absolute Time Base API +--------------------------- + + +TC-FR9-001 — IAbsoluteTime::Now() Returns UTC Time +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +:Type: System Function +:Method: Test Tool +:Priority: Medium + +**Preconditions** + +1. NTP sync completed +2. Test tool available +3. Accurate UTC time known (confirmed via phone or other device) + +**Test Steps** + +1. Call IAbsoluteTime::Now() +2. Record returned UTC time +3. Compare with UTC time displayed on reference device + +**Expected Result** + +- ✓ Return value is valid UTC timestamp (UNIX Epoch format, not 0) +- ✓ Offset from reference UTC time < 1s (NTP accuracy range) +- ✓ Time value monotonically increasing across multiple calls + +FR-10 Absolute Time Base Accuracy Qualifier +------------------------------------------- + + +TC-FR10-001 — Absolute Time AccuracyQualifier State Verification +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +:Type: System Function +:Method: Test Tool + Log Verification +:Priority: Medium + +**Preconditions** + +1. Test tool available +2. NTP sync state controllable + +**Test Steps** + +1. Query IAbsoluteTime GetAccuracyQualifier() when NTP not synced, record state +2. Query again after NTP sync completed +3. View log records of absolute time accuracy + +**Expected Result** + +- ✓ Returns appropriate low accuracy level when NTP not synced +- ✓ Accuracy level improves after NTP sync +- ✓ Accuracy level changes are logged + +FR-11 Absolute Time Base Security Qualifier +------------------------------------------- + + +TC-FR11-001 — Absolute Time SecurityQualifier State Verification +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +:Type: System Function +:Method: Test Tool + Log Verification +:Priority: Medium + +**Preconditions** + +1. Test tool available +2. Different security level clock sources can be simulated + +**Test Steps** + +1. Query IAbsoluteTime GetSecurityQualifier() when using unauthenticated NTP source +2. Query again when using authenticated/secure NTP source +3. View security level records in log + +**Expected Result** + +Security levels (low to high): ``NoTimeAvailable``, ``NotTrustworthy``, ``Trustworthy``, ``VeryTrustworthy`` + +- ✓ Returns corresponding security level for different security sources +- ✓ State changes are logged + +FR-12 Absolute Time Synchronization Status Log +---------------------------------------------- + + +TC-FR12-001 — Absolute Time Sync Log Recording +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +:Type: Manual Acceptance +:Method: Log Verification +:Priority: Low + +**Preconditions** + +1. NTP sync function enabled +2. Logs accessible + +**Test Steps** + +1. Perform NTP sync operation (restart service to re-sync) +2. View log, search: AbsoluteTime, NTP, UTC +3. Check log content completeness + +**Expected Result** + +- ✓ Log contains NTP sync start/completion records +- ✓ Absolute time accuracy level change records present +- ✓ Security level status records present +- ✓ Log format includes timestamp + +FR-13 High Precision Clock API +------------------------------ + + +TC-FR13-001 — HighPrecisionClock::Now() Returns High Precision Time +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +:Type: System Function +:Method: Test Tool +:Priority: Medium + +**Preconditions** + +1. Test tool available +2. System clock (CLOCK_REALTIME) synchronized + +**Test Steps** + +1. Call HighPrecisionClockImpl::Now() +2. Record returned time value (precise to nanoseconds) +3. Compare with system clock_gettime(CLOCK_REALTIME) return value +4. Call 10 consecutive times, confirm monotonicity + +**Expected Result** + +- ✓ Return value differs from system CLOCK_REALTIME time by < 1ms +- ✓ Return value has nanosecond precision +- ✓ 10 consecutive calls are monotonically increasing +- ✓ No call failures + + +TC-FR13-002 — Time Relationship Between HighPrecisionClock and VehicleTime +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +:Type: System Function +:Method: Test Tool +:Priority: Low + +**Preconditions** + +1. gPTP sync completed +2. Test tool can read both interfaces simultaneously + +**Test Steps** + +1. Simultaneously call HighPrecisionClockImpl::Now() and IVehicleTime::Now() +2. Calculate difference between them +3. Repeat 5 times + +**Expected Result** + +- ✓ Difference is stable (fixed offset, not randomly varying) +- ✓ Variance of difference < 100 μs (indicating both synced to same clock domain) + +FR-14 Monotonic Clock API +------------------------- + + +TC-FR14-001 — MonotonicClock::Now() Monotonicity Verification +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +:Type: System Function +:Method: Test Tool +:Priority: High + +**Preconditions** + +1. Test tool available + +**Test Steps** + +1. Call MonotonicClockImpl::Now() 20 times at 100ms intervals +2. Record each return value +3. Check if sequence is strictly increasing + +**Expected Result** + +- ✓ All 20 return values strictly increasing (T[i+1] > T[i]) +- ✓ Adjacent differences approximately 100ms (error < 5%) +- ✓ No wraparound or jumps + + +TC-FR14-002 — MonotonicClock Maintains Monotonicity During System Clock Adjustment +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +:Type: System Function +:Method: Test Tool +:Priority: High + +**Preconditions** + +1. Test tool available +2. Permission to adjust system clock (date -s or chronyc makestep) + +**Test Steps** + +1. Start continuous sampling of MonotonicClock::Now() at 50ms intervals +2. Execute system time jump during sampling (e.g., advance clock by 5s) +3. Continue sampling for 30s +4. Check monotonicity of complete sample sequence + +**Expected Result** + +- ✓ Entire sample sequence (including during clock jump) is strictly monotonically increasing +- ✓ MonotonicClock is not affected by system clock adjustment + + +TC-FR14-003 — MonotonicClock Corresponds to CLOCK_MONOTONIC +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +:Type: System Function +:Method: Test Tool +:Priority: Medium + +**Preconditions** + +1. Test tool available +2. Can read system CLOCK_MONOTONIC at the same time + +**Test Steps** + +1. Simultaneously call MonotonicClockImpl::Now() and system clock_gettime(CLOCK_MONOTONIC) +2. Compare two return values +3. Repeat 5 times + +**Expected Result** + +- ✓ Two values approximately equal (difference < 1ms) +- ✓ Both increase at the same rate + +FR-15 score::time Mocking APIs +------------------------------ + + +TC-FR15-001 — ManualVehicleTime Can Set Time Manually +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +:Type: System Function +:Method: Test Tool +:Priority: Medium + +**Preconditions** + +1. score::time service started in Mock mode (ManualVehicleTime implementation) +2. Test tool available + +**Test Steps** + +1. Set ManualVehicleTime to specified time T_set (e.g., 2024-01-01 12:00:00) +2. Call IVehicleTime::Now(), record T_read +3. Wait 1s, call Now() again, record T_read2 + +**Expected Result** + +- ✓ T_read == T_set (allow < 1ms error) +- ✓ T_read2 == T_set (time does not advance automatically unless manually advanced) +- ✓ Does not depend on real gPTP network + + +TC-FR15-002 — ManualVehicleTime Time Can Be Manually Advanced +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +:Type: System Function +:Method: Test Tool +:Priority: Medium + +**Preconditions** + +1. Mock mode started, ManualVehicleTime initial time set +2. Test tool available + +**Test Steps** + +1. Record current ManualVehicleTime value T0 +2. Advance time by +500ms via test tool +3. Call Now(), record T1 +4. Advance by +1s more +5. Call Now(), record T2 + +**Expected Result** + +- ✓ T1 - T0 == 500ms (error < 1ms) +- ✓ T2 - T1 == 1s (error < 1ms) +- ✓ Time advancement is controllable, not affected by system clock + + +TC-FR15-003 — ManualVehicleTime AccuracyQualifier Can Be Set Manually +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +:Type: System Function +:Method: Test Tool +:Priority: Medium + +**Preconditions** + +1. Mock mode started + +**Test Steps** + +1. Set AccuracyQualifier to kNoTime, confirm with GetAccuracyQualifier() +2. Set to kSynchronized, confirm again +3. Set to kUnstable, confirm again + +**Expected Result** + +- ✓ All 3 settings take effect, GetAccuracyQualifier() return value matches set value +- ✓ State switching causes no crash + + +TC-FR15-004 — ManualAbsoluteTime Can Set UTC Time +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +:Type: System Function +:Method: Test Tool +:Priority: Low + +**Preconditions** + +1. Mock mode started (ManualAbsoluteTime implementation) +2. Test tool available + +**Test Steps** + +1. Set ManualAbsoluteTime to specified UTC time +2. Call IAbsoluteTime::Now(), verify return value +3. Set SecurityQualifier to Trustworthy, verify GetSecurityQualifier() return value + +**Expected Result** + +- ✓ IAbsoluteTime::Now() returns the set UTC time +- ✓ GetSecurityQualifier() returns Trustworthy +- ✓ Function decoupled from real NTP sync behavior + + +TC-FR15-005 — ManualMonotonicClock Isolation in Unit Tests +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +:Type: Manual Acceptance +:Method: Test Tool +:Priority: Low + +**Preconditions** + +1. Unit test framework configured to use Mock implementation +2. No real hardware environment required + +**Test Steps** + +1. Run unit tests using ManualMonotonicClock +2. Manually set and advance time in tests, verify time-related logic +3. Confirm tests do not depend on system time + +**Expected Result** + +- ✓ Unit tests pass without gPTP/NTP network environment +- ✓ Test execution time not affected by system clock +- ✓ Mock object behavior consistent with interface specification diff --git a/docs/time/_assets/app/app_class.puml b/docs/features/time_daemon/_assets/app/app_class.puml similarity index 100% rename from docs/time/_assets/app/app_class.puml rename to docs/features/time_daemon/_assets/app/app_class.puml diff --git a/docs/time/_assets/app/app_init_seq.puml b/docs/features/time_daemon/_assets/app/app_init_seq.puml similarity index 100% rename from docs/time/_assets/app/app_init_seq.puml rename to docs/features/time_daemon/_assets/app/app_init_seq.puml diff --git a/docs/time/_assets/app/app_workflow_seq.puml b/docs/features/time_daemon/_assets/app/app_workflow_seq.puml similarity index 100% rename from docs/time/_assets/app/app_workflow_seq.puml rename to docs/features/time_daemon/_assets/app/app_workflow_seq.puml diff --git a/docs/time/_assets/ctrlflow/ctrlflow_class.puml b/docs/features/time_daemon/_assets/ctrlflow/ctrlflow_class.puml similarity index 100% rename from docs/time/_assets/ctrlflow/ctrlflow_class.puml rename to docs/features/time_daemon/_assets/ctrlflow/ctrlflow_class.puml diff --git a/docs/time/_assets/ctrlflow/ctrlflow_init_seq.puml b/docs/features/time_daemon/_assets/ctrlflow/ctrlflow_init_seq.puml similarity index 100% rename from docs/time/_assets/ctrlflow/ctrlflow_init_seq.puml rename to docs/features/time_daemon/_assets/ctrlflow/ctrlflow_init_seq.puml diff --git a/docs/time/_assets/ctrlflow/ctrlflow_workflow_seq.puml b/docs/features/time_daemon/_assets/ctrlflow/ctrlflow_workflow_seq.puml similarity index 100% rename from docs/time/_assets/ctrlflow/ctrlflow_workflow_seq.puml rename to docs/features/time_daemon/_assets/ctrlflow/ctrlflow_workflow_seq.puml diff --git a/docs/time/_assets/dd_class.puml b/docs/features/time_daemon/_assets/dd_class.puml similarity index 100% rename from docs/time/_assets/dd_class.puml rename to docs/features/time_daemon/_assets/dd_class.puml diff --git a/docs/time/_assets/dd_data_control_flow.puml b/docs/features/time_daemon/_assets/dd_data_control_flow.puml similarity index 100% rename from docs/time/_assets/dd_data_control_flow.puml rename to docs/features/time_daemon/_assets/dd_data_control_flow.puml diff --git a/docs/time/_assets/dd_deployment.puml b/docs/features/time_daemon/_assets/dd_deployment.puml similarity index 100% rename from docs/time/_assets/dd_deployment.puml rename to docs/features/time_daemon/_assets/dd_deployment.puml diff --git a/docs/time/_assets/examples/abs_time/abs_time_data_control_flow.puml b/docs/features/time_daemon/_assets/examples/abs_time/abs_time_data_control_flow.puml similarity index 100% rename from docs/time/_assets/examples/abs_time/abs_time_data_control_flow.puml rename to docs/features/time_daemon/_assets/examples/abs_time/abs_time_data_control_flow.puml diff --git a/docs/time/_assets/examples/abs_time/abs_time_deployment.puml b/docs/features/time_daemon/_assets/examples/abs_time/abs_time_deployment.puml similarity index 100% rename from docs/time/_assets/examples/abs_time/abs_time_deployment.puml rename to docs/features/time_daemon/_assets/examples/abs_time/abs_time_deployment.puml diff --git a/docs/time/_assets/examples/qvt/qvt_data_control_flow.puml b/docs/features/time_daemon/_assets/examples/qvt/qvt_data_control_flow.puml similarity index 100% rename from docs/time/_assets/examples/qvt/qvt_data_control_flow.puml rename to docs/features/time_daemon/_assets/examples/qvt/qvt_data_control_flow.puml diff --git a/docs/time/_assets/examples/qvt/qvt_deployment.puml b/docs/features/time_daemon/_assets/examples/qvt/qvt_deployment.puml similarity index 100% rename from docs/time/_assets/examples/qvt/qvt_deployment.puml rename to docs/features/time_daemon/_assets/examples/qvt/qvt_deployment.puml diff --git a/docs/time/_assets/ipc/ipc_class.puml b/docs/features/time_daemon/_assets/ipc/ipc_class.puml similarity index 100% rename from docs/time/_assets/ipc/ipc_class.puml rename to docs/features/time_daemon/_assets/ipc/ipc_class.puml diff --git a/docs/time/_assets/ipc/ipc_init_seq.puml b/docs/features/time_daemon/_assets/ipc/ipc_init_seq.puml similarity index 100% rename from docs/time/_assets/ipc/ipc_init_seq.puml rename to docs/features/time_daemon/_assets/ipc/ipc_init_seq.puml diff --git a/docs/time/_assets/ipc/ipc_publish_seq.puml b/docs/features/time_daemon/_assets/ipc/ipc_publish_seq.puml similarity index 100% rename from docs/time/_assets/ipc/ipc_publish_seq.puml rename to docs/features/time_daemon/_assets/ipc/ipc_publish_seq.puml diff --git a/docs/time/_assets/ipc/ipc_receive_seq.puml b/docs/features/time_daemon/_assets/ipc/ipc_receive_seq.puml similarity index 100% rename from docs/time/_assets/ipc/ipc_receive_seq.puml rename to docs/features/time_daemon/_assets/ipc/ipc_receive_seq.puml diff --git a/docs/time/_assets/msg_broker/msg_broker_class.puml b/docs/features/time_daemon/_assets/msg_broker/msg_broker_class.puml similarity index 100% rename from docs/time/_assets/msg_broker/msg_broker_class.puml rename to docs/features/time_daemon/_assets/msg_broker/msg_broker_class.puml diff --git a/docs/time/_assets/msg_broker/msg_broker_init_seq.puml b/docs/features/time_daemon/_assets/msg_broker/msg_broker_init_seq.puml similarity index 100% rename from docs/time/_assets/msg_broker/msg_broker_init_seq.puml rename to docs/features/time_daemon/_assets/msg_broker/msg_broker_init_seq.puml diff --git a/docs/time/_assets/msg_broker/msg_broker_workflow_seq.puml b/docs/features/time_daemon/_assets/msg_broker/msg_broker_workflow_seq.puml similarity index 100% rename from docs/time/_assets/msg_broker/msg_broker_workflow_seq.puml rename to docs/features/time_daemon/_assets/msg_broker/msg_broker_workflow_seq.puml diff --git a/docs/time/_assets/mw/mw_class.puml b/docs/features/time_daemon/_assets/mw/mw_class.puml similarity index 100% rename from docs/time/_assets/mw/mw_class.puml rename to docs/features/time_daemon/_assets/mw/mw_class.puml diff --git a/docs/time/_assets/mw/mw_time_receive_seq.puml b/docs/features/time_daemon/_assets/mw/mw_time_receive_seq.puml similarity index 100% rename from docs/time/_assets/mw/mw_time_receive_seq.puml rename to docs/features/time_daemon/_assets/mw/mw_time_receive_seq.puml diff --git a/docs/time/_assets/mw/mw_time_receive_simple_seq.puml b/docs/features/time_daemon/_assets/mw/mw_time_receive_simple_seq.puml similarity index 100% rename from docs/time/_assets/mw/mw_time_receive_simple_seq.puml rename to docs/features/time_daemon/_assets/mw/mw_time_receive_simple_seq.puml diff --git a/docs/time/_assets/ptp_machine/ptp_machine_class.puml b/docs/features/time_daemon/_assets/ptp_machine/ptp_machine_class.puml similarity index 100% rename from docs/time/_assets/ptp_machine/ptp_machine_class.puml rename to docs/features/time_daemon/_assets/ptp_machine/ptp_machine_class.puml diff --git a/docs/time/_assets/ptp_machine/ptp_machine_get_new_data_seq.puml b/docs/features/time_daemon/_assets/ptp_machine/ptp_machine_get_new_data_seq.puml similarity index 100% rename from docs/time/_assets/ptp_machine/ptp_machine_get_new_data_seq.puml rename to docs/features/time_daemon/_assets/ptp_machine/ptp_machine_get_new_data_seq.puml diff --git a/docs/time/_assets/ptp_machine/ptp_machine_init_seq.puml b/docs/features/time_daemon/_assets/ptp_machine/ptp_machine_init_seq.puml similarity index 100% rename from docs/time/_assets/ptp_machine/ptp_machine_init_seq.puml rename to docs/features/time_daemon/_assets/ptp_machine/ptp_machine_init_seq.puml diff --git a/docs/time/_assets/sad_deployment.puml b/docs/features/time_daemon/_assets/sad_deployment.puml similarity index 100% rename from docs/time/_assets/sad_deployment.puml rename to docs/features/time_daemon/_assets/sad_deployment.puml diff --git a/docs/time/_assets/ver_machine/ver_class.puml b/docs/features/time_daemon/_assets/ver_machine/ver_class.puml similarity index 100% rename from docs/time/_assets/ver_machine/ver_class.puml rename to docs/features/time_daemon/_assets/ver_machine/ver_class.puml diff --git a/docs/time/_assets/ver_machine/ver_init_seq.puml b/docs/features/time_daemon/_assets/ver_machine/ver_init_seq.puml similarity index 100% rename from docs/time/_assets/ver_machine/ver_init_seq.puml rename to docs/features/time_daemon/_assets/ver_machine/ver_init_seq.puml diff --git a/docs/time/_assets/ver_machine/ver_verification_seq.puml b/docs/features/time_daemon/_assets/ver_machine/ver_verification_seq.puml similarity index 100% rename from docs/time/_assets/ver_machine/ver_verification_seq.puml rename to docs/features/time_daemon/_assets/ver_machine/ver_verification_seq.puml diff --git a/docs/time/index.rst b/docs/features/time_daemon/index.rst similarity index 99% rename from docs/time/index.rst rename to docs/features/time_daemon/index.rst index aa2d3873..c2b4b50b 100644 --- a/docs/time/index.rst +++ b/docs/features/time_daemon/index.rst @@ -1,12 +1,12 @@ Concept for TimeDaemon -====================== +======================= .. contents:: Table of Contents :depth: 3 :local: TimeDaemon concept ------------------- +------------------- Use Cases ~~~~~~~~~ diff --git a/docs/TimeSlave/_assets/gptp_engine/gptp_engine_class.puml b/docs/features/time_slave/_assets/gptp_engine/gptp_engine_class.puml similarity index 90% rename from docs/TimeSlave/_assets/gptp_engine/gptp_engine_class.puml rename to docs/features/time_slave/_assets/gptp_engine/gptp_engine_class.puml index f079879b..39209e23 100644 --- a/docs/TimeSlave/_assets/gptp_engine/gptp_engine_class.puml +++ b/docs/features/time_slave/_assets/gptp_engine/gptp_engine_class.puml @@ -18,8 +18,8 @@ package "score::ts::details" { - opts_ : GptpEngineOptions - rx_thread_ : std::thread - pdelay_thread_ : std::thread - - socket_ : unique_ptr - - identity_ : unique_ptr + - socket_ : unique_ptr + - identity_ : unique_ptr - codec_ : FrameCodec - parser_ : GptpMessageParser - sync_sm_ : SyncStateMachine @@ -34,7 +34,7 @@ package "score::ts::details" { + ReadPTPSnapshot(data : GptpIpcData&) : bool } - interface IRawSocket #LightSkyBlue { + interface RawSocket #LightSkyBlue { + Open(iface) : bool + EnableHwTimestamping() : bool + Recv(buf, timeout_ms) : RecvResult @@ -51,7 +51,7 @@ package "score::ts::details" { QNX raw-socket shim } - interface INetworkIdentity #LightSkyBlue { + interface NetworkIdentity #LightSkyBlue { + Resolve(iface) : bool + GetClockIdentity() : ClockIdentity + GetMac() : MacAddress @@ -101,13 +101,13 @@ package "score::ts::details" { + step_threshold_ns : int64_t = 100000000 } - IRawSocket <|.. LinuxSocket - IRawSocket <|.. QnxSocket - INetworkIdentity <|.. NetworkIdentity + RawSocket <|.. LinuxSocket + RawSocket <|.. QnxSocket + NetworkIdentity <|.. NetworkIdentity PhcAdjuster *-- PhcConfig - GptpEngine *-- IRawSocket - GptpEngine *-- INetworkIdentity + GptpEngine *-- RawSocket + GptpEngine *-- NetworkIdentity GptpEngine *-- FrameCodec GptpEngine *-- GptpMessageParser GptpEngine *-- SyncStateMachine diff --git a/docs/TimeSlave/_assets/gptp_engine/gptp_threading.puml b/docs/features/time_slave/_assets/gptp_engine/gptp_threading.puml similarity index 100% rename from docs/TimeSlave/_assets/gptp_engine/gptp_threading.puml rename to docs/features/time_slave/_assets/gptp_engine/gptp_threading.puml diff --git a/docs/TimeSlave/_assets/shm_ptp_engine/shm_ptp_engine_class.puml b/docs/features/time_slave/_assets/shm_ptp_engine/shm_ptp_engine_class.puml similarity index 100% rename from docs/TimeSlave/_assets/shm_ptp_engine/shm_ptp_engine_class.puml rename to docs/features/time_slave/_assets/shm_ptp_engine/shm_ptp_engine_class.puml diff --git a/docs/TimeSlave/_assets/shm_ptp_engine/shm_ptp_engine_init_seq.puml b/docs/features/time_slave/_assets/shm_ptp_engine/shm_ptp_engine_init_seq.puml similarity index 100% rename from docs/TimeSlave/_assets/shm_ptp_engine/shm_ptp_engine_init_seq.puml rename to docs/features/time_slave/_assets/shm_ptp_engine/shm_ptp_engine_init_seq.puml diff --git a/docs/TimeSlave/_assets/shm_ptp_engine/shm_ptp_engine_read_seq.puml b/docs/features/time_slave/_assets/shm_ptp_engine/shm_ptp_engine_read_seq.puml similarity index 100% rename from docs/TimeSlave/_assets/shm_ptp_engine/shm_ptp_engine_read_seq.puml rename to docs/features/time_slave/_assets/shm_ptp_engine/shm_ptp_engine_read_seq.puml diff --git a/docs/TimeSlave/_assets/timeslave_class.puml b/docs/features/time_slave/_assets/timeslave_class.puml similarity index 86% rename from docs/TimeSlave/_assets/timeslave_class.puml rename to docs/features/time_slave/_assets/timeslave_class.puml index 588766b5..6e2560ab 100644 --- a/docs/TimeSlave/_assets/timeslave_class.puml +++ b/docs/features/time_slave/_assets/timeslave_class.puml @@ -16,22 +16,26 @@ endlegend package "score::ts" { class TimeSlave #LightCyan { - - opts_ : GptpEngineOptions - - engine_ : unique_ptr - - publisher_ : GptpIpcPublisher + - opts_ : details::GptpEngineOptions + - engine_ : unique_ptr + - publisher_ : details::GptpIpcPublisher + Initialize(ctx) : int32_t + Run(stop_token) : int32_t } +} + +package "score::ts::details" { + class GptpEngine #LightSalmon { - opts_ : GptpEngineOptions - rx_thread_ : std::thread - pdelay_thread_ : std::thread - sync_sm_ : SyncStateMachine - - pdelay_ : PeerDelayMeasurer - - phc_adjuster_ : PhcAdjuster - - socket_ : unique_ptr - - identity_ : unique_ptr + - pdelay_ : unique_ptr + - phc_ : PhcAdjuster + - socket_ : unique_ptr + - identity_ : unique_ptr - codec_ : FrameCodec - parser_ : GptpMessageParser - snapshot_mutex_ : std::mutex @@ -44,17 +48,14 @@ package "score::ts" { } struct GptpEngineOptions #Beige { - + iface_name : string = "eth0" + + iface_name : string = "emac0" + pdelay_interval_ms : int = 1000 + pdelay_warmup_ms : int = 2000 + sync_timeout_ms : int = 3300 + jump_future_threshold_ns : int64_t = 500000000 + + phc_config : PhcConfig = {} } - TimeSlave *-- GptpEngine -} - -package "score::ts::details" { class FrameCodec #Wheat { + ParseEthernetHeader(frame, frame_len, ptp_offset) : bool + AddEthernetHeader(buf, buf_len, src_mac, buf_capacity) : bool @@ -96,7 +97,8 @@ package "score::ts::details" { class GptpIpcPublisher #LightPink { - region_ : GptpIpcRegion* - - shm_fd_ : int + - shm_resource_ : shared_ptr + - ipc_name_ : string + Init(name) : bool + Publish(data : GptpIpcData) : void + Destroy() : void diff --git a/docs/TimeSlave/_assets/timeslave_data_flow.puml b/docs/features/time_slave/_assets/timeslave_data_flow.puml similarity index 100% rename from docs/TimeSlave/_assets/timeslave_data_flow.puml rename to docs/features/time_slave/_assets/timeslave_data_flow.puml diff --git a/docs/TimeSlave/_assets/timeslave_deployment.puml b/docs/features/time_slave/_assets/timeslave_deployment.puml similarity index 100% rename from docs/TimeSlave/_assets/timeslave_deployment.puml rename to docs/features/time_slave/_assets/timeslave_deployment.puml diff --git a/docs/TimeSlave/_assets/libtsclient/ipc_channel.puml b/docs/features/time_slave/_assets/ts_client/ipc_channel.puml similarity index 92% rename from docs/TimeSlave/_assets/libtsclient/ipc_channel.puml rename to docs/features/time_slave/_assets/ts_client/ipc_channel.puml index ead16c43..ba0ce3c7 100644 --- a/docs/TimeSlave/_assets/libtsclient/ipc_channel.puml +++ b/docs/features/time_slave/_assets/ts_client/ipc_channel.puml @@ -13,7 +13,8 @@ endlegend package "TimeSlave Process" { class GptpIpcPublisher #LightPink { - region_ : GptpIpcRegion* - - shm_fd_ : int + - shm_resource_ : shared_ptr + - ipc_name_ : string + Init(name) : bool + Publish(data : GptpIpcData) : void + Destroy() : void @@ -34,7 +35,7 @@ package "Shared Memory" { package "TimeDaemon Process" { class GptpIpcReceiver #LightPink { - region_ : const GptpIpcRegion* - - shm_fd_ : int + - shm_resource_ : shared_ptr + Init(name) : bool + Receive() : std::optional + Close() : void diff --git a/docs/TimeSlave/_assets/libtsclient/ipc_sequence.puml b/docs/features/time_slave/_assets/ts_client/ipc_sequence.puml similarity index 100% rename from docs/TimeSlave/_assets/libtsclient/ipc_sequence.puml rename to docs/features/time_slave/_assets/ts_client/ipc_sequence.puml diff --git a/docs/TimeSlave/index.rst b/docs/features/time_slave/index.rst similarity index 96% rename from docs/TimeSlave/index.rst rename to docs/features/time_slave/index.rst index 29c56a46..31d2585f 100644 --- a/docs/TimeSlave/index.rst +++ b/docs/features/time_slave/index.rst @@ -225,7 +225,7 @@ The ``GptpEngine`` uses the following synchronization mechanisms: Hardware timestamping fallback ''''''''''''''''''''''''''''''' -During ``Initialize()``, ``GptpEngine`` calls ``IRawSocket::EnableHwTimestamping()`` to request NIC-level receive timestamps (``SO_TIMESTAMPING`` on Linux). If the NIC does not support hardware timestamping, the call returns ``false`` and a warning is logged: +During ``Initialize()``, ``GptpEngine`` calls ``RawSocket::EnableHwTimestamping()`` to request NIC-level receive timestamps (``SO_TIMESTAMPING`` on Linux). If the NIC does not support hardware timestamping, the call returns ``false`` and a warning is logged: .. code-block:: none @@ -406,7 +406,7 @@ The Class Diagram is presented below:
-.. uml:: _assets/libtsclient/ipc_channel.puml +.. uml:: _assets/ts_client/ipc_channel.puml :alt: Class Diagram .. raw:: html @@ -439,7 +439,7 @@ The seqlock protocol workflow is presented in the following sequence diagram:
-.. uml:: _assets/libtsclient/ipc_sequence.puml +.. uml:: _assets/ts_client/ipc_sequence.puml :alt: Seqlock Protocol .. raw:: html @@ -471,7 +471,7 @@ TimeSlave supports two target platforms with platform-specific implementations s - ``CLOCK_MONOTONIC`` via ``clock_gettime()`` - QNX ``ClockCycles()`` CPU instruction (reads hardware performance counter directly, equivalent to ``RDTSC`` on x86 / ``CNTVCT`` on ARM64), converted to nanoseconds via cycles-per-second calibration. Used instead of ``clock_gettime()`` because QNX ``CLOCK_MONOTONIC`` resolution is limited to microsecond level, whereas ``ClockCycles()`` provides nanosecond-level precision with no syscall overhead. -The ``IRawSocket`` and ``INetworkIdentity`` interfaces provide the abstraction boundary. Platform-specific source files are organized under ``score/TimeSlave/code/gptp/platform/linux/`` and ``score/TimeSlave/code/gptp/platform/qnx/``. +The ``RawSocket`` and ``NetworkIdentity`` interfaces provide the abstraction boundary. Platform-specific source files are organized under ``score/time_slave/src/gptp/platform/linux/`` and ``score/time_slave/src/gptp/platform/qnx/``. Instrumentation ~~~~~~~~~~~~~~~~ @@ -655,13 +655,13 @@ The TimeSlave architecture supports the following extensibility points: Platform extensibility '''''''''''''''''''''' -1. New target platforms can be supported by implementing the ``IRawSocket`` and ``INetworkIdentity`` interfaces under a new ``platform//`` directory and selecting the implementation via ``Bazel select()`` +1. New target platforms can be supported by implementing the ``RawSocket`` and ``NetworkIdentity`` interfaces under a new ``platform//`` directory and selecting the implementation via ``Bazel select()`` 2. The ``PhcAdjuster`` platform implementations (``clock_adjtime`` on Linux, EMAC ioctls on QNX) can be extended for additional hardware without changing protocol logic Protocol extensibility '''''''''''''''''''''' -1. The ``GptpEngine`` accepts injected ``IRawSocket`` and ``INetworkIdentity`` dependencies, making it straightforward to test or replace individual platform abstractions +1. The ``GptpEngine`` accepts injected ``RawSocket`` and ``NetworkIdentity`` dependencies, making it straightforward to test or replace individual platform abstractions 2. The shared memory IPC channel name is configurable (``GptpIpcPublisher::Init(name)`` / ``GptpIpcReceiver::Init(name)``), allowing multiple gPTP instances per ECU if needed TimeDaemon integration extensibility @@ -804,10 +804,10 @@ The ``TimeSlave`` and its constituent components can be tested on an x86 Linux h * - Abstraction - Production implementation - Test replacement - * - ``IRawSocket`` + * - ``RawSocket`` - ``RawSocket`` (AF_PACKET) - ``FakeSocket`` (push-based frame queue) - * - ``INetworkIdentity`` + * - ``NetworkIdentity`` - ``NetworkIdentity`` (ioctl) - ``FakeIdentity`` (fixed clock identity) * - ``HighPrecisionLocalSteadyClock`` @@ -819,7 +819,6 @@ The ``GptpEngine`` provides a dedicated test constructor that accepts injected i .. code-block:: cpp GptpEngine engine(opts, - std::make_unique(), std::make_unique(), std::make_unique()); diff --git a/docs/index.rst b/docs/index.rst index 03e6a297..b21c00bd 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -12,10 +12,10 @@ # SPDX-License-Identifier: Apache-2.0 # ******************************************************************************* -TimeDaemon Documentation -======================== +time_daemon Documentation +========================= -This documentation describes the **TimeDaemon** and the **score::time** module. +This documentation describes the **time_daemon** and the **score::time** module. .. contents:: Table of Contents :depth: 2 @@ -24,36 +24,37 @@ This documentation describes the **TimeDaemon** and the **score::time** module. Overview -------- -**TimeDaemon** is a non-AUTOSAR adaptive process designed to provide synchronized vehicle time to client applications. +**time_daemon** is a non-AUTOSAR adaptive process designed to provide synchronized vehicle time to client applications. It supports multiple time bases including **in-vehicle synchronized time** (PTP - Precision Time Protocol) and **external synchronized time** (absolute time base). The daemon retrieves time information from the respective time sources, verifies and validates the timepoints, and distributes this time information across multiple clients through efficient IPC mechanisms. -The main responsibilities of TimeDaemon include: +The main responsibilities of time_daemon include: - **Providing current Vehicle time** to different applications - **Setting synchronization qualifiers** (e.g., Synchronized, Timeout, etc.) - **Providing diagnostic information** for system monitoring - **Supporting additional verification mechanisms** such as QualifiedVehicleTime (QVT) for safety-critical applications -For a detailed concept and architectural design, please refer to the :doc:`TimeDaemon Concept Documentation