DrvModbusSlave Communicator Driver (Custom)
Functional Description
DrvModbusSlave is a custom Communicator driver in ScadaV6CommExt for field device connectivity. Protocol details follow the source implementation.
Scope and Version
- Source:
ScadaV6CommExt/DrvModbusSlave.Logic - TFM:
net8.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
32: internal Dictionary dictionary;
46: private bool DataTimeout;
54: private delegate bool ReceiveRequestDelegate(Connection connection_0, out SlaveRequest request);
67: this.DataTimeout = false;
68: base.ConnectionRequired = false;
82: this.templateDict.dictionary = new Dictionary();
83: this.templateDict.scadaClient = new ScadaClient(base.CommContext.AppConfig.ConnectionOptions);
87: private DeviceTemplate GetDeviceTemplate(string fileName)
89: DeviceTemplate deviceTemplate = null;
96: if (this.templateDict.dictionary.TryGetValue(fileName, out DeviceTemplate existingTemplate))
103: DeviceTemplate newTemplate = new DeviceTemplate();
118: private void InitDeviceTemplate()
124: DeviceTemplate deviceTemplate = this.GetDeviceTemplate(this.modbusSlaveDeviceConfig.IndependentDeviceOptions.TemplateFileName);
134: DeviceTemplate deviceTemplate = this.GetDeviceTemplate(this.modbusSlaveDeviceConfig.DeviceGatewayOptions.TemplateFileName);
216: private bool ReceiveRtuRequest(Connection connection_0, out SlaveRequest slaveRequest)
218: int num = connection_0.Read(this.buffer, 0, 6, base.PollingOptions.Timeout, 0, out string logText);
226: int num5 = connection_0.Read(this.buffer, 6, num4, base.PollingOptions.Timeout, 0, out logText);
253: private bool ReceiveTcpRequest(Connection connection, out SlaveRequest request)
256: int num = connection.Read(this.buffer, 0, 7, base.PollingOptions.Timeout, 0, out text);
261: int num3 = connection.Read(this.buffer, 7, num2, base.PollingOptions.Timeout, 0, out text);
281: private void DecodeIncomingRequest(Connection connection, SlaveRequest slaveRequest, IncomingRequestArgs incomingRequestArgs)
519: OptionList customOptions = base.LineContext.LineConfig.CustomOptions;
520: this.transMode = ScadaUtils.GetValueAsEnum(customOptions, "TransMode", TransMode.RTU);
526: this.InitDeviceTemplate();
601: this.DataTimeout = true;
Administrator UI (DrvModbusSlave.View)
Configure in Administrator → Communicator. Labels below come from the View language pack.
- View source:
ScadaV6CommExt/DrvModbusSlave.View - Main forms:
FrmChannelGatewayOptions.csFrmDeviceConfig.cs
| Phrase key | Text |
|---|---|
ConfigDirRequired | The device template file must be located inside {0} |
lblTemplateFileName | Device template |
lblTemplateFileName | Device template |
this | Device {0} Properties - Modbus Slave |
IndependentDeviceDescription | Receives data from Modbus Master. |
DeviceGatewayDescription | Provides data of the selected device to Modbus Master. |
gbDeviceGateway | Device Gateway Options |
btnEditTemplate | Edit |
btnBrowseTemplate | Browse... |
lblSourceDeviceNum | Data source device |
lblAddress | Address |
lblAddressHint | DEC, starting from 0 |
gbIndependentDevice | Independent Device Options |
btnEditTemplate | Edit |
btnBrowseTemplate | Browse... |
cbDevicesMode.Items[0] | Independent device |
cbDevicesMode.Items[1] | Device gateway |
cbDevicesMode.Items[2] | Channel gateway |
ChannelGatewayDescription | Provides data of the selected channels to Modbus Master. |
gbChannelGateway | Channel Gateway Options |
btnEdit | Edit |
btnSelect | Select |
gbElem | Element Parameters |
lblChannel | Channel |
lblDataType | Data type |
cbType.Items[0] | Undefined |
cbType.Items[1] | ushort (2 bytes) |
cbType.Items[2] | short (2 bytes) |
cbType.Items[3] | uint (4 bytes) |
cbType.Items[4] | int (4 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/DrvModbusSlave.Logic- Common: n/a
Overrides
OnCommLineStart(), InitDeviceTags(), InitDeviceData(), BindDeviceTags(), Session(), SendCommand(), ReceiveIncomingRequest(), ProcessIncomingRequest()
CmdLine / template
未匹配到 PollingOptions.CmdLine 单行片段。
DeviceConfig properties referenced
| Property | Note |
|---|---|
GeneralOptions | 源码中对 DeviceConfig 的引用 |
IndependentDeviceOptions | 源码中对 DeviceConfig 的引用 |
DeviceGatewayOptions | 源码中对 DeviceConfig 的引用 |
ChannelGatewayOptions | 源码中对 DeviceConfig 的引用 |
IsBound | 源码中对 DeviceConfig 的引用 |
Load | 源码中对 DeviceConfig 的引用 |
GetFileName | 源码中对 DeviceConfig 的引用 |
Line CustomOptions
| Key | Default |
|---|---|
| 未在 Logic 中检测到 CustomOptions.GetValueAs*(可能全部从设备模板 XML 读取)。 | |
XML keys (Common)
| Node | Note |
|---|---|
| 未在 Common 中解析到 GetChildAs*/AppendElem 节点(或无 Common 工程)。 | |
Code excerpt
84:
85: private DeviceTemplate GetDeviceTemplate(string fileName)
86: {
87: DeviceTemplate deviceTemplate = null;
121: {
122: DeviceTemplate deviceTemplate = this.GetDeviceTemplate(this.modbusSlaveDeviceConfig.IndependentDeviceOptions.TemplateFileName);
123: if (deviceTemplate != null)
124: {
131: {
132: DeviceTemplate deviceTemplate = this.GetDeviceTemplate(this.modbusSlaveDeviceConfig.DeviceGatewayOptions.TemplateFileName);
133: if (deviceTemplate != null)
134: {
516: {
517: OptionList customOptions = base.LineContext.LineConfig.CustomOptions;
518: this.transMode = ScadaUtils.GetValueAsEnum(customOptions, "TransMode", TransMode.RTU);
519: this.InitLineData();
554:
555: public override void InitDeviceTags()
556: {
557: this.InitElemsTags(this.elemGroupFactory.discreteInputsElemGroup);
592:
593: public override void Session()
594: {
595: if (!this.DeviceError && this.modbusSlaveDeviceConfig.GeneralOptions.DeviceMode == DeviceMode.IndependentDevice && this.modbusSlaveDeviceConfig.IndependentDeviceOptions.DataLifetime > 0)
Troubleshooting
- No data: line, address, template, connectivity.
- Template load errors: check logs.
- Options ignored: verify option scope (line vs device).