DrvKeyencePlc Communicator Driver (Custom)
Functional Description
DrvKeyencePlc is a custom Communicator driver in ScadaV6CommExt for field device connectivity. Protocol details follow the source implementation.
Scope and Version
- Source:
ScadaV6CommExt/DrvKeyencePlc.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. |
EnableWriteBitToWordRegister | — | Extracted from source; confirm meaning in driver implementation. |
IsStringReverseByteWord | — | Extracted from source; confirm meaning in driver implementation. |
UseStation | — | Extracted from source; confirm meaning in driver implementation. |
Station | — | Extracted from source; confirm meaning in driver implementation. |
Code hints
23: protected DeviceTemplate deviceTemplate;
43: ConnectionRequired = false; //不使用默认连接池
77: string fileName = PollingOptions.CmdLine.Trim();
78: deviceTemplate = new DeviceTemplate();
94: InitPlcConnection();
111: if (plcDeviceSession.CheckPlcConnection(keyenceMcNet, deviceTemplate))
173: private void InitPlcConnection()
175: var deviceType = LineContext.LineConfig.CustomOptions.GetValueAsEnum("CpuType", CpuType.Mc_3E_Binary);
176: RetryCount = (short)LineContext.LineConfig.CustomOptions.GetValueAsInt("RetryCount");
188: Log.WriteAction($"[Channel]TcpClientChannelOptions, host: {tcpClientChannel.Host}, port: {tcpClientChannel.TcpPort}");
190: keyenceMcNet.EnableWriteBitToWordRegister = LineContext.LineConfig.CustomOptions.GetValueAsBool("EnableWriteBitToWordRegister");
191: keyenceMcNet.ByteTransform.IsStringReverseByteWord = LineContext.LineConfig.CustomOptions.GetValueAsBool("IsStringReverseByteWord");
192: keyenceMcNet.CommunicationPipe = new PipeTcpNet(tcpClientChannel.Host, tcpClientChannel.TcpPort)
198: IsPersistentConnection = true,
236: protected DeviceTemplate deviceTemplate;
256: ConnectionRequired = false; //不使用默认连接池
290: string fileName = PollingOptions.CmdLine.Trim();
291: deviceTemplate = new DeviceTemplate();
307: InitPlcConnection();
324: if (plcDeviceSession.CheckPlcConnection(keyenceNano, deviceTemplate))
386: private void InitPlcConnection()
388: var deviceType = LineContext.LineConfig.CustomOptions.GetValueAsEnum("CpuType", CpuType.Mc_3E_Binary);
389: RetryCount = (short)LineContext.LineConfig.CustomOptions.GetValueAsInt("RetryCount");
398: if (channelOptions is SerialPortChannelOptions serialPortChannel)
400: keyenceNano.UseStation = LineContext.LineConfig.CustomOptions.GetValueAsBool("UseStation");
Administrator UI (DrvKeyencePlc.View)
Configure in Administrator → Communicator. Labels below come from the View language pack.
- View source:
ScadaV6CommExt/DrvKeyencePlc.View - Main forms:
| Phrase key | Text |
|---|
| No phrases parsed; check Lang folder in View project. |
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/DrvKeyencePlc.Logic- Common:
DrvKeyencePlc.Common
Overrides
OnCommLineStart(), OnCommLineTerminate(), InitDeviceTags(), Session(), SendCommand()
CmdLine / template
PollingOptions.CmdLine.Trim();
DeviceConfig properties referenced
| Property | Note |
|---|
| 未检测到 DeviceConfig.* 引用(可能使用基类封装)。 |
Line CustomOptions
| Key | Default |
|---|
RetryCount | — |
EnableWriteBitToWordRegister | — |
IsStringReverseByteWord | — |
UseStation | — |
Station | — |
XML keys (Common)
| Node | Note |
|---|
| 未在 Common 中解析到 GetChildAs*/AppendElem 节点(或无 Common 工程)。 |
Code excerpt
72:
73: public override void InitDeviceTags()
74: {
75: string fileName = PollingOptions.CmdLine.Trim();
74: {
75: string fileName = PollingOptions.CmdLine.Trim();
76: deviceTemplate = new DeviceTemplate();
77: if (!deviceTemplate.Load(Storage, fileName, out string errMsg))
86: //初始化点位
87: plcDeviceSession.InitDeviceTags(DeviceTags, deviceTemplate);
88:
89: CanSendCommands = deviceTemplate.Cmds.Count > 0;
92: InitPlcConnection();
93: Log.WriteAction($"InitDeviceTags -> Line running");
94: }
95:
97:
98: public override void Session()
99: {
100: base.Session();
99: {
100: base.Session();
101: if (deviceTemplate == null)
102: {
Troubleshooting
- No data: line, address, template, connectivity.
- Template load errors: check logs.
- Options ignored: verify option scope (line vs device).