Esempio n. 1
0
        /// <summary>
        /// Устанавливает положение манипулятора в исходное состояние
        /// </summary>
        public void Home()
        {
            try
            {
                if (checkAlgoritm.Checked)
                {
                    if ((string)comboHomeMode.SelectedItem == "work")
                    {
                        Point homePoint = new Point(0, 0, 8, 0, 245, 0);

                        Point.tempPoint = homePoint;
                        serialPort.Write(homePoint);
                        trackBarSet(homePoint);
                    }
                    else if ((string)comboHomeMode.SelectedItem == "steady")
                    {
                        Point homePoint = new Point(0, 45, 87, 0, 240, 0);
                        Point.tempPoint = homePoint;
                        serialPort.Write(homePoint);
                        trackBarSet(homePoint);
                    }
                }
                else
                {
                    if ((string)comboHomeMode.SelectedItem == "work")
                    {
                        //Dec homeDec = new Dec(0, 85, 135, 120, 0);
                        //trackBarSet(homeDec);
                        //trackBar_A_Scroll(new object(), new EventArgs());
                        Point homePoint = new Point(0, 53, 95, 0, 245, 0);
                        Dec   homeDec   = DecPointTransform.PointToDec(homePoint);
                        trackBarSet(homeDec);
                        trackBar_D_Scroll(new object(), new EventArgs());
                    }
                    else if ((string)comboHomeMode.SelectedItem == "steady")
                    {
                        Point homePoint = new Point(0, 150, 54, 120, 0, 155);
                        Dec   homeDec   = DecPointTransform.PointToDec(homePoint);
                        trackBarSet(homeDec);
                        trackBar_D_Scroll(new object(), new EventArgs());
                    }
                }
            }
            catch (Exception ce)
            {
                MessageBox.Show(ce.ToString(),
                                "Ошибка!",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }
        }
        private void checkAlgoritm_CheckedChanged(object sender, EventArgs e)
        {
            if (checkAlgoritm.Checked)
            {
                valueCoordX.Enabled = false;
                valueCoordY.Enabled = false;
                valueCoordZ.Enabled = false;
                valueCoordA.Enabled = false;
                valueCoordB.Enabled = false;

                label1.Text = "канал А";
                label2.Text = "канал B";
                label3.Text = "канал C";
                label4.Text = "канал D";
                label5.Text = "канал E";

                Dec   dec   = getDec();
                Point point = DecPointTransform.DecToPoint(dec, trackBar_F.Value, 0);

                trackBar_A.Maximum = 90;
                trackBar_A.Minimum = -90;
                trackBar_B.Maximum = 180;
                trackBar_B.Minimum = 0;
                trackBar_C.Maximum = 220;
                trackBar_C.Minimum = 40;
                trackBar_D.Maximum = 280;
                trackBar_D.Minimum = 100;
                trackBar_E.Maximum = 90;
                trackBar_E.Minimum = -90;

                trackBar_A.Value = (int)point.CanA;
                trackBar_B.Value = (int)point.CanB;
                trackBar_C.Value = (int)point.CanC;
                trackBar_D.Value = (int)point.CanD;
                trackBar_E.Value = (int)point.CanE;
            }
            else
            {
                valueCoordX.Enabled = true;
                valueCoordY.Enabled = true;
                valueCoordZ.Enabled = true;
                valueCoordA.Enabled = true;
                valueCoordB.Enabled = true;

                label1.Text = "Ось X";
                label2.Text = "Ось Y";
                label3.Text = "Ось Z";
                label4.Text = "Наклон";
                label5.Text = "Горизонт";

                Point point = getPoint();
                Dec   dec   = DecPointTransform.PointToDec(point);

                trackBar_A.Maximum = DecPointTransform.Lmax;
                trackBar_A.Minimum = -DecPointTransform.Lmax;
                trackBar_B.Maximum = DecPointTransform.Lmax;
                trackBar_B.Minimum = 0;
                trackBar_C.Maximum = DecPointTransform.Lmax;
                trackBar_C.Minimum = -100;
                trackBar_D.Maximum = 180;
                trackBar_D.Minimum = 0;
                trackBar_E.Maximum = 90;
                trackBar_E.Minimum = -90;

                trackBar_A.Value = (int)dec.decX;
                trackBar_B.Value = (int)dec.decY;
                trackBar_C.Value = (int)dec.decZ;
                trackBar_D.Value = (int)dec.decB;
                trackBar_E.Value = (int)dec.decA;

                valueCoordX.Text = trackBar_A.Value.ToString();
                valueCoordY.Text = trackBar_B.Value.ToString();
                valueCoordZ.Text = trackBar_C.Value.ToString();
                valueCoordA.Text = trackBar_E.Value.ToString();
                valueCoordB.Text = trackBar_D.Value.ToString();
            }
        }