DrvIEC104 Communicator Driver (Custom)
Functional Description
DrvIEC104 is a custom Communicator driver in ScadaV6CommExt for field device connectivity. Protocol details follow the source implementation.
Scope and Version
- Source:
ScadaV6CommExt/DrvIEC104.Logic - TFM:
net8.0 - Version:
6.1.6
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
33: protected class TemplateDict : Dictionary
46: private DeviceTemplate deviceTemplate;
51: private Connection mIEC104Con; // IEC104连接对象
69: var (hostName, port) = ParseConnectionAddress();
74: mIEC104Con = new Connection(hostName, port);
76: mIEC104Con.ConnectTimeout = 5000;
80: mIEC104Con.SetConnectionHandler(ConnectionHandler, null);
112: private (string hostName, int port) ParseConnectionAddress()
122: if (int.TryParse(address.Substring(colonIndex + 1), out int parsedPort))
124: port = parsedPort;
161: private void ConnectionHandler(object parameter, ConnectionEvent connectionEvent)
169: case ConnectionEvent.OPENED:
170: Log.WriteInfo("ConnectionHandler-> Connection opened successfully");
175: case ConnectionEvent.CLOSED:
176: Log.WriteInfo("ConnectionHandler-> Connection closed");
181: case ConnectionEvent.STARTDT_CON_RECEIVED:
182: Log.WriteInfo("ConnectionHandler-> STARTDT CON received");
185: case ConnectionEvent.STOPDT_CON_RECEIVED:
186: Log.WriteInfo("ConnectionHandler-> STOPDT CON received");
190: Log.WriteInfo($"ConnectionHandler-> Unknown event: {connectionEvent}");
196: Log.WriteError($"ConnectionHandler-> Exception: {ex.Message}");
267: ConnectionRequired = false; // 不使用默认连接池
501: int timeoutMs = mappedCmd.TimeoutMs > 0 ? mappedCmd.TimeoutMs : 5000;
607: int timeoutMs = mappedCmd.TimeoutMs > 0 ? mappedCmd.TimeoutMs : 5000;
633: Log.WriteWarning($"DownloadEntryWithRetry-> Timeout ioa={ioa} nof={nof} try={i}/{attempts}");
Administrator UI (DrvIEC104.View)
Configure in Administrator → Communicator. Labels below come from the View language pack.
- View source:
ScadaV6CommExt/DrvIEC104.View - Main forms:
FrmAuthSetting.csFrmDeviceProps.csFrmDeviceTemplate.csFrmTemplateSettings.cs
| Phrase key | Text |
|---|
this | IEC104. Device Template Editor |
btnAddCmd.ToolTip | Add command |
gbDevTemplate | Device template |
gbCmd | Command parameters |
lblCmdAddress | Element address |
lblCmdNum | Command number |
CmdsNode | Commands |
DefCmdName | |
lblDevTemplate | Device template |
TemplNotExists | The device template file does not exist. |
btnNew.ToolTip | Create new template |
btnOpen.ToolTip | Open template |
btnSave.ToolTip | Save template |
btnSaveAs.ToolTip | Save template as |
btnEditSettings.ToolTip | Edit template settings |
lblGrAddress | Start element address |
lblElemAddress | Address |
lblCmdName | Name |
lblCmdTableType | Data table |
cbCmdTableType.Items[0] | 归一化遥测值 (NVA) |
cbCmdTableType.Items[1] | 标度化值(SVA) |
cbCmdTableType.Items[2] | 短浮点数(Float) |
chkCmdMultiple | Multiple |
lblCmdFuncCode | Function code |
lblCmdElemType | Element type |
lblCmdElemCnt | Element count |
lblCmdByteOrder | Byte order |
lblCmdByteOrderExample | For example, 01234567 |
AddressHint | {0}, starting from {1} |
SaveTemplateConfirm | Template has been modified. Save the changes? |
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/DrvIEC104.Logic- Common:
DrvIEC104.Common
Overrides
Session(), SendCommand(), OnCommLineTerminate(), InitDeviceTags()
CmdLine / template
PollingOptions.CmdLine.Trim();
DeviceConfig properties referenced
| Property | Note |
|---|
Name | 源码中对 DeviceConfig 的引用 |
StrAddress | 源码中对 DeviceConfig 的引用 |
Line CustomOptions
| Key | Default |
|---|
| 未在 Logic 中检测到 CustomOptions.GetValueAs*(可能全部从设备模板 XML 读取)。 |
XML keys (Common)
| Node | Note |
|---|
Settings | 来自 Common 配置加载/保存相关源码中的 XML 节点名 |
ElemGroups | 来自 Common 配置加载/保存相关源码中的 XML 节点名 |
ElemGroup | 来自 Common 配置加载/保存相关源码中的 XML 节点名 |
Cmds | 来自 Common 配置加载/保存相关源码中的 XML 节点名 |
Cmd | 来自 Common 配置加载/保存相关源码中的 XML 节点名 |
ServerInterrogationInterval | 来自 Common 配置加载/保存相关源码中的 XML 节点名 |
ServerCommonAddress | 来自 Common 配置加载/保存相关源码中的 XML 节点名 |
ServerClockSync | 来自 Common 配置加载/保存相关源码中的 XML 节点名 |
Elem | 来自 Common 配置加载/保存相关源码中的 XML 节点名 |
AuthCode | 来自 Common 配置加载/保存相关源码中的 XML 节点名 |
AuthSett | 来自 Common 配置加载/保存相关源码中的 XML 节点名 |
Code excerpt
111: {
112: var address = DeviceConfig.StrAddress;
113: var hostName = address;
114: var port = 2404;
271: #region 主要会话方法
272: public override void Session()
273: {
274: base.Session();
273: {
274: base.Session();
275:
276: try
318:
319: FinishSession();
320: }
321:
1639: #region 显示功能
1640: public override void InitDeviceTags()
1641: {
1642: deviceTemplate = GetDeviceTemplate();
1641: {
1642: deviceTemplate = GetDeviceTemplate();
1643: if (deviceTemplate == null) return;
1644: // 配置读取公共地址和总召时间
Troubleshooting
- No data: line, address, template, connectivity.
- Template load errors: check logs.
- Options ignored: verify option scope (line vs device).