DrvDLMS Communicator Driver (Custom)
Functional Description
DrvDLMS is a custom Communicator driver in ScadaV6CommExt for field device connectivity. Protocol details follow the source implementation.
Scope and Version
- Source:
ScadaV6CommExt/DrvDLMS.Logic - TFM:
net8.0 - Version:
6.2.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
26: DeviceTemplate deviceTemplate;
32: private DlmsConnection dlmsConnection;
42: ConnectionRequired = false;
51: private DlmsConnection GetDlmsConnection()
53: var dlmsConnectionKey = $"Conn_{LineContext.CommLineNum}";
54: DlmsConnection connection = LineContext.SharedData.ContainsKey(dlmsConnectionKey) ?
55: LineContext.SharedData[dlmsConnectionKey] as DlmsConnection : null;
59: connection = new DlmsConnection(LineContext);
60: LineContext.SharedData.Add(dlmsConnectionKey, connection);
72: this.dlmsConnection = GetDlmsConnection();
80: interfaceType = LineContext.LineConfig.CustomOptions.GetValueAsEnum("TransMode", InterfaceType.HDLC);
100: if (dlmsConnection != null) dlmsConnection.Close();
113: string fileName = PollingOptions.CmdLine.Trim();
114: deviceTemplate = new DeviceTemplate();
328: dlmsConnection.Open(); //重新连接
329: dlmsReader = new DLMSReader(dlmsClient, dlmsConnection.DlmsMedia, Log, "");
330: dlmsReader.WaitTime = Math.Max(PollingOptions.Timeout, 1000); //读取超时时间
331: dlmsReader.InitializeConnection();
Administrator UI (DrvDLMS.View)
Configure in Administrator → Communicator. Labels below come from the View language pack.
- View source:
ScadaV6CommExt/DrvDLMS.View - Main forms:
FrmDeviceProps.csFrmDeviceTemplate.csFrmTemplateSettings.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} - 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/DrvDLMS.Logic- Common:
DrvDLMS.Common
Overrides
OnCommLineStart(), OnCommLineTerminate(), InitDeviceTags(), Session(), SendCommand()
CmdLine / template
PollingOptions.CmdLine.Trim();
DeviceConfig properties referenced
| Property | Note |
|---|
DeviceNum | 源码中对 DeviceConfig 的引用 |
Line CustomOptions
| Key | Default |
|---|
| 未在 Logic 中检测到 CustomOptions.GetValueAs*(可能全部从设备模板 XML 读取)。 |
XML keys (Common)
| Node | Note |
|---|
Elem | 来自 Common 配置加载/保存相关源码中的 XML 节点名 |
Settings | 来自 Common 配置加载/保存相关源码中的 XML 节点名 |
ElemGroups | 来自 Common 配置加载/保存相关源码中的 XML 节点名 |
ElemGroup | 来自 Common 配置加载/保存相关源码中的 XML 节点名 |
ClientAddress | 来自 Common 配置加载/保存相关源码中的 XML 节点名 |
Password | 来自 Common 配置加载/保存相关源码中的 XML 节点名 |
LogicalAddress | 来自 Common 配置加载/保存相关源码中的 XML 节点名 |
PhysicalAddress | 来自 Common 配置加载/保存相关源码中的 XML 节点名 |
AuthenticationType | 来自 Common 配置加载/保存相关源码中的 XML 节点名 |
Code excerpt
77: {
78: interfaceType = LineContext.LineConfig.CustomOptions.GetValueAsEnum("TransMode", InterfaceType.HDLC);
79: dlmsClient.InterfaceType = interfaceType; //传输类型
80: var authentication = ScadaUtils.XmlParseEnum(deviceTemplate.Settings.AuthenticationType.ToString());
108: ///
109: public override void InitDeviceTags()
110: {
111: string fileName = PollingOptions.CmdLine.Trim();
110: {
111: string fileName = PollingOptions.CmdLine.Trim();
112: deviceTemplate = new DeviceTemplate();
113: if (!deviceTemplate.Load(Storage, fileName, out string errMsg))
163: ///
164: public override void Session()
165: {
166: if (this.IsTerminated) return;
166: if (this.IsTerminated) return;
167: base.Session();
168: if (deviceTemplate.ElemGroups.Count > 0)
169: {
260: FinishRequest();
261: FinishSession();
262: }
263:
Troubleshooting
- No data: line, address, template, connectivity.
- Template load errors: check logs.
- Options ignored: verify option scope (line vs device).