private string GetPanMoveStatus() { #region string strStatus = ""; while (true)//다른 메세지도 같이 오기 때문에 계속 읽어오면서 필터링 { AUTHORITY_PACKET AuthPacket = RecvAuthorityCmd(); if (AuthPacket.bySTX == 0 || AuthPacket.byETX == 0) { break; } if (AuthPacket.byCmdGroup == CommandPTZReqResp.CMDGROUP_PTZREQ) { if (AuthPacket.byCmdType == CommandPTZReqResp.CMDTYPE_PTZREQ_PAN_MOVESTATUS_RESP) { string receivedName = AuthorityCommUtil.ByteToString(AuthPacket.srcName.name); string receiveddata = AuthorityCommUtil.ByteToString(AuthPacket.authorityData.data); strStatus = receiveddata; break; } } } return(strStatus); #endregion }
private string GetSavePosStatus(int nCh) { #region string strStatus = ""; while (true)//다른 메세지도 같이 오기 때문에 계속 읽어오면서 필터링 { AUTHORITY_PACKET AuthPacket = RecvAuthorityCmd(nCh); if (AuthPacket.bySTX == 0 || AuthPacket.byETX == 0) { break; } if (AuthPacket.byCmdGroup == CommandPTZFAbsMove.CMDGROUP_PTZFABSMOVE) { if (AuthPacket.byCmdType == CommandPTZFAbsMove.CMDTYPE_PTZFABSMOVE_RESP_SAVEPOS) { string receivedName = AuthorityCommUtil.ByteToString(AuthPacket.srcName.name); string receiveddata = AuthorityCommUtil.ByteToString(AuthPacket.authorityData.data); strStatus = receiveddata; break; } } } return(strStatus); #endregion }
private string GetPanTiltHomeStatus() { #region string strStatus = ""; while (true)//다른 메세지도 같이 오기 때문에 계속 읽어오면서 필터링 { AUTHORITY_PACKET AuthPacket = RecvAuthorityCmd(); if (AuthPacket.bySTX == 0 || AuthPacket.byETX == 0) { break; } if (AuthPacket.byCmdGroup == CommandPanTiltInit.CMDGROUP_PANTILTINIT) { if (AuthPacket.byCmdType == CommandPanTiltInit.CMDTYPE_PANTILTINIT_RESP_HOMEPOS) { string receivedName = AuthorityCommUtil.ByteToString(AuthPacket.srcName.name); string receiveddata = AuthorityCommUtil.ByteToString(AuthPacket.authorityData.data); strStatus = receiveddata; break; } } } return(strStatus); #endregion }
private string GetThermCamPowerStatus() { #region string strStatus = ""; while (true)//다른 메세지도 같이 오기 때문에 계속 읽어오면서 필터링 { AUTHORITY_PACKET AuthPacket = RecvAuthorityCmd(); if (AuthPacket.bySTX == 0 || AuthPacket.byETX == 0) { break; } if (AuthPacket.byCmdGroup == CommandPowerMgt.CMDGROUP_POWERMGT) { if (AuthPacket.byCmdType == CommandPowerMgt.CMDTYPE_POWERMGT_THERMCAM_PWR_STATUS) { string receivedName = AuthorityCommUtil.ByteToString(AuthPacket.srcName.name); string receiveddata = AuthorityCommUtil.ByteToString(AuthPacket.authorityData.data); strStatus = receiveddata; break; } } } return(strStatus); #endregion }
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); } }); }
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(); }
// 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);//상태 체크 }); }
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); } }); }