# ottowayi/pycomm3 architecture

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

- Interactive diagram: https://gitdiagram.com/ottowayi/pycomm3
- Repository: https://github.com/ottowayi/pycomm3

## Overview

##### Main Components

a) Core Components:
- CIP Driver (Base Layer)
- LogixDriver (PLC-specific Layer)
- SLCDriver (Legacy Layer)
- Packet Handling System
- Data Type System

b) External Interfaces:
- Ethernet/IP Network Interface
- PLC Devices (ControlLogix, CompactLogix, Micro800, SLC500)

**[Network Layer]**
- ↑↓
**[Socket Layer]**
- ↑↓
**[CIP Protocol Layer]**
- ↑↓
**[Driver Layer]**
- ↑↓
**[Client Application]**

##### Component Details

a) Network Layer:
- Ethernet/IP connection to PLCs
- Supported PLC types as separate components

b) Socket Layer (pycomm3/socket_.py):
- Handles raw communication
- TCP/IP socket management

c) CIP Protocol Layer:
- Packet handling (pycomm3/packets/)
- CIP services (pycomm3/cip/)
- Object library and data types

d) Driver Layer:
- Three drivers with their relationships
- Inheritance from CIPDriver
- Main services for each driver

##### Important Details

a) Driver Capabilities:
- CIPDriver: Show generic messaging, device discovery
- LogixDriver: Show tag read/write, time sync
- SLCDriver: Show data file operations

b) Data Flow:
- Bidirectional communication paths
- Packet transformation stages
- Fragmentation handling points

##### Implementation Notes

- Use rectangles for modules/components
- Use diamonds for decision points
- Notes for key features like:
- Multiple Service Packet handling
- Tag list uploading
- Structure reading/writing
- Automatic type conversion

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client["Client Application Layer"]
        App[Client Application]
    end

    subgraph Drivers["Driver Layer"]
        CIPDriver["CIP Driver (Base)"]:::core
        LogixDriver["Logix Driver"]:::core
        SLCDriver["SLC Driver"]:::core
        TagMgmt["Tag Management"]:::core
    end

    subgraph Protocol["Protocol Layer"]
        CIPProtocol["CIP Protocol"]:::protocol
        PacketHandler["Packet Handler"]:::protocol
        DataTypes["Data Types"]:::protocol
        ObjectLib["Object Library"]:::protocol
        CIPServices["CIP Services"]:::protocol
        PCCC["PCCC Protocol"]:::legacy
        LogixPackets["Logix Packets"]:::protocol
        BasePackets["Base Packets"]:::protocol
        StatusInfo["Status Information"]:::protocol
    end

    subgraph Network["Network Layer"]
        Socket["Socket Layer"]:::network
        EthernetIP["Ethernet/IP"]:::network
    end

    subgraph PLCs["PLC Devices"]
        ControlLogix["ControlLogix"]:::plc
        CompactLogix["CompactLogix"]:::plc
        Micro800["Micro800"]:::plc
        SLC500["SLC500"]:::plc
    end

    %% Relationships
    App --> CIPDriver
    App --> LogixDriver
    App --> SLCDriver

    CIPDriver --> PacketHandler
    CIPDriver --> CIPProtocol
    CIPDriver --> TagMgmt

    LogixDriver --> CIPDriver
    LogixDriver --> LogixPackets
    LogixDriver --> StatusInfo

    SLCDriver --> CIPDriver
    SLCDriver --> PCCC

    PacketHandler --> BasePackets
    PacketHandler --> LogixPackets
    PacketHandler --> EthernetIP

    CIPProtocol --> DataTypes
    CIPProtocol --> ObjectLib
    CIPProtocol --> CIPServices

    EthernetIP --> Socket

    Socket --> ControlLogix
    Socket --> CompactLogix
    Socket --> Micro800
    Socket --> SLC500

    %% Styles
    classDef core fill:#3498db,stroke:#2980b9,color:white
    classDef protocol fill:#f1c40f,stroke:#f39c12,color:black
    classDef network fill:#2ecc71,stroke:#27ae60,color:white
    classDef plc fill:#95a5a6,stroke:#7f8c8d,color:white
    classDef legacy fill:#e74c3c,stroke:#c0392b,color:white

    %% Click Events
    click CIPDriver "https://github.com/ottowayi/pycomm3/blob/master/pycomm3/cip_driver.py"
    click LogixDriver "https://github.com/ottowayi/pycomm3/blob/master/pycomm3/logix_driver.py"
    click SLCDriver "https://github.com/ottowayi/pycomm3/blob/master/pycomm3/slc_driver.py"
    click Socket "https://github.com/ottowayi/pycomm3/blob/master/pycomm3/socket_.py"
    click CIPProtocol "https://github.com/ottowayi/pycomm3/tree/master/pycomm3/cip/"
    click PacketHandler "https://github.com/ottowayi/pycomm3/tree/master/pycomm3/packets/"
    click DataTypes "https://github.com/ottowayi/pycomm3/blob/master/pycomm3/cip/data_types.py"
    click ObjectLib "https://github.com/ottowayi/pycomm3/blob/master/pycomm3/cip/object_library.py"
    click CIPServices "https://github.com/ottowayi/pycomm3/blob/master/pycomm3/cip/services.py"
    click EthernetIP "https://github.com/ottowayi/pycomm3/blob/master/pycomm3/packets/ethernetip.py"
    click TagMgmt "https://github.com/ottowayi/pycomm3/blob/master/pycomm3/tag.py"
    click StatusInfo "https://github.com/ottowayi/pycomm3/blob/master/pycomm3/cip/status_info.py"
    click PCCC "https://github.com/ottowayi/pycomm3/blob/master/pycomm3/cip/pccc.py"
    click BasePackets "https://github.com/ottowayi/pycomm3/blob/master/pycomm3/packets/base.py"
    click LogixPackets "https://github.com/ottowayi/pycomm3/blob/master/pycomm3/packets/logix.py"
```
