コード例 #1
0
        public bool LoadFIle(string filePathName)
        {
            ini = new IniFile(filePathName);

            string temp = ini.IniReadValue("common", "NumberOfPreset");

            if (temp == "")
            {
                return(false);
            }

            int numberOfPreset = int.Parse(temp);

            presetList.Clear();

            for (int i = 0; i < numberOfPreset; i++)
            {
                string num = string.Format("Num{0:d2}", i + 1);

                //string _no = ini.IniReadValue(num, "no");
                string _no      = (i + 1).ToString();
                string _name    = ini.IniReadValue(num, "name");
                string _time    = ini.IniReadValue(num, "time");
                string _panAbs  = ini.IniReadValue(num, "pan");
                string _tiltAbs = ini.IniReadValue(num, "tilt");
                string _zoom    = ini.IniReadValue(num, "zoom");
                string _focus   = ini.IniReadValue(num, "focus");

                try
                {
                    int           no      = int.Parse(_no);
                    string        name    = _name;
                    int           time    = int.Parse(_time);
                    double        panAbs  = double.Parse(_panAbs);
                    double        tiltAbs = double.Parse(_tiltAbs);
                    int           zoom    = int.Parse(_zoom);
                    int           focus   = int.Parse(_focus);
                    PresetListRow row     = new PresetListRow(no, name, time, panAbs, tiltAbs, zoom, focus);
                    presetList.Add(row);
                }
                catch (Exception e)
                {
                }
            }

            return(true);
        }
コード例 #2
0
        public bool AddPresetRow(PresetListRow presetRow)//Add 할땐 No를 할당 하지 않는다.
        {
            if (ini == null)
            {
                return(false);
            }

            //현재 프리셋 개수를 얻어와서 (No)넘버를 부여 한다.
            int count = presetList.Count();

            presetRow.No = count + 1;

            presetList.Add(presetRow);

            AsyncIniWritePresetList();

            return(true);
        }
コード例 #3
0
        private void EditPresetRow_Click(object sender, RoutedEventArgs e)
        {
            if (m_SelectedIndex < 0)
            {
                MessageBox.Show("선택된 항목이 없습니다.");
                return;
            }
            int nIndex = m_nCh - 1;


            int    no;
            string name;
            int    time;
            double panAbs;
            double tiltAbs;
            int    zoom;
            int    focus;

            try
            {
                no      = int.Parse(No.Content.ToString());
                name    = Name.Text;
                time    = int.Parse(Time.Text);
                panAbs  = double.Parse(PanAbs.Text);
                tiltAbs = double.Parse(TiltAbs.Text);
                zoom    = int.Parse(Zoom.Text);
                focus   = int.Parse(Focus.Text);
            }
            catch (Exception ee)
            {
                MessageBox.Show("입력된 값이 잘못되었습니다.");
                return;
            }



            PresetListRow row = new PresetListRow(no, Name.Text, time, panAbs, tiltAbs, zoom, focus);

            m_arrPresetListReadWrite[nIndex].SetRow(m_SelectedIndex, row);
        }
コード例 #4
0
        private void PresetList_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            /* 선택된 참조점명, 섹션 뽑기 */
            ListView lv     = sender as ListView;
            int      nIndex = lv.SelectedIndex;

            if (nIndex < 0)
            {
                return;
            }

            m_SelectedIndex = nIndex;

            int           curChIndex = m_nCh - 1;
            PresetListRow row        = m_arrPresetListReadWrite[curChIndex].GetRow(nIndex);

            //화면에 업데이트
            No.Content   = row.No.ToString();
            Time.Text    = row.Time.ToString();
            PanAbs.Text  = row.PanAbs.ToString();
            TiltAbs.Text = row.TiltAbs.ToString();
            Zoom.Text    = row.Zoom.ToString();
            Focus.Text   = row.Focus.ToString();
        }
コード例 #5
0
        private void AllRowMove_Click(object sender, RoutedEventArgs e)
        {
            //이동
            int nCh = m_nCh;

            if (m_bPresetStart[nCh - 1] == true)
            {
                string temp = String.Format("채널 {0} 이미 프리셋 진행 중입니다.", nCh);
                MessageBox.Show(temp);
                return;
            }

            int nNumOfPreset = m_arrPresetListReadWrite[nCh - 1].GetNumberOfPreset();


            if (nNumOfPreset < 0)
            {
                string temp = String.Format("채널 {0} 프리셋 리스트 항목이 없습니다.", nCh);
                MessageBox.Show(temp);
                return;
            }

            //프리셋 저장
            for (int i = 0; i < nNumOfPreset; i++)
            {
                //int nIndex = m_nCh - 1;
                PresetListRow row = m_arrPresetListReadWrite[nCh - 1].GetRow(i);

                string strPTZF = String.Format("{0:000};{1:000.####};{2:+00.####;-00.####;+00.0000 };{3:00000};{4:00000}", i + 1, row.PanAbs, row.TiltAbs, row.Zoom, row.Focus);

                SendAuthorityCmd(nCh, CommandPTZFAbsMove.CMDGROUP_PTZFABSMOVE, CommandPTZFAbsMove.CMDTYPE_PTZFABSMOVE_SAVE_POS, strPTZF);
            }

            Thread.Sleep(500);
            //저장된 리스트 확인
#if false//170423 저장된 리스트에 대한 응답이 비정상적으로옴 일단 주석처리하고 나중에 확인 해야 할 듯
            for (int i = 0; i < nNumOfPreset; i++)
            {
                //int nIndex = m_nCh - 1;
                PresetListRow row = m_arrPresetListReadWrite[nCh - 1].GetRow(i);

                string strNo = String.Format("{0:000};", i + 1);

                SendAuthorityCmd(nCh, CommandPTZFAbsMove.CMDGROUP_PTZFABSMOVE, CommandPTZFAbsMove.CMDTYPE_PTZFABSMOVE_REQ_SAVEPOS, strNo);
                string strRecvStatus = GetSavePosStatus(nCh);
                System.Console.WriteLine(strRecvStatus);

                //잘 저장 되었는지 검증
                if (strRecvStatus == "")
                {
                    string temp = String.Format("채널 {0} 팬틸트에 저장된 프리셋 항목({1})이 수신 실패.", nCh, i + 1);
                    MessageBox.Show(temp);
                    return;
                }
                string[] arrRecvString = strRecvStatus.Split(';');
                string   strRecvPan    = arrRecvString[0].Substring(0, arrRecvString[0].Length - 1);
                string   strRecvTilt   = arrRecvString[1].Substring(0, arrRecvString[1].Length - 1);
                string   strRecvZoom   = arrRecvString[2]; //.Substring(0, arrRecvString[2].Length - 1);
                string   strRecvFocus  = arrRecvString[3]; //.Substring(0, arrRecvString[3].Length - 1);

                //string strPTZF = String.Format("{0:000.####};{1:+00.####;-00.####;+00.0000 };{2:00000};{3:00000}", row.PanAbs, row.TiltAbs, row.Zoom, row.Focus
                string strPan = String.Format("{0:000.####}", row.PanAbs);
                strPan = strPan.Substring(0, strPan.Length - 1);
                string strTilt = String.Format("{0:+00.####;-00.####;+00.0000}", row.TiltAbs);
                strTilt = strTilt.Substring(0, strTilt.Length - 1);

                string strZoom  = String.Format("{0:00000}", row.Zoom);
                string strFocus = String.Format("{0:00000}", row.Focus);
                //MessageBox.Show("a" + strRecvFocus);
                //MessageBox.Show("b" + strFocus);

                if (strRecvPan == strPan &&
                    strRecvTilt == strTilt &&
                    strRecvZoom == strZoom &&
                    strRecvFocus == strFocus)
                {
                }
                else
                {
                    string temp = String.Format("채널 {0} 팬틸트에 프리셋 항목({1})이 비정상 저장됨.", nCh, i + 1);
                    MessageBox.Show(temp);
                    //temp = strRecvPan +" "+ strPan + " " + strRecvTilt + " " + strTilt + " " + strRecvZoom + " " + strZoom + " " + strRecvFocus + " " + strFocus;
                    //MessageBox.Show(temp);
                    return;
                }
            }
#endif
            string status = String.Format("채널 {0} 프리셋 시작", nCh);
            this.PresetStatusLabel.Content    = status;
            this.m_bPresetStart[nCh - 1]      = true;
            this.m_bPresetThreadStop[nCh - 1] = false;
#if true
            //선택이동 스레드
            #region
            Task.Run(() =>
            {
                const int nTimeOut     = 20;
                int nCount             = 0;
                int nTimeStamp         = 1;
                string strPresetStatus = "";

                bool bForward = true;
                int nPresetNo = 0;
                while (true)
                {
                    if (m_bPresetThreadStop[nCh - 1] == true)
                    {
                        break;
                    }

                    nTimeStamp = 1;

                    if (bForward == true)
                    {
                        nPresetNo++;
                    }
                    else
                    {
                        nPresetNo--;
                    }

                    if (nPresetNo == nNumOfPreset)
                    {
                        bForward = false;
                    }
                    else if (nPresetNo == 1)
                    {
                        bForward = true;
                    }

                    SendAuthorityCmd(nCh, CommandPTZFAbsMove.CMDGROUP_PTZFABSMOVE, CommandPTZFAbsMove.CMDTYPE_PTZFABSMOVE_MOVE_SAVEPOS, nPresetNo.ToString());
                    strPresetStatus = string.Format("채널 {0} 프리셋({1}) 이동시작({2})", nCh, nPresetNo, nTimeStamp);
                    SetPresetStatus(nCh, strPresetStatus);
                    Thread.Sleep(1000);

                    while (true)
                    {
                        if (m_bPresetThreadStop[nCh - 1] == true)
                        {
                            break;
                        }

                        SendAuthorityCmd(nCh, CommandPTZReqResp.CMDGROUP_PTZREQ, CommandPTZReqResp.CMDTYPE_PTZREQ_PAN_MOTORSTATUS_REQ);
                        Thread.Sleep(1000);
                        string strStatus = GetPanMoveStatus(nCh);

                        if (strStatus == "1")
                        {
                            nCount = 0;
                            //System.Console.WriteLine("프리셋 이동중...");
                            strPresetStatus = string.Format("채널 {0} 프리셋({1}) 이동중({2})", nCh, nPresetNo, nTimeStamp);
                        }
                        else if (strStatus == "2")
                        {
                            nCount = 0;
                            //System.Console.WriteLine("프리셋 이동 완료...");
                            strPresetStatus = string.Format("채널 {0} 프리셋({1}) 이동 정지({2})", nCh, nPresetNo, nTimeStamp);

                            break;
                        }
                        else
                        {
                            strPresetStatus = string.Format("채널 {0} 프리셋({1}) 상태 인식 실패({2})", nCh, nPresetNo, nTimeStamp);
                        }

                        SetPresetStatus(nCh, strPresetStatus);
                        Thread.Sleep(1);
                        SendAuthorityCmd(nCh, CommandPTZReqResp.CMDGROUP_PTZREQ, CommandPTZReqResp.CMDTYPE_PTZREQ_PANTILT_POS_REQ);
                        //Thread.Sleep(1000);
                        Thread.Sleep(500);

                        nCount++;
                        nTimeStamp++;
                        if (nCount >= nTimeOut)
                        {
                            break;
                        }
                    }
                    if (m_bPresetThreadStop[nCh - 1] == true)
                    {
                        break;
                    }

                    //대기 시간
                    PresetListRow row = m_arrPresetListReadWrite[nCh - 1].GetRow(nPresetNo - 1);
                    strPresetStatus   = string.Format("채널 {0} 프리셋({1}) 대기중({2}초)", nCh, nPresetNo, row.Time);
                    SetPresetStatus(nCh, strPresetStatus);

                    for (int i = 0; i < row.Time; i++)
                    {
                        Thread.Sleep(1000);
                        strPresetStatus = string.Format("채널 {0} 프리셋({1}) 대기중({2}초)", nCh, nPresetNo, row.Time - (i + 1));
                        SetPresetStatus(nCh, strPresetStatus);
                        if (m_bPresetThreadStop[nCh - 1] == true)
                        {
                            break;
                        }
                    }
                }
                SendAuthorityCmd(nCh, CommandPTZReqResp.CMDGROUP_PTZREQ, CommandPTZReqResp.CMDTYPE_PTZREQ_PANTILT_POS_REQ);
                strPresetStatus = String.Format("채널 {0} 프리셋 이동 종료({1})", nCh, nTimeStamp);
                SetPresetStatus(nCh, strPresetStatus);
                this.m_bPresetStart[nCh - 1]      = false;
                this.m_bPresetThreadStop[nCh - 1] = false;
            });
            #endregion
#endif
        }
コード例 #6
0
        private void AddPresetRow_Click(object sender, RoutedEventArgs e)
        {
            int nIndex = m_nCh - 1;
            int nCh    = m_nCh;

            //패킷 전송
            SendAuthorityCmd(m_nCh, CommandPTZReqResp.CMDGROUP_PTZREQ, CommandPTZReqResp.CMDTYPE_PTZREQ_PANTILT_POS_REQ);


            //패킷 수신 및 분석
            string strPanAbs  = "";
            string strTiltAbs = "";
            string strZoom    = "";
            string strFocus   = "";

            while (true)//다른 메세지도 같이 오기 때문에 계속 읽어오면서 필터링
            {
                AUTHORITY_PACKET AuthPacket = RecvAuthorityCmd(nCh);

                if (AuthPacket.bySTX == 0 || AuthPacket.byETX == 0)
                {
                    break;
                }
                if (AuthPacket.byCmdGroup == CommandPTZReqResp.CMDGROUP_PTZREQ)
                {
                    if (AuthPacket.byCmdType == CommandPTZReqResp.CMDTYPE_PTZREQ_PANTILT_POS_RESP)
                    {
                        string receivedName = AuthorityCommUtil.ByteToString(AuthPacket.srcName.name);
                        string receiveddata = AuthorityCommUtil.ByteToString(AuthPacket.authorityData.data);

                        int index1 = receiveddata.IndexOf(';');
                        //index1 += 1;
                        strPanAbs  = receiveddata.Substring(0, index1);
                        strTiltAbs = receiveddata.Substring(index1 + 1, receiveddata.Length - index1 - 1);

                        SendAuthorityCmd(m_nCh, CommandPTZReqResp.CMDGROUP_PTZREQ, CommandPTZReqResp.CMDTYPE_PTZREQ_DAYZF_POS_REQ);
                    }
                    if (AuthPacket.byCmdType == CommandPTZReqResp.CMDTYPE_PTZREQ_DAYZF_POS_RESP)
                    {
                        string receivedName = AuthorityCommUtil.ByteToString(AuthPacket.srcName.name);
                        string receiveddata = AuthorityCommUtil.ByteToString(AuthPacket.authorityData.data);

                        int index1 = receiveddata.IndexOf(';');
                        //index1 += 1;
                        strZoom  = receiveddata.Substring(0, index1);
                        strFocus = receiveddata.Substring(index1 + 1, receiveddata.Length - index1 - 1);
                    }
                }
            }
            if (strPanAbs != "" && strTiltAbs != "" && strZoom != "" && strFocus != "")
            {
                //화면에 업데이트
                this.Dispatcher.Invoke(DispatcherPriority.Normal, (Action)(() =>
                {
                    this.PanAbs.Text = strPanAbs;
                    this.TiltAbs.Text = strTiltAbs;
                    this.Zoom.Text = strZoom;
                    this.Focus.Text = strFocus;
                }));
            }
            else
            {
                MessageBox.Show("팬/틸트 줌/포커스 값 수신 실패");
                return;
            }

            /////////////////////////////////////////////////////////////////////////////////////////////////////////
            /////////////////////////////////////////////////////////////////////////////////////////////////////////
            /////////////////////////////////////////////////////////////////////////////////////////////////////////
            /////////////////////////////////////////////////////////////////////////////////////////////////////////
            //프리셋 리스트 저장

            int    no      = m_arrPresetListReadWrite[nIndex].GetNumberOfPreset();
            string name    = Name.Text;
            int    time    = 0;
            double panAbs  = 0;
            double tiltAbs = 0;
            int    zoom    = 0;
            int    focus   = 0;

            try
            {
                //수동 입력

                /*
                 * time     = int.Parse(Time.Text);
                 * panAbs   = double.Parse(PanAbs.Text);
                 * tiltAbs  = double.Parse(TiltAbs.Text);
                 * zoom     = int.Parse(Zoom.Text);
                 * focus    = int.Parse(Focus.Text);
                 */

                //리스트에 저장할 변수들
                time    = int.Parse(Time.Text);//수동 입력
                panAbs  = double.Parse(strPanAbs);
                tiltAbs = double.Parse(strTiltAbs);
                zoom    = int.Parse(strZoom);
                focus   = int.Parse(strFocus);
            }
            catch (Exception ee)
            {
                //MessageBox.Show(ee.ToString());
                MessageBox.Show("입력된 값이 잘못되었습니다.");
                return;
            }

            PresetListRow row = new PresetListRow(Name.Text, time, panAbs, tiltAbs, zoom, focus);

            bool ret = m_arrPresetListReadWrite[nIndex].AddPresetRow(row);

            if (ret == false)
            {
                MessageBox.Show("프리셋 그룹 파일이 없습니다.");//프리셋 추가 실패
                return;
            }


            PresetListView.ItemsSource = m_arrPresetListReadWrite[nIndex].GetPresetList();
        }
コード例 #7
0
        public void SetRow(int nIndex, PresetListRow row)
        {
            this.presetList[nIndex] = row;

            AsyncIniWritePresetList();
        }