/// <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); } } }
private void btnAutoConn_Click(object sender, EventArgs e) { RefreshOnlineDevice(); if (comboBoxOnlineDevice.Items.Count == 0) { return; } if (btnAutoConn.Text == "一键连接播放") { if (comboBoxOnlineDevice.Items.Count >= 1) { for (int i = 0; i < comboBoxOnlineDevice.Items.Count; i++) { ConnectionCamer(_LstEnumInfo[i].intCamIp); FormDisplay frmDisplay = _DataControl.GetBindedDisplayForm(_LstEnumInfo[i].intCamIp); //选择已经绑定的IP的显示窗口 if (frmDisplay != null) { frmDisplay.GetDateDisplay().Play(); ChangeBtnCursor(2); } } btnAutoConn.Text = "一键断开停止播放"; } } else if (btnAutoConn.Text == "一键断开停止播放") { DialogResult MsgBoxResult = MessageBox.Show("确定要停止播放且停止采集热点?", //对话框的显示内容 "操作提示", //对话框的标题 MessageBoxButtons.YesNo, //定义对话框的按钮,这里定义了YSE和NO两个按钮 MessageBoxIcon.Question, //定义对话框内的图表式样,这里是一个黄色三角型内加一个感叹号 MessageBoxDefaultButton.Button2); //定义对话框的按钮式样 if (MsgBoxResult == DialogResult.Yes) { if (comboBoxOnlineDevice.Items.Count >= 1) { for (int i = 0; i < comboBoxOnlineDevice.Items.Count; i++) { DislinkCamera(_LstEnumInfo[i].intCamIp); FormDisplay frmDisplay = _DataControl.GetBindedDisplayForm(_LstEnumInfo[i].intCamIp); //选择已经绑定的IP的显示窗口 if (frmDisplay != null) { frmDisplay.Stop = false; frmDisplay.GetDateDisplay().GetDevice().StopProcessImage(); frmDisplay.Invalidate(false); isThreadRun = false; ChangeBtnCursor(1); } } FormMain.GetOPCTaskInfo("视频停止播放,热点信息停止采集,任务停止发送!"); } btnAutoConn.Text = "一键连接播放"; } } RefreshOnlineDevice(); }
/// <summary> /// 断开摄像头连接 /// </summary> /// <param name="intCameraIP"></param> private void DislinkCamera(uint intCameraIP) { FormDisplay frmDisplay = _DataControl.GetBindedDisplayForm(intCameraIP); if (frmDisplay != null) { MagDevice device = frmDisplay.GetDateDisplay().GetDevice(); device.StopProcessImage(); device.DisLinkCamera(); frmDisplay.Invalidate(false); } }
public FormDisplay GetCurrDisplayForm() { FormDisplay frmDisplay = Globals.GetMainFrm().GetFormDisplay(DataDisplay.CurrSelectedWndIndex); MagDevice device = frmDisplay.GetDateDisplay().GetDevice(); if (device.GetDevIPAddress() == 0) { return(frmDisplay); } else { return(GetFirstFreeDisplayForm()); } }
public FormDisplay GetFirstFreeDisplayForm() { uint max_wnd = Globals.GetMainFrm().GetMaxDeviceWnd(); for (uint i = 0; i < max_wnd; i++) { FormDisplay frmDisplay = Globals.GetMainFrm().GetFormDisplay(i); MagDevice device = frmDisplay.GetDateDisplay().GetDevice(); if (device.GetDevIPAddress() == 0) { return(frmDisplay); } } return(null); }
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(); }
private void buttonPlay_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); FormDisplay frmDisplay = _DataControl.GetBindedDisplayForm(_LstEnumInfo[index].intCamIp); if (frmDisplay != null) { frmDisplay.GetDateDisplay().Play(); } }
private void buttonPlay_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); for (int i = 0; i < comboBoxOnlineDevice.Items.Count; i++) { FormDisplay frmDisplay = _DataControl.GetBindedDisplayForm(_LstEnumInfo[i].intCamIp); //选择已经绑定的IP的显示窗口 if (frmDisplay != null) { frmDisplay.GetDateDisplay().Play(); ChangeBtnCursor(2); } } }
void InitializeAllWindows() { //主窗口 this.Width = (int)MAINWINDOW_WIDTH; this.Height = (int)MAINWINDOW_HEIGHT; //控制窗口 _FormControl = new FormControl(); _FormControl.TopLevel = false; _FormControl.Parent = this; _FormControl.FormBorderStyle = FormBorderStyle.Fixed3D; _FormControl.ControlBox = false; _FormControl.Left = (int)(MAINWINDOW_WIDTH - CONTROLWINDOW_WIDTH); _FormControl.Top = 0; _FormControl.Width = (int)CONTROLWINDOW_WIDTH; _FormControl.Height = (int)(CONTROLWINDOW_HEIGHT); _FormControl.Show(); //显示窗口的背景窗口 _FormDisplayBG = new FormDisplayBG(); _FormDisplayBG.TopLevel = false; _FormDisplayBG.Parent = this; _FormDisplayBG.FormBorderStyle = FormBorderStyle.None; _FormDisplayBG.TopLevel = false; _FormDisplayBG.Hide(); //显示窗口 _FormDisplayLst = new FormDisplay[MAX_DEVWINDOW_NUM]; for (uint i = 0; i < MAX_DEVWINDOW_NUM; i++) { _FormDisplayLst[i] = new FormDisplay(); _FormDisplayLst[i].TopLevel = false; _FormDisplayLst[i].Parent = _FormDisplayBG; _FormDisplayLst[i].FormBorderStyle = FormBorderStyle.None; _FormDisplayLst[i].Hide(); _FormDisplayLst[i].GetDateDisplay().WndIndex = i; } }
private void FormDisplayBG_Paint(object sender, PaintEventArgs e) { Graphics graphic = e.Graphics; graphic.FillRectangle(Brushes.White, new Rectangle(0, 0, this.Width, this.Height)); FormMain formMain = Globals.GetMainFrm(); uint row = 0, col = 0; formMain.GetFormControl().GetDataControl().GetDisplayWndNum(ref row, ref col); int bdr_width = (int)formMain.GetSelectionBorderWidth(); uint num = row * col; for (uint i = 0; i < num; i++) { FormDisplay frmDiplay = Globals.GetMainFrm().GetFormDisplay(i); Point pt = new Point(frmDiplay.Left, frmDiplay.Top); int left = pt.X - bdr_width; int top = pt.Y - bdr_width; int w = frmDiplay.Width + bdr_width * 2; int h = frmDiplay.Height + bdr_width * 2; if (DataDisplay.CurrSelectedWndIndex == frmDiplay.GetDateDisplay().WndIndex) { graphic.FillRectangle(Brushes.LightGreen, new Rectangle(left, top, w, h)); } else { graphic.FillRectangle(Brushes.DarkGray, new Rectangle(left, top, w, h)); } } }
private void buttonStop_Click(object sender, EventArgs e) { int index = comboBoxOnlineDevice.SelectedIndex; if (index < 0) { return; } DialogResult MsgBoxResult = MessageBox.Show("确定要停止播放且停止采集热点?", //对话框的显示内容 "操作提示", //对话框的标题 MessageBoxButtons.YesNo, //定义对话框的按钮,这里定义了YSE和NO两个按钮 MessageBoxIcon.Question, //定义对话框内的图表式样,这里是一个黄色三角型内加一个感叹号 MessageBoxDefaultButton.Button2); //定义对话框的按钮式样 if (MsgBoxResult == DialogResult.Yes) { MagService service = _DataControl.GetService(); uint dev_num = service.GetTerminalList(_LstEnumInfo, MAX_ENUMDEVICE); for (int i = 0; i < comboBoxOnlineDevice.Items.Count; i++) { FormDisplay frmDisplay = _DataControl.GetBindedDisplayForm(_LstEnumInfo[i].intCamIp); if (frmDisplay == null) { continue; } frmDisplay.Stop = false; frmDisplay.GetDateDisplay().GetDevice().StopProcessImage(); frmDisplay.Invalidate(false); isThreadRun = false; FormMain.GetOPCTaskInfo("线程停止!"); FormMain.GetOPCTaskInfo("视频停止播放,热点信息停止采集,任务停止发送!"); ChangeBtnCursor(1); } } }
void OnUpdateDisplayPostion() { uint row = 0, col = 0; _FormControl.GetDataControl().GetDisplayWndNum(ref row, ref col); uint w = (uint)this.Width; uint h = (uint)this.Height; //先计算显示窗口的位置和大小,依据为:在不超过主窗口大小的情况下尽可能大,同时严格保持4:3的比例显示 uint real_width = w - CONTROLWINDOW_WIDTH; uint real_height = h; uint display_width = (real_width - DISPLAYWND_MARGIN * 2 - (col - 1) * DISPLAYWND_GAP) / col; //单个相机显示区域的宽度(还未考虑比例) uint display_height = (real_height - DISPLAYWND_MARGIN * 2 - (row - 1) * DISPLAYWND_GAP) / row; //单个相机显示区域的高度(还未考虑比例) if (display_width * 3 >= display_height * 4) //考虑比例 { uint ret = display_height % 3; if (ret != 0) { display_height -= ret; } display_width = display_height * 4 / 3; } else { uint ret = display_width % 4; if (ret != 0) { display_width -= ret; } display_height = display_width * 3 / 4; } for (uint i = 0; i < row; i++) { uint y = DISPLAYWND_MARGIN + (display_height + DISPLAYWND_GAP) * i; for (uint j = 0; j < col; j++) { uint x = DISPLAYWND_MARGIN + (display_width + DISPLAYWND_GAP) * j; FormDisplay frm = _FormDisplayLst[i * col + j]; frm.Left = (int)x; frm.Top = (int)y; frm.Width = (int)display_width; frm.Height = (int)display_height; } } //计算显示窗口的背景窗口的位置和大小 uint display_bg_width = DISPLAYWND_MARGIN * 2 + display_width * col + DISPLAYWND_GAP * (col - 1); uint display_bg_height = DISPLAYWND_MARGIN * 2 + display_height * row + DISPLAYWND_GAP * (row - 1); _FormDisplayBG.Left = 0; _FormDisplayBG.Top = 0; _FormDisplayBG.Width = (int)display_bg_width; _FormDisplayBG.Height = (int)display_bg_height; _FormDisplayBG.Show(); //更新显示窗口的显示与隐藏 uint num = row * col; for (uint i = 0; i < num; i++) { _FormDisplayLst[i].Show(); } for (uint i = num; i < MAX_DEVWINDOW_NUM; i++) { _FormDisplayLst[i].Hide(); } }
/// <summary> /// 当值发生改变时 /// </summary> /// <param name="group"></param> /// <param name="clientId"></param> /// <param name="values"></param> public async void OnDataChange(int group, int[] clientId, object[] values) { if (group == 2) //任务下发位置 { for (int i = 0; i < clientId.Length; i++) // 获取跳变信号 { int tempvalue = int.Parse((values[i].ToString())); //标志位 if (tempvalue == 0) //如果等于0 就是已经处理 可以下发任务 { if (!isWork) { isWork = true; aa : Posistion posistion = new Posistion { x = RobitGroup.ReadD(0).CastTo <float>(-1), y = RobitGroup.ReadD(1).CastTo <float>(-1), z = RobitGroup.ReadD(2).CastTo <float>(-1), Ry = RobitGroup.ReadD(3).CastTo <float>(-1), Rx = RobitGroup.ReadD(4).CastTo <float>(-1), Rz = RobitGroup.ReadD(5).CastTo <float>(-1) }; //机器人矩阵 Transform transform = new Transform(); //相机矩阵 if (CalculatorClass.Rpy_to_trans(posistion, ref transform) == 0) //机器人姿态转为相机所在为位置 { if (transform.v1.x > 0) //如果是一号热像仪可用 { CamIndex = 0; } else if (transform.v1.x > 1)//如果是二号热像仪可用 { CamIndex = 1; } else//都不可用的情况下 再取一次机器人的位置 { Thread.Sleep(50); goto aa; } FormDisplay frmDisplay = _DataControl.GetBindedDisplayForm(_LstEnumInfo[CamIndex].intCamIp); //选择已经绑定的IP的显示窗口 FormMain.GetOPCTaskInfo("正在使用窗体:" + frmDisplay.Name + "的热像仪!"); object[] obj = new object[36]; RpyGroup.SyncWrite(obj);//写入坐标和温度 isWork = false; } else { FormMain.GetOPCTaskInfo("机器人姿态转为相机位置失败"); } } else { FormMain.GetOPCTaskInfo("在获取热点信息时,产生了一次跳变信号,第" + JumpSingle + "次"); JumpSingle++; } } else { FormMain.GetOPCTaskInfo("跳变未找到Group组"); } } } #region 暂时无用 //else if (group == 3)//机器人姿态位置 //{ // for (int i = 0; i < clientId.Length; i++)// 获取跳变信号 // { // aa: Posistion posistion = new Posistion // { // x = float.Parse(RobitGroup.ReadD(0).ToString()), // y = float.Parse(RobitGroup.ReadD(1).ToString()), // z = float.Parse(RobitGroup.ReadD(2).ToString()), // Rx = float.Parse(RobitGroup.ReadD(3).ToString()), // Ry = float.Parse(RobitGroup.ReadD(4).ToString()), // Rz = float.Parse(RobitGroup.ReadD(5).ToString()) // }; // Transform transform = new Transform(); // if (CalculatorClass.Rpy_to_trans(posistion, ref transform) > 0)//机器人姿态转换相机位置 // { // if(transform.v1.x > 0)//如果是一号热像仪可用 // { // CamIndex = 0; // } // else if(transform.v1.x > 1)//如果是二号热像仪可用 // { // CamIndex = 1; // } // else//都不可用的情况下 再取一次机器人的位置 // { // goto aa; // } // FormDisplay frmDisplay = _DataControl.GetBindedDisplayForm(_LstEnumInfo[CamIndex].intCamIp); //选择已经绑定的IP的显示窗口 // FormMain.GetOPCTaskInfo("正在使用窗体:"+frmDisplay.Name +"的热像仪!"); // object[] obj = new object[36]; // await Task.Run(()=> frmDisplay.GetInfo(1, out obj) ); // RpyGroup.SyncWrite(obj);//写入坐标和温度 // } // else // { // FormMain.GetOPCTaskInfo("Rpy_to_trans:机器人姿态值转变失败,组:" + group); // } // } //} #endregion else { FormMain.GetOPCTaskInfo("跳变信号组错误,组:" + group); } }
void OnUpdateDisplayPostion() { uint row = 0, col = 0; _FormControl.GetDataControl().GetDisplayWndNum(ref row, ref col); uint w = (uint)this.Width; uint h = (uint)this.Height; //先计算显示窗口的位置和大小,依据为:在不超过主窗口大小的情况下尽可能大,同时严格保持4:3的比例显示 uint real_width = w - CONTROLWINDOW_WIDTH; uint real_height = h; uint display_width = (real_width - DISPLAYWND_MARGIN * 2 - (col - 1) * DISPLAYWND_GAP) / col; //单个相机显示区域的宽度(还未考虑比例) uint display_height = (real_height - DISPLAYWND_MARGIN * 2 - (row - 1) * DISPLAYWND_GAP) / row; //单个相机显示区域的高度(还未考虑比例) if (display_width * 3 >= display_height * 4) //考虑比例 { uint ret = display_height % 3; if (ret != 0) { display_height -= ret; } display_width = display_height * 4 / 3; } else { uint ret = display_width % 4; if (ret != 0) { display_width -= ret; } display_height = display_width * 3 / 4; } for (uint i = 0; i < row; i++) { uint y = DISPLAYWND_MARGIN + (display_height + DISPLAYWND_GAP) * i; for (uint j = 0; j < col; j++) { uint x = DISPLAYWND_MARGIN + (display_width + DISPLAYWND_GAP) * j; FormDisplay frm = _FormDisplayLst[i * col + j]; frm.Left = (int)x; frm.Top = (int)y; frm.Width = (int)display_width; frm.Height = (int)display_height; frm.Name = "视频" + (j + 1); } } //计算显示窗口的背景窗口的位置和大小 uint display_bg_width = DISPLAYWND_MARGIN * 2 + display_width * col + DISPLAYWND_GAP * (col - 1); uint display_bg_height = DISPLAYWND_MARGIN * 2 + display_height * row + DISPLAYWND_GAP * (row - 1); _FormDisplayBG.Left = 0; _FormDisplayBG.Top = 0; _FormDisplayBG.Width = (int)display_bg_width; _FormDisplayBG.Height = (int)display_bg_height; _FormDisplayBG.BackColor = Color.Red; _FormDisplayBG.Show(); int count = rw.IniReadValue("ListCout", "Count").CastTo <int>(-1); FormDateSet.getNewZGInfo += GetZGinfoToDisplay; //更新显示窗口的显示与隐藏 uint num = row * col; for (uint i = 0; i < num; i++) { _FormDisplayLst[i].Show(); } for (uint i = num; i < MAX_DEVWINDOW_NUM; i++) { _FormDisplayLst[i].Hide(); } if (!CheckCanshuOkbuOk(count)) { GetOPCTaskInfo("未找到任何甑锅的参数,请录入甑锅参数后重启程序"); MessageBox.Show("未找到任何甑锅的参数,请录入甑锅参数!", "参数文件未找到!", MessageBoxButtons.OK, MessageBoxIcon.Error); fds.ShowDialog(); } }
// Label lblErrInfo = new Label(); void InitializeAllWindows() { //this.label2.AutoSize = true; //this.label2.Font = new System.Drawing.Font("微软雅黑", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); //this.label2.Location = new System.Drawing.Point(15, 71); //this.label2.Name = "label2"; //this.label2.Size = new System.Drawing.Size(21, 20); //this.label2.TabIndex = 1; //this.label2.Text = "y:"; FormPwd = new FormPwd(); //主窗口 this.Width = (int)MAINWINDOW_WIDTH; this.Height = (int)MAINWINDOW_HEIGHT; this.Controls.Add(this.list_data); this.list_data.Dock = DockStyle.Bottom; this.list_data.FormattingEnabled = true; this.list_data.ItemHeight = 12; this.list_data.Location = new System.Drawing.Point(0, 0); this.list_data.Name = "list_data"; handle += upDateList; this.list_data.TabIndex = 40; //lblErrInfo.Location = new Point(0, list_data.Height ); //lblErrInfo.Text = "错误信息"; //lblErrInfo.Font = new System.Drawing.Font("微软雅黑", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); //lblErrInfo.Size = new Size(21, 20); //list_data.Controls.Add(lblErrInfo); //控制窗口 _FormControl = new FormControl(); _FormControl.TopLevel = false; _FormControl.Parent = this; _FormControl.FormBorderStyle = FormBorderStyle.Fixed3D; _FormControl.ControlBox = false; _FormControl.Left = (int)(MAINWINDOW_WIDTH - CONTROLWINDOW_WIDTH); _FormControl.Top = 0; _FormControl.Width = (int)CONTROLWINDOW_WIDTH - 20; _FormControl.Height = (int)CONTROLWINDOW_HEIGHT; _FormControl.Dock = DockStyle.Right; //显示窗口的背景窗口 _FormDisplayBG = new FormDisplayBG(); _FormDisplayBG.TopLevel = false; _FormDisplayBG.Parent = this; _FormDisplayBG.FormBorderStyle = FormBorderStyle.None; _FormDisplayBG.TopLevel = false; _FormDisplayBG.Hide(); //显示窗口 _FormDisplayLst = new FormDisplay[MAX_DEVWINDOW_NUM]; for (uint i = 0; i < MAX_DEVWINDOW_NUM; i++) { _FormDisplayLst[i] = new FormDisplay(); _FormDisplayLst[i].TopLevel = false; _FormDisplayLst[i].Parent = _FormDisplayBG; _FormDisplayLst[i].FormBorderStyle = FormBorderStyle.None; _FormDisplayLst[i].Hide(); _FormDisplayLst[i].GetDateDisplay().WndIndex = i; } this.list_data.Size = new System.Drawing.Size(Width - _FormControl.Width - 30, Height - _FormDisplayLst[0].Height - 320); list_data.Font = new System.Drawing.Font("微软雅黑", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); _FormControl.Height = (int)(CONTROLWINDOW_HEIGHT)-40 - list_data.Size.Height; _FormControl.Show(); }
/// <summary> /// 线程读取DB块 /// </summary> private void ThreadReadServer() { aa : while (isThreadRun) //线程的运行状态 { flag = s7Postion.Read(0).CastTo <int>(-1); //获取标志位 listRobot.Clear(); list.Clear(); if (flag == 1 && isThreadRun)//允许采集热点信息 { stopwatch.Reset(); stopwatch.Start(); SendFlag = flag; try { axis_3_x = s7Postion.Read(1).CastTo <double>(-1); //axis 3 x 轴三点中心点X坐标 axis_3_y = s7Postion.Read(2).CastTo <double>(-1); //axis 3 y 轴三点中心点Y坐标 //获取相机所在的位置 AngleTheta = s7Postion.Read(3).CastTo <double>(-1) / 1000; // 角度 theta θ AngleAlpha = s7Postion.Read(4).CastTo <double>(-1) / 1000; //角度2 alpha α shishibanjing = s7Postion.Read(5).CastTo <double>(-1); //实时半径 UpdataLabel(lblrealreidan, "实时半径:" + shishibanjing); } catch (Exception ex) { FormMain.GetOPCTaskInfo("读取PLC错误:" + ex.Message); goto bb; } calculator.PotDiamerter = shishibanjing; for (int i = 0; i < comboBoxOnlineDevice.Items.Count; i++)//获取到在线相机 { if (comboBoxOnlineDevice.Items[i].ToString().Contains("conn")) { FormDisplay frmDisplay = _DataControl.GetBindedDisplayForm(_LstEnumInfo[i].intCamIp); if (frmDisplay == null) { //FormMain.GetOPCTaskInfo("未获取到该热像仪画面: IP:" + _LstEnumInfo[i].intCamIp); continue; } else { try { calculator.GetCameraPosition(AngleTheta, AngleAlpha, axis_3_x, axis_3_y, _LstEnumInfo[i].intCamIp); //计算当前相机所在的位置 //if(i == 0) //{ // //相机与柱心距离=515.5 // // UpdataLabel( lbl1x,"相机1X"+ axis_3_x + "-" + 515.5 + "*Math.Cos((" + AngleTheta + "+" + AngleAlpha + ")*(" + (Math.PI / 180) + "))=" + (axis_3_x - 515.5 * Math.Cos((AngleTheta + AngleAlpha) * (Math.PI / 180)))); // // UpdataLabel(lbl1y, "相机1Y"+ axis_3_y + "-" + 515.5 + "*Math.Sin((" + AngleTheta + "+" + AngleAlpha + ")*(" + (Math.PI / 180) + "))=" + (axis_3_y - 515.5 * Math.Sin((AngleTheta + AngleAlpha) * (Math.PI / 180)))); // // FormMain.GetOPCTaskInfo(lbl1x.Text); // // FormMain.GetOPCTaskInfo(lbl1y.Text); // // LogManager.WriteLog(LogFile.Trace,"相机1坐标X"+ lbl1x.Text); // //LogManager.WriteLog(LogFile.Trace, "相机2坐标Y"+lbl1y.Text); //} //else if( i==1) //{ // // UpdataLabel(lbl2x,"相机2x"+ axis_3_x + "+" + 515.5 + "*Math.Cos((" + AngleTheta + "+" + AngleAlpha + ")*(" + (Math.PI / 180) + "))=" + (axis_3_x + 515.5 * Math.Cos((AngleTheta + AngleAlpha) * (Math.PI / 180)))); // // UpdataLabel(lbl2y,"相机2y"+ axis_3_y + "+" + 515.5 + "*Math.Sin((" + AngleTheta + "+" + AngleAlpha + ")*(" + (Math.PI / 180) + "))=" + (axis_3_y + 515.5 * Math.Sin((AngleTheta + AngleAlpha) * (Math.PI / 180)))); // // FormMain.GetOPCTaskInfo(lbl2x.Text); // // FormMain.GetOPCTaskInfo(lbl2y.Text); // // LogManager.WriteLog(LogFile.Trace,"相机2坐标X"+ lbl2x.Text); // // LogManager.WriteLog(LogFile.Trace, "相机2坐标Y"+ lbl2y.Text); //} list.Add(frmDisplay.NewGetInfo()); //获取温度信息 //FormMain.GetOPCTaskInfo("窗体:" + frmDisplay.Name + ",IP:" + _LstEnumInfo[i].intCamIp); } catch (Exception ex) { FormMain.GetOPCTaskInfo(ex.Message); LogManager.WriteLog(LogFile.Error, GetSaveStringFromException("获取相机坐标时出错", ex)); goto bb; } } } else { //FormMain.GetOPCTaskInfo("此相机不处于连接状态:" + comboBoxOnlineDevice.Items[i].ToString()); } } for (int i = 0; i < list.Count; i++) { if (list[i].Count == 0) { continue; } outlist.Clear(); //1.移除在一个区间内的温度点(现在取出来的都是相机里面的坐标) outlist = calculator.RecursiveDeduplication(list[i], Globals.ComparisonInterval, new List <ImgPosition>(), Globals.AngleInterval); //2.将相机温度坐标转换成实际坐标 try { List <RobotPositionSort> realTmper = calculator.GetRobotPositionByImagePoint(outlist, (AngleTheta + AngleAlpha), axis_3_x, axis_3_y, _LstEnumInfo[i].intCamIp, out string OutStr);//将一个相机的热点进行实际值的换算 FormMain.GetOPCTaskInfo(OutStr); // UpdataLabel(lbldetail, "计算明细:" + OutStr); foreach (var item in realTmper) { listRobot.Add(item);//将实际坐标放到一个集合里面 } } catch (Exception ex) { LogManager.WriteLog(LogFile.Error, GetSaveStringFromException("计算热点发生致命错误:", ex)); FormMain.GetOPCTaskInfo("计算热点发生致命错误,停止采集,错误信息:" + GetSaveStringFromException("计算热点发生致命错误:", ex)); goto bb; } } listRobot.Sort(new RobotPositionSort());//温度从高到低排序 if (listRobot.Count == 0) { FormMain.GetOPCTaskInfo("未采集到热点,重新采集"); goto aa; } FormMain.GetOPCTaskInfo("采集到热点个数:" + listRobot.Count); try { //移除实际坐标相近的点 listRobot = calculator.RecursiveDeduplicationReal(listRobot, Globals.ComparisonIntervalReal, new List <RobotPositionSort>(), Globals.AngleIntervalReal); listRobot = calculator.Filtering(listRobot, 1);//滤波 } catch (Exception ex) { LogManager.WriteLog(LogFile.Error, GetSaveStringFromException("滤波或者移除相近坐标时发生致命错误,停止采集,错误信息:", ex)); FormMain.GetOPCTaskInfo("滤波或者移除相近坐标时发生致命错误,停止采集,错误信息:" + GetSaveStringFromException("滤波或者移除相近坐标时发生致命错误:", ex)); goto bb; } object[] values = calculator.ReplaceIndex(listRobot.Take(20).ToList()); //重新排序 s7Task.Write(values); //写入任务 FormMain.GetOPCTaskInfo("写入任务!热点个数:" + values[0]); stopwatch.Stop(); UpdataLabel(lblOutTime, "整体耗时:" + stopwatch.Elapsed.TotalMilliseconds + "毫秒"); Thread.Sleep(timeSleep);//未取到数据时 根据间隔再取 } else { if (SendFlag.GetHashCode() != flag.GetHashCode()) { FormMain.GetOPCTaskInfo("读取到标志位为" + flag + ",0.5秒后重复读取,直到标志位变化!"); SendFlag = flag; } Thread.Sleep(timeSleep);//根据间隔再取 标志位数据 } } Thread.Sleep(500); goto aa; bb : FormMain.GetOPCTaskInfo("因为错误,停止采集热点信息!"); }