← Back to Docs

DrvHikvisionCounter Driver (Custom)

DrvHikvisionCounter communicator driver documentation.

Custom Communicator DriversVersion6.0.0Updated2026-04-29OwnerScadaV6CommExt

DrvHikvisionCounter Communicator Driver (Custom)

Functional Description

DrvHikvisionCounter is a custom Communicator driver in ScadaV6CommExt for field device connectivity. Protocol details follow the source implementation.

Scope and Version

  • Source: ScadaV6CommExt/DrvHikvisionCounter.Logic
  • TFM: net8.0
  • Version: 6.0.0

Install and Enable

  1. Deploy driver binaries to Communicator folders.
  2. Activate driver in Administrator → Communicator → Drivers.
  3. Upload configuration and restart Communicator.

Line and Device Configuration

  1. Create a communication line with the proper channel type.
  2. Add device and set address/timeouts.
  3. 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)

KeyDefaultNote
未在源码中匹配到明显的 GetValueAs* 调用,请在 Administrator 中打开该驱动的设备/线路配置界面逐项确认。

Code hints

35: protected class TemplateDict : Dictionary
69: ConnectionRequired = false;
94: protected virtual DeviceTemplate GetDeviceTemplate()
96: DeviceTemplate deviceTemplate = null;
97: string fileName = PollingOptions.CmdLine.Trim();
107: if (templateDict.TryGetValue(fileName, out DeviceTemplate existingTemplate))
115: DeviceTemplate newTemplate = CreateDeviceTemplate();
131: protected virtual DeviceTemplate CreateDeviceTemplate()
133: return new DeviceTemplate();
174: var camerePort = elemConfig.Value.Port;
177: //设备IP地址或者域名
178: byte[] byIP = System.Text.Encoding.Default.GetBytes(cameraIp);
180: byIP.CopyTo(struLogInfo.sDeviceAddress, 0);
192: struLogInfo.wPort = ushort.Parse(camerePort);//设备服务端口号
274: string strIP = System.Text.Encoding.UTF8.GetString(pAlarmer.sDeviceIP).TrimEnd('\0');
285: string stringAlarm = $"[视频检测报警上传][{strIP}], szTaskID:" + System.Text.Encoding.UTF8.GetString(struAIOPVideo.szTaskID).TrimEnd('\0') + ",报警触发时间:" + strTime;
293: ParseAlarmBuf(strIP, by, iLen);
302: private void ParseAlarmBuf(string strIP,byte[] by, int iLen)
311: WriteInfoLog($"Process Alarm [{strIP}]{total}");
314: var allTotal = CameraCounterMapper[strIP];
315: CameraCounterMapper[strIP] = allTotal + total;
323: private HikvisionCmd CreateMelsecMcCmd(DeviceTemplateOptions options,
341: DeviceTemplate deviceTemplate = GetDeviceTemplate();
457: Thread.Sleep(DeviceConfig.PollingOptions.Delay);

Administrator UI (DrvHikvisionCounter.View)

Configure in Administrator → Communicator. Labels below come from the View language pack.

  • View source: ScadaV6CommExt/DrvHikvisionCounter.View
  • Main forms:
    • FrmDeviceProps.cs
    • FrmDeviceTemplate.cs
Phrase keyText
gbCmdCommand Parameters
lblCmdCodeCommand code
lblCmdAddressElement address
lblTemplateFileNameDevice template
ConfigDirRequiredThe device template file must be located inside {0}
TemplateNotExistsThe device template file does not exist.
btnAddCmd.ToolTipAdd Command
gbTemplateDevice Template
TemplateTitle{0} - HikvisionCounter. Device Template Editor
DuplicatedCmdNumsDuplicated command numbers:
EmptyCmdCodesEmpty command codes found.
AddressHint{0}, starting from {1}
lblCmdNameName
lblCmdCodeWarnFill out code
chkCmdMultipleMultiple
lblCmdFuncCodeFunction code
lblCmdFuncCodeHexHexadecimal
lblCmdElemTypeElement type
lblCmdElemCntElement count
lblElemAddressAddress
lblGrAddressStart element address
thisDevice {0} Properties
gbCommLineCommunication Line
lblTransModeProtocol
gbDeviceDevice
btnEditTemplateEdit
btnBrowseTemplateBrowse...
btnNew.ToolTipNew Template
btnOpen.ToolTipOpen Template
btnSave.ToolTipSave 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/DrvHikvisionCounter.Logic
  • Common: DrvHikvisionCounter.Common

Overrides

InitDeviceTags(), Session(), SendCommand(), OnCommLineTerminate()

CmdLine / template

  • PollingOptions.CmdLine.Trim();

DeviceConfig properties referenced

PropertyNote
PollingOptions源码中对 DeviceConfig 的引用
DeviceNum源码中对 DeviceConfig 的引用

Line CustomOptions

KeyDefault
未在 Logic 中检测到 CustomOptions.GetValueAs*(可能全部从设备模板 XML 读取)。

XML keys (Common)

NodeNote
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

91:         /// 
92:         protected virtual DeviceTemplate GetDeviceTemplate()
93:         {
94:             DeviceTemplate deviceTemplate = null;

94:             DeviceTemplate deviceTemplate = null;
95:             string fileName = PollingOptions.CmdLine.Trim();
96: 
97:             if (string.IsNullOrEmpty(fileName))

336:         /// 
337:         public override void InitDeviceTags()
338:         {
339:             DeviceTemplate deviceTemplate = GetDeviceTemplate();

338:         {
339:             DeviceTemplate deviceTemplate = GetDeviceTemplate();
340:             if (deviceTemplate == null)
341:                 return;

436:         /// 
437:         public override void Session()
438:         {
439:             base.Session();

438:         {
439:             base.Session();
440:             if (!CameraSDKReady)
441:             {

Troubleshooting

  • No data: line, address, template, connectivity.
  • Template load errors: check logs.
  • Options ignored: verify option scope (line vs device).