# waleed999ahmed/mio-tac architecture

> Architecture diagram of the GitHub repository waleed999ahmed/mio-tac, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-08). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/waleed999ahmed/mio-tac
- Repository: https://github.com/waleed999ahmed/mio-tac

## Overview

##### Project Type and Purpose
- This is a standalone desktop application (Python) for automated hardware testing of a gimbal (Pan, Tilt, Roll).
- Key responsibilities:
- Read configuration (serial port)
- Open MAVLink communication over serial
- Send test commands to gimbal motors
- Receive telemetry (orientation)
- Render real‐time gauges in a modern GUI

##### File Structure
- main.py – entry point: orchestrates startup, reads config, spawns threads, initializes GUI.
- connection.txt – simple config file storing COM port and baud rate.
- requirements.txt – declares external Python libraries (e.g., pymavlink, ttkbootstrap, tkinter).
- README.md – project overview and instructions.
- MIO-TAC.mp4 – demo video (optional documentation asset).

##### Extract Architecture Insights from README
- GUI: built with Tkinter + ttkbootstrap, displays real‐time gauge meters.
- Communication: MAVLink protocol over serial port.
- Concurrency: uses Python threads to avoid blocking the UI.
- Hardware target: Daly BMS–compatible gimbals.

##### Main Components
A. Configuration Module
- Reads `connection.txt` (COM port, baud rate) on startup.
B. Communication Layer
- Serial Port Interface
- MAVLink Message Parser & Encoder (via pymavlink)
- Command Scheduler (automates Pan/Tilt/Roll test sequences)
- Telemetry Listener
C. Business Logic / Controller
- Test Sequence Manager (decides next gimbal movement, verifies responses)
D. Presentation Layer (GUI)
- Tkinter Main Window
- Gauge Widgets (ttkbootstrap) showing Pan/Tilt/Roll angles in real time
- Status console or logs (optional)
E. Threading & Synchronization
- UI Thread (mainloop)
- Comm Thread (handles all MAVLink send/receive)
- Shared Data Structures / Thread‐safe Queues for passing telemetry and commands

##### Relationships and Data Flows
- Startup → Config Module loads parameters → passes to Communication Layer
- Comm Thread ↔ Serial Port ↔ Gimbal Hardware (via MAVLink)
- Comm Thread → pushes telemetry updates → Business Logic & GUI
- Business Logic → generates next movement commands → Comm Thread
- GUI Thread reads shared telemetry → updates gauges

##### Architectural Patterns / Principles
- Layered Architecture: clear separation of UI, control logic, and hardware interface.
- Producer–Consumer (Threading): Comm Thread produces telemetry; UI thread consumes it.
- Single Responsibility: each module does one job (config, comms, UI, test logic).

##### Technologies & Frameworks to call out
- Python 3.x
- pymavlink (MAVLink protocol)
- Tkinter + ttkbootstrap (UI)
- threading or concurrent.futures (Python threading)
- Serial (pyserial – implied for COM port access)

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "UI Thread"
        ConfigLoader["Config Loader"]:::util
        TestSeqMgr["Test Sequence Manager"]:::logic
        GUIWindow["Tkinter Main Window\n(ttkbootstrap)"]:::ui
        GaugeWidgets["Gauge Widgets"]:::ui
        StatusConsole["Status Console"]:::ui
    end

    subgraph "Comm Thread"
        SerialInterface["Serial Port Interface"]:::comm
        MAVParser["MAVLink Parser & Encoder"]:::comm
        CmdScheduler["Command Scheduler"]:::comm
        TelemetryListener["Telemetry Listener"]:::comm
        SharedQueue["Shared Data Structures\n(Thread-safe Queues)"]:::util
    end

    ConfigFile["connection.txt"]:::util
    ExternalHardware["Gimbal Hardware"]:::external
    Readme["README.md"]:::util
    Reqs["requirements.txt"]:::util
    DemoVideo["MIO-TAC.mp4"]:::external

    ConfigFile -->|"Config Params"| ConfigLoader
    ConfigLoader -->|"Load Params"| SerialInterface
    SerialInterface -->|"MAVLink Stream"| MAVParser
    SerialInterface -->|"Raw Serial Data"| TelemetryListener
    MAVParser --> CmdScheduler
    CmdScheduler -->|"MAVLink Command"| SerialInterface
    TelemetryListener -->|"Telemetry Packet"| SharedQueue
    SharedQueue -->|"Telemetry Update"| TestSeqMgr
    SharedQueue -->|"Telemetry Update"| GUIWindow
    TestSeqMgr -->|"Next Movement Cmd"| CmdScheduler
    GUIWindow -->|"UI Event"| GaugeWidgets
    GUIWindow -->|"UI Event"| StatusConsole
    SerialInterface -->|"via Serial"| ExternalHardware
    ExternalHardware -->|"Orientation Data"| TelemetryListener

    Readme -.-> ConfigLoader
    Reqs -.-> ConfigLoader
    DemoVideo -.-> ConfigLoader

    click ConfigLoader "https://github.com/waleed999ahmed/mio-tac/blob/main/main.py"
    click SerialInterface "https://github.com/waleed999ahmed/mio-tac/blob/main/main.py"
    click MAVParser "https://github.com/waleed999ahmed/mio-tac/blob/main/main.py"
    click CmdScheduler "https://github.com/waleed999ahmed/mio-tac/blob/main/main.py"
    click TelemetryListener "https://github.com/waleed999ahmed/mio-tac/blob/main/main.py"
    click TestSeqMgr "https://github.com/waleed999ahmed/mio-tac/blob/main/main.py"
    click GUIWindow "https://github.com/waleed999ahmed/mio-tac/blob/main/main.py"
    click ConfigFile "https://github.com/waleed999ahmed/mio-tac/blob/main/connection.txt"
    click Readme "https://github.com/waleed999ahmed/mio-tac/blob/main/README.md"
    click Reqs "https://github.com/waleed999ahmed/mio-tac/blob/main/requirements.txt"
    click DemoVideo "https://github.com/waleed999ahmed/mio-tac/blob/main/MIO-TAC.mp4"

    classDef ui fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef logic fill:#90EE90,stroke:#333,stroke-width:1px
    classDef comm fill:#FFA500,stroke:#333,stroke-width:1px
    classDef util fill:#D3D3D3,stroke:#333,stroke-width:1px
    classDef external fill:#EEEEEE,stroke:#333,stroke-width:1px
```
