private void btnMotionConcave_Click(object sender, EventArgs e)
        {
            int x_pos_abs = 0;
            int y_pos_abs = 0;
            int z_pos_abs = 0;

            for (int i = 1; i <= 24; i++)
            {
                Thread.Sleep(1000);
                string[] arr = SQLite.Instance().GetZCoorBending(i);

                x_pos_abs = Coordinates.Xcoordinate.Instance().x_coor[i - 1];
                y_pos_abs = Coordinates.Ycoordinate.Instance().y_coor[i - 1] - VarGlobal.OFFSET_CONCAVE;
                z_pos_abs = Calculate.Calculate_Coordinate_pulse(float.Parse(arr[1]), Calculate.STEP_Z);


                VarGlobal.Instance().Move_All_Axis_Abs_Pos(x_pos_abs, y_pos_abs);
                Thread.Sleep(1000);
                if (!VarGlobal.Instance().Move_Z_Axis_Abs_Pos(z_pos_abs))
                {
                    return;
                }
                Thread.Sleep(2000);
                if (!VarGlobal.Instance().Move_Z_Axis_Abs_Pos(VarGlobal.POSITION_INTERMEDIATE_Z_AXIS))
                {
                    return;
                }
            }
        }
        private void cbbPoint_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (!VarGlobal.Instance().Move_Z_Axis_Abs_Pos(VarGlobal.POSITION_INTERMEDIATE_Z_AXIS))
            {
                return;
            }
            Thread.Sleep(500);
            if (radConvex.Checked)
            {
                x_pos_abs = Coordinates.Xcoordinate.Instance().x_coor[cbbPoint.SelectedIndex];
                y_pos_abs = Coordinates.Ycoordinate.Instance().y_coor[cbbPoint.SelectedIndex] - VarGlobal.OFFSET_CONVEX;
            }
            if (radConcave.Checked)
            {
                x_pos_abs = Coordinates.Xcoordinate.Instance().x_coor[cbbPoint.SelectedIndex];
                y_pos_abs = Coordinates.Ycoordinate.Instance().y_coor[cbbPoint.SelectedIndex] - VarGlobal.OFFSET_CONCAVE;
            }
            VarGlobal.Instance().Move_All_Axis_Abs_Pos(x_pos_abs, y_pos_abs);

            if (!SQLite.Instance().CheckExistData("T24ZCoordinateBending", cbbPoint.SelectedIndex + 1))
            {
                return;
            }
            string[] arr = SQLite.Instance().GetZCoorBending(cbbPoint.SelectedIndex + 1);
            txtZCoorConvex.Text  = arr[0];
            txtZCoorConcave.Text = arr[1];
        }
        private void fmSettingCoorZ_Load(object sender, EventArgs e)
        {
            ChekedRad();

            for (int i = 1; i <= 24; i++)
            {
                cbbPoint.Items.Add("Point " + i);
            }
            if (SQLite.Instance().CheckExistData("T24ZCoordinateBending", cbbPoint.SelectedIndex + 1))
            {
                string[] arr = SQLite.Instance().GetZCoorBending(cbbPoint.SelectedIndex + 1);
                txtZCoorConvex.Text  = arr[0];
                txtZCoorConcave.Text = arr[1];
            }
            if (!VarGlobal.Instance().Move_Z_Axis_Abs_Pos(VarGlobal.POSITION_INTERMEDIATE_Z_AXIS))
            {
                return;
            }
            Thread.Sleep(500);
        }
Exemplo n.º 4
0
        private void GetTemplate_FormClosing(object sender, FormClosingEventArgs e)
        {
            try
            {
                checkdone.Stop();
                VarGlobal.Instance().All_Move_Stop();
                _thread.Abort();
                t.Stop();

                if (GetDoneTemp != null)
                {
                    foreach (KeyValuePair <int, float> value in dicHeightPoint)
                    {
                        GetDoneTemp(value.Key, value.Value);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        /// <summary>
        /// Run first
        /// </summary>
        private void Run_1()
        {
            if (VarGlobal.m_Connected == false)
            {
                MessageBox.Show("No Connection!", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            //Chạy trục Z đến vị trí đo
            z_pos_abs = Coordinates.Zcoordinate.Instance().z_coor[0];
            if (!VarGlobal.Instance().Move_Z_Axis_Abs_Pos(z_pos_abs))
            {
                return;
            }

            //Vẽ 1 hình chữ nhật tượng trưng
            gp = this.pnGraphics.CreateGraphics();
            gp.DrawRectangle(mPen, 65, 25, 230, 380);

            _CountFail = 0;

            for (int point = 1; point < 25; point++)
            {
                //Lấy tọa độ tuyệt đối lần lượt của 24 điểm
                x_pos_abs = Coordinates.Xcoordinate.Instance().x_coor[point - 1];
                y_pos_abs = Coordinates.Ycoordinate.Instance().y_coor[point - 1];

                //Chạy tới điểm tương ứng
                VarGlobal.Instance().Move_All_Axis_Abs_Pos(x_pos_abs, y_pos_abs);
                Thread.Sleep(500);

                Invoke(new MethodInvoker(delegate
                {
                    lblStatus.Text       = "Measuring";
                    lblStatus.ForeColor  = Color.LimeGreen;
                    lblProcess.ForeColor = Color.LimeGreen;
                    timeProcess.Start();
                }));

                float height = 0;
                if (VarGlobal.adam_Connected)
                {
                    if (VarGlobal.adamCom.AnalogInput(VarGlobal.Adam_iAddr).GetValue(5, out float value, out Adam4000_ChannelStatus status))
                    {
                        if (status == Adam4000_ChannelStatus.Normal)
                        {
                            height = value * (float)6.0714;

                            float deltaL = height - _arrMeasureValueTemplate[point - 1];

                            if (deltaL > 0.07)
                            {
                                lstPointFail.Add(point - 1);
                                _arrValueDeltaLFail[point - 1] = deltaL;
                                _CountFail++;
                                mBrush = new SolidBrush(Color.Red);

                                Invoke(new MethodInvoker(delegate
                                {
                                    ListViewItem lvi = new ListViewItem("Point " + point);
                                    lvi.SubItems.Add(height.ToString("0.0000"));
                                    lvi.SubItems.Add(deltaL.ToString("0.0000"));
                                    lvi.BackColor = Color.Red;
                                    lviPointMeasurement.Items.Add(lvi);
                                }));
                            }
                            if (deltaL < -0.07)
                            {
                                lstPointFail.Add(point - 1);
                                _arrValueDeltaLFail[point - 1] = deltaL;
                                _CountFail++;
                                mBrush = new SolidBrush(Color.Yellow);

                                Invoke(new MethodInvoker(delegate
                                {
                                    ListViewItem lvi = new ListViewItem("Point " + point);
                                    lvi.SubItems.Add(height.ToString("0.0000"));
                                    lvi.SubItems.Add(deltaL.ToString("0.0000"));
                                    lvi.BackColor = Color.Yellow;
                                    lviPointMeasurement.Items.Add(lvi);
                                }));
                            }
                            else if (deltaL < 0.07 && deltaL > -0.07)
                            {
                                mBrush = new SolidBrush(Color.LimeGreen);
                                Invoke(new MethodInvoker(delegate
                                {
                                    ListViewItem lvi = new ListViewItem("Point " + point);
                                    lvi.SubItems.Add(height.ToString("0.000"));
                                    lvi.SubItems.Add(deltaL.ToString("0.0000"));
                                    lvi.BackColor = Color.LimeGreen;
                                    lviPointMeasurement.Items.Add(lvi);
                                }));
                            }

                            float x_pos_mm = Calculate.Calculate_Coordinate_mm(x_pos_abs, Calculate.STEP_X);
                            float y_pos_mm = Calculate.Calculate_Coordinate_mm(y_pos_abs, Calculate.STEP_Y);
                            DrawPoint(x_pos_mm, y_pos_mm, point);
                        }
                        else
                        {
                            MessageBox.Show("Fail to get Value");
                        }
                    }
                    else
                    {
                        MessageBox.Show("Fail to get Value");
                    }
                }
                Thread.Sleep(1000);
            }
Exemplo n.º 6
0
        void GetTemp()
        {
            if (VarGlobal.m_Connected == false)
            {
                MessageBox.Show("No Connection!", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            VarGlobal.Instance().ResetAlarm();

            z_pos_abs = Coordinates.Zcoordinate.Instance().z_coor[0];
            if (!VarGlobal.Instance().Move_Z_Axis_Abs_Pos(z_pos_abs))
            {
                return;
            }

            gp = this.pnGraphics.CreateGraphics();
            gp.DrawRectangle(mPen, 60, 25, 230, 380);

            Invoke(new MethodInvoker(delegate
            {
                lblStatus.Text      = "Getting data";
                lblStatus.ForeColor = Color.Red;
                t.Start();
            }));

            for (int point = 1; point < 25; point++)
            {
                x_pos_abs = Coordinates.Xcoordinate.Instance().x_coor[point - 1];
                y_pos_abs = Coordinates.Ycoordinate.Instance().y_coor[point - 1];

                VarGlobal.Instance().Move_All_Axis_Abs_Pos(x_pos_abs, y_pos_abs);
                Thread.Sleep(500);

                float height = 0;
                if (VarGlobal.adam_Connected)
                {
                    if (VarGlobal.adamCom.AnalogInput(VarGlobal.Adam_iAddr).GetValue(5, out float value, out Adam4000_ChannelStatus status))
                    {
                        if (status == Adam4000_ChannelStatus.Normal)
                        {
                            height = value * (float)6.0714;

                            dicHeightPoint.Add(point, height);

                            ListViewItem lvi = new ListViewItem("Point " + point);
                            lvi.SubItems.Add(height.ToString("0.0000" + " mm"));
                            lviPointMeasurement.Invoke((Action)(() =>
                            {
                                lviPointMeasurement.BeginUpdate();
                                lviPointMeasurement.Items.Add(lvi);
                                lviPointMeasurement.EndUpdate();
                            }));
                            // Invoke(new MethodInvoker(delegate
                            //{
                            //    lviPointMeasurement.Items.Add(lvi);
                            //}));
                            float x_pos_mm = Calculate.Calculate_Coordinate_mm(x_pos_abs, Calculate.STEP_X);
                            float y_pos_mm = Calculate.Calculate_Coordinate_mm(y_pos_abs, Calculate.STEP_Y);
                            DrawPoint(x_pos_mm, y_pos_mm, point);
                        }
                    }
                }
                if (SQLite.Instance().GetMeasureValueTemplate("MeasureValueTemplate", "Value", 1) != null)
                {
                    SQLite.Instance().UpdateMeasureValueTemplate(point, height.ToString("0.0000"));
                }
                else
                {
                    SQLite.Instance().InsertData(point, "Point" + point, height.ToString("0.0000"));
                }

                Thread.Sleep(1000);
            }
            _checkDone = true;
            Invoke(new MethodInvoker(delegate
            {
                lblStatus.Text      = "Done!";
                lblProcess.Text     = "";
                lblStatus.ForeColor = Color.Green;
                t.Stop();
            }));

            _flag = true;
        }
 private void btnMoveConcave_Click(object sender, EventArgs e)
 {
     VarGlobal.Instance().Move_Z_Axis_Abs_Pos(Calculate.Calculate_Coordinate_pulse(
                                                  float.Parse(txtZCoorConcave.Text.Trim()), Calculate.STEP_Z));
 }