# eclipse-4diac/4diac-forte architecture

> Architecture diagram of the GitHub repository eclipse-4diac/4diac-forte, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-31). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/eclipse-4diac/4diac-forte
- Repository: https://github.com/eclipse-4diac/4diac-forte

## Overview

This project is Eclipse 4diac FORTE – a highly portable runtime environment for executing IEC 61499 control applications. Essentially, it’s a control system runtime written in C++ that has been designed to cater to a multitude of operating systems and hardware targets, especially embedded systems like PLCs.

##### Project Context and Overall Purpose
- Recognize that FORTE is a runtime engine focused on IEC 61499-based control applications.
- Understand that it is built in C++ for portability and supports many operating systems (e.g., POSIX, VxWorks, Win32, and more) with dedicated architecture and communication modules.
- The system incorporates a range of communication protocols (OPC UA, MQTT, Modbus, and others) and various modules (IEC61131-3, arrowhead, ads, etc.) to support industrial control scenarios.

##### File Tree
- Top-level directories such as “src”, “modules”, “arch”, “com”, and “core” indicate a layered architecture.
- The “src” folder contains architecture-specific implementations (e.g., posix, win32, vxworks, etc) that abstract OS-specific features like threading, socket handling, and timing.
- The “com” directory and many subdirectories under “modules” cover communication protocols (HTTP, OPC UA, MQTT, Modbus, ROS, etc.) and other integrated services.
- The “core” directory appears to include the runtime’s heart such as event handling, function block execution, device and IO abstraction, and the underlying common infrastructure.
- Additional folders like “tests” and “systemtests” indicate a well-structured test framework for validating different architectural components and integrations.

##### Main Components
a. Runtime Engine Core
- The central engine responsible for executing IEC 61499 function blocks.
- Includes event handling, function block management, resource management, and execution scheduling.
b. Communication/Interface Layers
- Communication modules under “com” (e.g., HTTP, MQTT, OPC UA, Modbus, Powerlink, etc.) that provide different protocol interfaces.
- Core communication infrastructure inside “core/cominfra” manages data exchange between function blocks or external systems.
c. Device IO and Adapter Abstractions
- The I/O and device abstraction (located within “core/io” and the “modules” subdirectories for ads, i2c_dev, etc.) that enables hardware communication.
d. Platform-Specific Abstractions (Architecture Support)
- The “arch” folder contains implementations for various operating systems/platforms ensuring portability.
- Abstraction (e.g., POSIX, freeRTOS, win32, vxworks) as separate but similar layers that plug into the runtime core.
e. IEC 61131-3 Modules and Additional Function Blocks
- Modules for IEC 61131-3 operations (Arithmetic, Bitwise, Conversion, etc.) provide standardized function block libraries.
f. Extended Modules and Integration Components
- Extra modules (e.g., arrowhead, ads, convert, rt_events, embrick) that integrate specific communication or control capabilities.
g. Build and System Testing Infrastructure
- The existence of extensive “tests”, “systemtests”, and build scripts (CMakeLists, Docker, systemd service definitions) underline the role of automated building, integration, and deployment.

##### Relationships and Data Flow
- The runtime core dispatches events and runs function blocks and communicates with the communication layer.
- Communication modules (in “com” and “modules”) interact directly with the runtime via standardized adapters, converting control commands into protocol-specific messages.
- I/O layers, device communications, and adapters bridge the gap between the external hardware and the control algorithms.
- Testing modules interact with nearly every layer for validation.

##### Architectural Patterns and Design Principles
- Layered Architecture: Separate concerns by isolating platform-specific (arch), runtime core, and protocol/adapter modules.
- Adapter/Facade Patterns: Communication interfaces translate between internal messages and external protocols.
- Modularity & Extensibility: Each module (IEC61131-3, arrowhead, ads, etc.) is developed independently, which supports plug-and-play extensibility.
- Dependency Inversion/Abstraction: High-level runtime interacts with abstract IO and communication interfaces defined in the “core” and “modules” directories.

##### Detailed Steps for the Principal Software Engineer
- Surround it with layers representing the OS abstraction (arch) on one side and the communication modules on the opposite side.
- Branch out additional modules (IEC61131-3, arrowhead, etc.) around these core layers.
- Provide annotations or callouts to note critical design patterns (e.g., adapter usage in com modules) and how the system achieves portability.
- Be as granular as possible in capturing the many components (each directory that corresponds to a key architectural concern should be represented either individually or as part of an aggregated layer).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Build and Testing Infrastructure
    subgraph "Build & Testing"
        BS["Build Scripts & CMake (CMakeLists.txt)"]:::build
        ST["System & Unit Tests (tests/systemtests)"]:::testing
    end

    %% Platform-Specific Abstractions Layer
    subgraph "Platform Abstraction Layer"
        PAP["Platform-Specific Abstractions (arch)"]:::platform
    end

    %% Runtime Core Layer
    subgraph "Runtime Core"
        RC["Runtime Engine Core (src/core)"]:::core
        ComInfra["Core Communication Infrastructure (src/core/cominfra)"]:::core
        IO["Device & IO Abstraction (src/core/io)"]:::core
    end

    %% Communication Layers
    subgraph "Communication Layers"
        CP["Communication Protocol Interfaces (src/com)"]:::comm
    end

    %% IEC 61131-3 Function Block Libraries
    subgraph "IEC 61131-3 Libraries"
        IEC["IEC61131-3 Function Block Libraries (src/modules/IEC61131-3)"]:::module
    end

    %% Extended Modules and Integration Components
    subgraph "Extended Modules"
        Arrowhead["Arrowhead Integration (src/modules/arrowhead)"]:::module
        Convert["Convert Modules (src/modules/convert)"]:::module
        RTE["Real-time Events (src/modules/rt_events)"]:::module
        Embrick["Embrick Modules (src/modules/embrick)"]:::module
        I2C["I2C Device Adapters (src/modules/i2c_dev)"]:::module
        LMS["LMS Event Modules (src/modules/lms_ev3)"]:::module
        ADS["ADS Device Adapter (src/modules/ads)"]:::module
    end

    %% Connections between Build & Testing and Runtime Core
    BS -->|"triggers_build"| RC
    ST -->|"validates"| RC

    %% Platform Abstraction dependencies
    PAP -->|"provides_platform_support"| RC

    %% Communication interactions
    CP -->|"sends/receives"| RC
    RC -->|"uses_infra"| ComInfra
    ComInfra -->|"interfaces_with"| CP

    %% Device IO interactions
    RC -->|"delegates_IO"| IO
    ADS ---|"integrates_with"| IO

    %% IEC 61131-3 integration
    RC -->|"executes_FBs"| IEC

    %% Extended Modules Dependencies
    Arrowhead -->|"integrates_with"| RC
    Convert -->|"integrates_with"| RC
    RTE -->|"notifies"| RC
    Embrick -->|"augments"| RC
    I2C -->|"feeds_IO_data"| IO
    LMS -->|"feeds_IO_data"| IO
    ADS -->|"enhances_IO"| IO

    %% Extended Modules interacting with Communication Layer
    Arrowhead -->|"uses_protocols"| CP
    Convert -->|"uses_protocols"| CP

    %% Click Events
    click RC "https://github.com/eclipse-4diac/4diac-forte/tree/release/src/core"
    click CP "https://github.com/eclipse-4diac/4diac-forte/tree/release/src/com"
    click ComInfra "https://github.com/eclipse-4diac/4diac-forte/tree/release/src/core/cominfra"
    click IO "https://github.com/eclipse-4diac/4diac-forte/tree/release/src/core/io"
    click ADS "https://github.com/eclipse-4diac/4diac-forte/tree/release/src/modules/ads"
    click PAP "https://github.com/eclipse-4diac/4diac-forte/tree/release/src/arch"
    click IEC "https://github.com/eclipse-4diac/4diac-forte/tree/release/src/modules/IEC61131-3"
    click Arrowhead "https://github.com/eclipse-4diac/4diac-forte/tree/release/src/modules/arrowhead"
    click Convert "https://github.com/eclipse-4diac/4diac-forte/tree/release/src/modules/convert"
    click RTE "https://github.com/eclipse-4diac/4diac-forte/tree/release/src/modules/rt_events"
    click Embrick "https://github.com/eclipse-4diac/4diac-forte/tree/release/src/modules/embrick"
    click I2C "https://github.com/eclipse-4diac/4diac-forte/tree/release/src/modules/i2c_dev"
    click LMS "https://github.com/eclipse-4diac/4diac-forte/tree/release/src/modules/lms_ev3"
    click BS "https://github.com/eclipse-4diac/4diac-forte/tree/release/buildsupport"
    click ST "https://github.com/eclipse-4diac/4diac-forte/tree/release/tests"

    %% Styles
    classDef build fill:#FFD700,stroke:#333,stroke-width:2px;
    classDef testing fill:#FFA07A,stroke:#333,stroke-width:2px;
    classDef platform fill:#ADD8E6,stroke:#333,stroke-width:2px;
    classDef core fill:#FFB6C1,stroke:#333,stroke-width:2px;
    classDef comm fill:#98FB98,stroke:#333,stroke-width:2px;
    classDef module fill:#DDA0DD,stroke:#333,stroke-width:2px;
```
