DrvHikvisionTool Communicator Driver (Custom)
Functional Description
DrvHikvisionTool is a custom Communicator driver in ScadaV6CommExt for field device connectivity. Protocol details follow the source implementation.
Scope and Version
- Source:
ScadaV6CommExt/DrvHikvisionTool.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
30: protected class TemplateDict : Dictionary
43: private DeviceTemplate deviceTemplate;
61: ConnectionRequired = false;
86: protected virtual DeviceTemplate GetDeviceTemplate()
88: DeviceTemplate deviceTemplate = null;
89: string fileName = PollingOptions.CmdLine.Trim();
99: if (templateDict.TryGetValue(fileName, out DeviceTemplate existingTemplate))
107: DeviceTemplate newTemplate = CreateDeviceTemplate();
123: protected virtual DeviceTemplate CreateDeviceTemplate()
125: return new DeviceTemplate();
160: var camerePort = elemConfig.Value.Port;
163: WriteInfoLog($"Connect to camera IP:{cameraIp},Port:{camerePort},User:{cameraUser},Pwd:{cameraPwd}");
164: //设备IP地址或者域名
165: byte[] byIP = System.Text.Encoding.Default.GetBytes(cameraIp);
167: byIP.CopyTo(struLogInfo.sDeviceAddress, 0);
180: ushort.TryParse(camerePort, out struLogInfo.wPort);
215: private HikvisionCmd CreateHikCmd(DeviceTemplateOptions options,
233: deviceTemplate = GetDeviceTemplate();
350: Log.WriteLine($"获取门禁状态失败,IP:{elemConfig.Ip}");
Administrator UI (DrvHikvisionTool.View)
Configure in Administrator → Communicator. Labels below come from the View language pack.
- View source:
ScadaV6CommExt/DrvHikvisionTool.View - Main forms:
FrmDeviceProps.csFrmDeviceTemplate.cs
| Phrase key | Text |
|---|
gbCmd | Command Parameters |
lblCmdCode | Command code |
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 | {0} - HikvisionTool. Device Template Editor |
DuplicatedCmdNums | Duplicated command numbers: |
EmptyCmdCodes | Empty command codes found. |
AddressHint | {0}, starting from {1} |
lblCmdName | Name |
lblCmdCodeWarn | Fill out code |
chkCmdMultiple | Multiple |
lblCmdFuncCode | Function code |
lblCmdFuncCodeHex | Hexadecimal |
lblCmdElemType | Element type |
lblCmdElemCnt | Element count |
lblElemAddress | Address |
lblGrAddress | Start element address |
this | Device {0} Properties |
gbCommLine | Communication Line |
lblTransMode | Protocol |
gbDevice | Device |
btnEditTemplate | Edit |
btnBrowseTemplate | Browse... |
btnNew.ToolTip | New Template |
btnOpen.ToolTip | Open Template |
btnSave.ToolTip | Save Template |
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/DrvHikvisionTool.Logic- Common:
DrvHikvisionTool.Common
Overrides
InitDeviceTags(), Session(), SendCommand(), OnCommLineTerminate()
CmdLine / template
PollingOptions.CmdLine.Trim();
DeviceConfig properties referenced
| Property | Note |
|---|
DeviceNum | 源码中对 DeviceConfig 的引用 |
Line CustomOptions
| Key | Default |
|---|
| 未在 Logic 中检测到 CustomOptions.GetValueAs*(可能全部从设备模板 XML 读取)。 |
XML keys (Common)
| Node | Note |
|---|
Elem | 来自 Common 配置加载/保存相关源码中的 XML 节点名 |
ZeroAddr | 来自 Common 配置加载/保存相关源码中的 XML 节点名 |
DecAddr | 来自 Common 配置加载/保存相关源码中的 XML 节点名 |
DefByteOrder2 | 来自 Common 配置加载/保存相关源码中的 XML 节点名 |
DefByteOrder4 | 来自 Common 配置加载/保存相关源码中的 XML 节点名 |
DefByteOrder8 | 来自 Common 配置加载/保存相关源码中的 XML 节点名 |
ElemGroups | 来自 Common 配置加载/保存相关源码中的 XML 节点名 |
ElemGroup | 来自 Common 配置加载/保存相关源码中的 XML 节点名 |
Cmds | 来自 Common 配置加载/保存相关源码中的 XML 节点名 |
Cmd | 来自 Common 配置加载/保存相关源码中的 XML 节点名 |
Code excerpt
83: ///
84: protected virtual DeviceTemplate GetDeviceTemplate()
85: {
86: DeviceTemplate deviceTemplate = null;
86: DeviceTemplate deviceTemplate = null;
87: string fileName = PollingOptions.CmdLine.Trim();
88:
89: if (string.IsNullOrEmpty(fileName))
228: ///
229: public override void InitDeviceTags()
230: {
231: deviceTemplate = GetDeviceTemplate();
230: {
231: deviceTemplate = GetDeviceTemplate();
232: if (deviceTemplate == null)
233: return;
322: ///
323: public override void Session()
324: {
325: base.Session();
324: {
325: base.Session();
326: if (!CameraSDKReady)
327: {
Troubleshooting
- No data: line, address, template, connectivity.
- Template load errors: check logs.
- Options ignored: verify option scope (line vs device).