Example #1
0
        void DisConnectBackCallFunc(int lLoginID, string pchDVRIP, int nDVRPort, IntPtr dwUser)
        {
            for (int i = 0; i < 16; i++)
            {
                if (lLoginID == m_videoform[i].GetLoginHandle())
                {
                    m_videoform[i].OnDisconnct();
                }
            }

            foreach (DEV_INFO devinfo in dictDevInfo.Values)
            {
                if (devinfo.lLoginID == lLoginID)
                {
                    NETSDK.H264_DVR_Logout(lLoginID);
                    dictDevInfo.Remove(devinfo.lLoginID);
                    dictDiscontDev.Add(devinfo.lLoginID, devinfo);
                    break;
                }
            }

            if (dictDiscontDev.Count > 0)
            {
                timerDisconnect.Enabled = true;
                timerDisconnect.Start();
            }
        }
Example #2
0
        public int InitSDK()
        {
            //initialize
            disCallback = new NETSDK.fDisConnect(DisConnectBackCallFunc);
            GC.KeepAlive(disCallback);
            int bResult = NETSDK.H264_DVR_Init(disCallback, this.Handle);

            //the messages received in SDK from DVR which need to upload such as alarm information diary information may do through callback function
            msgcallback = new NETSDK.fMessCallBack(MessCallBack);
            NETSDK.H264_DVR_SetDVRMessCallBack(msgcallback, this.Handle);

            NETSDK.H264_DVR_SetConnectTime(5000, 3);

            return(bResult);
        }
Example #3
0
        private void PTZControl(int nCommand, bool bStop, int nSpeed)
        {
            ClientDemo clientForm    = (ClientDemo)this.Owner;
            int        nCurVideoform = clientForm.m_nCurIndex;

            if (nCurVideoform >= 0)
            {
                int nPlayHandel = clientForm.m_videoform[nCurVideoform].m_iPlayhandle;
                if (nPlayHandel > 0)
                {
                    int nLoginID = clientForm.m_videoform[nCurVideoform].m_lLogin;
                    int nChannel = clientForm.m_videoform[nCurVideoform].m_iChannel;
                    NETSDK.H264_DVR_PTZControl(nLoginID, nChannel, (int)nCommand, bStop, nSpeed);
                }
            }
        }
Example #4
0
        int DevLogin(ref DEV_INFO pdev)
        {
            if (Convert.ToBoolean(pdev.bSerialID)) //
            {
                int         maxDeviceNum = 100;    //
                DDNS_INFO[] pDDNSInfo    = new DDNS_INFO[maxDeviceNum];
                SearchMode  searchmode;
                int         nReNum = 0; //
                searchmode.nType        = (int)SearchModeType.DDNS_SERIAL;
                searchmode.szSerIP      = pdev.szSerIP;
                searchmode.nSerPort     = pdev.nSerPort;
                searchmode.szSerialInfo = pdev.szSerialInfo;
                bool bret = Convert.ToBoolean(NETSDK.H264_DVR_GetDDNSInfo(ref searchmode, out pDDNSInfo, maxDeviceNum, out nReNum));
                if (!bret)
                {
                    return(0);
                }
                pdev.szIpaddress = pDDNSInfo[0].IP;
                pdev.nPort       = pDDNSInfo[0].MediaPort;
            }

            H264_DVR_DEVICEINFO OutDev;
            int nError = 0;

            //
            NETSDK.H264_DVR_SetConnectTime(3000, 1);//

            int lLogin = NETSDK.H264_DVR_Login(pdev.szIpaddress, Convert.ToUInt16(pdev.nPort), pdev.szUserName,
                                               pdev.szPsw, out OutDev, out nError, SocketStyle.TCPSOCKET);

            if (lLogin <= 0)
            {
                int nErr = NETSDK.H264_DVR_GetLastError();
                if (nErr == (int)SDK_RET_CODE.H264_DVR_PASSWORD_NOT_VALID)
                {
                    MessageBox.Show("Error.PwdErr");
                }
                else
                {
                    MessageBox.Show("Error.NotFound");
                }
                return(lLogin);
            }
            NETSDK.H264_DVR_SetupAlarmChan(lLogin);
            return(lLogin);
        }
Example #5
0
        public static bool Run(NETSDK engine)
        {
            if (isRunning)
            {
                return(true);
            }

            cts = new CancellationTokenSource();
            ct  = cts.Token;

            PlatformEngine = engine;
            ts             = new TwittwerService(Settings.ast, Settings.atn);

            LinkEvents();

            return(ts.Connected);
        }
Example #6
0
        public int Connect(ref DEV_INFO pDev, int nChannel, int nWndIndex)
        {
            int nRet = 0;

            //if device did not login, login first
            if (pDev.lLoginID <= 0)
            {
                H264_DVR_DEVICEINFO OutDev;
                int nError = 0;
                //
                int lLogin = NETSDK.H264_DVR_Login(pDev.szIpaddress, (ushort)pDev.nPort, pDev.szUserName, pDev.szPsw, out OutDev, out nError, SocketStyle.TCPSOCKET);
                if (lLogin <= 0)
                {
                    int nErr = NETSDK.H264_DVR_GetLastError();
                    if (nErr == (int)SDK_RET_CODE.H264_DVR_PASSWORD_NOT_VALID)
                    {
                        MessageBox.Show(("Error.PwdErr"));
                    }
                    else
                    {
                        MessageBox.Show(("Error.NotFound"));
                    }

                    return(nRet);
                }

                pDev.lLoginID = lLogin;
                NETSDK.H264_DVR_SetupAlarmChan(lLogin);
            }

            int nWnd = m_nCurIndex;

            if (nWndIndex >= 0)
            {
                nWnd = nWndIndex;
            }

            if (nWnd >= m_nTotalWnd)
            {
                return(nRet);
            }

            return(m_videoform[nWnd].ConnectRealPlay(ref pDev, nChannel));
        }
Example #7
0
        public TweetPanel(User tweetUser, NETSDK platformEngine, Dictionary <EventType, bool> set)
        {
            this.DoubleBuffered = true;

            PlatformEngine = platformEngine;
            this.user      = tweetUser;
            this.Dock      = DockStyle.Fill;

            ctss = new System.Threading.CancellationTokenSource();
            ct   = ctss.Token;

            if (set != null)
            {
                settings = Settings.Set;
            }

            Populate();

            tweetBtn.Click += (o, e) =>
            {
                if (OnTweet != null)
                {
                    MM();
                }
            };

            tweetText.KeyDown += MessageText_KeyDown;

            tweetText.TextChanged += (o, e) =>
            {
                var length = tweetText.TextLength;
                tweetBtn.Text      = BTN_TEXT + " [" + (length) + "]";
                tweetBtn.Enabled   = length > 0 && length <= MAX_TWEET_LENGTH;
                tweetBtn.BackColor = (tweetBtn.Enabled) ? Settings.mainFontColor : Color.Gray;
            };

            statusPanel.onLogoutClicked = () =>
            {
                if (OnLogout != null)
                {
                    OnLogout.Invoke();
                }
            };

            statusPanel.onSettingsClicked = () =>
            {
                settingsPanel.ShowSet();
                // await M();
            };

            statusPanel.onAutoTweetClicked = () =>
            {
                if (!settingsPanel.HasEvents)
                {
                    statusPanel.AutoTweet = false;
                    ShowNotice("There is no events to tweet!");
                    return;
                }

                statusPanel.AutoTweet = !statusPanel.AutoTweet;

                if (OnAutoTweetToggle != null)
                {
                    OnAutoTweetToggle.Invoke(statusPanel.AutoTweet);
                }

                ShowNotice((statusPanel.AutoTweet) ? "AutoTweet Enabled!" : "AutoTweet Disabled!");

                if (statusPanel.AutoTweet)
                {
                    AutoTweet.OnAutoTweetSend    += ShowNotice;
                    AutoTweet.OnAutoTweetRespond += ShowNotice;
                }
                else
                {
                    AutoTweet.OnAutoTweetSend    -= ShowNotice;
                    AutoTweet.OnAutoTweetRespond -= ShowNotice;
                }
            };

            settingsPanel.OnApply = () =>
            {
                AutoTweet.LinkEvents();

                if (!settingsPanel.HasEvents)
                {
                    statusPanel.AutoTweet = false;
                    ShowNotice("AutoTweet Stopped!");
                    return;
                }

                foreach (EventType item in Enum.GetValues(typeof(EventType)))
                {
                    settings[item] = settingsPanel[item];
                }

                if (OnSettingsApplied != null)
                {
                    OnSettingsApplied.Invoke(settings);
                }

                ShowNotice("Settings applied!");
            };

            picPanel.OnMaxPics = () =>
            {
                ShowNotice("Only 4 pics are allowed for one tweet!");
            };
        }
Example #8
0
 public bool ExitSDk()
 {
     return(NETSDK.H264_DVR_Cleanup());
 }
Example #9
0
        public void ReConnect(object source, System.Timers.ElapsedEventArgs e)
        {
            foreach (DEV_INFO devinfo in dictDiscontDev.Values)
            {
                H264_DVR_DEVICEINFO OutDev = new H264_DVR_DEVICEINFO();
                int nError = 0;

                int lLogin = NETSDK.H264_DVR_Login(devinfo.szIpaddress, (ushort)devinfo.nPort, devinfo.szUserName, devinfo.szPsw, out OutDev, out nError, SocketStyle.TCPSOCKET);
                if (lLogin <= 0)
                {
                    int nErr = NETSDK.H264_DVR_GetLastError();
                    if (nErr == (int)SDK_RET_CODE.H264_DVR_PASSWORD_NOT_VALID)
                    {
                        MessageBox.Show(("Password Error"));
                    }
                    else if (nErr == (int)SDK_RET_CODE.H264_DVR_LOGIN_USER_NOEXIST)
                    {
                        MessageBox.Show(("User Not Exist"));
                    }

                    return;
                }
                dictDiscontDev.Remove(devinfo.lLoginID);

                ClientDemo clientForm = new ClientDemo();

                foreach (Form form in Application.OpenForms)
                {
                    if (form.Name == "ClientDemo")
                    {
                        clientForm = (ClientDemo)form;
                        break;
                    }
                }
                DEV_INFO devAdd = new DEV_INFO();
                devAdd          = devinfo;
                devAdd.lLoginID = lLogin;


                foreach (TreeNode node in clientForm.devForm.DevTree.Nodes)
                {
                    if (node.Name == "Device")
                    {
                        DEV_INFO dev = (DEV_INFO)node.Tag;
                        if (dev.lLoginID == devinfo.lLoginID)
                        {
                            node.Text = devAdd.szDevName;
                            node.Tag  = devAdd;
                            node.Name = "Device";

                            foreach (TreeNode channelnode in node.Nodes)
                            {
                                CHANNEL_INFO chInfo = (CHANNEL_INFO)channelnode.Tag;
                                if (chInfo.nWndIndex > -1)
                                {
                                    clientForm.m_videoform[chInfo.nWndIndex].ConnectRealPlay(ref devAdd, chInfo.nChannelNo);
                                    Thread.Sleep(10);
                                }
                            }
                            break;
                        }
                    }
                }

                dictDevInfo.Add(lLogin, devAdd);
                NETSDK.H264_DVR_SetupAlarmChan(lLogin);
            }
            if (0 == dictDiscontDev.Count)
            {
                timerDisconnect.Enabled = false;
                timerDisconnect.Stop();
            }
        }