/// <summary>
        /// 添加设备2处理
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnAddDevice2_Click(object sender, EventArgs e)
        {
            frm_AddDevice fAddDev = new frm_AddDevice();

            fAddDev.ShowDialog();
            try
            {
                if (fAddDev.blnOKEnter == true)
                {
                    //设备用户信息获得
                    deviceInfo = new NET_DEVICEINFO();
                    int error = 0;
                    //设备2登录:注意登录ID
                    pLoginID2 = DHClient.DHLogin(fAddDev.cmbDevIP.Text.ToString(), ushort.Parse(fAddDev.txtDevProt.Text.ToString()), fAddDev.txtName.Text.ToString(), fAddDev.txtPassword.Text.ToString(), out deviceInfo, out error);
                    //是否登录成功判断
                    if (pLoginID2 != 0)
                    {
                        MessageBox.Show("设备2登录成功!", "提示");
                    }
                    else
                    {
                        MessageBox.Show("设备2登录失败!", "提示");
                    }
                }
            }
            catch
            {
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Add device1 handling
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnAddDevice2_Click(object sender, EventArgs e)
        {
            frm_AddDevice fAddDev = new frm_AddDevice();

            fAddDev.ShowDialog();
            try
            {
                if (fAddDev.blnOKEnter == true)
                {
                    //Get device user info.
                    deviceInfo = new NET_DEVICEINFO();
                    int error = 0;
                    //Device2 login:Pay attention to the login ID.
                    pLoginID2 = NETClient.NETLogin(fAddDev.cmbDevIP.Text.ToString(), ushort.Parse(fAddDev.txtDevProt.Text.ToString()), fAddDev.txtName.Text.ToString(), fAddDev.txtPassword.Text.ToString(), out deviceInfo, out error);
                    //Judge if it login success.
                    if (pLoginID2 != 0)
                    {
                        MessageBox.Show("Device2 login successed!", "Warning");
                    }
                    else
                    {
                        MessageBox.Show("Device2 login failed!", "Warning");
                    }
                }
            }
            catch
            {
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 初始化函数
        /// </summary>
        /// <param name="strServerIP">视频IP</param>
        /// <param name="iChannel">通道号</param>
        /// <param name="strUserName">用户名</param>
        /// <param name="strPsw">密码</param>
        /// <param name="strPath">抓图存储路径 如:\\LoadWeightPic\\FrontImage.jpg</param>
        public void Initialize(string strServerIP, int iChannel, string strUserName, string strPsw, string strPath)
        {
            try
            {
                if (IsLogin)
                {
                    disConnect = new fDisConnect(DisConnectEvent);
                    DHClient.DHInit(disConnect, IntPtr.Zero);
                    DHClient.DHSetEncoding(LANGUAGE_ENCODING.gb2312);

                    deviceInfo = new NET_DEVICEINFO();
                    int iLoginError = 0;
                    iLogin  = DHClient.DHLogin(strServerIP, ushort.Parse("37777"), strUserName, strPsw, out deviceInfo, out iLoginError);
                    IsLogin = false;
                }

                _strPath     = strPath;
                _strServerIP = strServerIP;
                _iChannel    = iChannel;
                iRealPlay    = DHClient.DHRealPlay(iLogin, _iChannel, this.Pic.Handle);
            }
            catch (Exception ex)
            {
                Log.WriteLog("大华视频显示控件-初始化:", ex);
            }
        }
Exemplo n.º 4
0
        private void login(int cantidadVentanas)
        {
            //this.initPantallas(cantidadVentanas);
            //this.inicializarVentanas(cantidadVentanas);

            int error = 0;

            if (pLoginID == 0)
            {
                deviceInfo = new NET_DEVICEINFO();
                pLoginID   = DHClient.DHLogin(this.ip, this.port, this.user, this.pass, out deviceInfo, out error);
            }
            if (pLoginID != 0)
            {
                this.startButtons(false);

                pRealPlayHandle = new int[deviceInfo.byChanNum];
                cantidadCamaras = deviceInfo.byChanNum;
                comboBoxCamaras.Items.Clear();
                for (int i = 0; i < cantidadCamaras; i++)
                {
                    comboBoxCamaras.Items.Add((i + 1).ToString());
                }

                //this.play(this.channel);

                comboBoxCamaras.SelectedIndex  = this.channel;
                comboBoxVentanas.SelectedIndex = this.getIndexCantidadVentanas(cantidadVentanas);
                realPlay();
            }
            else
            {
                /*btnStartRealPlay.Enabled = false;
                 * btnLogin.Enabled = true;
                 * btnLogout.Enabled = false;*/
                this.startButtons(true);
                if (DHClient.LastOperationInfo.errCode == "-2147483548")
                {
                    MessageBox.Show("Error de conexion a la camara: Password incorrecto!", pMsgTitle);
                }
                else if (DHClient.LastOperationInfo.errCode == "-2147483547")
                {
                    MessageBox.Show("Error de conexion a la camara: Usuario incorrecto!", pMsgTitle);
                }
                else if (DHClient.LastOperationInfo.errCode == "-2147483541")
                {
                    MessageBox.Show("Error de conexion a la camara! No fue posible conectar a la IP o puerto especificado", pMsgTitle);
                }
                else
                {
                    MessageBox.Show("Error de conexion a la camara:" + DHClient.LastOperationInfo.errCode, pMsgTitle);
                }



                Application.Exit();
            }
        }
Exemplo n.º 5
0
 /// <summary>
 /// [设备用户注销]按钮按下
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnUserLogout_Click(object sender, EventArgs e)
 {
     try
     {
         bool result = DHClient.DHLogout(pLoginID);
         if (result == false)
         {
             //报最后一次操作的错误信息
             MessageBox.Show(DHClient.LastOperationInfo.ToString(pErrInfoFormatStyle), pMsgTitle);
         }
         picRealPlay0.Refresh();
         picRealPlay1.Refresh();
         picRealPlay2.Refresh();
         picRealPlay3.Refresh();
         picRealPlay4.Refresh();
         picRealPlay5.Refresh();
         picRealPlay6.Refresh();
         picRealPlay7.Refresh();
         if (picRealPlay != null)
         {
             picRealPlay.Refresh();
         }
         //画面初期化
         this.Controls.Clear();
         InitializeComponent();
         StringUtil.InitControlText(this);
         pLoginID                    = 0;
         fileInfo                    = new NET_RECORDFILE_INFO();
         playBy                      = 0;
         pRealPlayHandle             = new int[16];
         pPlayBackHandle             = new int[16];
         pPlayBackChannelID          = 0;
         deviceInfo                  = new NET_DEVICEINFO();
         this.WindowState            = FormWindowState.Normal;
         btnRealPlay.Enabled         = false;
         btnPlayBackByTime.Enabled   = false;
         gpbPlayBackControl.Enabled  = false;
         btnUserLogout.Enabled       = false;
         btnRealPlay.Text            = StringUtil.ConvertString("实时监视开始");
         btnPlayByRecordFile.Enabled = false;
         gpbPlayBackControl.Enabled  = false;
         gpbPTZControl.Enabled       = false;
     }
     catch
     {
         MessageBox.Show("设备用户注销失败!", pMsgTitle);
     }
 }
Exemplo n.º 6
0
        /// <summary>
        /// [user login]Press the button.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnUserLogin_Click(object sender, EventArgs e)
        {
            frm_AddDevice fAddDev = new frm_AddDevice();

            fAddDev.ShowDialog();
            try
            {
                if (fAddDev.blnOKEnter == true)
                {
                    //Device User Info Acquisition
                    deviceInfo = new NET_DEVICEINFO();
                    int error = 0;
                    pLoginID = NETClient.NETLogin(fAddDev.cmbDevIP.Text.ToString(), ushort.Parse(fAddDev.txtDevProt.Text.ToString()), fAddDev.txtName.Text.ToString(), fAddDev.txtPassword.Text.ToString(), out deviceInfo, out error);
                    if (pLoginID != 0)
                    {
                        pPlayBackHandle             = new int[deviceInfo.byChanNum];
                        pRealPlayHandle             = null;
                        btnRealPlay.Text            = StringUtil.ConvertString("Start Real-time Monitoring");
                        btnMultiPlay.Text           = strMultiPlayStart;
                        btnUserLogin.Enabled        = false;
                        btnRealPlay.Enabled         = true;
                        btnPlayBackByTime.Enabled   = true;
                        gpbPlayBackControl.Enabled  = false;
                        btnUserLogout.Enabled       = true;
                        gpbPTZControl.Enabled       = false;
                        btnPlayByRecordFile.Enabled = true;
                        btnMultiPlay.Enabled        = true;
                        cmbChannelSelect.Items.Clear();
                        picRealPlay = picRealPlay0;
                        for (int i = 0; i < deviceInfo.byChanNum; i++)
                        {
                            cmbChannelSelect.Items.Add(i.ToString());
                        }
                    }
                    else
                    {
                        MessageBox.Show(NETClient.LastOperationInfo.ToString(pErrInfoFormatStyle), pMsgTitle);
                        btnUserLogin_Click(null, null);
                    }
                }
            }
            catch
            {
                MessageBox.Show(NETClient.LastOperationInfo.ToString(pErrInfoFormatStyle), pMsgTitle);
                btnUserLogin_Click(null, null);
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// [设备用户登录]按钮按下
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnUserLogin_Click(object sender, EventArgs e)
        {
            frm_AddDevice fAddDev = new frm_AddDevice();

            fAddDev.ShowDialog();
            //DHClient.DHSetShowException(true);
            try
            {
                if (fAddDev.blnOKEnter == true)
                {
                    //设备用户信息获得
                    deviceInfo = new NET_DEVICEINFO();
                    int error = 0;
                    pLoginID = DHClient.DHLogin(fAddDev.cmbDevIP.Text.ToString(), ushort.Parse(fAddDev.txtDevProt.Text.ToString()), fAddDev.txtName.Text.ToString(), fAddDev.txtPassword.Text.ToString(), out deviceInfo, out error);
                    if (pLoginID != 0)
                    {
                        pPlayBackHandle = new int[deviceInfo.byChanNum];
                        //画面按钮有效性控制
                        pRealPlayHandle             = null;
                        btnRealPlay.Text            = StringUtil.ConvertString("实时监视开始");
                        btnUserLogin.Enabled        = false;
                        btnRealPlay.Enabled         = true;
                        btnPlayBackByTime.Enabled   = true;
                        gpbPlayBackControl.Enabled  = false;
                        btnUserLogout.Enabled       = true;
                        gpbPTZControl.Enabled       = false;
                        btnPlayByRecordFile.Enabled = true;
                        cmbChannelSelect.Items.Clear();
                        for (int i = 0; i < deviceInfo.byChanNum; i++)
                        {
                            cmbChannelSelect.Items.Add(i.ToString());
                        }
                    }
                    else
                    {
                        MessageBox.Show(DHClient.LastOperationInfo.ToString(pErrInfoFormatStyle), pMsgTitle);
                        btnUserLogin_Click(null, null);
                    }
                }
            }
            catch
            {
                //报最后一次操作的错误信息
                MessageBox.Show(DHClient.LastOperationInfo.ToString(pErrInfoFormatStyle), pMsgTitle);
                btnUserLogin_Click(null, null);
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// press the user login button to deal with
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnUserLogin_Click(object sender, EventArgs e)
        {
            string strBtn = btnUserLogin.Text;

            if (strBtn == Utility.StringUtil.ConvertString("Equipment users login"))
            {
                frm_AddDevice fLogin = new frm_AddDevice();
                fLogin.ShowDialog();
                if (fLogin.blnOKEnter == true)
                {
                    //achieve the information of the equipment users
                    deviceInfo = new NET_DEVICEINFO();
                    int error = 0;
                    //equipment users login
                    pLoginID = NETClient.NETLogin(fLogin.cmbDevIP.Text.ToString(), ushort.Parse(fLogin.txtDevProt.Text.ToString()), fLogin.txtName.Text.ToString(), fLogin.txtPassword.Text.ToString(), out deviceInfo, out error);
                    if (pLoginID != 0)
                    {
                        strUserName            = fLogin.txtDevName.Text;
                        btnUserLogin.BackColor = Color.Yellow;
                        btnUserLogin.Text      = StringUtil.ConvertString("Equipment users logout");
                        grbMain.Enabled        = true;
                    }
                    else
                    {
                        //report the error information of the last operation
                        MessageUtil.ShowMsgBox(StringUtil.ConvertString(NETClient.LastOperationInfo.errMessage, "ErrorMessage"),
                                               StringUtil.ConvertString(pMsgTitle));
                    }
                }
            }
            else if (strBtn == Utility.StringUtil.ConvertString("Equipment users logout"))
            {
                bool result = NETClient.NETLogout(pLoginID);
                if (result == false)
                {
                    //report the error information of the last operation
                    MessageUtil.ShowMsgBox(StringUtil.ConvertString(NETClient.LastOperationInfo.errMessage, "ErrorMessage"),
                                           StringUtil.ConvertString(pMsgTitle));
                }
                btnUserLogin.BackColor = Color.Transparent;
                btnUserLogin.Text      = StringUtil.ConvertString("Equipment users login");
                grbMain.Enabled        = false;

                Utility.StringUtil.InitControlText(this);
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// 用户登录按钮按下处理
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnUserLogin_Click(object sender, EventArgs e)
        {
            string strBtn = btnUserLogin.Text;

            if (strBtn == Utility.StringUtil.ConvertString("设备用户登录"))
            {
                frm_AddDevice fLogin = new frm_AddDevice();
                fLogin.ShowDialog();
                if (fLogin.blnOKEnter == true)
                {
                    //设备用户信息获得
                    deviceInfo = new NET_DEVICEINFO();
                    int error = 0;
                    //设备用户登录
                    pLoginID = DHClient.DHLogin(fLogin.cmbDevIP.Text.ToString(), ushort.Parse(fLogin.txtDevProt.Text.ToString()), fLogin.txtName.Text.ToString(), fLogin.txtPassword.Text.ToString(), out deviceInfo, out error);
                    if (pLoginID != 0)
                    {
                        strUserName            = fLogin.txtDevName.Text;
                        btnUserLogin.BackColor = Color.Yellow;
                        btnUserLogin.Text      = StringUtil.ConvertString("设备用户注销");
                        grbMain.Enabled        = true;
                    }
                    else
                    {
                        //报最后一次操作的错误信息
                        MessageUtil.ShowMsgBox(StringUtil.ConvertString(DHClient.LastOperationInfo.errMessage, "ErrorMessage"),
                                               StringUtil.ConvertString(pMsgTitle));
                    }
                }
            }
            else if (strBtn == Utility.StringUtil.ConvertString("设备用户注销"))
            {
                bool result = DHClient.DHLogout(pLoginID);
                if (result == false)
                {
                    //报最后一次操作的错误信息
                    MessageUtil.ShowMsgBox(StringUtil.ConvertString(DHClient.LastOperationInfo.errMessage, "ErrorMessage"),
                                           StringUtil.ConvertString(pMsgTitle));
                }
                btnUserLogin.BackColor = Color.Transparent;
                btnUserLogin.Text      = StringUtil.ConvertString("设备用户登录");
                grbMain.Enabled        = false;

                Utility.StringUtil.InitControlText(this);
            }
        }
Exemplo n.º 10
0
 /// <summary>
 /// [Logout User]Press The Button.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnUserLogout_Click(object sender, EventArgs e)
 {
     try
     {
         bool result = NETClient.NETLogout(pLoginID);
         if (result == false)
         {
             //Report the Error Information of the Last Operation.
             MessageBox.Show(NETClient.LastOperationInfo.ToString(pErrInfoFormatStyle), pMsgTitle);
         }
         StopMultiPlay();
         RefreshAllPlayBox();
         //Image Initialized
         this.Controls.Clear();
         InitializeComponent();
         InitPlayBoxManger();
         Utility.StringUtil.InitControlText(this);
         pLoginID                    = 0;
         fileInfo                    = new NET_RECORDFILE_INFO();
         playBy                      = 0;
         pRealPlayHandle             = new int[16];
         pPlayBackHandle             = new int[16];
         pPlayBackChannelID          = 0;
         deviceInfo                  = new NET_DEVICEINFO();
         this.WindowState            = FormWindowState.Normal;
         btnRealPlay.Enabled         = false;
         btnPlayBackByTime.Enabled   = false;
         gpbPlayBackControl.Enabled  = false;
         btnUserLogout.Enabled       = false;
         btnMultiPlay.Enabled        = false;
         btnRealPlay.Text            = StringUtil.ConvertString("Start Real-time Monitoring");
         btnPlayByRecordFile.Enabled = false;
         gpbPlayBackControl.Enabled  = false;
         gpbPTZControl.Enabled       = false;
         pLoginID                    = 0;
         m_LastScrollValue           = 0;
     }
     catch
     {
         MessageBox.Show("Device User Logout Failed!", pMsgTitle);
     }
 }
Exemplo n.º 11
0
        /// <summary>
        /// 初始化设备
        /// </summary>
        private bool Init()
        {
            //初始化SDK
            if (initialized == false)
            {
                //DHClient.DHInit(disConnect, IntPtr.Zero);
                //DHClient.DHSetAutoReconnect(onlineMsg, IntPtr.Zero);
                //initialized = true;
                //这里不直接使用DHClient初始化,是因为DHClient的disConnect和onlineMsg只支持一个事件回调,
                //所以这里使用管理器的事件处理,在管理器中使用DHClient初始化
                DaHuaSDKManager.GetInstance().DisConnectEventHandle -= disConnect;
                DaHuaSDKManager.GetInstance().DisConnectEventHandle += disConnect;
                DaHuaSDKManager.GetInstance().OnlineMsgEventHandle  -= onlineMsg;
                DaHuaSDKManager.GetInstance().OnlineMsgEventHandle  += onlineMsg;
                DaHuaSDKManager.GetInstance().InitSDK();
                initialized = true;
            }
            if (initialized == false)
            {
                return(false);
            }

            //登入设备
            if (m_nLoginID == 0)
            {
                NET_DEVICEINFO deviceInfo = new NET_DEVICEINFO();
                int            error      = 0;
                m_nLoginID = DHClient.DHLogin(VideoSource.MediaSource, (ushort)VideoSource.StreamPort
                                              , VideoSource.UserName, VideoSource.Password, out deviceInfo, out error);
            }
            if (m_nLoginID == 0)
            {
                return(false);
            }

            return(true);
        }
Exemplo n.º 12
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            frm_AddDevice fAddDev = new frm_AddDevice();

            fAddDev.ShowDialog();
            //NETClient.NETSetShowException(true);
            try
            {
                if (fAddDev.blnOKEnter == true)
                {
                    //Device username info get
                    deviceInfo = new NET_DEVICEINFO();
                    int error = 0;
                    //Device user login
                    pLoginID = NETClient.NETLogin(fAddDev.cmbDevIP.Text.ToString(), ushort.Parse(fAddDev.txtDevProt.Text.ToString()), fAddDev.txtName.Text.ToString(), fAddDev.txtPassword.Text.ToString(), out deviceInfo, out error);
                    if (pLoginID != 0)
                    {
                        btnStartRealPlay.Enabled = true;
                        btnLogin.Enabled         = false;
                        btnLogout.Enabled        = true;
                    }
                    else
                    {
                        btnStartRealPlay.Enabled = false;
                        btnLogin.Enabled         = true;
                        btnLogout.Enabled        = false;
                        MessageBox.Show(NETClient.LastOperationInfo.ToString(pErrInfoFormatStyle), pMsgTitle);
                    }
                }
            }
            catch
            {
                //Error in last operation
                MessageBox.Show(NETClient.LastOperationInfo.ToString(pErrInfoFormatStyle), pMsgTitle);
            }
        }
Exemplo n.º 13
0
 private void ConnectAllDevices()
 {
     while (true)
     {
         foreach (CarPlateDevice device in _Devices)
         {
             //登入设备
             if (device.m_nLoginID == 0 && device.VideoSource != null)
             {
                 NET_DEVICEINFO deviceInfo = new NET_DEVICEINFO();
                 int            error      = 0;
                 device.m_nLoginID = DHClient.DHLogin(device.IP, (ushort)device.VideoSource.StreamPort
                                                      , device.VideoSource.UserName, device.VideoSource.Password, out deviceInfo, out error);
                 if (device.m_nLoginID != 0)
                 {
                     //订阅事件
                     device.m_nRealLoadPic = DHClient.DHRealLoadPicture(device.m_nLoginID, device.VideoID, EventIvs.EVENT_IVS_ALL, anaCallback, 0);
                     device.State          = 1;
                 }
             }
         }
         Action action = delegate()
         {
             ShowItemsOnGrid(_Devices);
         };
         if (this.InvokeRequired)
         {
             this.Invoke(action);
         }
         else
         {
             action();
         }
         Thread.Sleep(30 * 1000);
     }
 }
Exemplo n.º 14
0
        private void Login_Click(object sender, EventArgs e)
        {
            if (!m_bInit)
            {
                MessageBox.Show("Library Initialization Failed");
                return;
            }

            //Obtain Device User Information
            NET_DEVICEINFO deviceInfo = new NET_DEVICEINFO();
            int            error      = 0;

            m_nLoginID = NETClient.NETLogin(this.textBoxIP.Text.ToString(), ushort.Parse(this.textBoxPort.Text.ToString()),
                                            this.textBoxUser.Text.ToString(), this.textBoxPsw.Text.ToString(), out deviceInfo, out error);

            if (m_nLoginID > 0)
            {
                this.Login.Enabled  = false;
                this.Logout.Enabled = true;
                m_nChannelNum       = deviceInfo.byChanNum;
                for (int i = 0; i < m_nChannelNum; ++i)
                {
                    this.comboBoxChannel.Items.Add(i.ToString());
                }

                //query json ability.
                Int32  dwRetLen   = 0;
                IntPtr pDevEnable = new IntPtr();
                pDevEnable = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(NET_DEV_ENABLE_INFO)));
                bool bRet = NETClient.NETQuerySystemInfo(m_nLoginID, NET_SYS_ABILITY.ABILITY_DEVALL_INFO, pDevEnable,
                                                         Marshal.SizeOf(typeof(NET_DEV_ENABLE_INFO)), ref dwRetLen, 1000);
                if (bRet == false)
                {
                    //MessageBox.Show(ConvertString("Query device ability failed."));
                    MessageBox.Show("Query device ability failed");
                    return;
                }


                NET_DEV_ENABLE_INFO devEnable = new NET_DEV_ENABLE_INFO();
                devEnable = (NET_DEV_ENABLE_INFO)Marshal.PtrToStructure(pDevEnable, typeof(NET_DEV_ENABLE_INFO));
                m_bJSON   = devEnable.IsFucEnable[(Int32)NET_FUN_SUPPORT.EN_JSON_CONFIG] > 0 ? true : false;

                if (m_bJSON == false)
                {
                    int    nRetLen      = 0;
                    IntPtr pStuSnapAttr = new IntPtr();
                    pStuSnapAttr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(NET_SNAP_ATTR_EN)));
                    bool nRet = NETClient.NETQueryDevState(m_nLoginID, (int)NETClient.NET_DEVSTATE_SNAP
                                                           , pStuSnapAttr, Marshal.SizeOf(typeof(NET_SNAP_ATTR_EN)), ref nRetLen, 1000);
                    if (nRet == false || nRetLen != Marshal.SizeOf(typeof(NET_SNAP_ATTR_EN)))
                    {
                        MessageBox.Show("Get Snap Capability Set Failed!");
                        return;
                    }
                    else
                    {
                        m_stuSnapAttr = (NET_SNAP_ATTR_EN)Marshal.PtrToStructure(pStuSnapAttr, typeof(NET_SNAP_ATTR_EN));
                    }
                }
                else //json
                {
                    InitSnapConfigExUI(0);
                }

                IntPtr pSnapCfg = new IntPtr();
                pSnapCfg = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(NETDEV_SNAP_CFG)) * 32);
                UInt32 dwRetConfig = 0;
                bRet = NETClient.NETGetDevConfig(m_nLoginID, CONFIG_COMMAND.NET_DEV_SNAP_CFG, -1, pSnapCfg, (UInt32)Marshal.SizeOf(typeof(NETDEV_SNAP_CFG)) * 32, ref dwRetConfig, 1000);
                if (!bRet)
                {
                    MessageBox.Show("Get Snap Configuration Failed!");
                    return;
                }
                else
                {
                    for (int i = 0; i < 32; ++i)
                    {
                        m_stuSnapCfg[i] = (NETDEV_SNAP_CFG)Marshal.PtrToStructure((IntPtr)((UInt32)pSnapCfg + i * Marshal.SizeOf(typeof(NETDEV_SNAP_CFG)))
                                                                                  , typeof(NETDEV_SNAP_CFG));
                    }
                }

                if (this.comboBoxChannel.Items.Count > 0)
                {
                    this.comboBoxChannel.SelectedIndex = 0;
                }

                this.buttonGet.Enabled   = true;
                this.buttonSet.Enabled   = true;
                this.buttonStart.Enabled = true;
                this.buttonStop.Enabled  = true;
            }
        }
Exemplo n.º 15
0
        /// <summary>
        /// string [0]status [1] result
        /// </summary>
        /// <param name="ip"></param>
        /// <param name="port"></param>
        /// <param name="username"></param>
        /// <param name="passwod"></param>
        /// <returns></returns>
        public List <string> Login(string ip, string port, string username, string passwod)
        {
            List <string> list = new List <string>();

            if (!m_bInit)
            {
                list.Add("未初始化或者初始化失败");
                return(list);
            }

            NET_DEVICEINFO deviceInfo = new NET_DEVICEINFO();
            int            error      = 0;

            m_nLoginID = NETClient.NETLogin(ip, (ushort)Convert.ToInt32(port), username, passwod, out deviceInfo, out error);

            if (m_nLoginID > 0)
            {
                m_nChannelNum = deviceInfo.byChanNum;

                Int32  dwRetLen   = 0;
                IntPtr pDevEnable = new IntPtr();
                pDevEnable = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(NET_DEV_ENABLE_INFO)));
                bool bRet = NETClient.NETQuerySystemInfo(m_nLoginID, NET_SYS_ABILITY.ABILITY_DEVALL_INFO, pDevEnable,
                                                         Marshal.SizeOf(typeof(NET_DEV_ENABLE_INFO)), ref dwRetLen, 1000);
                NET_DEV_ENABLE_INFO devEnable = new NET_DEV_ENABLE_INFO();
                devEnable = (NET_DEV_ENABLE_INFO)Marshal.PtrToStructure(pDevEnable, typeof(NET_DEV_ENABLE_INFO));
                m_bJSON   = devEnable.IsFucEnable[(Int32)NET_FUN_SUPPORT.EN_JSON_CONFIG] > 0 ? true : false;

                if (m_bJSON == false)
                {
                    int    nRetLen      = 0;
                    IntPtr pStuSnapAttr = new IntPtr();
                    pStuSnapAttr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(NET_SNAP_ATTR_EN)));
                    bool nRet = NETClient.NETQueryDevState(m_nLoginID, (int)NETClient.NET_DEVSTATE_SNAP
                                                           , pStuSnapAttr, Marshal.SizeOf(typeof(NET_SNAP_ATTR_EN)), ref nRetLen, 1000);
                    if (nRet == false || nRetLen != Marshal.SizeOf(typeof(NET_SNAP_ATTR_EN)))
                    {
                        //MessageBox.Show("查询设备状态失败");
                        list.Add("查询设备状态失败");
                        return(list);
                    }
                    else
                    {
                        m_stuSnapAttr = (NET_SNAP_ATTR_EN)Marshal.PtrToStructure(pStuSnapAttr, typeof(NET_SNAP_ATTR_EN));
                    }
                }

                IntPtr pSnapCfg = new IntPtr();
                pSnapCfg = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(NETDEV_SNAP_CFG)) * 32);
                UInt32 dwRetConfig = 0;
                bRet = NETClient.NETGetDevConfig(m_nLoginID, CONFIG_COMMAND.NET_DEV_SNAP_CFG, -1, pSnapCfg, (UInt32)Marshal.SizeOf(typeof(NETDEV_SNAP_CFG)) * 32, ref dwRetConfig, 1000);

                for (int i = 0; i < 32; ++i)
                {
                    m_stuSnapCfg[i] = (NETDEV_SNAP_CFG)Marshal.PtrToStructure((IntPtr)((UInt32)pSnapCfg + i * Marshal.SizeOf(typeof(NETDEV_SNAP_CFG)))
                                                                              , typeof(NETDEV_SNAP_CFG));
                }
            }
            list.Add("登陆成功");
            return(list);
        }
Exemplo n.º 16
0
 public static extern int CLIENT_Login(string pchDVRIP, ushort wDVRPort, string pchUserName, string pchPassword, out NET_DEVICEINFO lpDeviceInfo, out int error);
Exemplo n.º 17
0
        //摄像头视频显示
        private void RealPlay()
        {
            try
            {
                disConnect = new fDisConnect(DisConnectEvent);
                DHClient.DHInit(disConnect, IntPtr.Zero);
                DHClient.DHSetEncoding(LANGUAGE_ENCODING.gb2312);//字符编码格式设置,默认为gb2312字符编码,如果为其他字符编码请设置
                pRealPlayHandle = null;
                deviceInfo      = new NET_DEVICEINFO();
                int error = 0;
                pLoginID = DHClient.DHLogin(Program.g_localVedioIp, ushort.Parse(Program.g_localVedioPort), Program.g_localVadioUsername, Program.g_localVadioPassword, out deviceInfo, out error);
                if (pLoginID != 0)
                {
                    pPlayBackHandle = new int[deviceInfo.byChanNum];
                    //画面按钮有效性控制
                    pRealPlayHandle = null;
                    pRealPlayHandle = new int[deviceInfo.byChanNum];

                    for (int i = 0; i < deviceInfo.byChanNum; i++)
                    {
                        switch (i)
                        {
                        case 0:    //通道0的实时监视
                            pictureBox17.Invoke((MethodInvoker) delegate
                            {
                                pRealPlayHandle[i] = DHClient.DHRealPlay(pLoginID, i, pictureBox17.Handle);
                            });
                            break;

                        case 1:    //通道1的实时监视
                            pictureBox18.Invoke((MethodInvoker) delegate
                            {
                                pRealPlayHandle[i] = DHClient.DHRealPlay(pLoginID, i, pictureBox18.Handle);
                            });
                            break;

                        case 2:    //通道2的实时监视
                            pictureBox19.Invoke((MethodInvoker) delegate
                            {
                                pRealPlayHandle[i] = DHClient.DHRealPlay(pLoginID, i, pictureBox19.Handle);
                            });
                            break;

                        case 3:    //通道3的实时监视
                            pictureBox20.Invoke((MethodInvoker) delegate
                            {
                                pRealPlayHandle[i] = DHClient.DHRealPlay(pLoginID, i, pictureBox20.Handle);
                            });
                            break;

                        case 4:    //通道4的实时监视
                            pictureBox21.Invoke((MethodInvoker) delegate
                            {
                                pRealPlayHandle[i] = DHClient.DHRealPlay(pLoginID, i, pictureBox21.Handle);
                            });
                            break;
                        }
                    }
                }
            }
            catch (Exception vedioError)
            {
                Program.WriteLog("调用摄像头异常:" + vedioError.ToString());
            }
        }
Exemplo n.º 18
0
        private void SingleVideoDisplayForm_Load(object sender, EventArgs e)
        {
            picRealPlay1.Visible = false;
            picRealPlay2.Visible = false;
            picRealPlay3.Visible = false;
            picRealPlay4.Visible = false;
            picRealPlay5.Visible = false;
            picRealPlay6.Visible = false;

            switch (b)
            {
            case 0: groupBox1.Text = "一号电机视频监控"; break;

            case 1: groupBox1.Text = "二号电机视频监控"; break;

            case 2: groupBox1.Text = "三号电机视频监控"; break;

            case 3: groupBox1.Text = "控制室视频监控"; break;

            case 4: groupBox1.Text = "过道视频监控"; break;

            default:
                break;
            }


            int[] pPlayBackHandle;

            NET_DEVICEINFO deviceInfo;
            fDisConnect    disConnect;

            disConnect = new fDisConnect(DisConnectEvent);
            //DHClient.initialized = false;
            DHClient.DHInit(disConnect, IntPtr.Zero);
            DHClient.DHSetEncoding(LANGUAGE_ENCODING.gb2312);//字符编码格式设置,默认为gb2312字符编码,如果为其他字符编码请设置

            deviceInfo = new NET_DEVICEINFO();
            int error = 0;

            pLoginID = DHClient.DHLogin(IP, Port, Username, Password, out deviceInfo, out error);


            if (pLoginID != 0)
            {
                pPlayBackHandle = new int[5];
                //画面按钮有效性控制
                btnPlayByRecordFile.Enabled = true;
                RealPlay(true, b);
            }
            else
            {
                MessageBox.Show(DHClient.LastOperationInfo.ToString(pErrInfoFormatStyle), pMsgTitle);
            }
            gpbPlayBackControl.Enabled   = false;
            picRealPlay6.VisibleChanged += new EventHandler((o, j) =>
            {
                if (picRealPlay6.Visible == false)
                {
                    gpbPlayBackControl.Enabled  = false;
                    btnPlayBackByTime.Enabled   = true;
                    btnPlayByRecordFile.Enabled = true;
                }
                else
                {//如果回放激活
                    gpbPlayBackControl.Enabled = true;
                }
            });
        }
Exemplo n.º 19
0
 /// <summary>
 ///  registere users to the expansion interface device interface,Support a user to specify equipment support ability
 /// </summary>
 /// <param name="pchDVRIP">equipmentIP</param>
 /// <param name="wDVRPort">equipmentequipment port</param>
 /// <param name="pchUserName">user name</param>
 /// <param name="pchPassword">user password</param>
 /// <param name="nSpecCap">Equipment support ability,Value of 2 indicates active listening mode user login。[Vehicledvrlogin]</param>
 /// <param name="pCapParam">nSpecCap supplement parameter, when nSpecCap = 2,pCapParam Filling equipment serial number string。[vehicle dvr login]</param>
 /// <param name="lpDeviceInfo">equipment information,belongs to the output parameters</param>
 /// <param name="error">Return to the login error code</param>
 /// <returns>Failure to return0,return successfully equipmentID</returns>
 public static int NETLogin(string pchDVRIP, ushort wDVRPort, string pchUserName, string pchPassword, int nSpecCap, string pCapParam, out NET_DEVICEINFO lpDeviceInfo, out int error)
 {
     int result = CLIENT_LoginEx(pchDVRIP, wDVRPort, pchUserName, pchPassword, nSpecCap, pCapParam, out lpDeviceInfo, out error);
     NETThrowLastError(result);
     return result;
 }
Exemplo n.º 20
0
 private static extern int CLIENT_LoginEx(string pchDVRIP, ushort wDVRPort, string pchUserName, string pchPassword, int nSpecCap, string pCapParam, out NET_DEVICEINFO lpDeviceInfo, out int error);
Exemplo n.º 21
0
 private static extern Int32 CLIENT_Login(string pchDVRIP, ushort wDVRPort, string pchUserName,
                                          string pchPassword, out NET_DEVICEINFO lpDeviceInfo, out int error);
Exemplo n.º 22
0
        public bool LoginCam()
        {
            if (!m_bInit)
            {
                // MessageBox.Show("Library Initialization Failed");
                return(false);
            }

            //Obtain Device User Information
            NET_DEVICEINFO deviceInfo = new NET_DEVICEINFO();
            int            error      = 0;

            m_nLoginID = NETClient.NETLogin(ipCamGlobal1, ushort.Parse("37777"),
                                            "admin", "admin", out deviceInfo, out error);

            if (m_nLoginID > 0)
            {
                m_nChannelNum = deviceInfo.byChanNum;
                //query json ability.
                Int32  dwRetLen   = 0;
                IntPtr pDevEnable = new IntPtr();
                pDevEnable = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(NET_DEV_ENABLE_INFO)));
                bool bRet = NETClient.NETQuerySystemInfo(m_nLoginID, NET_SYS_ABILITY.ABILITY_DEVALL_INFO, pDevEnable,
                                                         Marshal.SizeOf(typeof(NET_DEV_ENABLE_INFO)), ref dwRetLen, 1000);
                if (bRet == false)
                {
                    //MessageBox.Show(ConvertString("Query device ability failed."));
                    // MessageBox.Show("Query device ability failed");
                    return(false);
                }


                NET_DEV_ENABLE_INFO devEnable = new NET_DEV_ENABLE_INFO();
                devEnable = (NET_DEV_ENABLE_INFO)Marshal.PtrToStructure(pDevEnable, typeof(NET_DEV_ENABLE_INFO));
                m_bJSON   = devEnable.IsFucEnable[(Int32)NET_FUN_SUPPORT.EN_JSON_CONFIG] > 0 ? true : false;

                if (m_bJSON == false)
                {
                    int    nRetLen      = 0;
                    IntPtr pStuSnapAttr = new IntPtr();
                    pStuSnapAttr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(NET_SNAP_ATTR_EN)));
                    bool nRet = NETClient.NETQueryDevState(m_nLoginID, (int)NETClient.NET_DEVSTATE_SNAP
                                                           , pStuSnapAttr, Marshal.SizeOf(typeof(NET_SNAP_ATTR_EN)), ref nRetLen, 1000);
                    if (nRet == false || nRetLen != Marshal.SizeOf(typeof(NET_SNAP_ATTR_EN)))
                    {
                        //   MessageBox.Show("Get Snap Capability Set Failed!");
                        return(false);
                    }
                    else
                    {
                        m_stuSnapAttr = (NET_SNAP_ATTR_EN)Marshal.PtrToStructure(pStuSnapAttr, typeof(NET_SNAP_ATTR_EN));
                    }
                }
                else//json
                {
                    InitSnapConfigExUI(0);
                }

                IntPtr pSnapCfg = new IntPtr();
                pSnapCfg = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(NETDEV_SNAP_CFG)) * 32);
                UInt32 dwRetConfig = 0;
                bRet = NETClient.NETGetDevConfig(m_nLoginID, CONFIG_COMMAND.NET_DEV_SNAP_CFG, -1, pSnapCfg, (UInt32)Marshal.SizeOf(typeof(NETDEV_SNAP_CFG)) * 32, ref dwRetConfig, 1000);
                if (!bRet)
                {
                    //  MessageBox.Show("Get Snap Configuration Failed!");
                    return(false);
                }
                else
                {
                    for (int i = 0; i < 32; ++i)
                    {
                        m_stuSnapCfg[i] = (NETDEV_SNAP_CFG)Marshal.PtrToStructure((IntPtr)((UInt32)pSnapCfg + i * Marshal.SizeOf(typeof(NETDEV_SNAP_CFG)))
                                                                                  , typeof(NETDEV_SNAP_CFG));
                    }
                }
            }

            NET_DEVICEINFO deviceInfo2 = new NET_DEVICEINFO();
            int            error2      = 0;

            m_nLoginID2 = NETClient.NETLogin(ipCamGlobal2, ushort.Parse("37777"),
                                             "admin", "admin", out deviceInfo2, out error2);
            if (m_nLoginID2 > 0)
            {
                //query json ability.
                Int32  dwRetLen   = 0;
                IntPtr pDevEnable = new IntPtr();
                pDevEnable = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(NET_DEV_ENABLE_INFO)));
                bool bRet = NETClient.NETQuerySystemInfo(m_nLoginID2, NET_SYS_ABILITY.ABILITY_DEVALL_INFO, pDevEnable,
                                                         Marshal.SizeOf(typeof(NET_DEV_ENABLE_INFO)), ref dwRetLen, 1000);
                if (bRet == false)
                {
                    //MessageBox.Show(ConvertString("Query device ability failed."));
                    //MessageBox.Show("Query device ability failed");
                    return(false);
                }


                NET_DEV_ENABLE_INFO devEnable = new NET_DEV_ENABLE_INFO();
                devEnable = (NET_DEV_ENABLE_INFO)Marshal.PtrToStructure(pDevEnable, typeof(NET_DEV_ENABLE_INFO));
                m_bJSON2  = devEnable.IsFucEnable[(Int32)NET_FUN_SUPPORT.EN_JSON_CONFIG] > 0 ? true : false;

                if (m_bJSON2 == false)
                {
                    int    nRetLen      = 0;
                    IntPtr pStuSnapAttr = new IntPtr();
                    pStuSnapAttr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(NET_SNAP_ATTR_EN)));
                    bool nRet = NETClient.NETQueryDevState(m_nLoginID2, (int)NETClient.NET_DEVSTATE_SNAP
                                                           , pStuSnapAttr, Marshal.SizeOf(typeof(NET_SNAP_ATTR_EN)), ref nRetLen, 1000);
                    if (nRet == false || nRetLen != Marshal.SizeOf(typeof(NET_SNAP_ATTR_EN)))
                    {
                        //   MessageBox.Show("Get Snap Capability Set Failed!");
                        return(false);
                    }
                    else
                    {
                        m_stuSnapAttr = (NET_SNAP_ATTR_EN)Marshal.PtrToStructure(pStuSnapAttr, typeof(NET_SNAP_ATTR_EN));
                    }
                }
                else//json
                {
                    InitSnapConfigExUI(0);
                }

                IntPtr pSnapCfg = new IntPtr();
                pSnapCfg = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(NETDEV_SNAP_CFG)) * 32);
                UInt32 dwRetConfig = 0;
                bRet = NETClient.NETGetDevConfig(m_nLoginID2, CONFIG_COMMAND.NET_DEV_SNAP_CFG, -1, pSnapCfg, (UInt32)Marshal.SizeOf(typeof(NETDEV_SNAP_CFG)) * 32, ref dwRetConfig, 1000);
                if (!bRet)
                {
                    // MessageBox.Show("Get Snap Configuration Failed!");
                    return(false);
                }
                else
                {
                    for (int i = 0; i < 32; ++i)
                    {
                        m_stuSnapCfg[i] = (NETDEV_SNAP_CFG)Marshal.PtrToStructure((IntPtr)((UInt32)pSnapCfg + i * Marshal.SizeOf(typeof(NETDEV_SNAP_CFG)))
                                                                                  , typeof(NETDEV_SNAP_CFG));
                    }
                } //else
            }     //if login


            NET_DEVICEINFO deviceInfo3 = new NET_DEVICEINFO();
            int            error3      = 0;

            m_nLoginID3 = NETClient.NETLogin(ipCamGlobal3, ushort.Parse("37777"),
                                             "admin", "admin", out deviceInfo3, out error3);
            if (m_nLoginID3 > 0)
            {
                //query json ability.
                Int32  dwRetLen   = 0;
                IntPtr pDevEnable = new IntPtr();
                pDevEnable = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(NET_DEV_ENABLE_INFO)));
                bool bRet = NETClient.NETQuerySystemInfo(m_nLoginID3, NET_SYS_ABILITY.ABILITY_DEVALL_INFO, pDevEnable,
                                                         Marshal.SizeOf(typeof(NET_DEV_ENABLE_INFO)), ref dwRetLen, 1000);
                if (bRet == false)
                {
                    //MessageBox.Show(ConvertString("Query device ability failed."));
                    //MessageBox.Show("Query device ability failed");
                    return(false);
                }


                NET_DEV_ENABLE_INFO devEnable = new NET_DEV_ENABLE_INFO();
                devEnable = (NET_DEV_ENABLE_INFO)Marshal.PtrToStructure(pDevEnable, typeof(NET_DEV_ENABLE_INFO));
                m_bJSON3  = devEnable.IsFucEnable[(Int32)NET_FUN_SUPPORT.EN_JSON_CONFIG] > 0 ? true : false;

                if (m_bJSON3 == false)
                {
                    int    nRetLen      = 0;
                    IntPtr pStuSnapAttr = new IntPtr();
                    pStuSnapAttr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(NET_SNAP_ATTR_EN)));
                    bool nRet = NETClient.NETQueryDevState(m_nLoginID3, (int)NETClient.NET_DEVSTATE_SNAP
                                                           , pStuSnapAttr, Marshal.SizeOf(typeof(NET_SNAP_ATTR_EN)), ref nRetLen, 1000);
                    if (nRet == false || nRetLen != Marshal.SizeOf(typeof(NET_SNAP_ATTR_EN)))
                    {
                        //   MessageBox.Show("Get Snap Capability Set Failed!");
                        return(false);
                    }
                    else
                    {
                        m_stuSnapAttr = (NET_SNAP_ATTR_EN)Marshal.PtrToStructure(pStuSnapAttr, typeof(NET_SNAP_ATTR_EN));
                    }
                }
                else//json
                {
                    InitSnapConfigExUI(0);
                }

                IntPtr pSnapCfg = new IntPtr();
                pSnapCfg = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(NETDEV_SNAP_CFG)) * 32);
                UInt32 dwRetConfig = 0;
                bRet = NETClient.NETGetDevConfig(m_nLoginID3, CONFIG_COMMAND.NET_DEV_SNAP_CFG, -1, pSnapCfg, (UInt32)Marshal.SizeOf(typeof(NETDEV_SNAP_CFG)) * 32, ref dwRetConfig, 1000);
                if (!bRet)
                {
                    // MessageBox.Show("Get Snap Configuration Failed!");
                    return(false);
                }
                else
                {
                    for (int i = 0; i < 32; ++i)
                    {
                        m_stuSnapCfg[i] = (NETDEV_SNAP_CFG)Marshal.PtrToStructure((IntPtr)((UInt32)pSnapCfg + i * Marshal.SizeOf(typeof(NETDEV_SNAP_CFG)))
                                                                                  , typeof(NETDEV_SNAP_CFG));
                    }
                } //else
            }     //if login

            NET_DEVICEINFO deviceInfo4 = new NET_DEVICEINFO();
            int            error4      = 0;

            m_nLoginID4 = NETClient.NETLogin(ipCamGlobal4, ushort.Parse("37777"),
                                             "admin", "admin", out deviceInfo4, out error4);
            if (m_nLoginID4 > 0)
            {
                //query json ability.
                Int32  dwRetLen   = 0;
                IntPtr pDevEnable = new IntPtr();
                pDevEnable = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(NET_DEV_ENABLE_INFO)));
                bool bRet = NETClient.NETQuerySystemInfo(m_nLoginID4, NET_SYS_ABILITY.ABILITY_DEVALL_INFO, pDevEnable,
                                                         Marshal.SizeOf(typeof(NET_DEV_ENABLE_INFO)), ref dwRetLen, 1000);
                if (bRet == false)
                {
                    //MessageBox.Show(ConvertString("Query device ability failed."));
                    //MessageBox.Show("Query device ability failed");
                    return(false);
                }


                NET_DEV_ENABLE_INFO devEnable = new NET_DEV_ENABLE_INFO();
                devEnable = (NET_DEV_ENABLE_INFO)Marshal.PtrToStructure(pDevEnable, typeof(NET_DEV_ENABLE_INFO));
                m_bJSON4  = devEnable.IsFucEnable[(Int32)NET_FUN_SUPPORT.EN_JSON_CONFIG] > 0 ? true : false;

                if (m_bJSON4 == false)
                {
                    int    nRetLen      = 0;
                    IntPtr pStuSnapAttr = new IntPtr();
                    pStuSnapAttr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(NET_SNAP_ATTR_EN)));
                    bool nRet = NETClient.NETQueryDevState(m_nLoginID4, (int)NETClient.NET_DEVSTATE_SNAP
                                                           , pStuSnapAttr, Marshal.SizeOf(typeof(NET_SNAP_ATTR_EN)), ref nRetLen, 1000);
                    if (nRet == false || nRetLen != Marshal.SizeOf(typeof(NET_SNAP_ATTR_EN)))
                    {
                        //   MessageBox.Show("Get Snap Capability Set Failed!");
                        return(false);
                    }
                    else
                    {
                        m_stuSnapAttr = (NET_SNAP_ATTR_EN)Marshal.PtrToStructure(pStuSnapAttr, typeof(NET_SNAP_ATTR_EN));
                    }
                }
                else//json
                {
                    InitSnapConfigExUI(0);
                }

                IntPtr pSnapCfg = new IntPtr();
                pSnapCfg = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(NETDEV_SNAP_CFG)) * 32);
                UInt32 dwRetConfig = 0;
                bRet = NETClient.NETGetDevConfig(m_nLoginID4, CONFIG_COMMAND.NET_DEV_SNAP_CFG, -1, pSnapCfg, (UInt32)Marshal.SizeOf(typeof(NETDEV_SNAP_CFG)) * 32, ref dwRetConfig, 1000);
                if (!bRet)
                {
                    // MessageBox.Show("Get Snap Configuration Failed!");
                    return(false);
                }
                else
                {
                    for (int i = 0; i < 32; ++i)
                    {
                        m_stuSnapCfg[i] = (NETDEV_SNAP_CFG)Marshal.PtrToStructure((IntPtr)((UInt32)pSnapCfg + i * Marshal.SizeOf(typeof(NETDEV_SNAP_CFG)))
                                                                                  , typeof(NETDEV_SNAP_CFG));
                    }
                } //else
            }     //if login

            return(true);
        }//Method
Exemplo n.º 23
0
 /// <summary>
 /// 注册用户到设备,当设备端把用户设置为复用(设备默认的用户如admin,不能设置为复用),则使用该帐号可以多次向设备注册
 /// </summary>
 /// <param name="pchDVRIP">设备IP</param>
 /// <param name="wDVRPort">设备端口</param>
 /// <param name="pchUserName">用户名</param>
 /// <param name="pchPassword">用户密码</param>
 /// <param name="lpDeviceInfo">设备信息,属于输出参数</param>
 /// <param name="error">返回登录错误码</param>
 /// <returns>失败返回0,成功返回设备ID</returns>
 public static int DHLogin(string pchDVRIP, ushort wDVRPort, string pchUserName, string pchPassword, out NET_DEVICEINFO lpDeviceInfo, out int error)
 {
     int result = CLIENT_Login(pchDVRIP, wDVRPort, pchUserName, pchPassword, out lpDeviceInfo, out error);
     DHThrowLastError(result);
     return result;
 }