← 返回文档中心

DrvModbusGst 通信驱动(自研)

DrvModbusGst 自研通信驱动文档。

自研通信驱动适用版本6.0.0更新时间2026-04-29负责人ScadaV6CommExt

DrvModbusGst 通信驱动(自研)

功能描述

DrvModbusGst 为 ScadaV6CommExt 中的自研 Communicator 驱动,用于与现场设备或系统进行数据采集与命令交互。具体协议与能力以源码实现为准。

适用范围与版本

  • 源码目录:ScadaV6CommExt/DrvModbusGst.Logic
  • 目标框架:netstandard2.0
  • 程序集版本:6.0.0

安装与启用

  1. 按 RapidSCADA 标准流程将驱动 DLL 部署到 Communicator 安装目录(保持目录层级)。
  2. 在 Administrator 中打开项目 → Communicator → 驱动程序,确认驱动已出现在可用列表并激活。
  3. 上传配置到服务器并重启 Communicator 服务。

线路与设备配置(使用步骤)

  1. Communicator → 通信线路 中新建线路,选择与本驱动匹配的通道类型(串口 / TCP / UDP 等,以界面为准)。
  2. 在线路下添加设备,填写设备地址、超时、重试等通用参数。
  3. 在设备 轮询选项 中填写 命令行(CmdLine) 及本驱动所需的其它选项;CmdLine 在本驱动中的含义(通常为模板文件名)、设备地址格式及线路级参数请对照下文 功能依据与配置要点(模板与源码) 与「线路 CustomOptions」小节。
  4. 保存项目并上传配置,观察 Communicator 日志与设备状态。

线路 CustomOptions 参数(源码提取)

下表由源码正则提取,供快速对照;最终以实际配置界面与注释为准。

参数键默认值/片段说明
未在源码中匹配到明显的 GetValueAs* 调用,请在 Administrator 中打开该驱动的设备/线路配置界面逐项确认。

配置相关源码片段(参考)

28: protected class TemplateDict : Dictionary
56: transMode = lineContext.LineConfig.CustomOptions.GetValueAsEnum("TransMode", TransMode.RTU);
91: private ModbusCmd CreateModbusCmd(DeviceTemplateOptions options, CmdConfig cmdConfig)
135: int timeout = PollingOptions.Timeout > 0 ? PollingOptions.Timeout : 3000; // 默认3秒
138: Timeout = timeout,
139: Connection = Connection,
592: protected virtual DeviceTemplate GetDeviceTemplate()
594: DeviceTemplate deviceTemplate = null;
595: string fileName = PollingOptions.CmdLine.Trim();
607: if (templateDict.TryGetValue(fileName, out DeviceTemplate existingTemplate))
617: DeviceTemplate newTemplate = CreateDeviceTemplate();
633: protected virtual DeviceTemplate CreateDeviceTemplate()
635: return new DeviceTemplate();
650: public override void OnConnectionSet()
653: if (Connection != null)
654: Connection.NewLine = ModbusUtils.CRLF;
658: modbusPoll.Connection = Connection;
666: DeviceTemplate deviceTemplate = GetDeviceTemplate();

管理端配置界面(DrvModbusGst.View)

配置在 RapidSCADA Administrator → Communicator 中完成。以下词条来自 View 工程语言包,便于对照界面字段含义。

  • View 源码:ScadaV6CommExt/DrvModbusGst.View
  • 主要窗体:
    • FrmDeviceProps.cs
    • FrmDeviceTemplate.cs
界面词条 key说明(中文)
未解析到语言词条,请直接打开 View 工程下 Lang 目录核对。

完整模板编辑(如存在)一般在「设备模板编辑器」窗体中维护 XML/CSV 导入导出。

功能依据与配置要点(模板与源码)

下列要点依据仓库内 Logic / Common 及设备模板 XML 归纳,用于说明本驱动的行为以及在 Administrator / Communicator 中需要配置的项(设备地址、CmdLine、线路 CustomOptions、模板 XML 节点等)。

逻辑入口

  • Logic 目录:ScadaV6CommExt/DrvModbusGst.Logic
  • Common 目录:ScadaV6CommExt/DrvModbusGst.Common

重写的关键方法

OnConnectionSet(), InitDeviceTags(), Session(), SendCommand()

设备模板 / CmdLine

  • PollingOptions.CmdLine.Trim();

DeviceConfig 字段引用(源码中出现)

属性说明
未检测到 DeviceConfig.* 引用(可能使用基类封装)。

线路 CustomOptions(GetValueAs*)

参数键默认值/片段
未在 Logic 中检测到 CustomOptions.GetValueAs*(可能全部从设备模板 XML 读取)。

模板/配置 XML 节点(Common 提取)

XML 节点备注
ZeroAddr来自 Common 配置加载/保存相关源码中的 XML 节点名
DecAddr来自 Common 配置加载/保存相关源码中的 XML 节点名
DefByteOrder2来自 Common 配置加载/保存相关源码中的 XML 节点名
DefByteOrder4来自 Common 配置加载/保存相关源码中的 XML 节点名
DefByteOrder8来自 Common 配置加载/保存相关源码中的 XML 节点名
ElemGroup来自 Common 配置加载/保存相关源码中的 XML 节点名
Loop来自 Common 配置加载/保存相关源码中的 XML 节点名
Device来自 Common 配置加载/保存相关源码中的 XML 节点名
Options来自 Common 配置加载/保存相关源码中的 XML 节点名
Controllers来自 Common 配置加载/保存相关源码中的 XML 节点名
Controller来自 Common 配置加载/保存相关源码中的 XML 节点名
Cmds来自 Common 配置加载/保存相关源码中的 XML 节点名
Cmd来自 Common 配置加载/保存相关源码中的 XML 节点名

关键源码片段(节选)

53:         {
54:             transMode = lineContext.LineConfig.CustomOptions.GetValueAsEnum("TransMode", TransMode.RTU);
55:             deviceModel = null;
56:             modbusPoll = null;

589:         /// 
590:         protected virtual DeviceTemplate GetDeviceTemplate()
591:         {
592:             DeviceTemplate deviceTemplate = null;

592:             DeviceTemplate deviceTemplate = null;
593:             string fileName = PollingOptions.CmdLine.Trim();
594: 
595:             if (string.IsNullOrEmpty(fileName))

661:         /// 
662:         public override void InitDeviceTags()
663:         {
664:             DeviceTemplate deviceTemplate = GetDeviceTemplate();

663:         {
664:             DeviceTemplate deviceTemplate = GetDeviceTemplate();
665: 
666:             if (deviceTemplate == null)

855:         /// 
856:         public override void Session()
857:         {
858:             base.Session();

排障

  • 设备无数据:检查线路通道、地址、模板文件、网络/串口连通性。
  • 模板加载失败:查看 Communicator 日志中 Device template / Load template 相关错误。
  • 参数不生效:确认 CustomOptions 是否写在线路或设备正确层级(以驱动读取位置为准)。