Пример #1
0
        public void InfoIPChannel()
        {
            uint dwSize = (uint)Marshal.SizeOf(m_struIpParaCfgV40);

            IntPtr ptrIpParaCfgV40 = Marshal.AllocHGlobal((Int32)dwSize);
            Marshal.StructureToPtr(m_struIpParaCfgV40, ptrIpParaCfgV40, false);

            uint dwReturn = 0;
            int iGroupNo = 0;
            if (!CHCNetSDK.NET_DVR_GetDVRConfig(m_lUserID, CHCNetSDK.NET_DVR_GET_IPPARACFG_V40, iGroupNo, ptrIpParaCfgV40, dwSize, ref dwReturn))
            {
                iLastErr = CHCNetSDK.NET_DVR_GetLastError();
                str = "NET_DVR_GET_IPPARACFG_V40 failed, error code= " + iLastErr;
                //获取IP资源配置信息失败,输出错误号 Failed to get configuration of IP channels and output the error code
                DebugInfo(str);
            }
            else
            {
                DebugInfo("NET_DVR_GET_IPPARACFG_V40 succ!");

                m_struIpParaCfgV40 = (CHCNetSDK.NET_DVR_IPPARACFG_V40)Marshal.PtrToStructure(ptrIpParaCfgV40, typeof(CHCNetSDK.NET_DVR_IPPARACFG_V40));

                for (i = 0; i < dwAChanTotalNum; i++)
                {
                    ListAnalogChannel(i + 1, m_struIpParaCfgV40.byAnalogChanEnable[i]);
                    iChannelNum[i] = i + (int)DeviceInfo.byStartChan;
                }

                byte byStreamType;
                for (i = 0; i < m_struIpParaCfgV40.dwDChanNum; i++)
                {
                    iChannelNum[i + dwAChanTotalNum] = i + (int)m_struIpParaCfgV40.dwStartDChan;
                    byStreamType = m_struIpParaCfgV40.struStreamMode[i].byGetStreamType;

                    dwSize = (uint)Marshal.SizeOf(m_struIpParaCfgV40.struStreamMode[i].uGetStream);
                    switch (byStreamType)
                    {
                        //目前NVR仅支持直接从设备取流 NVR supports only the mode: get stream from device directly
                        case 0:
                            IntPtr ptrChanInfo = Marshal.AllocHGlobal((Int32)dwSize);
                            Marshal.StructureToPtr(m_struIpParaCfgV40.struStreamMode[i].uGetStream, ptrChanInfo, false);
                            m_struChanInfo = (CHCNetSDK.NET_DVR_IPCHANINFO)Marshal.PtrToStructure(ptrChanInfo, typeof(CHCNetSDK.NET_DVR_IPCHANINFO));

                            //列出IP通道 List the IP channel
                            ListIPChannel(i + 1, m_struChanInfo.byEnable, m_struChanInfo.byIPID);
                            iIPDevID[i] = m_struChanInfo.byIPID + m_struChanInfo.byIPIDHigh * 256 - iGroupNo * 64 - 1;

                            Marshal.FreeHGlobal(ptrChanInfo);
                            break;
                        case 6:
                            IntPtr ptrChanInfoV40 = Marshal.AllocHGlobal((Int32)dwSize);
                            Marshal.StructureToPtr(m_struIpParaCfgV40.struStreamMode[i].uGetStream, ptrChanInfoV40, false);
                            m_struChanInfoV40 = (CHCNetSDK.NET_DVR_IPCHANINFO_V40)Marshal.PtrToStructure(ptrChanInfoV40, typeof(CHCNetSDK.NET_DVR_IPCHANINFO_V40));

                            //列出IP通道 List the IP channel
                            ListIPChannel(i + 1, m_struChanInfoV40.byEnable, m_struChanInfoV40.wIPID);
                            iIPDevID[i] = m_struChanInfoV40.wIPID - iGroupNo * 64 - 1;

                            Marshal.FreeHGlobal(ptrChanInfoV40);
                            break;
                        default:
                            break;
                    }
                }
            }
            Marshal.FreeHGlobal(ptrIpParaCfgV40);
        }
Пример #2
0
        private void IPChannelConfig_Load(object sender, EventArgs e)
        {
            int i = 0;

            //获取设备支持IPC协议列表
            if (CHCNetSDK.NET_DVR_GetIPCProtoList(m_lUserID, ref m_struProtoList))
            {
                for (i = 0; i < (int)m_struProtoList.dwProtoNum; i++)
                {
                    comboBoxFactory.Items.Add(m_struProtoList.struProto[i].byDescribe);
                }
            }

            comboBoxStreamType.SelectedIndex = 0;
            comboBoxFactory.SelectedIndex = 0;
            comboBoxStream.SelectedIndex = 0;
            comboBoxProtocol.SelectedIndex = 0;

            /***********************************************************
             * 显示当前IP通道配置
             * **********************************************************/
            if (iIPDevIndex < 0)
            {
                //该通道未添加有设备,空闲状态
                return;
            }

            comboBoxStreamType.SelectedIndex = m_struIPParaCfgV40.struStreamMode[iChanIndex].byGetStreamType;//取流方式
            textBoxIPAddr.Text = m_struIPParaCfgV40.struIPDevInfo[iIPDevIndex].struIP.sIpV4;//前端设备IP地址
            textBoxPort.Text = Convert.ToString(m_struIPParaCfgV40.struIPDevInfo[iIPDevIndex].wDVRPort);//前端设备端口
            textBoxUserName.Text = m_struIPParaCfgV40.struIPDevInfo[iIPDevIndex].sUserName;//前端设备用户名
            textBoxPsw.Text = m_struIPParaCfgV40.struIPDevInfo[iIPDevIndex].sPassword;//前端设备密码
            for (i = 0; i < (int)m_struProtoList.dwProtoNum; i++)
            {
                //设备(厂家)协议类型,通过NET_DVR_GetIPCProtoList获取
                if (m_struProtoList.struProto[i].dwType == m_struIPParaCfgV40.struIPDevInfo[iIPDevIndex].byProType)
                {
                    comboBoxFactory.SelectedIndex = i;
                }
            }

            switch (m_struIPParaCfgV40.struStreamMode[iChanIndex].byGetStreamType)
            {
                case 0: //直接从设备取流,对应联合体中结构NET_DVR_IPCHANINFO
                    IntPtr ptrChanInfo = Marshal.AllocHGlobal((Int32)dwUnionSize);
                    Marshal.StructureToPtr(m_struIPParaCfgV40.struStreamMode[iChanIndex].uGetStream, ptrChanInfo, false);
                    m_struChanInfo = (CHCNetSDK.NET_DVR_IPCHANINFO)Marshal.PtrToStructure(ptrChanInfo, typeof(CHCNetSDK.NET_DVR_IPCHANINFO));
                    textBoxChannel.Text = Convert.ToString(m_struChanInfo.byChannel);
                    Marshal.FreeHGlobal(ptrChanInfo);
                    break;
                case 6://直接从设备取流(扩展),对应联合体中结构NET_DVR_IPCHANINFO_V40
                    IntPtr ptrChanInfoV40 = Marshal.AllocHGlobal((Int32)dwUnionSize);
                    Marshal.StructureToPtr(m_struIPParaCfgV40.struStreamMode[iChanIndex].uGetStream, ptrChanInfoV40, false);
                    m_struChanInfoV40 = (CHCNetSDK.NET_DVR_IPCHANINFO_V40)Marshal.PtrToStructure(ptrChanInfoV40, typeof(CHCNetSDK.NET_DVR_IPCHANINFO_V40));
                    textBoxChannel.Text = Convert.ToString(m_struChanInfoV40.dwChannel);
                    comboBoxStream.SelectedIndex = m_struChanInfoV40.byTransMode;
                    comboBoxProtocol.SelectedIndex = m_struChanInfoV40.byTransProtocol;
                    Marshal.FreeHGlobal(ptrChanInfoV40);
                    break;
                default:
                    break;
            }
        }