Browse Source

再次上传

wb_han 5 years ago
parent
commit
723faa7312

+ 14 - 13
HOZProject/FormHOZMain.Designer.cs

@@ -39,6 +39,7 @@
             this.listmsg = new System.Windows.Forms.ListBox();
             this.pbImage = new System.Windows.Forms.PictureBox();
             this.plSEM = new System.Windows.Forms.Panel();
+            this.lblStateMessage = new System.Windows.Forms.Label();
             this.lblFlowContent = new System.Windows.Forms.Label();
             this.plLeft = new System.Windows.Forms.Panel();
             this.label1 = new System.Windows.Forms.Label();
@@ -56,7 +57,6 @@
             this.pbSave = new System.Windows.Forms.PictureBox();
             this.pbOpen = new System.Windows.Forms.PictureBox();
             this.pbNew = new System.Windows.Forms.PictureBox();
-            this.lblStateMessage = new System.Windows.Forms.Label();
             this.plMain.SuspendLayout();
             this.plFill.SuspendLayout();
             this.groupBox1.SuspendLayout();
@@ -177,7 +177,7 @@
             this.listmsg.FormattingEnabled = true;
             this.listmsg.ItemHeight = 12;
             this.listmsg.Location = new System.Drawing.Point(417, 2);
-            this.listmsg.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
+            this.listmsg.Margin = new System.Windows.Forms.Padding(2);
             this.listmsg.Name = "listmsg";
             this.listmsg.Size = new System.Drawing.Size(477, 196);
             this.listmsg.TabIndex = 18;
@@ -204,6 +204,18 @@
             this.plSEM.Size = new System.Drawing.Size(894, 56);
             this.plSEM.TabIndex = 19;
             // 
+            // lblStateMessage
+            // 
+            this.lblStateMessage.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
+            this.lblStateMessage.AutoSize = true;
+            this.lblStateMessage.Font = new System.Drawing.Font("宋体", 10F);
+            this.lblStateMessage.ForeColor = System.Drawing.Color.White;
+            this.lblStateMessage.Location = new System.Drawing.Point(875, 21);
+            this.lblStateMessage.Name = "lblStateMessage";
+            this.lblStateMessage.RightToLeft = System.Windows.Forms.RightToLeft.Yes;
+            this.lblStateMessage.Size = new System.Drawing.Size(0, 14);
+            this.lblStateMessage.TabIndex = 1;
+            // 
             // lblFlowContent
             // 
             this.lblFlowContent.AutoSize = true;
@@ -428,17 +440,6 @@
             this.pbNew.Visible = false;
             this.pbNew.Click += new System.EventHandler(this.pbNew_Click);
             // 
-            // lblStateMessage
-            // 
-            this.lblStateMessage.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
-            this.lblStateMessage.AutoSize = true;
-            this.lblStateMessage.Font = new System.Drawing.Font("宋体", 10F);
-            this.lblStateMessage.ForeColor = System.Drawing.Color.White;
-            this.lblStateMessage.Location = new System.Drawing.Point(757, 21);
-            this.lblStateMessage.Name = "lblStateMessage";
-            this.lblStateMessage.Size = new System.Drawing.Size(0, 14);
-            this.lblStateMessage.TabIndex = 1;
-            // 
             // FormHOZMain
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);

+ 31 - 4
HOZProject/FormHOZMain.cs

@@ -181,7 +181,7 @@ namespace HOZProject
                 ucCutHole.UControl_ParaInfo.Position = ListCutHole[i].Position;
                 ucCutHole.UControl_ParaInfo.StartTime = ListCutHole[i].START.ToString();
                 ucCutHole.UControl_ParaInfo.EndTime = ListCutHole[i].END.ToString();
-                ucCutHole.UControl_ParaInfo.State = ListCutHole[i].STATE.ToString();
+                ucCutHole.UControl_ParaInfo.State = (int)ListCutHole[i].STATE;
                 ucCutHole.UControl_ParaInfo.IsSwitch = ListCutHole[i].SWITCH;
                 ucCutHole.UControl_ParaInfo.Dock = DockStyle.Fill;
                 ucCutHole.UControl_ParaInfo.ShowParaInfo();
@@ -281,6 +281,7 @@ namespace HOZProject
                         m_Ms.key_stop = true;
                         IsClose = true;
                         lblStateMessage.Text = "正在关闭窗体...请等待";
+                        pbClose.Enabled = false;
                     }
                     return;
                 }
@@ -340,7 +341,7 @@ namespace HOZProject
             else
             {
                 //保存测量文件
-                if (m_MeasureFile.Save())
+                if (m_MeasureFile.SaveAs())
                 {
                     //获取测量文件所在路径
                     string savePath = m_MeasureFile.FilePath;
@@ -364,7 +365,33 @@ namespace HOZProject
 
         private void pbOpen_Click(object sender, EventArgs e)
         {
-
+            try
+            {
+                //打开默认路径
+                OpenFileDialog openFileDialog = new OpenFileDialog();
+                //设置筛选文件格式
+                openFileDialog.Filter = "测量文件(*.msf)|*.msf";
+                if (openFileDialog.ShowDialog() == DialogResult.OK)
+                {
+                    //读取文件
+                    string measureFileNamePath = openFileDialog.FileName;
+                    m_MeasureFile.FileName = measureFileNamePath;
+                    m_MeasureFile.Open();
+                    List<CutHole> ListCutHole = m_MeasureFile.ListCutHole;
+                    //文件路径
+                    string CutHoleFilePath = m_MeasureFile.CutHoleFilePath;
+                    CreateCutHoleList(ListCutHole);
+                    //保存测量文件
+                    if (IsSave)
+                    {
+                        m_MeasureFile.Save();
+                    }
+                }
+            }
+            catch (Exception ex)
+            {
+                LogManager.LogError(ex.Message);
+            }
         }
 
         private void pbInit_Click(object sender, EventArgs e)
@@ -527,7 +554,7 @@ namespace HOZProject
         #endregion
 
         #region 修改切孔状态
-        protected void ChangeCutHoleMeasureState(string CutHoleName, int States)
+        public void ChangeCutHoleMeasureState(string CutHoleName, int States)
         {
             if (plPrarInfo.Controls.Count > 0)
             {

+ 3 - 2
HOZProject/FormUnitControl.cs

@@ -1618,7 +1618,7 @@ namespace HOZProject
         /// <param name="rag">行、列数</param>
         /// <param name="ptsx">计算生成所有X轴坐标</param>
         /// <param name="ptsy">计算生成所有Y轴坐标</param>
-        public List<PointF> AnalysisPosition(float centerX, float centerY, float firstX, float firstY,float distance,int rag)
+        public List<PointF> AnalysisPosition(float centerX, float centerY, float firstX, float firstY, float distance, int rag)
         {
             //求样品1的水平角度
             double angle = 0;
@@ -1660,7 +1660,7 @@ namespace HOZProject
                 }
             }
             List<PointF> pts = new List<PointF>();
-            for (int i=0;i<ptsx.Count;i++)
+            for (int i = 0; i < ptsx.Count; i++)
             {
                 //增加的点
                 PointF pf = new PointF();
@@ -1672,6 +1672,7 @@ namespace HOZProject
         }
 
 
+
         private void btn30_Click(object sender, EventArgs e)
         {
             txtsample1x.Text = "21.7";

+ 112 - 54
HOZProject/UserControls/UControl_Init.cs

@@ -58,32 +58,39 @@ namespace HOZProject
         #region 加载切孔文件,生成切孔列表
         private void pbCutHoleFile_Click(object sender, EventArgs e)
         {
-            if (FormHOZMainObject.m_MeasureFile == null)
-            {
-                MessageBox.Show("请新建一个测量文件!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
-            }
-            else
+            try
             {
-                if (!FormHOZMainObject.m_MeasureFile.GetCutHolesFromFile(""))
+                if (FormHOZMainObject.m_MeasureFile == null)
                 {
-                    MessageBox.Show("导入切孔失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
+                    MessageBox.Show("请新建一个测量文件!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 }
                 else
                 {
-                    List<CutHole> ListCutHole = FormHOZMainObject.m_MeasureFile.ListCutHole;
-                    //文件路径
-                    string CutHoleFilePath = FormHOZMainObject.m_MeasureFile.CutHoleFilePath;
-                    FormHOZMainObject.CreateCutHoleList(ListCutHole);
-                    //显示导入的切孔数量
-                    lblCutHoleCount.Text = string.Format("成功导入{0}个切孔", ListCutHole.Count);
-                    tbCutHoleFilePath.Text = CutHoleFilePath;
-                    //保存测量文件
-                    if (FormHOZMainObject.IsSave)
+                    if (!FormHOZMainObject.m_MeasureFile.GetCutHolesFromFile(""))
                     {
-                        FormHOZMainObject.m_MeasureFile.Save();
+                        MessageBox.Show("导入切孔失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
+                    }
+                    else
+                    {
+                        List<CutHole> ListCutHole = FormHOZMainObject.m_MeasureFile.ListCutHole;
+                        //文件路径
+                        string CutHoleFilePath = FormHOZMainObject.m_MeasureFile.CutHoleFilePath;
+                        FormHOZMainObject.CreateCutHoleList(ListCutHole);
+                        //显示导入的切孔数量
+                        lblCutHoleCount.Text = string.Format("成功导入{0}个切孔", ListCutHole.Count);
+                        tbCutHoleFilePath.Text = CutHoleFilePath;
+                        //保存测量文件
+                        if (FormHOZMainObject.IsSave)
+                        {
+                            FormHOZMainObject.m_MeasureFile.Save();
+                        }
                     }
                 }
             }
+            catch (Exception ex)
+            {
+                LogManager.LogError(ex.Message);
+            }
         }
         #endregion
 
@@ -95,55 +102,96 @@ namespace HOZProject
         /// <param name="e"></param>
         private void pbCutHoleAuto_Click(object sender, EventArgs e)
         {
-            if (FormHOZMainObject.m_MeasureFile == null)
-            {
-                MessageBox.Show("请新建一个测量文件!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
-            }
-            else
+            try
             {
-                if (!FormHOZMainObject.m_MeasureFile.GetCutHolesFromFile(""))
+                if (FormHOZMainObject.m_MeasureFile == null)
                 {
-                    MessageBox.Show("导入切孔失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
+                    MessageBox.Show("请新建一个测量文件!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 }
                 else
                 {
-                    List<CutHole> ListCutHole = FormHOZMainObject.m_MeasureFile.ListCutHole;
-                    //根据切孔文件的一个切孔,自动计算其他切孔位置
-
-                    //文件路径
-                    string CutHoleFilePath = FormHOZMainObject.m_MeasureFile.CutHoleFilePath;
-                    FormHOZMainObject.CreateCutHoleList(ListCutHole);
-                    //显示导入的切孔数量
-                    lblCutHoleCount.Text = string.Format("成功导入{0}个切孔", ListCutHole.Count);
-                    tbCutHoleFilePath.Text = CutHoleFilePath;
-                    //保存测量文件
-                    if (FormHOZMainObject.IsSave)
+                    if (!FormHOZMainObject.m_MeasureFile.GetCutHolesFromFile(""))
                     {
-                        FormHOZMainObject.m_MeasureFile.Save();
+                        MessageBox.Show("导入切孔失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
+                    }
+                    else
+                    {
+                        List<CutHole> ListCutHole = FormHOZMainObject.m_MeasureFile.ListCutHole;
+                        if (ListCutHole != null)
+                        {
+                            if (ListCutHole.Count > 0)
+                            {
+                                //根据切孔文件的一个切孔,自动计算其他切孔位置
+                                float centerX = 65;
+                                float centerY = 65;
+                                float firstX = ListCutHole[0].Position.X;
+                                float firstY = ListCutHole[0].Position.Y;
+                                //距离
+                                float distance = 30;
+                                //矩阵 4*4
+                                int rag = 4;
+                                List<PointF> cutHolePoint = new List<PointF>();
+                                //根据一个切孔点计算其他切孔信息
+                                cutHolePoint = AnalysisPosition(centerX, centerY, firstX, firstY, distance, rag);
+                                if (!FormHOZMainObject.m_MeasureFile.GetCutHolesFromAnalysisPosition(cutHolePoint))
+                                {
+                                    MessageBox.Show("生成切孔失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
+                                }
+                                else
+                                {
+                                    //文件路径
+                                    string CutHoleFilePath = FormHOZMainObject.m_MeasureFile.CutHoleFilePath;
+                                    //重新获取切孔列表信息
+                                    ListCutHole = FormHOZMainObject.m_MeasureFile.ListCutHole;
+                                    //创建切孔列表信息
+                                    FormHOZMainObject.CreateCutHoleList(ListCutHole);
+                                    //显示导入的切孔数量
+                                    lblCutHoleCount.Text = string.Format("成功生成{0}个切孔", ListCutHole.Count);
+                                    tbCutHoleFilePath.Text = CutHoleFilePath;
+                                }
+                            }
+                        }
+                        //保存测量文件
+                        if (FormHOZMainObject.IsSave)
+                        {
+                            FormHOZMainObject.m_MeasureFile.Save();
+                        }
                     }
                 }
             }
+            catch (Exception ex)
+            {
+                LogManager.LogError(ex.Message);
+            }
+        }
+
+        /// <summary>
+        /// 将分析点坐标,添加到切孔列表中
+        /// </summary>
+        public void AddCutHole()
+        {
+
         }
 
         /// <summary>
-        /// 根据一个切孔点计算其他切孔信息
+        /// 分析点坐标
         /// </summary>
-        /// <param name="centerX"></param>
-        /// <param name="centerY"></param>
-        /// <param name="firstX"></param>
-        /// <param name="firstY"></param>
-        /// <param name="distance"></param>
-        /// <param name="rag"></param>
-        /// <param name="ptsx"></param>
-        /// <param name="ptsy"></param>
-        public void AnalysisPosition(Double centerX, Double centerY, Double firstX, Double firstY, Double distance, int rag, ref List<Double> ptsx, ref List<Double> ptsy)
+        /// <param name="centerX">中心点X轴坐标</param>
+        /// <param name="centerY">中心点Y轴坐标</param>
+        /// <param name="firstX">第一个点X轴坐标</param>
+        /// <param name="firstY">第一个点Y轴坐标</param>
+        /// <param name="distance">点与点的距离</param>
+        /// <param name="rag">行、列数</param>
+        /// <param name="ptsx">计算生成所有X轴坐标</param>
+        /// <param name="ptsy">计算生成所有Y轴坐标</param>
+        public List<PointF> AnalysisPosition(float centerX, float centerY, float firstX, float firstY, float distance, int rag)
         {
             //求样品1的水平角度
             double angle = 0;
 
             //清空所有点信息
-            ptsx.Clear();
-            ptsy.Clear();
+            List<float> ptsx = new List<float>();
+            List<float> ptsy = new List<float>();
             //将第一个点加入到点信息中
             ptsx.Add(firstX);
             ptsy.Add(firstY);
@@ -156,27 +204,37 @@ namespace HOZProject
             angle = 45 - angle;
             angle = angle * Math.PI / 180;
 
-            double tx = 0;
-            double ty = 0;
+            float tx = 0;
+            float ty = 0;
             for (int j = 0; j < rag; j++)
             {
                 //计算每行第一个点的坐标
                 if (j > 0)
                 {
-                    tx = distance * j * Math.Sin(angle);
-                    ty = distance * j * Math.Cos(angle);
+                    tx = (float)(distance * j * Math.Sin(angle));
+                    ty = (float)(distance * j * Math.Cos(angle));
                     ptsx.Add(tx + ptsx[0]);
                     ptsy.Add(ptsy[0] - ty);
                 }
                 //计算每行其他点的坐标
                 for (int i = 1; i < rag; i++)
                 {
-                    tx = distance * i * Math.Cos(angle);
-                    ty = distance * i * Math.Sin(angle);
+                    tx = (float)(distance * i * Math.Cos(angle));
+                    ty = (float)(distance * i * Math.Sin(angle));
                     ptsx.Add(tx + ptsx[j * rag]);
                     ptsy.Add(ty + ptsy[j * rag]);
                 }
             }
+            List<PointF> pts = new List<PointF>();
+            for (int i = 0; i < ptsx.Count; i++)
+            {
+                //增加的点
+                PointF pf = new PointF();
+                pf.X = ptsx[i];
+                pf.Y = ptsy[i];
+                pts.Add(pf);
+            }
+            return pts;
         }
         #endregion
 

+ 30 - 3
HOZProject/UserControls/UControl_ParaInfo.cs

@@ -27,7 +27,7 @@ namespace HOZProject
         /// <summary>
         /// 状态
         /// </summary>
-        private string state;
+        private int state;
         /// <summary>
         /// 位置
         /// </summary>
@@ -40,7 +40,7 @@ namespace HOZProject
         public FormHOZMain FormHOZMainObject { get => formHOZMain; set => formHOZMain = value; }
         public string StartTime { get => startTime; set => startTime = value; }
         public string EndTime { get => endTime; set => endTime = value; }
-        public string State { get => state; set => state = value; }
+        public int State { get => state; set => state = value; }
         public SemPosition Position { get => position; set => position = value; }
         public string CutHoleName { get => cutHoleName; set => cutHoleName = value; }
         public bool IsSwitch { get => isSwitch; set => isSwitch = value; }
@@ -154,7 +154,34 @@ namespace HOZProject
             lblM.Text = Position.M.ToString();
             lblShowStartTime.Text = StartTime;
             lblShowEndTime.Text = EndTime;
-            lblShowState.Text = State;
+            //设置切孔状态
+            switch (State)
+            {
+                //准备
+                case (int)MeasureThread.ThreadState.Ready:
+                    //修改切孔状态
+                    lblShowState.Text = "准备";
+                    break;
+                //等待
+                case (int)MeasureThread.ThreadState.Waiting:
+                    //修改切孔状态
+                    lblShowState.Text = "等待";
+                    break;
+                //进行中
+                case (int)MeasureThread.ThreadState.InProcess:
+                    //修改切孔状态
+                    lblShowState.Text = "进行中";
+                    break;
+                //完成
+                case (int)MeasureThread.ThreadState.Success:
+                    //修改切孔状态
+                    lblShowState.Text = "完成";
+                    break;
+                //失败
+                case (int)MeasureThread.ThreadState.Failed:
+                    lblShowState.Text = "失败";
+                    break;
+            }
             lblCutHoleName.Text = CutHoleName;
             CkIsSwitch.Checked = IsSwitch;
         }