DrvABPlc Communicator Driver (Custom)
Functional Description
DrvABPlc is a custom Communicator driver in ScadaV6CommExt for field device connectivity. Protocol details follow the source implementation.
Scope and Version
- Source:
ScadaV6CommExt/DrvABPlc.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 |
|---|
RetryCount | — | Extracted from source; confirm meaning in driver implementation. |
Slot | — | Extracted from source; confirm meaning in driver implementation. |
Station | — | Extracted from source; confirm meaning in driver implementation. |
DstNode | — | Extracted from source; confirm meaning in driver implementation. |
SrcNode | — | Extracted from source; confirm meaning in driver implementation. |
Code hints
26: protected DeviceTemplate deviceTemplate;
47: ConnectionRequired = false; //不使用默认连接池
91: string fileName = PollingOptions.CmdLine.Trim();
92: deviceTemplate = new DeviceTemplate();
107: InitPlcConnection();
124: if (plcDeviceSession.CheckPlcConnection(allenBradleyNet, deviceTemplate))
186: private void InitPlcConnection()
188: var deviceType = LineContext.LineConfig.CustomOptions.GetValueAsEnum("CpuType", CpuType.AllenBradleyNet);
189: RetryCount = (short)LineContext.LineConfig.CustomOptions.GetValueAsInt("RetryCount");
199: allenBradleyNet.Slot = (byte)LineContext.LineConfig.CustomOptions.GetValueAsInt("Slot");
203: Log.WriteAction($"[Channel]TcpClientChannelOptions, host: {tcpClientChannel.Host}, port: {tcpClientChannel.TcpPort}");
205: allenBradleyNet.CommunicationPipe = new PipeTcpNet(tcpClientChannel.Host, tcpClientChannel.TcpPort)
211: IsPersistentConnection = true,
216: Log.WriteAction($"[Channel]UdpClientChannelOptions, host: {udpClientChannel.Host}, port: {udpClientChannel.TcpPort}");
218: allenBradleyNet.CommunicationPipe = new PipeUdpNet(udpClientChannel.Host, udpClientChannel.TcpPort)
223: IsPersistentConnection = true,
259: protected DeviceTemplate deviceTemplate;
280: ConnectionRequired = false; //不使用默认连接池
324: string fileName = PollingOptions.CmdLine.Trim();
325: deviceTemplate = new DeviceTemplate();
340: InitPlcConnection();
357: if (plcDeviceSession.CheckPlcConnection(allenBradleySLCNet, deviceTemplate))
419: private void InitPlcConnection()
421: var deviceType = LineContext.LineConfig.CustomOptions.GetValueAsEnum("CpuType", CpuType.AllenBradleyNet);
422: RetryCount = (short)LineContext.LineConfig.CustomOptions.GetValueAsInt("RetryCount");
Administrator UI (DrvABPlc.View)
Configure in Administrator → Communicator. Labels below come from the View language pack.
- View source:
ScadaV6CommExt/DrvABPlc.View - Main forms:
| 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 | AllenBradley. 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 |
chkCmdMultiple | Multiple |
lblCmdFuncCode | Function code |
lblCmdFuncCodeHex | Hexadecimal |
lblCmdElemType | Element type |
lblCmdElemCnt | Element count |
lblCmdByteOrder | Byte order |
lblCmdByteOrderExample | For example, 01234567 |
lblElemAddress | Address |
lblGrAddress | Start element address |
this | Device {0} Properties |
gbCommLine | Communication Line |
lblTransMode | Protocol |
gbDevice | Device |
btnEditTemplate | Edit |
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/DrvABPlc.Logic- Common:
DrvABPlc.Common
Overrides
OnCommLineStart(), OnCommLineTerminate(), InitDeviceTags(), Session(), SendCommand()
CmdLine / template
PollingOptions.CmdLine.Trim();
DeviceConfig properties referenced
| Property | Note |
|---|
| 未检测到 DeviceConfig.* 引用(可能使用基类封装)。 |
Line CustomOptions
| Key | Default |
|---|
RetryCount | — |
Slot | — |
XML keys (Common)
| Node | Note |
|---|
| 未在 Common 中解析到 GetChildAs*/AppendElem 节点(或无 Common 工程)。 |
Code excerpt
86:
87: public override void InitDeviceTags()
88: {
89: string fileName = PollingOptions.CmdLine.Trim();
88: {
89: string fileName = PollingOptions.CmdLine.Trim();
90: deviceTemplate = new DeviceTemplate();
91: if (!deviceTemplate.Load(Storage, fileName, out string errMsg))
99: //初始化点位
100: plcDeviceSession.InitDeviceTags(DeviceTags, deviceTemplate);
101:
102: CanSendCommands = deviceTemplate.Cmds.Count > 0;
105: InitPlcConnection();
106: Log.WriteAction($"InitDeviceTags -> Line running");
107: }
108:
110:
111: public override void Session()
112: {
113: base.Session();
112: {
113: base.Session();
114: if (deviceTemplate == null)
115: {
Troubleshooting
- No data: line, address, template, connectivity.
- Template load errors: check logs.
- Options ignored: verify option scope (line vs device).