DrvModbusGst Communicator Driver (Custom)
Functional Description
DrvModbusGst is a custom Communicator driver in ScadaV6CommExt for field device connectivity. Protocol details follow the source implementation.
Scope and Version
- Source:
ScadaV6CommExt/DrvModbusGst.Logic - TFM:
netstandard2.0 - Version:
6.0.0
Install and Enable
- Deploy driver binaries to Communicator folders.
- Activate driver in Administrator → Communicator → Drivers.
- Upload configuration and restart Communicator.
Line and Device Configuration
- Create a communication line with the proper channel type.
- Add device and set address/timeouts.
- Set polling options and CmdLine as required by this driver; see Functional notes and configuration (template and source) below for file names, address format, and line keys.
CustomOptions (extracted)
| Key | Default | Note |
|---|
未在源码中匹配到明显的 GetValueAs* 调用,请在 Administrator 中打开该驱动的设备/线路配置界面逐项确认。 |
Code hints
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();
Administrator UI (DrvModbusGst.View)
Configure in Administrator → Communicator. Labels below come from the View language pack.
- View source:
ScadaV6CommExt/DrvModbusGst.View - Main forms:
FrmDeviceProps.csFrmDeviceTemplate.cs
| Phrase key | Text |
|---|
gbCmd | Command Parameters |
lblCmdCode | Command code |
lblCmdNum | Command number |
lblCmdAddress | Element address |
lblTemplateFileName | Device template |
ConfigDirRequired | The device template file must be located inside {0} |
TemplateNotExists | The device template file does not exist. |
btnAddCmd.ToolTip | Add Command |
gbTemplate | Device Template |
TemplateTitle | {0} - MODBUS. Device Template Editor |
DuplicatedCmdNums | Duplicated command numbers: |
EmptyCmdCodes | Empty command codes found. |
AddressHint | {0}, starting from {1} |
lblCmdName | Name |
lblCmdCodeWarn | Fill out code |
lblCmdDataBlock | Data block |
cbCmdDataBlock.Items[0] | Coils (0X) |
cbCmdDataBlock.Items[1] | Holding Registers (4X) |
cbCmdDataBlock.Items[2] | Custom |
chkCmdMultiple | Multiple |
lblCmdFuncCode | Function code |
lblCmdFuncCodeHex | Hexadecimal |
lblCmdElemType | Element type |
cbCmdElemType.Items[0] | Undefined |
cbCmdElemType.Items[1] | ushort (2 bytes) |
cbCmdElemType.Items[2] | short (2 bytes) |
cbCmdElemType.Items[3] | uint (4 bytes) |
cbCmdElemType.Items[4] | int (4 bytes) |
cbCmdElemType.Items[5] | ulong (8 bytes) |
cbCmdElemType.Items[6] | long (8 bytes) |
Functional notes and configuration (template and source)
Derived from Logic/Common and device template XML: driver behavior and the Administrator/Communicator fields to set (address, CmdLine, line CustomOptions, template nodes).
Logic location
ScadaV6CommExt/DrvModbusGst.Logic- Common:
DrvModbusGst.Common
Overrides
OnConnectionSet(), InitDeviceTags(), Session(), SendCommand()
CmdLine / template
PollingOptions.CmdLine.Trim();
DeviceConfig properties referenced
| Property | Note |
|---|
| 未检测到 DeviceConfig.* 引用(可能使用基类封装)。 |
Line CustomOptions
| Key | Default |
|---|
| 未在 Logic 中检测到 CustomOptions.GetValueAs*(可能全部从设备模板 XML 读取)。 |
XML keys (Common)
| Node | Note |
|---|
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 节点名 |
Code excerpt
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();
Troubleshooting
- No data: line, address, template, connectivity.
- Template load errors: check logs.
- Options ignored: verify option scope (line vs device).