# dewetron/trion-sdk architecture

> Architecture diagram of the GitHub repository dewetron/trion-sdk, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-09-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/dewetron/trion-sdk
- Repository: https://github.com/dewetron/trion-sdk

## Overview

##### Project type and purpose
- This is a multi-language SDK and example suite for accessing DEWETRON hardware (TRION PXI, TRION3 PXIe, TRIONet, PUREC, NEXDAQ).
- It delivers:
- A core C API library (dewepxi_api) for hardware interaction
- Language bindings in C++, C#, Python
- Example programs under trion/ and trionet/ in each language
- A cross-platform .NET MAUI UI (“app/TRION-SDK-UI”)
- Sphinx-based documentation in docs/
- Primary use case: embed or script direct data-acquisition control of DEWETRON devices.

##### File structure
- Top-level:
- 3rdparty/pugixml – XML parser dependency
- trion_api/ – wrapper libraries (C, CS, CXX, python)
- trion/ & trionet/ – “bare-metal” examples per language
- app/TRION-SDK-UI – .NET MAUI multi-platform UI front-end
- docs/ – Sphinx docs (RST, static HTML/PDF)
- cmake/ – CMake settings, build scripts
- Patterns:
- Layered architecture: Core C API → multi-language bindings → consumers (examples + UI)
- Build: CMake for C/C++/C#, pyproject/setup.py for Python

##### Key README insights
- The SDK relies on an installed TRION Application (drivers + firmware).
- Examples show typical init → configure → acquire → cleanup flow.
- Python packaging via pip (trion_sdk).

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Hardware Layer
    subgraph "Hardware Layer"
        Hardware["DEWETRON Devices (PXI, PXIe, TRIONet, NEXDAQ)"]:::hardware
    end

    %% Core SDK Layer
    subgraph "Core SDK Layer"
        dewepxi_api["dewepxi_api (.dll/.so)"]:::native
        pugixml["pugixml (XML Parser)"]:::native
    end

    %% Binding Layer
    subgraph "Binding Layer"
        CXX["C++ Wrapper (trion_api/CXX)"]:::lang
        CS["C# Wrapper (TrionApi)"]:::lang
        Python["Python Wrapper (dewepxi_api Python)"]:::lang
    end

    %% Consumer Layer
    subgraph "Consumer Layer"
        C_ex["C Examples (trion/C)"]:::lang
        CXX_ex["C++ Examples (trion/CXX)"]:::lang
        CS_ex[".NET C# Examples (trion/CS/TRION_SDK_CS)"]:::lang
        Python_ex["Python Examples (trion/python)"]:::lang

        subgraph "TRIONet Examples"
            C_ex2["C Examples (trionet/C)"]:::lang
            CXX_ex2["C++ Examples (trionet/CXX)"]:::lang
            CS_ex2[".NET C# Examples (trionet/CS)"]:::lang
            Python_ex2["Python Examples (trionet/python)"]:::lang
        end

        UI_app[".NET MAUI UI Application\n(Android, iOS, Mac, Win)"]:::app
    end

    %% Documentation and Build & Packaging
    subgraph "Documentation & Packaging"
        docs["Sphinx Docs (docs/)"]:::docs
        CMake["CMake Settings (cmake/)"]:::build
        pip_pkg["Python Packaging (setup.py, pyproject.toml)"]:::build
        DotNet_sln[".NET Build Solution\n(TRION-SDK-UI.sln)"]:::build
    end

    %% Relationships
    C_ex -->|calls| CXX
    CXX_ex -->|calls| CXX
    CS_ex -->|calls| CS
    Python_ex -->|calls| Python
    C_ex2 -->|calls| CXX
    CXX_ex2 -->|calls| CXX
    CS_ex2 -->|calls| CS
    Python_ex2 -->|calls| Python
    UI_app -->|uses| CS

    CXX -->|p/invoke or direct| dewepxi_api
    CS -->|p/invoke| dewepxi_api
    Python -->|ctypes/cffi| dewepxi_api

    dewepxi_api -->|interfaces via drivers| Hardware
    pugixml -->|XML config parsing| dewepxi_api

    CMake -->|builds| dewepxi_api
    CMake -->|builds| CXX
    CMake -->|builds| CS
    CMake -->|builds| C_ex
    CMake -->|builds| CXX_ex
    CMake -->|builds| CS_ex
    CMake -->|builds| C_ex2
    CMake -->|builds| CXX_ex2
    CMake -->|builds| CS_ex2
    CMake -->|builds| UI_app

    pip_pkg -->|packages| Python
    DotNet_sln -->|builds| UI_app

    docs -->|generates HTML/PDF| docs

    %% Click Events
    click dewepxi_api "https://github.com/dewetron/trion-sdk/tree/main/trion_api/C/inc"
    click pugixml "https://github.com/dewetron/trion-sdk/blob/main/3rdparty/pugixml-1.9"
    click CXX "https://github.com/dewetron/trion-sdk/tree/main/trion_api/CXX/trion_api_cxx"
    click CS "https://github.com/dewetron/trion-sdk/tree/main/trion_api/CS/TrionApi"
    click Python "https://github.com/dewetron/trion-sdk/tree/main/trion_api/python"
    click C_ex "https://github.com/dewetron/trion-sdk/tree/main/trion/C"
    click CXX_ex "https://github.com/dewetron/trion-sdk/tree/main/trion/CXX"
    click CS_ex "https://github.com/dewetron/trion-sdk/tree/main/trion/CS/TRION_SDK_CS"
    click Python_ex "https://github.com/dewetron/trion-sdk/tree/main/trion/python"
    click C_ex2 "https://github.com/dewetron/trion-sdk/tree/main/trionet/C"
    click CXX_ex2 "https://github.com/dewetron/trion-sdk/tree/main/trionet/CXX"
    click CS_ex2 "https://github.com/dewetron/trion-sdk/tree/main/trionet/CS"
    click Python_ex2 "https://github.com/dewetron/trion-sdk/tree/main/trionet/python"
    click UI_app "https://github.com/dewetron/trion-sdk/tree/main/app/TRION-SDK-UI"
    click docs "https://github.com/dewetron/trion-sdk/tree/main/docs/"
    click CMake "https://github.com/dewetron/trion-sdk/tree/main/cmake/"
    click pip_pkg "https://github.com/dewetron/trion-sdk/blob/main/setup.py"
    click DotNet_sln "https://github.com/dewetron/trion-sdk/blob/main/app/TRION-SDK-UI/TRION-SDK-UI.sln"

    %% Styles
    classDef hardware fill:#dddddd,stroke:#888888,stroke-width:1px
    classDef native fill:#a2d5c6,stroke:#2e8b57,stroke-width:1px
    classDef lang fill:#b0c4de,stroke:#4682b4,stroke-width:1px
    classDef app fill:#ffdab9,stroke:#ff8c00,stroke-width:1px
    classDef build fill:#ffe4b5,stroke:#ff7f50,stroke-width:1px
    classDef docs fill:#d8bfd8,stroke:#9370db,stroke-width:1px
```
