# VibeCodingIndustrialWebScada **Repository Path**: idkook/VibeCodingIndustrialWebScada ## Basic Information - **Project Name**: VibeCodingIndustrialWebScada - **Description**: No description available - **Primary Language**: C# - **License**: Not specified - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-06-25 - **Last Updated**: 2026-06-25 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # IndustrialWebScada 基于 .NET 8 + Blazor Server 的工业 Web SCADA 系统,支持多泵站实时监控、报警管理、历史数据查询。 ## 技术架构 ``` ┌─────────────────────────────────────────────────────────┐ │ Blazor Server (InteractiveServer) │ │ Dashboard / PumpStationList / PumpStationDetail │ │ ↑ TagValueNotifier (100ms 防抖推送) │ ├─────────────────────────────────────────────────────────┤ │ Application 层 │ │ TagValueStore → AlarmEngine → PumpStationService │ ├─────────────────────────────────────────────────────────┤ │ BackgroundServices │ │ DataCollectionService (Modbus 并行轮询) │ │ DataPushService (SignalR 100ms 防抖广播) │ │ AlarmMonitorService / HistoryArchiveService │ ├─────────────────────────────────────────────────────────┤ │ Drivers 层 │ │ ModbusTcpDriver (批量读取、地址合并、自动重连) │ ├─────────────────────────────────────────────────────────┤ │ Infrastructure 层 │ │ EF Core SQLite (历史记录 + 报警记录) │ └─────────────────────────────────────────────────────────┘ ``` ## 项目结构 ``` IndustrialWebScada/ ├── config/ │ ├── devices.json # 设备列表配置 │ └── device-templates/ # 点表模板 │ └── pump-station.json # 四泵站标准模板(71 个标签) ├── src/ │ ├── IndustrialWebScada.Core/ # 领域模型、接口、事件 │ ├── IndustrialWebScada.Application/ # 业务逻辑(TagValueStore、AlarmEngine) │ ├── IndustrialWebScada.Drivers/ # 协议驱动(ModbusTcp、MQTT) │ ├── IndustrialWebScada.Infrastructure/ # 数据持久化(EF Core SQLite) │ ├── IndustrialWebScada.BackgroundServices/ # 后台服务(采集、推送、报警、归档) │ └── IndustrialWebScada.Web/ # Blazor Server Web 应用 │ ├── Components/ │ │ ├── Pages/ # 页面(Dashboard、PumpStationList 等) │ │ └── Shared/ # 共享组件(PumpStationCard、WaterLevelTank 等) │ └── Program.cs # 入口、DI 注册、中间件 └── tests/ └── IndustrialWebScada.Drivers.Tests/ # 单元测试 ``` ## 实时数据流 ``` Modbus 设备 → DataCollectionService (1s/2s/5s 轮询) → TagValueStore.Update() → TagValueNotifier (100ms 批量防抖) → Blazor 组件 StateHasChanged() [本地推送] → DataPushService (100ms 防抖) → ScadaHub (SignalR) [外部客户端推送] → AlarmEngine.Evaluate() → AlarmMonitorService → HistoryArchiveService → SQLite ``` ### 刷新机制 | 层级 | 机制 | 延迟 | |------|------|------| | Blazor 页面 | `TagValueNotifier` 推送 + 2s 兜底定时器 | ≤100ms | | 外部 SignalR 客户端 | `DataPushService` 广播 | ≤100ms | | 设备通讯状态 | 基于 `TagValueStore` 质量码实时判定 | 跟随采集周期 | ## 泵站模板 每个泵站 71 个标签,包括: - **16 个离散输入**(FC02):4 台泵的远控、变频运行、变频故障、故障信号 - **8 个线圈写入**(FC01):启停指令、累计时间清零 - **保持寄存器**(FC03):运行时间、液位设定、控制模式、频率等 - **输入寄存器**(FC04):当前液位、频率反馈 ## 快速开始 ### 环境要求 - .NET 8 SDK - Modbus TCP 模拟器(用于测试,如 ModRSsim2) ### 运行 ```bash # 还原依赖 dotnet restore # 运行 Web 应用 dotnet run --project src/IndustrialWebScada.Web ``` 应用默认监听 `http://localhost:5228`。 ### 配置设备 编辑 `config/devices.json` 添加或修改设备: ```json { "devices": [ { "deviceId": "Station01", "name": "东风泵站", "template": "pump-station", "modbusTcp": { "host": "127.0.0.1", "port": 502, "unitId": 1 } } ] } ``` ## 页面说明 | 路由 | 功能 | |------|------| | `/` | 泵站总览 Dashboard(在线/离线/报警统计、液位概览) | | `/pump-stations` | 泵站列表(液位、模式、运行/故障泵数) | | `/pump-stations/{StationId}` | 泵站详情(液位监控、泵组控制、趋势图、参数) | | `/alarms` | 报警记录查询与确认 | | `/history` | 历史数据查询 | ## 诊断 API | 端点 | 说明 | |------|------| | `GET /api/tags` | 所有标签当前值 | | `GET /api/status` | 系统状态摘要 | | `GET /api/device-status` | 设备通讯状态 | ## 主要依赖 | 包 | 用途 | |----|------| | NModbus 3.0.81 | Modbus TCP 通讯 | | MQTTnet 4.3.7 | MQTT 数据发布 | | Microsoft.EntityFrameworkCore.Sqlite | 历史数据存储 | | Serilog | 结构化日志 | | ECharts(CDN) | 趋势图表 | ## 许可证 MIT