Esempio n. 1
0
        /// <summary>
        /// 连接相机
        /// </summary>
        /// <param name="cmaerIp">相机IP</param>
        void ConnectionCamer(uint cmaerIp)
        {
            if (_DataControl.IsLinkedByMyself(cmaerIp))//如果是我自己在使用
            {
                return;
            }
            else if (_DataControl.IsLinkedByOthers(cmaerIp))//如果是其他人在使用
            {
                DialogResult result = MessageBox.Show("相机正与其它终端连接,确信要抢占吗?", "连接相机", MessageBoxButtons.YesNo);
                if (result != DialogResult.Yes)
                {
                    return;
                }
            }

            if (_DataControl.IsInvadedByOthers(cmaerIp)) //如果被别人抢了摄像头
            {
                DislinkCamera(cmaerIp);                  //就断开连接
            }

            FormDisplay display = _DataControl.GetCurrDisplayForm();

            if (display != null)
            {
                MagDevice device = display.GetDateDisplay().GetDevice();

                if (device.LinkCamera(cmaerIp, 2000))                                     //连接相机
                {
                    DataDisplay.CurrSelectedWndIndex = display.GetDateDisplay().WndIndex; //更新选中框
                    Globals.GetMainFrm().GetFormDisplayBG().Invalidate(false);
                }
            }
        }
Esempio n. 2
0
        void threadfthod()
        {
            if (!GroupSDK.MAG_IsChannelAvailable(0))
            {
                if (GroupSDK.MAG_NewChannel(0))
                {
                    if (GroupSDK.MAG_Initialize(0, IntPtr.Zero))
                    {
                        updateListBox("初始化成功");
                        updateListBox("创建通道0成功");
                        if (GroupSDK.MAG_IsUsingStaticIp())
                        {
                            updateListBox("使用静态IP");
                            uint loaclIP = magService.GetLocalIp();
                            updateListBox("获取到本机IP" + loaclIP);
                            if (magService.StartDHCPServer())
                            {
                                updateListBox("开启静态连接");
                                uint dev_num = 0;

                                if (magService.EnumCameras())
                                {
                                    updateListBox("枚举摄像机");
                                    Thread.Sleep(500);
                                    dev_num = magService.GetTerminalList(_LstEnumInfo, MAX_ENUMDEVICE);

                                    updateListBox("一共有" + dev_num + "摄像机,集合长度" + _LstEnumInfo[0].sName);
                                    if (mag.LinkCamera(loaclIP, 50))
                                    {
                                        updateListBox("连接成功");
                                    }
                                    else
                                    {
                                        updateListBox("连接false");
                                    }
                                }
                            }
                        }
                    }

                    //if (mag.LinkCamera("192.168.1.33", 50000))
                    //{
                    //    updateListBox("连接成功");
                    //}
                    //else
                    //{
                    //    updateListBox("连接失败");
                    //}
                }
            }
        }
Esempio n. 3
0
        private void buttonLink_Click(object sender, EventArgs e)
        {
            int index = comboBoxOnlineDevice.SelectedIndex;

            if (index < 0)
            {
                return;
            }

            MagService service = _DataControl.GetService();
            uint       dev_num = service.GetTerminalList(_LstEnumInfo, MAX_ENUMDEVICE);

            if (_DataControl.IsLinkedByMyself(_LstEnumInfo[index].intCamIp))
            {
                return;
            }
            else if (_DataControl.IsLinkedByOthers(_LstEnumInfo[index].intUsrIp))
            {
                DialogResult result = MessageBox.Show("相机正与其它终端连接,确信要抢占吗?", "连接相机", MessageBoxButtons.YesNo);
                if (result != DialogResult.Yes)
                {
                    return;
                }
            }

            if (_DataControl.IsInvadedByOthers(_LstEnumInfo[index].intUsrIp))
            {
                DislinkCamera(_LstEnumInfo[index].intCamIp);
            }

            FormDisplay display = _DataControl.GetCurrDisplayForm();

            if (display != null)
            {
                MagDevice device = display.GetDateDisplay().GetDevice();

                if (device.LinkCamera(_LstEnumInfo[index].intCamIp, 2000))
                {
                    DataDisplay.CurrSelectedWndIndex = display.GetDateDisplay().WndIndex;//更新选中框
                    Globals.GetMainFrm().GetFormDisplayBG().Invalidate(false);
                }
            }

            RefreshOnlineDevice();
        }