Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information

project = "Module Template Project"
project = "S-CORE Time"
project_url = "https://eclipse-score.github.io/module_template/"
project_prefix = "MODULE_TEMPLATE_"
author = "S-CORE"
Expand Down
39 changes: 25 additions & 14 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
# SPDX-License-Identifier: Apache-2.0
# *******************************************************************************

Module Template Documentation
=============================
TimeDaemon Documentation
========================

This documentation describes the structure, usage and configuration of the Bazel-based C++/Rust module template.
This documentation describes the **TimeDaemon** and the **score::time** module.

.. contents:: Table of Contents
:depth: 2
Expand All @@ -24,20 +24,25 @@ This documentation describes the structure, usage and configuration of the Bazel
Overview
--------

This repository provides a standardized setup for projects using **C++** or **Rust** and **Bazel** as a build system.
It integrates best practices for build, test, CI/CD and documentation.
**TimeDaemon** 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.

Requirements
------------
The main responsibilities of TimeDaemon include:

.. stkh_req:: Example Functional Requirement
:id: stkh_req__docgen_enabled__example
:status: valid
:safety: QM
:security: YES
:reqtype: Functional
:rationale: Ensure documentation builds are possible for all modules
- **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 <time/index>`.

.. toctree::
:maxdepth: 2
:caption: Contents:

time/index

Project Layout
--------------
Expand Down Expand Up @@ -65,6 +70,12 @@ To run tests:

bazel test //tests/...

To build the documentation:

.. code-block:: bash

bazel run //:docs

Configuration
-------------

Expand Down
44 changes: 44 additions & 0 deletions docs/time/_assets/app/app_class.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
@startuml application_class_diagram

title Application: Class Diagram

legend top left
|= Color |= Description |
| <#LightCyan> | TimeDaemon members |
| <#PaleTurquoise> | MessageBroker |
| <#Wheat> | PtpMachine |
| <#LightBlue> | ControlFlowDivider |
| <#Lavender> | VerificationMachine |
| <#LightPink> | IPC components |
endlegend

class "TimeDaemon" as vtd_app #LightCyan {
+std::int32_t Initialize(const ApplicationContext& context) override
+std::int32_t Run(amp::stop_token& token) override
}

class "TimebaseHandler" as tb_handler #LightCyan{
+void Initialize()
+void RunOnce(stop_token&)
+void Stop()
}
note right
There might be multiple TimebaseHandlers
based on amount of supported time bases.
end note

class "MessageBroker" as msg_broker #PaleTurquoise
class "PtpMachine" as ptp_machine #Wheat
class "VerificationMachine" as ver_machine #Lavender
class "ControlFlowDivider" as cf_divider #LightBlue
class "IpcPublisher" as ipc_publisher #LightPink

vtd_app *-- "1..*" tb_handler : owns

tb_handler *-- msg_broker : owns
tb_handler *-- ptp_machine : owns
tb_handler *-- ver_machine : owns
tb_handler *-- cf_divider : owns
tb_handler *-- ipc_publisher : owns

@enduml
71 changes: 71 additions & 0 deletions docs/time/_assets/app/app_init_seq.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
@startuml app_init_seq_diagram

title Application: Initialization Sequence

hide footbox
autoactivate on

autonumber "<font color=red><b>[00]"

legend top left
|= Color |= Description |
|<#LightCyan> | TimeDaemon members |
|<#LightGreen> | Middleware components |
|<#Beige> | SW components |
endlegend

participant "LifecycleManager" as lcm #LightGreen
participant "TimeDaemon" as vtd_app #LightCyan
participant "TimebaseHandler" as tb_handler #LightCyan
participant "Components" as components #Beige

== TimeDaemon Construction ==

lcm -> vtd_app ** : Construct TimeDaemon()
activate vtd_app
vtd_app -> tb_handler ** : create TimebaseHandler()
activate tb_handler

tb_handler -> components ** : create all components
note right of components
TimebaseHandler creates:
- MessageBroker
- PtpMachine
- VerificationMachine
- ControlFlowDivider
- IPCPublisher
end note

tb_handler --> vtd_app : TimebaseHandler instance
deactivate tb_handler
vtd_app --> lcm : TimeDaemon instance
deactivate vtd_app

== Initialization Phase ==

lcm -> vtd_app : Initialize(context)
activate vtd_app

vtd_app -> tb_handler : Initialize()
activate tb_handler

tb_handler -> tb_handler : Setup MessageBroker\nsubscriptions
note right
Connect components via topics:
- input_ptp_data
- raw_ptp_data
- validated_ptp_data
end note

tb_handler --> vtd_app
deactivate tb_handler

vtd_app --> lcm
deactivate vtd_app

note right of tb_handler
All components created and connected,
but not yet started
end note

@enduml
69 changes: 69 additions & 0 deletions docs/time/_assets/app/app_workflow_seq.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
@startuml app_init_seq_diagram

title Application: Initialization Sequence

hide footbox

autonumber "<font color=red><b>[00]"

legend top left
|= Color |= Description |
|<#LightCyan> | TimeDaemon members |
|<#Wheat> | PtpMachine |
|<#LightBlue> | ControlFlowDivider |
|<#LightGreen> | Middleware components |
endlegend

participant "LifecycleManager" as lcm #LightGreen
participant "Application" as vtd_app #LightCyan
participant "TimeBaseHandler" as tb_handler #LightCyan
participant "PtpMachine" as ptp_machine #Wheat
participant "ControlFlowDivider" as cf_divider #LightBlue

== Execution Phase ==

lcm -> vtd_app : Run(stopToken)
activate vtd_app

vtd_app -> tb_handler : RunOnce(stopToken)
activate tb_handler
tb_handler -> ptp_machine : start()
activate ptp_machine
ptp_machine --> tb_handler
deactivate ptp_machine
tb_handler -> cf_divider : start()
activate cf_divider
cf_divider --> tb_handler
deactivate cf_divider
tb_handler --> vtd_app
deactivate tb_handler

note over vtd_app: Monitor stop token\nfor termination request
vtd_app -> vtd_app: wait until stopToken is triggered

vtd_app --> lcm : return when stopped
deactivate vtd_app

== Shutdown Phase ==

lcm -> vtd_app : (stop token triggered)
activate vtd_app
vtd_app -> tb_handler : Stop()
activate tb_handler
tb_handler -> cf_divider : stop(stop token triggered)
activate cf_divider
cf_divider -> cf_divider: join activities
cf_divider --> tb_handler
deactivate cf_divider

tb_handler -> ptp_machine : stop(stop token triggered)
activate ptp_machine
ptp_machine -> ptp_machine: join activities
ptp_machine --> tb_handler
deactivate ptp_machine
tb_handler --> vtd_app
deactivate tb_handler
vtd_app --> lcm
deactivate vtd_app

@enduml
58 changes: 58 additions & 0 deletions docs/time/_assets/ctrlflow/ctrlflow_class.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
@startuml control_flow_divider_class_diagram

title ControlFlowDivider: Class Diagram

legend top left
|= Color |= Description |
| <#Beige> | Base classes |
| <#LightBlue> | ControlFlowDivider |
endlegend

class "PtpTimeInfo" as time_info #Beige {
+ptp: uint64
+local_time: uint64
+status: int
}

abstract class "BaseMachine" as base_machine #Beige {
+GetName(): string
+Init(): bool
}

abstract class "ProactiveMachine" as proactive_machine #Beige {
+Start(): void
+Stop(): void
}

abstract class "EventDrivenMachine" as event_machine #Beige {
+NotifyEvent(): void
#OnEvent(): void
#OnTimeout(): void
}

abstract class "Consumer<T>" as consumer #Beige {
+OnMessage(data: T): void
}

abstract class "Producer<T>" as producer #Beige {
+SetPublishCallback(callback): void
#Publish(data: T): void
}

class "ControlFlowDivider<DataType, BufferSize>" as cfd #LightBlue {
-data_buffer_: circular_buffer<DataType, BufferSize>
+OnMessage(data: DataType): void
+SetPublishCallback(callback): void
#OnEvent(): void
#OnTimeout(): void
}

base_machine <|-- proactive_machine
proactive_machine <|-- event_machine
event_machine <|-- cfd
consumer <|.. cfd
producer <|.. cfd

cfd --> time_info : processes

@enduml
63 changes: 63 additions & 0 deletions docs/time/_assets/ctrlflow/ctrlflow_init_seq.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
@startuml ctrlflow_init_seq_diagram

title ControlFlowDivider: Initialization Sequence

hide footbox

autonumber "<font color=red><b>[00]"

legend top left
|= Color |= Description |
|<#LightCyan> | TimeDaemon members |
|<#PaleTurquoise> | MessageBroker |
|<#LightBlue> | ControlFlowDivider |
endlegend

participant "TimeBaseHandler" as tb_handler #LightCyan
participant "ControlFlowDivider" as cfd #LightBlue
participant "MessageBroker" as broker #PaleTurquoise

== ControlFlowDivider Construction ==

tb_handler -> cfd ** : create(name, timeout)
activate tb_handler
activate cfd
cfd -> cfd : Initialize()
note right
Initialize buffer and
event-driven thread
end note
deactivate cfd
deactivate tb_handler

== Setup Connections ==

tb_handler -> cfd : SetPublishCallback(broker::publish)
activate tb_handler
activate cfd
cfd --> tb_handler
deactivate cfd
deactivate tb_handler

tb_handler -> broker : Subscribe("validated_ptp_data", cfd::OnMessage)
activate tb_handler
activate broker
broker --> tb_handler
deactivate broker
deactivate tb_handler

== Start Processing ==

tb_handler -> cfd : Start()
activate tb_handler
activate cfd
cfd -> cfd : Start thread
note right
Start event-driven thread
waiting for data or timeout
end note
cfd --> tb_handler
deactivate cfd
deactivate tb_handler

@enduml
Loading
Loading