# jianjipan/mes architecture

> Architecture diagram of the GitHub repository jianjipan/mes, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-07). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jianjipan/mes
- Repository: https://github.com/jianjipan/mes

## Overview

MMIS is a WPF-based MES for planning and executing production orders across an automated warehouse, AGV, and production-area equipment. Operators submit orders or manual material moves in the main window; command execution polls database-backed AGV and warehouse queues, while device messages and machine state update progress and records. The README also documents production overview, history and Excel export, warehouse inventory/location management, and standalone equipment control. Several of these capabilities are documented but their detailed implementations were not sampled, so their internal links are not inferred.

Main entry points: [`MMIS/MainWindow.xaml.cs`](https://github.com/jianjipan/mes/blob/master/MMIS/MainWindow.xaml.cs) (MES workspace), [`MMIS/Assist/DataBaseHandle.cs`](https://github.com/jianjipan/mes/blob/master/MMIS/Assist/DataBaseHandle.cs) (MES database), [`MMIS/AGVClient/AGVMsgHandle.cs`](https://github.com/jianjipan/mes/blob/master/MMIS/AGVClient/AGVMsgHandle.cs) (AGV workflow), [`MMIS/WHClient/WHMsgHandle.cs`](https://github.com/jianjipan/mes/blob/master/MMIS/WHClient/WHMsgHandle.cs) (Warehouse workflow)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_operator["Operator workflows"]
  node_main["MES workspace<br/>[MainWindow.xaml.cs]"]
  node_warehouse_view["Warehouse locations<br/>[KuweiShow.xaml.cs]"]
  node_history_export["History export<br/>[ExportToExcel.cs]"]
end

subgraph group_orchestration["Order orchestration"]
  node_orders["Order executor<br/>[ExecuteOrder.cs]"]
  node_agv_logic["AGV workflow<br/>[AGVMsgHandle.cs]"]
  node_wh_logic["Warehouse workflow<br/>[WHMsgHandle.cs]"]
  node_machine_state["Machine state<br/>[StateMachine.cs]"]
end

subgraph group_devices["Device communication"]
  node_agv_protocol["AGV protocol<br/>[SendPackage.cs]"]
  node_warehouse_protocol["Warehouse protocol<br/>[WHSendPackage.cs]"]
  node_dtu_server["Machine server<br/>[DTUServer.cs]"]
  node_dtu_session["Machine session<br/>[DTUSession.cs]"]
  node_dtu_request["Machine messages<br/>[DTURequestInfo.cs]"]
end

subgraph group_state["State and persistence"]
  node_database[("MES database<br/>[DataBaseHandle.cs]")]
  node_position_model["Warehouse positions<br/>[WHPosition.cs]"]
end

subgraph group_support["Configuration and records"]
  node_config["System settings<br/>[ConfigClass.cs]"]
  node_xml_config["XML settings<br/>[ReadWriteXml.cs]"]
  node_logging["Application logging<br/>[LogInfoHelp.cs]"]
end

node_operator(("Operator"))
node_agv_service(("AGV"))
node_warehouse_service(("Automated warehouse"))
node_production_equipment(("Production equipment"))

node_operator -->|"operates"| node_main
node_main -->|"records commands"| node_database
node_main -->|"loads settings"| node_xml_config
node_xml_config -->|"sets values"| node_config
node_main -->|"starts server"| node_dtu_server
node_main -->|"connects"| node_agv_service
node_main -->|"connects"| node_warehouse_service
node_orders -->|"polls commands"| node_database
node_agv_logic -->|"updates status"| node_database
node_wh_logic -->|"updates inventory"| node_database
node_machine_state -->|"saves results"| node_database
node_agv_logic -->|"uses messages"| node_agv_protocol
node_agv_logic -->|"requests moves"| node_warehouse_service
node_wh_logic -->|"uses messages"| node_warehouse_protocol
node_wh_logic -->|"notifies workflow"| node_agv_logic
node_dtu_server -->|"hosts sessions"| node_dtu_session
node_dtu_session -->|"receives messages"| node_dtu_request
node_machine_state -.->|"tracks status"| node_production_equipment
node_warehouse_view -->|"reads locations"| node_database
node_warehouse_view -->|"displays positions"| node_position_model
node_history_export -.->|"exports history"| node_database
node_main -.->|"coordinates orders"| node_agv_logic
node_main -.->|"coordinates orders"| node_wh_logic
node_agv_logic -->|"logs events"| node_logging
node_wh_logic -->|"logs events"| node_logging

click node_main "https://github.com/jianjipan/mes/blob/master/MMIS/MainWindow.xaml.cs"
click node_warehouse_view "https://github.com/jianjipan/mes/blob/master/MMIS/Assist/KuweiShow.xaml.cs"
click node_history_export "https://github.com/jianjipan/mes/blob/master/MMIS/Assist/ExportToExcel.cs"
click node_orders "https://github.com/jianjipan/mes/blob/master/MMIS/ExecuteOrder.cs"
click node_agv_logic "https://github.com/jianjipan/mes/blob/master/MMIS/AGVClient/AGVMsgHandle.cs"
click node_wh_logic "https://github.com/jianjipan/mes/blob/master/MMIS/WHClient/WHMsgHandle.cs"
click node_machine_state "https://github.com/jianjipan/mes/blob/master/MMIS/Server/StateMachine.cs"
click node_agv_protocol "https://github.com/jianjipan/mes/blob/master/MMIS/AGVClient/SendPackage.cs"
click node_warehouse_protocol "https://github.com/jianjipan/mes/blob/master/MMIS/WHClient/WHSendPackage.cs"
click node_dtu_server "https://github.com/jianjipan/mes/blob/master/MMIS/Server/DTUServer.cs"
click node_dtu_session "https://github.com/jianjipan/mes/blob/master/MMIS/Server/DTUSession.cs"
click node_dtu_request "https://github.com/jianjipan/mes/blob/master/MMIS/Server/DTURequestInfo.cs"
click node_database "https://github.com/jianjipan/mes/blob/master/MMIS/Assist/DataBaseHandle.cs"
click node_position_model "https://github.com/jianjipan/mes/blob/master/MMIS/Assist/WHPosition.cs"
click node_config "https://github.com/jianjipan/mes/blob/master/MMIS/Config/ConfigClass.cs"
click node_xml_config "https://github.com/jianjipan/mes/blob/master/MMIS/Config/ReadWriteXml.cs"
click node_logging "https://github.com/jianjipan/mes/blob/master/MMIS/LogInfoHelp.cs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_main,node_warehouse_view,node_history_export toneBlue
class node_orders,node_agv_logic,node_wh_logic,node_machine_state toneAmber
class node_agv_protocol,node_warehouse_protocol,node_dtu_server,node_dtu_session,node_dtu_request toneMint
class node_database,node_position_model toneRose
class node_config,node_xml_config,node_logging,node_operator,node_agv_service,node_warehouse_service,node_production_equipment toneIndigo
```

## Components

### Operator workflows

- [MES workspace](https://github.com/jianjipan/mes/blob/master/MMIS/MainWindow.xaml.cs): `MMIS/MainWindow.xaml.cs`
- [Warehouse locations](https://github.com/jianjipan/mes/blob/master/MMIS/Assist/KuweiShow.xaml.cs): `MMIS/Assist/KuweiShow.xaml.cs`
- [History export](https://github.com/jianjipan/mes/blob/master/MMIS/Assist/ExportToExcel.cs): `MMIS/Assist/ExportToExcel.cs`

### Order orchestration

- [Order executor](https://github.com/jianjipan/mes/blob/master/MMIS/ExecuteOrder.cs): `MMIS/ExecuteOrder.cs`
- [AGV workflow](https://github.com/jianjipan/mes/blob/master/MMIS/AGVClient/AGVMsgHandle.cs): `MMIS/AGVClient/AGVMsgHandle.cs`
- [Warehouse workflow](https://github.com/jianjipan/mes/blob/master/MMIS/WHClient/WHMsgHandle.cs): `MMIS/WHClient/WHMsgHandle.cs`
- [Machine state](https://github.com/jianjipan/mes/blob/master/MMIS/Server/StateMachine.cs): `MMIS/Server/StateMachine.cs`

### Device communication

- [AGV protocol](https://github.com/jianjipan/mes/blob/master/MMIS/AGVClient/SendPackage.cs): `MMIS/AGVClient/SendPackage.cs`
- [Warehouse protocol](https://github.com/jianjipan/mes/blob/master/MMIS/WHClient/WHSendPackage.cs): `MMIS/WHClient/WHSendPackage.cs`
- [Machine server](https://github.com/jianjipan/mes/blob/master/MMIS/Server/DTUServer.cs): `MMIS/Server/DTUServer.cs`
- [Machine session](https://github.com/jianjipan/mes/blob/master/MMIS/Server/DTUSession.cs): `MMIS/Server/DTUSession.cs`
- [Machine messages](https://github.com/jianjipan/mes/blob/master/MMIS/Server/DTURequestInfo.cs): `MMIS/Server/DTURequestInfo.cs`

### State and persistence

- [MES database](https://github.com/jianjipan/mes/blob/master/MMIS/Assist/DataBaseHandle.cs): `MMIS/Assist/DataBaseHandle.cs`
- [Warehouse positions](https://github.com/jianjipan/mes/blob/master/MMIS/Assist/WHPosition.cs): `MMIS/Assist/WHPosition.cs`

### Configuration and records

- [System settings](https://github.com/jianjipan/mes/blob/master/MMIS/Config/ConfigClass.cs): `MMIS/Config/ConfigClass.cs`
- [XML settings](https://github.com/jianjipan/mes/blob/master/MMIS/Config/ReadWriteXml.cs): `MMIS/Config/ReadWriteXml.cs`
- [Application logging](https://github.com/jianjipan/mes/blob/master/MMIS/LogInfoHelp.cs): `MMIS/LogInfoHelp.cs`

### Other components

- **Operator**
- **AGV**
- **Automated warehouse**
- **Production equipment**

## Connections

- Operator → MES workspace: operates
- MES workspace → MES database: records commands (evidence: `MMIS/Assist/DataBaseHandle.cs`)
- MES workspace → XML settings: loads settings (evidence: `MMIS/MainWindow.xaml.cs`)
- XML settings → System settings: sets values (evidence: `MMIS/Config/ReadWriteXml.cs`)
- MES workspace → Machine server: starts server (evidence: `MMIS/MainWindow.xaml.cs`)
- MES workspace → AGV: connects (evidence: `MMIS/MainWindow.xaml.cs`)
- MES workspace → Automated warehouse: connects (evidence: `MMIS/MainWindow.xaml.cs`)
- Order executor → MES database: polls commands (evidence: `MMIS/ExecuteOrder.cs`)
- AGV workflow → MES database: updates status (evidence: `MMIS/AGVClient/AGVMsgHandle.cs`)
- Warehouse workflow → MES database: updates inventory (evidence: `MMIS/WHClient/WHMsgHandle.cs`)
- Machine state → MES database: saves results (evidence: `MMIS/Server/StateMachine.cs`)
- AGV workflow → AGV protocol: uses messages (evidence: `MMIS/AGVClient/AGVMsgHandle.cs`)
- AGV workflow → Automated warehouse: requests moves (evidence: `MMIS/AGVClient/AGVMsgHandle.cs`)
- Warehouse workflow → Warehouse protocol: uses messages (evidence: `MMIS/WHClient/WHMsgHandle.cs`)
- Warehouse workflow → AGV workflow: notifies workflow (evidence: `MMIS/WHClient/WHMsgHandle.cs`)
- Machine server → Machine session: hosts sessions (evidence: `MMIS/Server/DTUServer.cs`)
- Machine session → Machine messages: receives messages (evidence: `MMIS/Server/DTUSession.cs`)
- Machine state → Production equipment: tracks status
- Warehouse locations → MES database: reads locations (evidence: `MMIS/Assist/KuweiShow.xaml.cs`)
- Warehouse locations → Warehouse positions: displays positions (evidence: `MMIS/Assist/KuweiShow.xaml.cs`)
- History export → MES database: exports history
- MES workspace → AGV workflow: coordinates orders (evidence: `MMIS/MainWindow.xaml.cs`)
- MES workspace → Warehouse workflow: coordinates orders (evidence: `MMIS/MainWindow.xaml.cs`)
- AGV workflow → Application logging: logs events (evidence: `MMIS/AGVClient/AGVMsgHandle.cs`)
- Warehouse workflow → Application logging: logs events (evidence: `MMIS/WHClient/WHMsgHandle.cs`)
