Ejemplo n.º 1
0
        /// <summary>
        /// 登出设备
        /// </summary>
        /// <param name="info">所有操作使用的UseInfo对象</param>
        /// <returns>true:操作成功,false:操作失败</returns>
        public bool Logout(ref DvrUseInfo info)
        {
            bool b = false;

            //停止回放 Stop playback
            if (info.PlaybackId >= 0)
            {
                b = HikVideoApi.NET_DVR_StopPlayBack(info.PlaybackId);
                info.PlaybackId = -1;
            }

            //停止下载 Stop download
            if (info.DownId >= 0)
            {
                b           = HikVideoApi.NET_DVR_StopGetFile(info.DownId);
                info.DownId = -1;
            }

            //注销登录 Logout the device
            if (info.UserId >= 0)
            {
                b           = HikApi.NET_DVR_Logout(info.UserId);
                info.UserId = -1;
            }
            return(b);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 获取屏幕拼接参数
        /// </summary>
        /// <param name="userId">注册设备的ID</param>
        /// <param name="config">大屏拼接参数结构体</param>
        /// <param name="screenNo">大屏序号</param>
        /// <returns>成功:true,失败:false</returns>
        public bool GetScreenDeviceConfig(int userId, ref HikScreenStruct.NET_DVR_SINGLEWALLPARAM config, int screenNo = 0)
        {
            uint   dwSize          = 4 + MAX_COUNT * (uint)Marshal.SizeOf(config);
            IntPtr ptrIpParaCfgV40 = Marshal.AllocHGlobal((Int32)dwSize);

            Marshal.StructureToPtr(config, ptrIpParaCfgV40, false);

            return(HikApi.NET_DVR_GetDeviceConfig(userId, (int)9002, 0xffffffff, IntPtr.Zero, 0, IntPtr.Zero, ptrIpParaCfgV40, dwSize));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 获取屏幕拼接参数
        /// </summary>
        /// <param name="userId">用户id</param>
        /// <param name="config">大屏拼接参数结构体</param>
        /// <param name="screenNo">大屏序号</param>
        /// <returns>成功:true,失败:false</returns>
        public bool GetScreenConfig(int userId, ref HikScreenStruct.NET_DVR_SCREEN_SPLICE_CFG config, int screenNo = 0)
        {
            uint   dwSize          = (uint)Marshal.SizeOf(config);
            IntPtr ptrIpParaCfgV40 = Marshal.AllocHGlobal((Int32)dwSize);

            Marshal.StructureToPtr(config, ptrIpParaCfgV40, false);
            uint dwReturn = 0;

            return(HikApi.NET_DVR_GetDVRConfig(userId, (int)9039, screenNo, ptrIpParaCfgV40, dwSize, ref dwReturn));
        }
Ejemplo n.º 4
0
 /// <summary>
 /// 撤销报警上传通道
 /// </summary>
 /// <param name="info">建立报警上传通道时的UserInfo对象</param>
 /// <returns>true:成功,false:失败</returns>
 public bool CloseAlarmChanV30(ref DvrUseInfo info)
 {
     if (info.UserId >= 0)
     {
         return(HikApi.NET_DVR_CloseAlarmChan_V30(info.AlarmId));
     }
     else
     {
         return(false);
     }
 }
Ejemplo n.º 5
0
        /// <summary>
        /// 登出设备
        /// </summary>
        /// <param name="info">所有操作使用的UseInfo对象</param>
        /// <returns>true:操作成功,false:操作失败</returns>
        public bool Logout(ref DvrUseInfo info)
        {
            bool b = false;

            //注销登录 Logout the device
            if (info.UserId >= 0)
            {
                b           = HikApi.NET_DVR_Logout(info.UserId);
                info.UserId = -1;
            }
            return(b);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 启动设备状态巡检
        /// </summary>
        /// <param name="timer">定时检测设备工作状态,单位:ms,0表示使用默认值(30000),最小值为1000 </param>
        /// <returns>TRUE表示成功,FALSE表示失败。</returns>
        /// <remarks>
        /// 启动后,SDK定时巡检设备,获取到的设备状态信息在结构体的回调函数中返回。相当于实现定时调用NET_DVR_GetDeviceConfig(命令:NET_DVR_GET_WORK_STATUS)。
        /// </remarks>
        public bool StartGetDevState(int timer = 0)
        {
            workState += FrmWNServer_workState;
            NET_DVR_CHECK_DEV_STATE state = new NET_DVR_CHECK_DEV_STATE()
            {
                byRes = new byte[60], dwTimeout = (uint)timer, pUserData = IntPtr.Zero, fnStateCB = workState
            };
            uint   dwSize          = (uint)Marshal.SizeOf(state);
            IntPtr ptrIpParaCfgV40 = Marshal.AllocHGlobal((Int32)dwSize);

            Marshal.StructureToPtr(state, ptrIpParaCfgV40, false);
            return(HikApi.NET_DVR_StartGetDevState(ptrIpParaCfgV40));
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 停止设备监听
        /// </summary>
        /// <param name="listenId">监听设备时Id</param>
        /// <returns>true:成功,false:失败</returns>
        public bool StopListenV30(ref int listenId)
        {
            bool b = HikApi.NET_DVR_StopListen_V30(listenId);

            if (b)
            {
                listenId = -1;
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 启动监听,接收设备主动上传的报警等信息(支持多线程)。
        /// </summary>
        /// <param name="alarmCallBack">报警消息回调</param>
        /// <param name="listenId">返回监听ID</param>
        /// <param name="listenIp">监听IP</param>
        /// <param name="listenPort">监听端口</param>
        /// <returns>true:成功,false:失败</returns>
        public bool StartLisenV30(HikDelegate.MSGCallBack alarmCallBack, ref int listenId, string listenIp, int listenPort = 7100)
        {
            if (string.IsNullOrWhiteSpace(listenIp) || string.IsNullOrWhiteSpace(listenPort.ToString()))
            {
                return(false);
            }
            listenId = HikApi.NET_DVR_StartListen_V30(listenIp, (short)listenPort, alarmCallBack, IntPtr.Zero);
            uint x = HikApi.NET_DVR_GetLastError();

            if (listenId < 0)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// 获取模拟通道信息
        /// </summary>
        /// <param name="info">登录设备时的UseInfo对象</param>
        /// <returns>通道属性对象集合</returns>
        private List <ChannelState> GetAnalogChannelInfo(ref DvrUseInfo info)
        {
            NET_DVR_IPPARACFG_V40  m_struIpParaCfgV40 = new NET_DVR_IPPARACFG_V40();
            NET_DVR_DEVICEINFO_V30 deviceInfo         = new NET_DVR_DEVICEINFO_V30();
            List <ChannelState>    states             = new List <ChannelState>();
            uint dwSize = (uint)Marshal.SizeOf(m_struIpParaCfgV40);

            IntPtr ptrIpParaCfgV40 = Marshal.AllocHGlobal((Int32)dwSize);

            Marshal.StructureToPtr(m_struIpParaCfgV40, ptrIpParaCfgV40, false);

            uint dwReturn = 0;

            if (!HikApi.NET_DVR_GetDVRConfig(info.UserId, NET_DVR_GET_IPPARACFG_V40, -1, ptrIpParaCfgV40, dwSize, ref dwReturn))
            {
                return(states);
            }
            else
            {
                m_struIpParaCfgV40 = (NET_DVR_IPPARACFG_V40)Marshal.PtrToStructure(ptrIpParaCfgV40, typeof(NET_DVR_IPPARACFG_V40));
                for (int i = 0; i < dwAChanTotalNum; i++)
                {
                    ChannelState state = new ChannelState()
                    {
                        Num = i + 1, IsIpChannel = false
                    };
                    if (m_struIpParaCfgV40.byAnalogChanEnable[i] == 0)
                    {
                        state.IsEnabled = false;  //通道已被禁用 This channel has been disabled
                    }
                    else
                    {
                        state.IsEnabled = true;  //通道处于启用状态
                    }
                    states.Add(state);
                    iChannelNum[i] = i + (int)deviceInfo.byStartChan;
                }
            }
            Marshal.FreeHGlobal(ptrIpParaCfgV40);
            return(states);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// 登录设备
        /// </summary>
        /// <param name="info">登录设备所需的信息</param>
        /// <returns>true:成功,false:失败</returns>
        public bool Login(ref DvrUseInfo info)
        {
            bool b = false;

            if (info.UserId <= -1)
            {
                string DVRIPAddress  = info.DvrIp;                            //设备IP地址或者域名
                short  DVRPortNumber = short.Parse(info.DvrPoint.ToString()); //设备服务端口号
                string DVRUserName   = info.UserName;                         //设备登录用户名
                string DVRPassword   = info.UserPwd;                          //设备登录密码
                NET_DVR_DEVICEINFO_V30 DeviceInfo = new NET_DVR_DEVICEINFO_V30();
                //登录设备 Login the device
                info.UserId = HikApi.NET_DVR_Login_V30(DVRIPAddress, DVRPortNumber, DVRUserName, DVRPassword, ref DeviceInfo);
                if (info.UserId < 0)
                {
                    b = false;
                }
                else
                {
                    b = true;
                }
            }
            return(b);
        }
Ejemplo n.º 11
0
 /// <summary>
 /// 远程控制
 /// </summary>
 /// <param name="useInfo">登录设备时的UseInfo对象</param>
 /// <param name="control">控制类型</param>
 /// <param name="lpInBuffer">窗口号或者解码文件信息</param>
 /// <returns>成功:true,失败:false</returns>
 public bool RemoteControl(ref DvrUseInfo useInfo, RemoteControl control, IntPtr lpInBuffer)
 {
     return(HikApi.NET_DVR_RemoteControl(useInfo.UserId, (uint)control, lpInBuffer, 0));
 }
Ejemplo n.º 12
0
        /// <summary>
        /// 获取IP通道信息
        /// </summary>
        /// <param name="info">登录设备时的UseInfo对象</param>
        /// <returns>通道属性对象集合</returns>
        private List <ChannelState> GetIPChannelInfo(ref DvrUseInfo info)
        {
            NET_DVR_IPPARACFG_V40    m_struIpParaCfgV40 = new NET_DVR_IPPARACFG_V40();
            NET_DVR_GET_STREAM_UNION m_unionGetStream   = new NET_DVR_GET_STREAM_UNION();
            NET_DVR_IPCHANINFO       m_struChanInfo     = new NET_DVR_IPCHANINFO();
            List <ChannelState>      states             = new List <ChannelState>();
            uint dwSize = (uint)Marshal.SizeOf(m_struIpParaCfgV40);

            IntPtr ptrIpParaCfgV40 = Marshal.AllocHGlobal((Int32)dwSize);

            Marshal.StructureToPtr(m_struIpParaCfgV40, ptrIpParaCfgV40, false);

            uint dwReturn = 0;

            if (!HikApi.NET_DVR_GetDVRConfig(info.UserId, NET_DVR_GET_IPPARACFG_V40, -1, ptrIpParaCfgV40, dwSize, ref dwReturn))
            {
                return(states);
            }
            else
            {
                m_struIpParaCfgV40 = (NET_DVR_IPPARACFG_V40)Marshal.PtrToStructure(ptrIpParaCfgV40, typeof(NET_DVR_IPPARACFG_V40));

                byte byStreamType;
                for (int i = 0; i < m_struIpParaCfgV40.dwDChanNum; i++)
                {
                    ChannelState state = new ChannelState();
                    iChannelNum[i + dwAChanTotalNum] = i + (int)m_struIpParaCfgV40.dwStartDChan;
                    byStreamType     = m_struIpParaCfgV40.struStreamMode[i].byGetStreamType;
                    m_unionGetStream = m_struIpParaCfgV40.struStreamMode[i].uGetStream;
                    switch (byStreamType)
                    {
                    //目前NVR仅支持 0- 直接从设备取流一种方式
                    case 0:
                        dwSize = (uint)Marshal.SizeOf(m_unionGetStream);
                        IntPtr ptrChanInfo = Marshal.AllocHGlobal((Int32)dwSize);
                        Marshal.StructureToPtr(m_unionGetStream, ptrChanInfo, false);
                        m_struChanInfo    = (NET_DVR_IPCHANINFO)Marshal.PtrToStructure(ptrChanInfo, typeof(NET_DVR_IPCHANINFO));
                        state.Num         = i + 1;
                        state.IsIpChannel = true;

                        if (m_struChanInfo.byIPID == 0)
                        {
                            state.IsNull = true;      //通道空闲,没有添加前端设备
                        }
                        else
                        {
                            state.IsNull = false;
                            if (m_struChanInfo.byEnable == 0)
                            {
                                state.IsOnline = false;     //通道不在线
                            }
                            else
                            {
                                state.IsOnline = true;     //通道在线
                            }
                        }
                        Marshal.FreeHGlobal(ptrChanInfo);
                        states.Add(state);
                        break;

                    default:
                        break;
                    }
                }
            }
            Marshal.FreeHGlobal(ptrIpParaCfgV40);
            return(states);
        }
Ejemplo n.º 13
0
 /// <summary>
 /// 停止设备巡检
 /// </summary>
 /// <returns></returns>
 public bool StopGetDevState()
 {
     workState -= FrmWNServer_workState;
     return(HikApi.NET_DVR_StopGetDevState());
 }
Ejemplo n.º 14
0
 /// <summary>
 /// 获取设备工作状态
 /// </summary>
 /// <param name="userId">用户ID</param>
 /// <param name="status">工作状态</param>
 /// <returns>true:获取成功,false:获取失败</returns>
 public bool GetDVRWorkState_V30(int userId, ref NET_DVR_WORKSTATE_V30 status)
 {
     return(HikApi.NET_DVR_GetDVRWorkState_V30(userId, ref status));
 }
Ejemplo n.º 15
0
 /// <summary>
 /// 获取设备工作状态
 /// </summary>
 /// <param name="userId">用户ID</param>
 /// <param name="lpWorkState">设备工作状态信息体</param>
 /// <returns>true:成功,false:失败</returns>
 public bool GetDeviceWorkState(int userId, ref NET_DVR_WORKSTATE lpWorkState)
 {
     return(HikApi.NET_DVR_GetDVRWorkState(userId, ref lpWorkState));
 }