void UpdateLog() { if (LockReportUpdate) { return; } ReportTextBox.Text = _barbaComm.ReadLog(); ReportTextBox.ScrollToEnd(); }
void UpdateLog() { if (LockReportUpdate || WindowState == WindowState.Minimized || !IsVisible) { return; } ReportTextBox.Text = _barbaComm.ReadLog(); ReportTextBox.Select(ReportTextBox.Text.Length, 0); ReportTextBox.ScrollToEnd(); }
//-------------------------------------------------------------- //-------------------------------------------------------------- void SaveReport() { if (ReportTextBox.Text == "") { MessageBox.Show("There is no report to save."); } else { if (saveFileDialog1.ShowDialog() == DialogResult.OK) { ReportTextBox.SaveFile(saveFileDialog1.FileName); } } }
/// <summary> /// 生成结果报告 /// </summary> private void OutMaReport() { ReportTextBox.AppendText("-------------------- 陀螺经纬仪定向精度评定--------------------" + Environment.NewLine); ReportTextBox.AppendText("序号| 地理方位角 | 陀螺方位角 | 仪器常数 | 差值" + Environment.NewLine); for (int i = 0; i < groundData.Count; i++) { ReportTextBox.AppendText(String.Format("{0,-3} | {1,-14} |{2,-14} | {3,-9} |{4,-8}", DataTableGridView.Rows[i].Cells[0].Value.ToString(), DataTableGridView.Rows[i].Cells[1].Value.ToString(), DataTableGridView.Rows[i].Cells[2].Value.ToString(), DataTableGridView.Rows[i].Cells[3].Value.ToString(), DataTableGridView.Rows[i].Cells[4].Value.ToString())); ReportTextBox.AppendText(Environment.NewLine); } ReportTextBox.AppendText(Environment.NewLine + "仪器常数一次测定中误差为" + String.Format("{0:N4}", mv) + Environment.NewLine); ReportTextBox.AppendText(Environment.NewLine + "各个陀螺边的误差为:" + Environment.NewLine); for (int i = 0; i < gyroEdge.Count; i++) { int index = i + 1; ReportTextBox.AppendText("陀螺边" + index + ": " + String.Format("{0:N2}", gyroEdge[i].Ma) + "″" + Environment.NewLine); } }
void MainWindow_Loaded(object sender, RoutedEventArgs e) { UpdateStatus(); ReportTextBox.ScrollToEnd(); }
/// <summary> /// 贯通误差预计 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void EstiThroughErrToolStripMenuItem_Click(object sender, EventArgs e) { if (!isCalma) { MessageBox.Show("未计算井下方位角", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); return; } if (isEstiThroErr) { return; } ReportTextBox.AppendText(Environment.NewLine + "--------------------贯通误差预计--------------------" + Environment.NewLine); ReportTextBox.AppendText(Environment.NewLine + "1、各段重心坐标为:" + Environment.NewLine); // 求符合导线的重心 for (int i = 0; i < connectTraverse.Count; i++) { connectTraverse[i].Xcoor = traverseEdge[connectTraverse[i].StartPoint.Pointindex].StartPoint.XCoor; connectTraverse[i].Ycoor = traverseEdge[connectTraverse[i].StartPoint.Pointindex].StartPoint.YCoor; for (int j = 0; j < connectTraverse[i].SurveyNum; j++) { connectTraverse[i].Xcoor += traverseEdge[connectTraverse[i].StartPoint.Pointindex + j].EndPoint.XCoor; connectTraverse[i].Ycoor += traverseEdge[connectTraverse[i].StartPoint.Pointindex + j].EndPoint.YCoor; } connectTraverse[i].Xcoor = connectTraverse[i].Xcoor / (connectTraverse[i].SurveyNum + 1); connectTraverse[i].Ycoor = connectTraverse[i].Ycoor / (connectTraverse[i].SurveyNum + 1); ReportTextBox.AppendText("方向附合导线" + (i + 1) + "的重心在y'轴坐标: " + String.Format("{0:N4}", connectTraverse[i].Ycoor) + "m" + Environment.NewLine); } /** * 计算导线量边误差 */ ReportTextBox.AppendText(Environment.NewLine + "2、由测角量边引起的终点K的贯通误差为:" + Environment.NewLine); double mxKl = 0.0; for (int i = 0; i < traverseEdge.Count; i++) { mxKl += Math.Pow(ml * Math.Cos(traverseEdge[i].GetAzi()), 2) / 2; } ReportTextBox.AppendText("MxKl=" + Math.Round(Math.Sqrt(mxKl), 3) + "m" + Environment.NewLine); /** * 计算导线测角误差 */ double mxKb = 0.0; //初始化导线测角误差 ReportTextBox.AppendText(Environment.NewLine + "3、由导线测角误差引起的K点贯通误差为" + Environment.NewLine); // 符合导线各点到重心在y轴的投影 ReportTextBox.AppendText("方向符合导线边:" + Environment.NewLine); ReportTextBox.AppendText("点号| η | η2" + Environment.NewLine); for (int i = 0; i < connectTraverse.Count; i++) { int Pointindex = connectTraverse[i].StartPoint.Pointindex; double Ry = traverseEdge[Pointindex].StartPoint.YCoor - connectTraverse[i].Ycoor; double PowerRy = Math.Pow(Ry, 2); mxKb += PowerRy; ReportTextBox.AppendText(String.Format("{0,3} | {1,14} |{2,14} ", traverseEdge[Pointindex].StartPoint.PointName, Math.Round(Ry, 3), Math.Round(PowerRy, 3))); ReportTextBox.AppendText(Environment.NewLine); for (int j = 0; j < connectTraverse[i].SurveyNum; j++) { Pointindex = connectTraverse[i].StartPoint.Pointindex + j; Ry = traverseEdge[Pointindex].EndPoint.YCoor - connectTraverse[i].Ycoor; PowerRy = Math.Pow(Ry, 2); mxKb += PowerRy; ReportTextBox.AppendText(String.Format("{0,3} | {1,14} |{2,14} ", traverseEdge[Pointindex].EndPoint.PointName, Math.Round(Ry, 3), Math.Round(PowerRy, 3))); ReportTextBox.AppendText(Environment.NewLine); } ReportTextBox.AppendText("---------------------------------" + Environment.NewLine); } // 支导线各点到k点的连线在y轴上的投影 ReportTextBox.AppendText(Environment.NewLine); ReportTextBox.AppendText("支导线边:" + Environment.NewLine); ReportTextBox.AppendText("点号| η | η2" + Environment.NewLine); for (int i = 0; i < openTraverse.Count; i++) { int Pointindex = openTraverse[i].StartPoint.Pointindex; double Ry = traverseEdge[Pointindex].StartPoint.YCoor - traverseEdge[0].StartPoint.YCoor; double PowerRy = Math.Pow(Ry, 2); mxKb += PowerRy; ReportTextBox.AppendText(String.Format("{0,3} | {1,14} |{2,14} ", traverseEdge[Pointindex].StartPoint.PointName, Math.Round(Ry, 3), Math.Round(PowerRy, 3))); ReportTextBox.AppendText(Environment.NewLine); for (int j = 0; j < openTraverse[i].SurveyNum; j++) { Pointindex = openTraverse[i].StartPoint.Pointindex + j; Ry = traverseEdge[Pointindex].EndPoint.YCoor - traverseEdge[0].StartPoint.YCoor; PowerRy = Math.Pow(Ry, 2); mxKb += PowerRy; ReportTextBox.AppendText(String.Format("{0,3} | {1,14} |{2,14} ", traverseEdge[Pointindex].EndPoint.PointName, Math.Round(Ry, 3), Math.Round(PowerRy, 3))); ReportTextBox.AppendText(Environment.NewLine); } } //由导线测角误差引起的K点贯通误差为 mxKb *= mb * mb / 2; ReportTextBox.AppendText(Environment.NewLine); ReportTextBox.AppendText("MxKb=" + Math.Round(Math.Sqrt(mxKb), 3) + "m" + Environment.NewLine); /** * 计算由陀螺定向边的定向误差 */ ReportTextBox.AppendText(Environment.NewLine + "4、由陀螺定向边的定向误差引起的K点贯通误差为" + Environment.NewLine); double mxKo = 0.0; //初始化陀螺定向边引起贯通误差 mxKo += Math.Pow(traverseEdge[0].StartPoint.YCoor - connectTraverse[0].Ycoor, 2) * gyroEdge[0].Ma * gyroEdge[0].Ma / (206264.808 * 206264.808); for (int i = 0; i < connectTraverse.Count - 1; i++) { mxKo += Math.Pow(connectTraverse[i].Ycoor - connectTraverse[i + 1].Ycoor, 2) * gyroEdge[i + 1].Ma * gyroEdge[i + 1].Ma / (206264.808 * 206264.808); } mxKo += Math.Pow(traverseEdge[0].StartPoint.YCoor - connectTraverse[connectTraverse.Count - 1].Ycoor, 2) * gyroEdge[gyroEdge.Count - 1].Ma * gyroEdge[gyroEdge.Count - 1].Ma / (206264.808 * 206264.808); ReportTextBox.AppendText("MxKo=" + Math.Round(Math.Sqrt(mxKo), 3) + Environment.NewLine); ReportTextBox.AppendText(Environment.NewLine + "5、最终K点在水平重要方向x上的贯通估计误差估算公式为" + Environment.NewLine); Mx = Math.Sqrt(mxKl + mxKb + mxKo); // 最终误差 ReportTextBox.AppendText("MxK=" + Math.Round(Mx, 3) + "m" + Environment.NewLine); ReportTextBox.AppendText(Environment.NewLine + "6、贯通相遇点K在水平重要方向x上的预计误差为" + Environment.NewLine); Mx = 2 * Mx; ReportTextBox.AppendText("MxK预=" + Math.Round(Mx, 3) + "m" + Environment.NewLine); isEstiThroErr = true; MessageBox.Show("导线中加测陀螺定向边后导线误差终点误差估算完成,结果报告已生成", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1); }
private void InitState() { //isCalGtroAzi = false; isCalma = false; isEstiThroErr = false; DataTableGridView.Rows.Clear(); ReportTextBox.Clear(); /** * 初始化数据 */ //初始化陀螺边 int gyroEdgeNum = 0; for (int i = 0; i < traverseEdge.Count; i++) { if (traverseEdge[i].IsGyroDirEdge) { gyroEdge.Add(traverseEdge[i]); gyroEdgeNum += 1; } } //初始化符合导线和支导线 TraverseEdge tempTraverse = new TraverseEdge(); //符合导线 bool isstartEdge = false; //第一个边是否是陀螺边 bool isendEdge = false; if (traverseEdge[0].IsGyroDirEdge) { isstartEdge = true; tempTraverse.StartPoint = traverseEdge[0].EndPoint; tempTraverse.SurveyNum = 1; } else { isstartEdge = false; tempTraverse.StartPoint = traverseEdge[0].StartPoint; } for (int i = 0; i < traverseEdge.Count - 1; i++) { tempTraverse.SurveyNum += 1; //判断结束边是否是陀螺边 if (traverseEdge[i].IsGyroDirEdge) { isendEdge = true; if (isstartEdge && isendEdge) { tempTraverse.EndPoint = traverseEdge[i].StartPoint; tempTraverse.SurveyNum -= 1; connectTraverse.Add(tempTraverse); isstartEdge = true; tempTraverse = new TraverseEdge(); tempTraverse.StartPoint = traverseEdge[i].EndPoint; } else { tempTraverse.EndPoint = traverseEdge[i].StartPoint; tempTraverse.SurveyNum -= 1; openTraverse.Add(tempTraverse); isstartEdge = true; tempTraverse = new TraverseEdge(); tempTraverse.StartPoint = traverseEdge[i].EndPoint; } } } if (traverseEdge[traverseEdge.Count - 1].IsGyroDirEdge) { isendEdge = true; if (isstartEdge && isendEdge) { tempTraverse.EndPoint = traverseEdge[traverseEdge.Count - 1].StartPoint; connectTraverse.Add(tempTraverse); } else { tempTraverse.EndPoint = traverseEdge[traverseEdge.Count - 1].EndPoint; openTraverse.Add(tempTraverse); } } else { tempTraverse.SurveyNum += 1; tempTraverse.EndPoint = traverseEdge[traverseEdge.Count - 1].EndPoint; openTraverse.Add(tempTraverse); } }