# 工业温湿度监控系统V2.0 **Repository Path**: linbo7749/TempHumMonitor ## Basic Information - **Project Name**: 工业温湿度监控系统V2.0 - **Description**: 此上位机软件基于C#+WPF+.NET8平台,结合西门子PLC200Smart+温湿度传感器等硬件开发的工业温湿度数据监控系统,包含实时数据、告警记录、历史趋势、用户管理、系统配置模块。 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 2 - **Created**: 2026-03-10 - **Last Updated**: 2026-04-07 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # TempHumMonitor Temperature and Humidity Monitoring System - An Industrial-Grade Real-Time Temperature and Humidity Monitoring Solution Based on WPF + .NET 8.0 ## Project Overview TempHumMonitor is a comprehensive temperature and humidity monitoring system designed for industrial environments to collect, monitor, alarm, and analyze historical trends of temperature and humidity data. Built with modern WPF technology, it integrates the Prism MVVM framework, SqlSugar ORM, and Siemens S7-200 Smart PLC communication protocols to deliver a stable and reliable monitoring solution for factory floors, warehouses, laboratories, and similar settings. Core functionalities include real-time data acquisition and display, multi-zone multi-point monitoring, threshold-based alerting and notifications, historical trend analysis, user permission management, and system log auditing. Through seamless integration with PLC devices, the system automatically collects temperature and humidity data from all monitoring points and triggers alerts when values exceed predefined thresholds, enabling managers to rapidly respond to environmental anomalies and ensure the safety and stability of production environments and product quality. ## Technology Stack This project utilizes the following mainstream frameworks and components: - **.NET 8.0** - The latest .NET runtime, offering high performance and cross-platform capabilities - **WPF (Windows Presentation Foundation)** - Windows desktop application UI framework - **Prism.DryIoc** - A mature MVVM framework providing dependency injection, navigation, and event aggregation - **SqlSugar** - A lightweight ORM framework supporting multiple databases (SQLite, MySQL, SQL Server, etc.) - **HslCommunication** - An industrial communication library for connecting with Siemens S7-200 Smart PLCs - **HandyControl** - A beautiful WPF control library offering modern UI components - **LiveChartsCore** - A powerful charting library for data visualization - **OxyPlot** - A professional plotting component for historical trend analysis - **CommunityToolkit.Mvvm** - An MVVM toolkit simplifying property and command implementation - **NLog** - A logging framework ## Functional Modules The system provides complete modules covering all aspects of temperature and humidity monitoring: ### 1. Real-Time Monitoring (Dashboard) The real-time monitoring module serves as the core interface, displaying temperature and humidity data from each monitoring point in card format. The interface uses prominent color indicators to show device online status and renders live curves of temperature and humidity changes. It supports both manual and automatic data acquisition modes, allowing users to switch flexibly based on requirements. Data is automatically collected every 60 seconds, with manual on-demand acquisition also supported. ### 2. Alarm Records (AlarmRecord) The alarm records module logs all temperature and humidity threshold exceedance events and provides multi-dimensional query and filtering capabilities. Users can perform precise searches by site, alarm type, time range, and more. Alarm data can be exported to Excel format for archiving and further analysis. Alarm types include: high temperature, low temperature, high humidity, low humidity, and data reading errors. ### 3. Historical Trends (HistoryTrend) The historical trends module enables long-term visualization and analysis of temperature and humidity data. Users can select different time periods (day, hour, minute) and multiple monitoring sites; the system generates detailed data curve charts. This module supports overlaying data from multiple sites for easy comparison of temperature and humidity trends across regions. Data export functionality is also available. ### 4. Log Query (Log) The system log module records all operational behaviors and system events, including system startup/shutdown, user login/logout, parameter modifications, and exceptions/errors. Logs are categorized and searchable by type and time range, with export functionality for audit and traceability purposes. ### 5. User Management (UserManage) The user management module controls system access permissions. Three user roles are supported: Super Administrator, Administrator, and Operator. Super Administrators have full privileges, including adding, editing, deleting users, and resetting passwords. Regular users can only view data and cannot modify system configurations. ### 6. Parameter Settings (SystemSetting) The parameter settings module allows users to configure critical system parameters, including temperature and humidity upper/lower thresholds, data collection intervals, and historical data retention days. These settings directly influence data acquisition logic and alarm triggering rules. ## System Architecture The project follows a classic three-tier architecture combined with the MVVM pattern to achieve high code decoupling: ``` TempHumMonitor/ ├── App.xaml # Application entry point, configures dependency injection ├── Common/ # Common utility classes │ └── Converters/ # Value converters ├── Enums/ # Enum definitions ├── Event/ # Event definitions (Prism event aggregator) ├── Infrastructure/ # Infrastructure layer │ ├── Database/ # Database access (SqlSugar) │ ├── Helpers/ # Helper utilities (logging, encryption) │ └── PLC/ # PLC communication encapsulation ├── Models/ # Data models ├── Services/ # Business service layer ├── ViewModels/ # View model layer ├── Views/ # View layer (XAML) └── Styles/ # Style resources ``` ## Quick Start ### Environment Requirements - Windows 10/11 operating system - .NET 8.0 Runtime - Visual Studio 2022 (for development) ### Configure PLC Connection Set the PLC IP address in `DashboardViewModel.cs`: ```csharp private const string _plcIp = "192.168.1.100"; // Modify to the actual PLC IP address ``` ### Database Configuration The system uses SQLite by default (`TempHumMonitor.db`). The database and tables are automatically created upon first launch. To use another database, modify the connection string in `SqlHelper.cs`. ### Default User A default admin account is pre-configured: - Username: admin - Password: (no password required on first login, or contact system administrator) ## Project Structure Overview | Directory/File | Description | |----------------|-------------| | `Common/Store.cs` | Global static configuration storage | | `Infrastructure/PLC/S7_200SmartPLCHelperV2.cs` | Siemens PLC communication encapsulation class | | `Infrastructure/Database/SqlHelper.cs` | Database initialization and connection management | | `Services/TempHumRecordService.cs` | Temperature and humidity record business logic | | `Services/SystemLogService.cs` | System log business logic | | `Services/UserService.cs` | User authentication and management business logic | | `ViewModels/DashboardViewModel.cs` | Real-time monitoring page logic | | `ViewModels/AlarmRecordViewModel.cs` | Alarm records page logic | | `ViewModels/HistoryTrendViewModel.cs` | Historical trends page logic | ## Interface Preview The system interface features a modern dark theme and includes the following pages: **Login Interface** - User authentication entry point **Main Interface** - Classic layout with top title bar, left navigation menu, and right content area **Real-Time Monitoring** - Displays real-time temperature and humidity data cards and live curves for all monitoring points **Alarm Records** - Tabular display of alarm events with pagination and export support **Historical Trends** - Multi-curve charts showing historical temperature and humidity changes **Log Query** - Search and export of operational logs **User Management** - CRUD operations for user list **Parameter Settings** - Configuration and saving of system parameters ## Dependencies This project depends on the following core NuGet packages: - Prism.DryIoc.Wpf (8.1.97) - SqlSugar (5.1.4.135) - HslCommunication (9.2.6) - HandyControl (3.5.1) - LiveChartsCore.SkiaSharpView.WPF (2.0.0-rc2) - OxyPlot.Wpf (2.1.2) - CommunityToolkit.Mvvm (8.2.2) - NLog (5.2.8) ## License This project is intended solely for learning and reference purposes. Please comply with applicable open-source license terms.