# 3dudu/agv-wcs architecture

> Architecture diagram of the GitHub repository 3dudu/agv-wcs, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-10-22). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/3dudu/agv-wcs
- Repository: https://github.com/3dudu/agv-wcs

## Overview

##### Project Type and Purpose
- This is a full‐stack, monolithic .NET Framework (4.5.2) solution implementing a Warehouse Control System (WCS) for automated guided vehicles (AGVs).
- It provides:
- Communication with AGV hardware and PLCs
- Dispatch logic and route planning
- Data access to SQL Server / SQLite (db3.0)
- Multiple UIs: dispatch console, monitoring display, PDA client, 2D/3D simulators, map/edit tools

##### High‐Level Layered Structure
- Presentation Layer:
- AGVDispatchServer (WinForms dispatch UI)
- (monitoring map, status dashboards)
- WindowPDAClient (PDA Windows client)
- RCSEditTool (map & parameter editor)
- Simulation, SimulatorAGVTCP, SimulateCallBox, Wpf3DSimulator (2D/3D simulation UIs)
- Business Logic Layer:
- AGVCore (core events, state machine, dispatcher interfaces)
- AGVComponents (route planning, traffic control)
- AGVDispacth (dispatch engine, external/internal handlers, non-standard dispatch)
- DipatchModel (typed data contracts for commands, enums)
- SimulationModel (runtime simulation behavior)
- Communication & Integration Layer:
- AGVCommunication (AGV protocol sessions: OMARK, Fbell, custom)
- SocketServer / SocketClient / SocketModel (TCP socket framework, message packaging)
- S7PLCClient_AGV, PlcSMICECallAGV (Siemens PLC connectivity modules)
- MesModel (MES callback data structures)
- SQLServerOperator (generic DB operator)
- Tool (web service agent, encryption, config)
- Data Access Layer:
- AGVDAccess (client/server/simulation data repositories)
- Model (Comoon: shared DTOs for users, parameters; MDM: master data; MSM: I/O device info; CarInfoExtend)
- SQLXML folders (predefined SQL queries / schemas)

##### Component Relationships & Data Flow
- UI components invoke dispatch or simulation actions via public interfaces in AGVDispacth / SimulationModel.
- Dispatch engine calls AGVComponents for route planning and interacts with AGVCore state machine.
- Communication layer (AGVCommunication, SocketServer, PLC clients) sends/receives messages to/from AGV hardware and PLC.
- Business logic calls Data Access (AGVDAccess, SQLServerOperator) to read/write master and runtime data in SQL Server or SQLite.

##### Architectural Patterns & Principles
- Layered architecture: Presentation → Business → Integration → Data Access
- Separation of concerns: protocols (AGVCommunication), business rules (AGVCore, AGVComponents), UI, data storage
- Use of DTOs / typed contracts (Model and DipatchModel) for strong typing across layers
- Plugin‐style protocol sessions (AGVSessionBase + derived)

##### Technologies & Frameworks
- .NET Framework 4.5.2, C#
- WinForms (DispatchServer, Display, RCSEditTool, PDA, SimulationCommon)
- WPF (Wpf3DSimulator)
- SuperSocket (AGVDispacth/SupperSocket)
- ADO.NET / SQLXML for database
- SQLite (db3.0) for local data
- Custom TCP socket layer (SocketModel, SocketServer, SocketClient)

##### Detail Level
- Break each major module into subcomponents (e.g., AGVSessionBase + specific session classes)
- External dependencies (SuperSocket library, SQLXML scripts, images)
- Don’t over-partition: group by layer but call out specialized protocol/session plugins

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        direction TB
        DispatchServer["AGVDispatchServer"]:::presentation
        DisplayUI["Display"]:::presentation
        PDAClient["WindowPDAClient"]:::presentation
        RCSEditToolUI["RCSEditTool"]:::presentation
        Sim2D["Simulation"]:::presentation
        SimTCP["SimulatorAGVTCP"]:::presentation
        CallBox["SimulateCallBox"]:::presentation
        Sim3D["Wpf3DSimulator"]:::presentation
    end

    %% Business Logic Layer
    subgraph "Business Logic Layer"
        direction TB
        AGVCoreNode["AGVCore"]:::business
        AGVComponentsNode["AGVComponents"]:::business
        AGVDispatchNode["AGVDispacth"]:::business
        DispatchModelNode["DipatchModel"]:::business
        SimulationModelNode["SimulationModel"]:::business
    end

    %% Integration & Communication Layer
    subgraph "Integration & Communication Layer"
        direction TB
        AGVComm["AGVCommunication"]:::integration
        SocketServerNode["SocketServer"]:::integration
        SocketClientNode["SocketClient"]:::integration
        SocketModelNode["SocketModel"]:::integration
        PLC_S7["S7PLCClient_AGV"]:::integration
        PLC_Call["PlcSMICECallAGV"]:::integration
        MesModelNode["MesModel"]:::integration
        ToolNode["Tool"]:::integration
        SQLServerOp["SQLServerOperator"]:::integration
    end

    %% Data Access Layer
    subgraph "Data Access Layer"
        direction TB
        AGVDAccessNode["AGVDAccess"]:::dataaccess
        ModelNode["Model"]:::dataaccess
    end

    %% Databases
    SQLServer[(SQL Server)]:::external
    SQLite[(SQLite)]:::external

    %% External Systems
    AGVHardware((AGV Hardware)):::external
    PLCNetwork((PLC Network)):::external
    MESWeb((MES Web Service)):::external

    %% Presentation -> Business
    DispatchServer -->|"invoke dispatch"| AGVDispatchNode
    DisplayUI -->|"monitor data"| AGVCoreNode
    PDAClient -->|"invoke dispatch"| AGVDispatchNode
    RCSEditToolUI -->|"edit map/params"| ModelNode
    Sim2D -->|"simulate"| SimulationModelNode
    SimTCP -->|"simulate TCP"| SimulationModelNode
    CallBox -->|"simulate call box"| SimulationModelNode
    Sim3D -->|"simulate 3D"| SimulationModelNode

    %% Business internal
    AGVDispatchNode -->|"dispatch tasks"| AGVComponentsNode
    AGVDispatchNode -->|"state events"| AGVCoreNode
    SimulationModelNode -->|"use DTOs"| DispatchModelNode

    %% Business -> Integration
    AGVDispatchNode -->|"send AGV messages"| AGVComm
    AGVDispatchNode -->|"open socket"| SocketServerNode
    AGVDispatchNode -->|"PLC calls"| PLC_S7
    AGVDispatchNode -->|"PLC UI"| PLC_Call
    SimulationModelNode -->|"socket client"| SocketClientNode
    SimulationModelNode -->|"message pack"| SocketModelNode

    %% Business -> Data Access
    AGVDispatchNode -->|"CRUD master/runtime"| AGVDAccessNode
    SimulationModelNode -->|"store simulation"| AGVDAccessNode
    RCSEditToolUI -->|"read/write DTOs"| AGVDAccessNode

    %% Integration -> External
    AGVComm -->|"TCP"| AGVHardware
    SocketServerNode -->|"TCP"| AGVHardware
    SocketClientNode -->|"TCP"| AGVHardware
    PLC_S7 -->|"Siemens S7"| PLCNetwork
    PLC_Call -->|"Siemens S7"| PLCNetwork
    ToolNode -->|"web service"| MESWeb
    MesModelNode -->|"data contracts"| MESWeb

    %% Integration -> Data Access
    SQLServerOp -->|"DB operations"| SQLServer
    SQLServerOp -->|"DB operations"| SQLite

    %% Data Access -> Databases
    AGVDAccessNode -->|"ADO.NET/SQLXML"| SQLServer
    AGVDAccessNode -->|"SQLite3"| SQLite
    ModelNode -->|"DTO storage"| SQLServer

    %% Click Events
    click DispatchServer "https://github.com/3dudu/agv-wcs/tree/main/AGVDispatchServer/"
    click DisplayUI "https://github.com/3dudu/agv-wcs/tree/main/Display/"
    click PDAClient "https://github.com/3dudu/agv-wcs/tree/main/WindowPDAClient/"
    click RCSEditToolUI "https://github.com/3dudu/agv-wcs/tree/main/RCSEditTool/"
    click Sim2D "https://github.com/3dudu/agv-wcs/tree/main/Simulation/"
    click SimTCP "https://github.com/3dudu/agv-wcs/tree/main/SimulatorAGVTCP/"
    click CallBox "https://github.com/3dudu/agv-wcs/tree/main/SimulateCallBox/"
    click Sim3D "https://github.com/3dudu/agv-wcs/tree/main/Wpf3DSimulator/"
    click AGVCoreNode "https://github.com/3dudu/agv-wcs/tree/main/AGVCore/"
    click AGVComponentsNode "https://github.com/3dudu/agv-wcs/tree/main/AGVComponents/"
    click AGVDispatchNode "https://github.com/3dudu/agv-wcs/tree/main/AGVDispacth/"
    click DispatchModelNode "https://github.com/3dudu/agv-wcs/tree/main/DipatchModel/"
    click SimulationModelNode "https://github.com/3dudu/agv-wcs/tree/main/SimulationModel/"
    click AGVComm "https://github.com/3dudu/agv-wcs/tree/main/AGVCommunication/"
    click SocketServerNode "https://github.com/3dudu/agv-wcs/tree/main/SocketServer/"
    click SocketClientNode "https://github.com/3dudu/agv-wcs/tree/main/SocketClient/"
    click SocketModelNode "https://github.com/3dudu/agv-wcs/tree/main/SocketModel/"
    click PLC_S7 "https://github.com/3dudu/agv-wcs/tree/main/S7PLCClient_AGV/"
    click PLC_Call "https://github.com/3dudu/agv-wcs/tree/main/PlcSMICECallAGV/"
    click MesModelNode "https://github.com/3dudu/agv-wcs/tree/main/MesModel/"
    click SQLServerOp "https://github.com/3dudu/agv-wcs/tree/main/SQLServerOperator/"
    click ToolNode "https://github.com/3dudu/agv-wcs/tree/main/Tool/"
    click AGVDAccessNode "https://github.com/3dudu/agv-wcs/tree/main/AGVDAccess/"
    click ModelNode "https://github.com/3dudu/agv-wcs/tree/main/Model/"

    %% Styles
    classDef presentation fill:#add8e6,stroke:#333,stroke-width:1px
    classDef business fill:#90ee90,stroke:#333,stroke-width:1px
    classDef integration fill:#ffcc99,stroke:#333,stroke-width:1px
    classDef dataaccess fill:#dda0dd,stroke:#333,stroke-width:1px
    classDef external fill:#d3d3d3,stroke:#333,stroke-width:1px,stroke-dasharray: 5 5
```
