# waelegate/tcp-ip-python-v3 architecture

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

- Interactive diagram: https://gitdiagram.com/waelegate/tcp-ip-python-v3
- Repository: https://github.com/waelegate/tcp-ip-python-v3

## Overview

##### Project type and purpose
- This is a Python-based SDK (library) and demo application for controlling Dobot robots over TCP/IP.
- It wraps the Dobot TCP/IP control protocol in easy-to-use Python classes and ships with both CLI (main.py, PythonExample.py) and simple GUI demos (main_UI.py, ui.py).

##### File structure
- Top-level:
- dobot_api.py – core SDK module defining DobotApi, DobotApiDashboard, DobotApiMove, MyType.
- PythonExample.py – code samples for SDK usage.
- main.py – command-line demo (connect, enable, MovL/J, feedback).
- main_UI.py & ui.py – simple UI front end.
- files/ – alarm configuration (JSON) + corresponding Python classes.
- images/ – assets used in README.
- README.md / README-EN.md – project description and usage.
- SDK uses numpy for feedback deserialization.
- The SDK establishes three separate TCP sockets to the robot controller: dashboardPort (29999), movePort (30003), feedPort (30004).

##### README for additional insights
- Detailed description of each class’s responsibility.
- Usage patterns:
- Instantiate Dashboard, Move, Feed clients.
- Main thread issues control & motion commands.
- Background threads handle feedback sampling and exception handling.

##### Key recommendations
- Three parallel channels—control, motion, feedback—and their threads.
- Alarm JSONs and show how they map to alarm_controller.py / alarm_servo.py.
- Data flow with sample ports (29999, 30003, 30004).

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% User Application Layer
    subgraph "User Application Layer"
        direction TB
        PythonExample["PythonExample"]:::application
        mainCLI["main.py CLI Demo"]:::application
        mainUI["main_UI.py GUI Demo"]:::application
        ui["ui.py"]:::application
    end

    %% SDK Core Layer
    subgraph "SDK Core Layer"
        direction TB
        dobot_api["dobot_api.py"]:::sdk
        subgraph "SDK Classes"
            direction TB
            Dashboard["DobotApiDashboard"]:::sdk
            Move["DobotApiMove"]:::sdk
            FeedType["MyType (Feedback Parser)"]:::sdk
        end
        subgraph "Alarm Config"
            direction TB
            alarmControllerJson["alarm_controller.json"]:::config
            alarmServoJson["alarm_servo.json"]:::config
            alarmControllerPy["alarm_controller.py"]:::config
            alarmServoPy["alarm_servo.py"]:::config
        end
    end

    %% External Libraries
    numpy["numpy"]:::external

    %% Network Layer
    subgraph "Network Layer"
        direction TB
        dashboardSocket["dashboardPort (29999)"]:::network
        moveSocket["movePort (30003)"]:::network
        feedSocket["feedPort (30004)"]:::network
    end

    %% Robot Controller
    DobotController["Dobot Controller"]:::robot

    %% Connections
    PythonExample -->|uses SDK| dobot_api
    mainCLI -->|uses SDK| dobot_api
    mainUI -->|uses SDK| dobot_api
    ui -->|uses SDK| dobot_api

    dobot_api -->|manages| Dashboard
    dobot_api -->|manages| Move
    dobot_api -->|uses| FeedType

    Dashboard -->|reads/writes| dashboardSocket
    Move -->|sends motion| moveSocket
    FeedType -->|parses feedback| feedSocket

    dashboardSocket -->|TCP/IP| DobotController
    moveSocket -->|TCP/IP| DobotController
    feedSocket -->|TCP/IP| DobotController

    FeedType -->|uses| numpy
    dobot_api -->|loads JSON| alarmControllerJson
    dobot_api -->|loads JSON| alarmServoJson
    alarmControllerJson --> alarmControllerPy
    alarmServoJson --> alarmServoPy

    %% Click Events
    click PythonExample "https://github.com/waelegate/tcp-ip-python-v3/blob/main/PythonExample.py"
    click mainCLI "https://github.com/waelegate/tcp-ip-python-v3/blob/main/main.py"
    click mainUI "https://github.com/waelegate/tcp-ip-python-v3/blob/main/main_UI.py"
    click ui "https://github.com/waelegate/tcp-ip-python-v3/blob/main/ui.py"
    click dobot_api "https://github.com/waelegate/tcp-ip-python-v3/blob/main/dobot_api.py"
    click alarmControllerJson "https://github.com/waelegate/tcp-ip-python-v3/blob/main/files/alarm_controller.json"
    click alarmServoJson "https://github.com/waelegate/tcp-ip-python-v3/blob/main/files/alarm_servo.json"
    click alarmControllerPy "https://github.com/waelegate/tcp-ip-python-v3/blob/main/files/alarm_controller.py"
    click alarmServoPy "https://github.com/waelegate/tcp-ip-python-v3/blob/main/files/alarm_servo.py"

    %% Styles
    classDef application fill:#AED6F1,stroke:#1F618D,color:#1F618D;
    classDef sdk fill:#D6EAF8,stroke:#2874A6,color:#2874A6;
    classDef config fill:#D5F5E3,stroke:#27AE60,color:#27AE60;
    classDef network fill:#F9E79F,stroke:#B9770E,color:#B9770E;
    classDef robot fill:#F5B7B1,stroke:#C0392B,color:#C0392B;
    classDef external fill:#E8DAEF,stroke:#884EA0,color:#884EA0;
```
