DrvMelsecPlc Communicator Driver (Custom)
Functional Description
DrvMelsecPlc is a custom Communicator driver in ScadaV6CommExt for field device connectivity. Protocol details follow the source implementation.
Scope and Version
- Source:
ScadaV6CommExt/DrvMelsecPlc.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. |
NetworkNumber | — | Extracted from source; confirm meaning in driver implementation. |
NetworkStationNumber | — | Extracted from source; confirm meaning in driver implementation. |
TargetIOStation | — | Extracted from source; confirm meaning in driver implementation. |
Code hints
24: protected DeviceTemplate deviceTemplate;
44: ConnectionRequired = false; //不使用默认连接池
78: string fileName = PollingOptions.CmdLine.Trim();
79: deviceTemplate = new DeviceTemplate();
95: InitPlcConnection();
112: if (plcDeviceSession.CheckPlcConnection(melsecMcNet, deviceTemplate))
174: private void InitPlcConnection()
176: var deviceType = LineContext.LineConfig.CustomOptions.GetValueAsEnum("CpuType", CpuType.None);
177: RetryCount = (short)LineContext.LineConfig.CustomOptions.GetValueAsInt("RetryCount");
189: Log.WriteAction($"[Channel]TcpClientChannelOptions, host: {tcpClientChannel.Host}, port: {tcpClientChannel.TcpPort}");
191: melsecMcNet.EnableWriteBitToWordRegister = LineContext.LineConfig.CustomOptions.GetValueAsBool("EnableWriteBitToWordRegister");
192: melsecMcNet.ByteTransform.IsStringReverseByteWord = LineContext.LineConfig.CustomOptions.GetValueAsBool("IsStringReverseByteWord");
193: melsecMcNet.NetworkNumber = (byte)LineContext.LineConfig.CustomOptions.GetValueAsInt("NetworkNumber");
194: melsecMcNet.NetworkStationNumber = (byte)LineContext.LineConfig.CustomOptions.GetValueAsInt("NetworkStationNumber");
195: melsecMcNet.TargetIOStation= (ushort)LineContext.LineConfig.CustomOptions.GetValueAsInt("TargetIOStation");
196: melsecMcNet.CommunicationPipe = new PipeTcpNet(tcpClientChannel.Host, tcpClientChannel.TcpPort)
202: IsPersistentConnection = true,
236: protected DeviceTemplate deviceTemplate;
255: ConnectionRequired = false; //不使用默认连接池
289: string fileName = PollingOptions.CmdLine.Trim();
290: deviceTemplate = new DeviceTemplate();
306: InitPlcConnection();
323: if (plcDeviceSession.CheckPlcConnection(deviceTcpNet, deviceTemplate))
385: private void InitPlcConnection()
388: var deviceType = LineContext.LineConfig.CustomOptions.GetValueAsEnum("CpuType", MelsecPlcCpuType.None);
Administrator UI (DrvMelsecPlc.View)
Configure in Administrator → Communicator. Labels below come from the View language pack.
- View source:
ScadaV6CommExt/DrvMelsecPlc.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/DrvMelsecPlc.Logic- Common:
DrvMelsecPlc.Common
Overrides
OnCommLineStart(), OnCommLineTerminate(), InitDeviceTags(), Session(), SendCommand()
CmdLine / template
PollingOptions.CmdLine.Trim();
DeviceConfig properties referenced
| Property | Note |
|---|
StrAddress | 源码中对 DeviceConfig 的引用 |
Line CustomOptions
| Key | Default |
|---|
RetryCount | — |
EnableWriteBitToWordRegister | — |
IsStringReverseByteWord | — |
NetworkNumber | — |
NetworkStationNumber | — |
TargetIOStation | — |
XML keys (Common)
| Node | Note |
|---|
| 未在 Common 中解析到 GetChildAs*/AppendElem 节点(或无 Common 工程)。 |
Code excerpt
73:
74: public override void InitDeviceTags()
75: {
76: string fileName = PollingOptions.CmdLine.Trim();
75: {
76: string fileName = PollingOptions.CmdLine.Trim();
77: deviceTemplate = new DeviceTemplate();
78: if (!deviceTemplate.Load(Storage, fileName, out string errMsg))
87: //初始化点位
88: plcDeviceSession.InitDeviceTags(DeviceTags, deviceTemplate);
89:
90: CanSendCommands = deviceTemplate.Cmds.Count > 0;
93: InitPlcConnection();
94: Log.WriteAction($"InitDeviceTags -> Line running");
95: }
96:
98:
99: public override void Session()
100: {
101: base.Session();
100: {
101: base.Session();
102: if (deviceTemplate == null)
103: {
Troubleshooting
- No data: line, address, template, connectivity.
- Template load errors: check logs.
- Options ignored: verify option scope (line vs device).