Skip to content

v0.8.2

Choose a tag to compare

@github-actions github-actions released this 17 Nov 07:42
· 30 commits to master since this release

[0.8.2] - 2026-11-17

新增

  • 点位级工程量变换:设备点位新增「工程量变换」(device_address.transform_json,迁移 036_device_address_transform.sql),在采集侧对原始值执行一次 scale / round / trim / default 流水线。实时值、点位阈值报警、触发规则、断网缓存与全部推送通道(MQTT / Kafka / HTTP / OPC UA / TDengine / InfluxDB)使用同一个工程值,时序库不再需要单独配置换算。scale(或保留小数位的 round)会把数值点位的 kind 提升为 float,OPC UA 整数节点相应提升为 Double;变换失败保留原值并限频记录日志。出站 mapping-json 的 transform 仍作为展示层保留,迁移到点位级后应删除通道侧重复的 scale。
  • 点位配置列表展示绑定与变换:设备点位配置列表新增「工程量变换」列,展示 缩放 ×0.1 → 四舍五入 2 位 形式的可读摘要(悬停看完整流水线),未配置时显示「原始值」;「物模型属性」列不再在窄屏下隐藏 —— 绑定关系与换算规则都属于排查采集值的必要信息。
  • 开放接口配置同步:/openApi 新增配置同步接口(文档 4.16):能力协商 GET /config/capabilities、物模型 / 设备点位 / 推送通道 / 告警 Webhook / 运行开关的脱敏只读(附 contentHash),以及推送通道、告警 Webhook、运行开关、设备点位的批量写入。只改网关配置、不触达设备,逐条部分成功;"***" 表示保留现有密钥,hash 采用 sha256-canonical-json-v1(密钥只计存在性)。物模型 upsert 新增 replaceProperties 删除未出现的属性;新增错误码 42001–42009。
  • 开放接口推送通道连通性测试:/openApi 新增 POST /pushChannel/testConnectivity(文档 4.16.7),用调用方传入的类型与未保存的通道配置真实连接一次下游(MQTT / HTTP / 时序库等)后立即断开,供管理平台保存推送通道前校验。configJson 与配置同步的 config 同结构,但密钥必须是真实值("***" 无法鉴权);失败时原样返回网关的具体原因(口令错误、地址不可达、端口拒绝)。只探测,不落库、不改网关配置。
  • 开放接口采集组列表:/openApi 新增 GET /collectorGroup/list(文档 4.16.2),按可选 deviceId 返回网关各设备的采集组,供管理平台推送通道「采集组订阅」下拉框使用 —— config.groupIds 是网关本地主键,平台只能从网关取这份列表。采集组 VO 新增设备编码 deviceCode,便于平台按「设备编码 + 组编码」与主数据对齐。
  • 开放接口出站映射预览:/openApi 新增 POST /pushChannel/previewMapping(文档 4.16.8),用网关内固定样例批次试编码 native-json / group-json / mapping-json / script,供管理平台可视化映射编辑器与无需映射的格式即时预览;native-json / group-json 不需要 mapping,只按 format 选编码器。只编码,不发送、不落库,映射或编码错误放在 data.error 而不当作接口失败。
  • 开放接口推送通道运行状态:/openApi 新增 GET /pushChannel/status(文档 4.22),返回推送引擎内存快照(运行/连接状态、队列与补发深度、发布/写出/丢弃计数、最近成功与错误),供管理平台按网关聚合监控。只读、不触达下游;计数重启清零,仅含已启用且加载成功的通道。
  • 物模型分类支持平台自定义 code:开放接口的分类校验由内置枚举改为格式校验(小写字母开头、≤32),词表由管理平台维护;本地管理端仍只能新建内置分类,但会保留并展示已下发的自定义分类。
  • Docker 基础镜像可覆盖:Dockerfile 新增 NODE_IMAGE / GOLANG_IMAGE / ALPINE_IMAGE 构建参数,docker-compose.yml 透传同名环境变量,便于切换国内镜像源或私有 registry,默认仍为官方标签。
  • 发现广播携带平台信息:notify / reply 新增 os / arch 字段,取自 Go 的 runtime.GOOS / runtime.GOARCH(如 linux/amd64、linux/arm64、windows/amd64),供管理平台发现网关后下发与它匹配的插件二进制。字段带 omitempty,旧版接收方照常解析。
  • 开放接口插件二进制下发:/openApi 新增 GET /plugin/info(平台 / 命名规则 / 上传限制)、GET /plugin/status(已加载插件的 sha256 快照)与 POST /plugin/importPlugin(multipart 上传,可选 X-Content-SHA256 完整性校验),供管理平台按 os/arch 选包下发;上传仍受 plugin.enabled、单文件 / 单批 / 请求体上限约束,新增错误码 90007(文档 4.17)。
  • 开放接口设备扫描:/openApi 新增设备扫描接口(文档 4.18):能力查询、发起 / 查询 / 续扫 / 取消、点位扫描能力,以及两种点位扫描——已下发设备按 deviceCode 取网关侧配置,未下发设备按 protocolName + protocolJson 用平台主数据配置直接扫描;discoverPointsFromScan 按 jobId + index 扫描结果中的设备,连接配置由服务端从任务快照取,不采信客户端。只提供扫描能力,结果不直接落库,设备与点位仍走 4.16.3 deviceConfig/batchUpsert 下发;受 deviceScan.enabled 控制,新增错误码 40021–40027。
  • 开放接口设备实时数据快照:/openApi 新增 GET /realtime/snapshot(文档 4.19),按 deviceId 或设备编码 code 定位设备(二者同时给出以 deviceId 为准),返回在线 / 采集中 / 采集引擎状态、最近成功时间与逐点最新值(质量码、stale 过期标记),供管理平台做设备实时监控。值直接取自采集引擎内存快照,不读时序库、不触达现场设备;未采集到的点位仍占位返回(collected=false)以保证分页之间行序稳定,stale=true 表示距上次更新超过该点位生效周期(绑定采集组时取组周期)的 3 倍。管理端按 UUID 查询、开放接口按自然键查询,两条路最终复用同一个 GetDeviceSnapshot,实时值语义不漂移。
  • 开放接口控制能力查询:/openApi 新增 GET /control/capability(文档 4.20),按 deviceId 或设备编码 code 返回 control.enabled、协议可写性 writable 与不可写原因 reason(disabled / device_disabled / protocol_missing / protocol_not_writable),供管理平台在展示写值入口前判断「现在能不能写、为什么不能写」。只读、不触达现场设备;真正写值仍走 4.8 /control/write。
  • 开放接口设备连接测试:/openApi 新增 POST /device/testConnection(文档 4.21),用调用方传入的协议名与未保存的连接配置真实连接一次现场设备(与管理端 POST /device/testDeviceConnection 同一条驱动路径),供管理平台「新建设备对象」在保存前校验连接配置。只探测:不写网关配置、不改设备状态;失败返回 40003 并原样带回驱动错误(地址不可达、串口被占用、超时等),调用方应原样展示。
  • OPC UA 验证工具:新增 backend/cmd/opcuaprobe,用标准 OPC UA 客户端完成 connect / browse / read / subscribe,独立验证网关 OPC UA Server 通道有没有把点位供出去,不依赖 UaExpert,便于在服务器、CI 或录屏环境里重复执行。
  • 实时监控写值区分原始值与工程值:设备实时快照透传点位 transformJson;控制下发弹窗的输入框始终按原始值填写,并按工程量变换只读预览对应的工程值(下发链路不做逆变换,避免把工程值当成原始值写入设备);同一弹窗新增设备信息卡与「复制地址」。前端换算算子与后端 mappingdsl 对齐(scale 默认 ×1+0、round 定长小数),换算失败时不显示预览。

变更

  • 控制台交互优化:点位与触发规则编辑弹窗改为分栏卡片并补充内联帮助,点位弹窗加宽到 min(900px, 94vw);设备扫描页重做统计卡、协议说明侧栏与结果区布局,扫描中的结果不再随轮询跳动。
  • 构建脚本目标校验:build.bat 新增 linux / native 目标,未知目标直接报错退出;此前未知目标会静默回落到全量构建,build.bat linux 实际编译了四个平台。

修复

  • 开机后的无谓采集重建:插件管理器首次扫描(Manager.Start)不再安排采集配置刷新。该次扫描必然早于采集引擎启动,加载到的驱动会自然进入首个采集任务;此前它仍会排一次 2s 防抖刷新,定时器到期时引擎已运行,导致每次开机后约 2 秒白白重建一轮全部采集任务(go test -race 下还会表现为 TestCollectionContinuesAcrossPluginHotUpgrade 偶发失败)。运行期的插件增删与热升级行为不变。

Added

  • Per-point engineering transform: device points gain an "engineering transform" (device_address.transform_json, migration 036_device_address_transform.sql) that runs a scale / round / trim / default pipeline once at collection. Live values, point threshold alarms, trigger rules, the offline spool and every push channel (MQTT / Kafka / HTTP / OPC UA / TDengine / InfluxDB) see the same engineering value, so TSDB channels no longer need their own conversion. scale (or round with decimal digits) promotes numeric points' kind to float, and integer OPC UA nodes become Double accordingly; on failure the raw value is kept and the error is logged with rate limiting. The outbound mapping-json transform remains a presentation layer — remove any duplicate scale from channel mappings after moving it to the point.
  • Point list shows bindings and transforms: the device point configuration list gains an "Engineering Transform" column with a readable summary (e.g. Scale ×0.1 → Round 2 dp, full pipeline on hover) and "Raw" when unset; the "Thing Model Property" column is no longer hidden on narrow screens, since both the binding and the conversion rule are needed to interpret a collected value.
  • OpenAPI configuration sync: adds a configuration-sync API group under /openApi (docs 4.16): capability negotiation via GET /config/capabilities, masked reads for thing models / devices & points / push channels / alarm webhooks / runtime switches (each with contentHash), and batch writes for push channels, alarm webhooks, runtime switches and device points. Writes only change gateway configuration — never field devices — and report per-item results; "***" keeps the existing secret, and hashes use sha256-canonical-json-v1 (secrets count by presence only). Thing-model upsert gains replaceProperties to drop absent properties; new error codes 42001–42009.
  • OpenAPI push channel connectivity test: /openApi gains POST /pushChannel/testConnectivity (docs 4.16.7), connecting once to the downstream (MQTT / HTTP / time-series database, …) with the caller's channel type and unsaved config, then disconnecting immediately, so the management platform can validate a push channel before saving it. configJson has the same shape as the config used by configuration sync, but secrets must hold real values ("***" cannot authenticate); failures return the gateway's concrete reason (bad credentials, unreachable host, refused port). Probe only — nothing is persisted and gateway configuration is unchanged.
  • OpenAPI collector group list: /openApi gains GET /collectorGroup/list (docs 4.16.2), returning the gateway's collector groups with an optional deviceId, for the management platform's push channel "collector group subscription" selector — config.groupIds are gateway-local keys, so the platform can only get this list from the gateway. The collector-group VO gains the device code deviceCode, so the platform can align groups with master data by "device code + group code".
  • OpenAPI outbound mapping preview: /openApi gains POST /pushChannel/previewMapping (docs 4.16.8), encoding native-json / group-json / mapping-json / script against the gateway's fixed sample batch, for the management platform's visual mapping editor and mapping-less formats to preview instantly; native-json / group-json need no mapping and pick the encoder from format alone. Encoding only — nothing is sent downstream or persisted, and mapping/encoding errors are returned in data.error rather than as API failures.
  • OpenAPI push channel runtime status: /openApi gains GET /pushChannel/status (docs 4.22), returning the push engine's in-memory snapshot (running/connected state, queue and spool depth, publish/row/dropped counters, last success and error) for the management platform to aggregate per gateway. Read-only with no downstream access; counters reset on restart and only enabled, successfully loaded channels appear.
  • Platform-defined thing-model categories: OpenAPI category validation now checks the format (lowercase letter start, ≤32) instead of a built-in whitelist, so the management platform owns the vocabulary; the local console still creates only built-in categories but keeps and displays custom codes delivered through the API.
  • Overridable Docker base images: Dockerfile gains NODE_IMAGE / GOLANG_IMAGE / ALPINE_IMAGE build args wired through docker-compose.yml, easing the switch to mainland mirrors or a private registry; defaults stay on the official tags.
  • Discovery broadcasts carry platform info: notify / reply gain os / arch fields taken from Go's runtime.GOOS / runtime.GOARCH (e.g. linux/amd64, linux/arm64, windows/amd64), so the management platform can deliver the matching plugin binaries. Both fields use omitempty, so older receivers parse the rest unchanged.
  • OpenAPI plugin binary delivery: /openApi gains GET /plugin/info (platform / naming rules / upload limits), GET /plugin/status (sha256 snapshot of loaded plugins) and POST /plugin/importPlugin (multipart upload with optional X-Content-SHA256 integrity check), so the management platform can select and deliver a package by os/arch. Uploads remain bounded by plugin.enabled and the per-file / per-batch / request-body limits; new error code 90007 (docs 4.17).
  • OpenAPI device scan: /openApi gains device-scan endpoints (docs 4.18): capabilities, start / status / continue / cancel, point-scan capability, and two point-scan modes — by deviceCode using the gateway's own device config, or by protocolName + protocolJson using the platform's master data for not-yet-delivered devices; discoverPointsFromScan scans one device in a job result by jobId + index, with the connection config taken from the job snapshot rather than the client. Scan results are not persisted here — devices and points still go through 4.16.3 deviceConfig/batchUpsert — and everything is gated by deviceScan.enabled; new error codes 40021–40027.
  • OpenAPI realtime snapshot: /openApi gains GET /realtime/snapshot (docs 4.19), locating a device by deviceId or device code code (deviceId wins when both are given) and returning online / collecting / collector-engine status, last success time and each point's latest value (quality code, stale flag) for the management platform's realtime device monitoring. Values come straight from the collector engine's in-memory snapshot — no time-series reads, no field-device access; points not yet collected still occupy a row (collected=false) so row order stays stable across pages, and stale=true means no update for 3× the point's effective period (the group period when bound to a collector group). The admin side queries by UUID and the OpenAPI by natural key, with both ending at the same GetDeviceSnapshot, so realtime semantics never drift.
  • OpenAPI control capability query: /openApi gains GET /control/capability (docs 4.20), returning by deviceId or device code code the control.enabled switch, protocol writability writable and a reason when not writable (disabled / device_disabled / protocol_missing / protocol_not_writable), so the management platform can decide whether to show a write entry. Read-only and never touching field devices; actual writes still go through 4.8 /control/write.
  • OpenAPI device connection test: /openApi gains POST /device/testConnection (docs 4.21), opening a real connection once to a field device with the caller's protocol name and unsaved connection config (the same driver path as the admin POST /device/testDeviceConnection), for the management platform to validate connection settings before saving a new device object. Probe only — no gateway config or device state changes; failures return 40003 with the raw driver error (unreachable address, serial port busy, timeout, …) that callers should surface verbatim.
  • OPC UA verification tool: adds backend/cmd/opcuaprobe, a standard OPC UA client with connect / browse / read / subscribe modes that independently checks whether the gateway's OPC UA Server channel exposes points, without UaExpert, so it can be re-run on a server, in CI or on a recording host.
  • Raw vs. engineering values in realtime writes: the realtime device snapshot now passes each point's transformJson through; the control-write dialog keeps the input in the raw value and shows a read-only preview of the corresponding engineering value (the write path has no inverse transform, so an engineering value is never sent as if it were raw). The same dialog gains a device identity card and "copy address". The frontend pipeline mirrors the backend mappingdsl operators (scale defaults to ×1+0, round to fixed decimals) and shows no preview when conversion fails.

Changed

  • Console interaction polish: point and trigger-rule edit dialogs are split into sectioned cards with inline help, and the point dialog widens to min(900px, 94vw); the device scan page gains a stat card, a protocol-help aside and a stable results area, so in-flight results no longer jump between polls.
  • Build script target validation: build.bat gains linux / native targets and rejects unknown targets; previously an unknown target silently fell back to the full build, so build.bat linux compiled all four platforms.

Fixed

  • Pointless collection rebuild after boot: the plugin manager's initial scan (Manager.Start) no longer schedules a collector refresh. That scan always runs before the collector starts, so the drivers it loads are picked up by the first collection task; previously it still queued a 2s-debounced refresh, which by then saw a running engine and rebuilt the entire collection task about 2 seconds after every boot (and made TestCollectionContinuesAcrossPluginHotUpgrade flaky under go test -race). Runtime plugin add/remove and hot-upgrade behavior is unchanged.