# MES_CSharp_Project **Repository Path**: DLGCY_Clone/MES_CSharp_Project ## Basic Information - **Project Name**: MES_CSharp_Project - **Description**: C#相关上位机项目、包含winform、WPF、运动控制上位机、机器视觉等实际项目。 - **Primary Language**: C# - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 2 - **Created**: 2026-08-20 - **Last Updated**: 2026-08-20 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # CSharp HMI (MES_Hmi) #### Description C# HMI solution based on .NET 8 (LTS), containing two independently built upper-computer applications: - **WPF HMI** (`src/Hmi.Wpf`): Dark industrial-style UI with tab-based device connection panels and a tag monitoring grid - **WinForms HMI** (`src/Hmi.WinForms`): Classic WinForms UI with tabbed device management and a real-time DataGridView The two HMI apps are **independent of each other and can be built separately**, sharing a common communication library. #### Software Architecture ``` MES_CSharp_Project/ ├── MES_Hmi.sln └── src/ ├── Hmi.Communication/ # Shared communication library (net8.0) │ ├── Abstractions/ # IDeviceDriver unified driver abstraction │ ├── Models/ # TagValue / TagDataType / Quality data models │ ├── Drivers/ │ │ ├── Siemens/ # Siemens S7 PLC (S7netplus) │ │ ├── Modbus/ # Modbus TCP / RTU (NModbus 3.x) │ │ └── OpcUa/ # OPC UA client (OPCFoundation.NetStandard.Opc.Ua) │ └── DeviceManager.cs # Driver registration & lifecycle management ├── Hmi.Wpf/ # WPF HMI (net8.0-windows) └── Hmi.WinForms/ # WinForms HMI (net8.0-windows) ``` #### Supported Protocols | Protocol | Library | Address format example | |---|---|---| | Siemens S7 | S7netplus | `DB1.DBD0`, `M100.0`, `Q0.0`, `I0.0` | | Modbus TCP | NModbus 3.x | `40001` (holding register), `30001` (input register), `00001` (coil), `10001` (discrete input) | | Modbus RTU | NModbus 3.x (serial) | Same as above | | OPC UA | OPCFoundation.NetStandard.Opc.Ua | `ns=2;s=Tag1` (NodeId string) | All tag read/write goes through the unified `IDeviceDriver` interface; `DeviceManager` handles driver registration, connection state, and disposal. #### Installation 1. Install the .NET 8 SDK (https://dotnet.microsoft.com/download/dotnet/8.0) 2. Restore and build: ```powershell dotnet build MES_Hmi.sln ``` 3. Or build either HMI app separately: ```powershell dotnet build src/Hmi.Wpf/Hmi.Wpf.csproj dotnet build src/Hmi.WinForms/Hmi.WinForms.csproj ``` #### Usage 1. Run one of the HMI apps (`dotnet run --project src/Hmi.Wpf` or `src/Hmi.WinForms`) 2. Fill in the connection parameters on the device tab and click "Connect" 3. In the tag area select a driver, enter the tag name and address, pick the data type, then click "Add" 4. Click "Start Polling" to periodically read tag values (default interval 1000 ms) 5. Select a tag row, enter a value, and click "Write" to write it down #### Contribution 1. Fork the repository 2. Create Feat_xxx branch 3. Commit your code 4. Create Pull Request