예제 #1
0
        private AUTHORITY_PACKET RecvAuthorityCmd(int nCh)//큐에 쌓인 것을 읽어온다.
        {
            const int nTimeout = 5;
            int       nCount   = 0;

            while (true)
            {
                //if (udpSock.queuePacketFromRelayServer.Count > 0)
                if (udpSock.GetNumberOfPacket(nCh) > 0)
                {
                    //IPEndPoint ep = udpSock.queueIPEndPointFromRelayServer.Dequeue();

                    Console.WriteLine("Parse Packet");
                    byte[] packet = udpSock.PopPacket(nCh);
                    string str    = Encoding.UTF8.GetString(packet);
                    //Console.WriteLine("Port={0} Received={1}", ep.Port, str.Length);

                    AUTHORITY_PACKET AuthPacket;
                    //AuthPacket.GetType()
                    //typeof(AUTHORITY_PACKET)
                    AuthPacket = (AUTHORITY_PACKET)AuthorityCommUtil.ByteToStructure(packet, typeof(AUTHORITY_PACKET));

                    return(AuthPacket);
                }

                Thread.Sleep(100);
                nCount++;
                if (nCount >= nTimeout)
                {
                    return(new AUTHORITY_PACKET());
                }
            }
        }
예제 #2
0
        private void CreatePacketParsingThread(int nCh)
        {
            //Parse
            Task.Run(() =>
            {
                while (true)
                {
                    //if (udpSock.queuePacketFromRelayServer.Count > 0)
                    if (udpSock.GetNumberOfPacket(nCh) > 0)
                    {
                        //IPEndPoint ep = udpSock.queueIPEndPointFromRelayServer.Dequeue();

                        Console.WriteLine("Parse Packet {0}", nCh);
                        byte[] packet = udpSock.PopPacket(nCh);
                        if (packet == null)
                        {
                            continue;
                        }

                        if (m_nCh != nCh)//선택된 채널과 현재 스레드의 채널이 같을 경우에만 디스플레이
                        {
                            continue;
                        }

                        string str = Encoding.UTF8.GetString(packet);
                        //Console.WriteLine("Port={0} Received={1}", ep.Port, str.Length);



                        AUTHORITY_PACKET AuthPacket;//제어권 패킷을 저장 할 변수
                        //AuthPacket.GetType()
                        //typeof(AUTHORITY_PACKET)
                        AuthPacket = (AUTHORITY_PACKET)AuthorityCommUtil.ByteToStructure(packet, typeof(AUTHORITY_PACKET));//바이트로 들어온걸 구조체로 변환


                        string name = AuthorityCommUtil.ByteToString(AuthPacket.srcName.name);
                        string data = AuthorityCommUtil.ByteToString(AuthPacket.authorityData.data);
                        //System.Console.WriteLine(data.Replace('\0', ' '));
                        //System.Console.WriteLine(name.Replace('\0', ' '));


                        if (AuthPacket.byCmdGroup == CommandThermCam.CMDGROUP_THERMCAM)
                        {
                            if (AuthPacket.byCmdType == CommandThermCam.CMDTYPE_THERMCAM_AGCMODE_RESP)
                            {
                                this.Dispatcher.Invoke(DispatcherPriority.Normal, (Action)(() =>
                                {
                                    //if (data == "1") ManualBtn.IsChecked = true;
                                    //if (data == "2") AutoBtn.IsChecked = true;
                                }));
                            }

                            if (AuthPacket.byCmdType == CommandThermCam.CMDTYPE_THERMCAM_CONTRAST_RESP)
                            {
                                this.Dispatcher.Invoke(DispatcherPriority.Normal, (Action)(() =>
                                {
                                    //Scontrast = data;
                                    //textContrast.Content = data;
                                    //sliderContrast.Value = Int32.Parse(data);
                                }));
                            }


                            if (AuthPacket.byCmdType == CommandThermCam.CMDTYPE_THERMCAM_BRIGHTNESS_RESP)
                            {
                                this.Dispatcher.Invoke(DispatcherPriority.Normal, (Action)(() =>
                                {
                                    //Sbright = data;
                                    //textBrightness.Content = data;
                                    //sliderBrightness.Value = Int32.Parse(data);
                                }));
                            }

                            if (AuthPacket.byCmdType == CommandThermCam.CMDTYPE_THERMCAM_DDE_RESP)
                            {
                                this.Dispatcher.Invoke(DispatcherPriority.Normal, (Action)(() =>
                                {
                                    //Sdde = data;
                                    //textDDE.Content = data;
                                    //sliderDDE.Value = Int32.Parse(data);
                                }));
                            }

                            if (AuthPacket.byCmdType == CommandThermCam.CMDTYPE_THERMCAM_ACE_RESP)
                            {
                                this.Dispatcher.Invoke(DispatcherPriority.Normal, (Action)(() =>
                                {
                                    Sace = data;
                                    //textACE.Content = data;
                                    // sliderACE.Value = Int32.Parse(data);
                                }));
                            }

                            if (AuthPacket.byCmdType == CommandThermCam.CMDTYPE_THERMCAM_SSO_RESP)
                            {
                                this.Dispatcher.Invoke(DispatcherPriority.Normal, (Action)(() =>
                                {
                                    Ssso = data;
                                    // textSSO.Content = data;
                                    // sliderSSO.Value = Int32.Parse(data);
                                }));
                            }

                            if (AuthPacket.byCmdType == CommandThermCam.CMDTYPE_THERMCAM_DZOOM_RESP)
                            {
                                this.Dispatcher.Invoke(DispatcherPriority.Normal, (Action)(() =>
                                {
                                    zoom = double.Parse(data);
                                    textZoom.Content = data;
                                }));
                            }



                            else if (AuthPacket.byCmdType == CommandPTZReqResp.CMDTYPE_PTZREQ_MAINBOARD_STATUS_RESP)
                            {
                                System.Console.WriteLine(data);
                            }
                        }
                    }

                    Thread.Sleep(1);
                    //Console.WriteLine("GetNumberOfPacket Sleep {0}", nCh);
                }
            });
        }
예제 #3
0
        //
        private void CreatePacketParsingThread(int nCh)
        {
            int nCurThreadCh = nCh;

            m_bDestroyPacketParsingThread[nCh - 1] = false;
            PanoramaCanvas[] arrCanvas = { panoramaCanvas1, panoramaCanvas2, panoramaCanvas3, panoramaCanvas4, panoramaCanvas5 };
            Task.Run(() =>
            {
                SetPacketParsingThread(nCurThreadCh, true);//상태 체크
                while (true)
                {
                    //if (udpSock.queuePacketFromRelayServer.Count > 0)
                    if (udpSock.GetNumberOfPacket(nCurThreadCh) > 0)
                    {
                        //IPEndPoint ep = udpSock.queueIPEndPointFromRelayServer.Dequeue();

                        Console.WriteLine("Ch={0} PopPacket Packet", nCurThreadCh);
                        byte[] packet = udpSock.PopPacket(nCurThreadCh);
                        if (packet == null)
                        {
                            continue;
                        }

                        string str = Encoding.UTF8.GetString(packet);
                        //Console.WriteLine("Port={0} Received={1}", ep.Port, str.Length);



                        AUTHORITY_PACKET AuthPacket;
                        //AuthPacket.GetType()
                        //typeof(AUTHORITY_PACKET)
                        AuthPacket  = (AUTHORITY_PACKET)AuthorityCommUtil.ByteToStructure(packet, typeof(AUTHORITY_PACKET));
                        string name = AuthorityCommUtil.ByteToString(AuthPacket.srcName.name);
                        string data = AuthorityCommUtil.ByteToString(AuthPacket.authorityData.data);
                        //System.Console.WriteLine(data.Replace('\0', ' '));
                        //System.Console.WriteLine(name.Replace('\0', ' '));

                        if (AuthPacket.byCmdGroup == CommandPTZReqResp.CMDGROUP_PTZREQ)
                        {
                            if (AuthPacket.byCmdType == CommandPTZReqResp.CMDTYPE_PTZREQ_PANTILT_POS_RESP)
                            {
                                this.Dispatcher.Invoke(DispatcherPriority.Normal, (Action)(() =>
                                {
                                    int index1 = data.IndexOf(';');
                                    string strPan = data.Substring(0, index1);
                                    string strTilt = data.Substring(index1 + 1, data.Length - (index1 + 1));
                                    double pan = double.Parse(strPan);
                                    double tilt = double.Parse(strTilt);

                                    int x = 0;
                                    int y = 0;

                                    PanTiltPosToImgAbsPos(pan, tilt, ref x, ref y, arrPanoInfo[nCh - 1]);
                                    arrCanvas[nCurThreadCh - 1].DrawPanTiltDirectionPoint(x, y);
                                    arrCanvas[nCurThreadCh - 1].panoSetupWindow.SetTilt(tilt);

                                    //int index2 = data.IndexOf('\0');
                                    //PanLabel.Content = "방위각 " + data.Substring(0, index1);
                                    //TiltLabel.Content = "고저각 " + data.Substring(index1 + 1, data.Length - (index1 + 1));
                                }));
                            }
                            else if (AuthPacket.byCmdType == CommandPTZReqResp.CMDTYPE_PTZREQ_MAINBOARD_STATUS_RESP)
                            {
                                System.Console.WriteLine(data);
                            }
                        }
                    }
                    if (IsDestroyPacketParsingThread(nCurThreadCh) == true)//스레드 종료
                    {
                        break;
                    }


                    Thread.Sleep(1);
                }
                SetPacketParsingThread(nCurThreadCh, false);//상태 체크
            });
        }
예제 #4
0
        private void CreatePacketParsingThread(int nCh)
        {
            //Parse
            Task.Run(() =>
            {
                while (true)
                {
                    //if (udpSock.queuePacketFromRelayServer.Count > 0)
                    if (udpSock.GetNumberOfPacket(nCh) > 0)
                    {
                        //IPEndPoint ep = udpSock.queueIPEndPointFromRelayServer.Dequeue();

                        Console.WriteLine("Parse Packet {0}", nCh);
                        byte[] packet = udpSock.PopPacket(nCh);
                        if (packet == null)
                        {
                            continue;
                        }

                        if (m_nCh != nCh)//선택된 채널과 현재 스레드의 채널이 같을 경우에만 디스플레이
                        {
                            continue;
                        }

                        string str = Encoding.UTF8.GetString(packet);
                        //Console.WriteLine("Port={0} Received={1}", ep.Port, str.Length);



                        AUTHORITY_PACKET AuthPacket;
                        //AuthPacket.GetType()
                        //typeof(AUTHORITY_PACKET)
                        AuthPacket  = (AUTHORITY_PACKET)AuthorityCommUtil.ByteToStructure(packet, typeof(AUTHORITY_PACKET));
                        string name = AuthorityCommUtil.ByteToString(AuthPacket.srcName.name);
                        string data = AuthorityCommUtil.ByteToString(AuthPacket.authorityData.data);
                        //System.Console.WriteLine(data.Replace('\0', ' '));
                        //System.Console.WriteLine(name.Replace('\0', ' '));

                        if (AuthPacket.byCmdGroup == CommandPTZReqResp.CMDGROUP_PTZREQ)
                        {
                            if (AuthPacket.byCmdType == CommandPTZReqResp.CMDTYPE_PTZREQ_PANTILT_POS_RESP)
                            {
                                this.Dispatcher.Invoke(DispatcherPriority.Normal, (Action)(() =>
                                {
                                    int index1 = data.IndexOf(';');
                                    //int index2 = data.IndexOf('\0');

                                    if (m_nCameraType == 1)
                                    {
                                        PanLabel.Content = "방위각 " + data.Substring(0, index1);
                                        TiltLabel.Content = "고저각 " + data.Substring(index1 + 1, data.Length - (index1 + 1));
                                    }
                                }));
                            }
                            else if (AuthPacket.byCmdType == CommandPTZReqResp.CMDTYPE_PTZREQ_DAYZF_POS_RESP)
                            {
                                this.Dispatcher.Invoke(DispatcherPriority.Normal, (Action)(() =>
                                {
                                    if (m_nCameraType == 1)
                                    {
                                        int index1 = data.IndexOf(';');
                                        //int index2 = data.IndexOf('\0');
                                        ZoomLabel.Content = "줌 " + data.Substring(0, index1);
                                        FocusLabel.Content = "포커스 " + data.Substring(index1 + 1, data.Length - (index1 + 1));

                                        try
                                        {
                                            int nCurZoom = int.Parse(data.Substring(0, index1));
                                            int nPtHighSpdZoom = int.Parse(systemPTZEnvSetup.ptHighSpeedZoomVal);
                                            int nPtMidSpdZoom = int.Parse(systemPTZEnvSetup.ptMidSpeedZoomVal);
                                            int nPtLowSpdZoom = int.Parse(systemPTZEnvSetup.ptLowSpeedZoomVal);

                                            //nPtHighSpdZoom nPtMidSpdZoom ~ nPtLowSpdZoom
                                            //84   ~        500    ~       600 ~

                                            //줌값이랑 팬틸트 속도 연동

                                            if (systemPTZEnvSetup.zoomPanTiltInterLocking == "True")
                                            {
                                                if (nCurZoom >= nPtLowSpdZoom && nCurZoom <= nPtMidSpdZoom)
                                                {
                                                    SetPTHighSpd();
                                                }
                                                else if (nCurZoom >= nPtMidSpdZoom && nCurZoom <= nPtHighSpdZoom)
                                                {
                                                    SetPTMidSpd();
                                                }
                                                else if (nCurZoom >= nPtHighSpdZoom)
                                                {
                                                    SetPTLowSpd();
                                                }
                                            }
                                        }
                                        catch (Exception e)
                                        {
                                        }
                                    }
                                }));
                            }
                            else if (AuthPacket.byCmdType == CommandPTZReqResp.CMDTYPE_PTZREQ_MAINBOARD_STATUS_RESP)
                            {
                                System.Console.WriteLine(data);
                            }
                        }
                        else if (AuthPacket.byCmdGroup == CommandThermCam.CMDGROUP_THERMCAM)
                        {
                            if (AuthPacket.byCmdType == CommandThermCam.CMDTYPE_THERMCAM_DZOOM_RESP)
                            {
                                this.Dispatcher.Invoke(DispatcherPriority.Normal, (Action)(() =>
                                {
                                    m_dArrDigitalZoom[m_nCh - 1] = double.Parse(data);
                                    string strZoom = String.Format("줌 {0:0.0}", m_dArrDigitalZoom[m_nCh - 1]);
                                    ZoomLabel.Content = strZoom;
                                }));
                            }
                        }
                    }

                    Thread.Sleep(1);
                }
            });
        }