# TGateway **Repository Path**: tinketbell/tgateway ## Basic Information - **Project Name**: TGateway - **Description**: No description available - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-07-31 - **Last Updated**: 2026-11-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README [star](https://gitee.com/ThingsGateway/ThingsGateway/stargazers) [star](https://github.com/ThingsGateway/ThingsGateway) [Ask DeepWiki](https://deepwiki.com/ThingsGateway/ThingsGateway) [NuGet(ThingsGateway.Foundation)](https://www.nuget.org/packages/ThingsGateway.Foundation/) [License](https://thingsgateway.cn/docs/1) [QQ](http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=NnBjPO-8kcNFzo_RzSbdICflb97u2O1i&authKey=V1MI3iJtpDMHc08myszP262kDykbx2Yev6ebE4Me0elTe0P0IFAmtU5l7Sy5w0jx&noverify=0&group_code=605534569) ## 项目简介 **ThingsGateway** 是开源工业物联网(IIoT)边缘计算网关,面向工业现场设备的**高效采集、边缘处理与可靠转发**。 本仓库基于 ThingsGateway **12.x**(见 `Directory.Build.props` 中 `GatewayVersion`),在保留原网关采集 / 插件 / 管理能力的同时,叠入 **Edge EMS**:现场策略、能源调度算法、安全门与写点闭环,适用于风光柴储、工商业储能、光储充等场景。 核心分工: > Cloud EMS 负责规划和优化;Edge EMS 负责现场实时决策与可靠执行。 - [前后端分离版本官网](https://runtime.thingsgateway.cn/) - [官网](https://thingsgateway.cn/) - [版权声明](https://thingsgateway.cn/docs/1) - [赞助途径](https://thingsgateway.cn/docs/1000) --- ## 本仓库在做什么 | 层 | 内容 | | --- | --- | | 网关底座 | 通道 / 设备 / 变量;Collect / Business 插件;断线重连与缓存补偿 | | Edge EMS | `ThingsGateway.Edge.Application` + `ThingsGateway.Edge.Razor`,由 `ThingsGateway.Server` 内嵌托管 | | 双通道决策 | **DeviceStrategy**(when → then 写变量/Rpc)∥ **EnergyStrategy**(Profile → 平衡 / 分配 → Decision) | | 汇合管道 | Decision → 仲裁 / 安全门 → 可选自动执行(默认关)或 MQTT 下发 | **不是**:完整 Cloud EMS(规划 / MILP / MPC)、32 位嵌入式固件。北向连云仍走 TG Business 插件。 --- ## 核心优势 - **高性能运行时**:.NET 异步模型;变量智能扫描打包与批量读取;高并发设备连接 - **插件化架构**:南北向按需扩展;能源算法另有 SPI + 外置 DLL(Collectible ALC) - **边缘计算**:过滤、转换、规则与能源功率决策,减少无效上云 - **工业级可靠性**:心跳、超时、重连、缓存与补偿;Edge 侧 Offline 自治 - **跨平台部署**:Windows / Linux;工控机、边缘服务器;官方 x64 / arm64 Docker --- ## 功能特性 ### 数据采集 - 异步非阻塞采集;变量自动扫描打包与批量读取 - 协议:Modbus(RTU / TCP)、OPC、MQTT、S7 等 - 统一设备模型:通道 → 设备 → 点位 - 心跳、超时、自动重连与异常隔离 ### 数据处理 - 边缘侧计算与 C# 脚本扩展;内存变量 - 规则引擎:条件触发与动作 - Edge:状态映射、DeviceStrategy 包、EnergyStrategy Profile ### 数据输出 - 转发至 MQTT、数据库、Web API、Kafka 等 - 可建 OPC UA / Modbus / MQTT Server - 异常时缓存与补偿;失败重试与批量发送 ### Edge EMS(本仓扩展) - **策略通道**:when/then 规则包;离线仅跑 `offlineAllowed=true` 的包 - **算法通道**:`IEnergyAlgorithm` / `IAllocationAlgorithm`;内置 ∪ 外置插件;Profile 选型与参数 - **安全与执行**:限值安全门;执行监视页控制自动下发;可选 MQTT 写设定 - **云边协同**:Online/Offline;可选 HTTP 心跳与配置版本字符串;算法制品 Push(默认关) 常用页面: | 能力 | 路由 | | --- | --- | | 状态映射 | `/edge/state` | | 策略 | `/edge/strategy` | | 算法 / Profile | `/edge/algorithm` | | 安全限值 | `/edge/safety/limits` | | 执行监视 | `/edge/exec/monitor` | | MQTT 下发调试 | `/edge/exec/mqtt-publish` | | 云边状态 | `/edge/cloud/status` | | 全链路追踪 | `/edge/trace` | > 自动执行默认关闭。现场联调见 [`docs/边缘/双通道下发检查单.md`](docs/边缘/双通道下发检查单.md)。 --- ## 文档入口 | 文档 | 说明 | | --- | --- | | [`docs/边缘/索引.md`](docs/边缘/索引.md) | Edge EMS 设计文档总索引(E00–E10 + 现网分册) | | [`docs/边缘/本地边缘网关部署与能力.md`](docs/边缘/本地边缘网关部署与能力.md) | 现场部署、工控机 / ARM64、能力边界 | | [`docs/边缘/策略模块.md`](docs/边缘/策略模块.md) | DeviceStrategy 现网结构全书 | | [`docs/边缘/算法模块.md`](docs/边缘/算法模块.md) | EnergyStrategy / 算法 SPI / 插件 / Push | | [`docs/边缘/策略与算法模块总览.md`](docs/边缘/策略与算法模块总览.md) | 双通道并列与汇合 | | [`docs/tg-edge-roadmap.md`](docs/tg-edge-roadmap.md) | R0–R8 落地路线图 | | [`docs/project-docs/`](docs/project-docs/) | 工程规范、架构事实、术语、ADR | | [`docs/project-docs/knowledge/agent-project-brief.md`](docs/project-docs/knowledge/agent-project-brief.md) | **给 Agent 的项目简述**(定向 / 权威顺序 / 代码地图) | | [`samples/nodered-pv-storage-ev/`](samples/nodered-pv-storage-ev/) | 光储充 Node-RED 联调样例 | 上游导读(非本仓权威):[DeepWiki](https://deepwiki.com/ThingsGateway/ThingsGateway)。 --- ## PRO 插件与商业支持 ThingsGateway **核心开源**;另有 [PRO 付费插件](https://thingsgateway.cn/docs/1001) 补充协议覆盖面与现场兼容性,包括但不限于: - FINS、CIP / EtherNet/IP、MC Protocol - IEC 60870-5-104(北向)、OPC AE、VIGOR - SECS / SECS-I / HSMS --- ## 快速开始 ### 环境要求 - .NET 8.0 / 10.0 或更高 ### 方式一:下载发行版 1. 从 Release 下载对应平台包并解压 2. 运行 `ThingsGateway.Server.exe`(Windows)或 `dotnet ThingsGateway.Server.dll`(Linux) 3. 浏览器访问 `http://localhost:5000` ### 方式二:Docker ```bash docker pull registry.cn-shenzhen.aliyuncs.com/thingsgateway/thingsgateway:latest docker pull registry.cn-shenzhen.aliyuncs.com/thingsgateway/thingsgateway_arm64:latest docker run -d -p 5000:5000 --name thingsgateway \ registry.cn-shenzhen.aliyuncs.com/thingsgateway/thingsgateway:latest ``` 参考:`docker/docker-compose-thingsgateway.yml`。 ### 方式三:从源码运行 ```bash git clone <本仓库地址> cd ThingsGateway-v12 dotnet run --project src/ThingsGateway.Server/ThingsGateway.Server.csproj ``` 指定框架与 URL 示例(Windows): ```bat dotnet run --project src\ThingsGateway.Server\ThingsGateway.Server.csproj -f net8.0 --urls http://localhost:5000 ``` 测试:`test/ThingsGateway.Edge.Test`、`test/ThingsGateway.Gateway.Test`。 --- ## 工程结构(摘要) ```text ThingsGateway.Server → ThingsGateway.Edge.Razor / Edge.Application (Edge EMS) → ThingsGateway.Gateway.Razor / Gateway.Application (原网关) ``` 解决方案:`ThingsGateway.slnx`。架构事实见 [`docs/project-docs/knowledge/architecture/overview.md`](docs/project-docs/knowledge/architecture/overview.md)。 --- ## 相关上游仓库 默认支持 net10.0 / net8.0。驱动库支持 netstandard2.1 / netstandard2.0 / net4.62 / net6.0。 | 项目 | 说明 | | --- | --- | | [ThingsGateway.Foundation](https://gitee.com/ThingsGateway/ThingsGateway.Foundation) | 工具库、驱动接口与实现 | | [ThingsGateway.SqlOrm](https://gitee.com/ThingsGateway/ThingsGateway.SqlOrm) | 轻量 ORM | | [ThingsGateway.AspNetCore](https://gitee.com/ThingsGateway/ThingsGateway.AspNetCore) | ASP.NET Core 扩展 | | [ThingsGateway.Admin](https://gitee.com/ThingsGateway/ThingsGateway.Admin) | 后台管理 | | [Docs](https://gitee.com/ThingsGateway/Docs) | 官方说明文档 | | [ThingsGateway.Plugin](https://gitee.com/ThingsGateway/ThingsGateway.Plugin) | 网关插件扩展 | | [ThingsGateway](https://gitee.com/ThingsGateway/ThingsGateway) | 工业网关上游平台 | --- ## 特别声明 ThingsGateway 项目已加入 [dotNET China](https://gitee.com/dotnetchina) 组织。