Exemplo n.º 1
0
    static void Main()
    {
        Console.WriteLine(10 < 20);
        Console.WriteLine(10.CompareTo(20));  // if 10 > 20 : -1, same : 0, 10 < 20 : 1

        string s1 = "AA", s2 = "BB";

        //        Console.WriteLine(s1 < s2); error, relational operator only used for numeric associate type
        Console.WriteLine(s1.CompareTo(s2)); // almost type, enable to compare

        Point p1 = new Point(1, 1);
        Point p2 = new Point(2, 2);

        Console.WriteLine(p1.CompareTo2(p2));


        // apply c# interface 2.0
        cPoint p3 = new cPoint(1, 1);
        cPoint p4 = new cPoint(2, 2);

        Console.WriteLine(p3.CompareTo(p4));
        object o2 = new cPoint(2, 2);

        Console.WriteLine(p3.CompareTo(o2));
    }
Exemplo n.º 2
0
        public void SetGlobalPoint(int index, cPoint p)
        {
            if (!m_IsConnected)
            {
                return;
            }

            m_Robot.SetGlobalPoint(index, p);
        }
Exemplo n.º 3
0
        public void EndContinuousMovP(cPoint p)
        {
            if (!m_IsConnected)
            {
                return;
            }

            m_Robot.EndContinuousMovP(p);
        }
Exemplo n.º 4
0
        public void MovP(cPoint p)
        {
            if (!m_IsConnected)
            {
                return;
            }

            m_Robot.MovP(p);
        }
Exemplo n.º 5
0
 //定时读取机械臂的信息
 private void timer_Robot_Tick(object sender, EventArgs e)
 {
     if (m_RobotDevice != null)
     {
         cPoint pos = m_RobotDevice.GetPos();
         textBox_CurX.Text  = (pos[eAxisName.X] / 1000).ToString("0.000");
         textBox_CurY.Text  = (pos[eAxisName.Y] / 1000).ToString("0.000");
         textBox_CurZ.Text  = (pos[eAxisName.Z] / 1000).ToString("0.000");
         textBox_CurRZ.Text = (pos[eAxisName.RZ] / 1000).ToString("0.000");
     }
 }
Exemplo n.º 6
0
 private void CBtnRobotTestMoveToPoint_MouseDown(object sender, MouseEventArgs e)
 {
     if (m_ManualRobot.IsConnected())
     {
         cPoint point = new cPoint();
         point = m_ManualRobot.GetGlobalPoint(m_ManualRobotGlobalPointIndex);
         if (point != null)
         {
             m_ManualRobot.GotoMovP(point);
         }
     }
 }
Exemplo n.º 7
0
        public void SetGrapPointCoords(int PointIndex, float x, float y, float z, float rz)
        {
            if (m_UniqueRobot != null)
            {
                cPoint TempPoint = m_UniqueRobot.GetGlobalPoint(PointIndex);
                if (TempPoint != null)
                {
                    TempPoint[eAxisName.X]  = x * 1000;
                    TempPoint[eAxisName.Y]  = y * 1000;
                    TempPoint[eAxisName.Z]  = z * 1000;
                    TempPoint[eAxisName.RZ] = rz * 1000;

                    m_UniqueRobot.SetGlobalPoint(PointIndex, TempPoint);
                }
            }
        }
Exemplo n.º 8
0
        private void button_RobotRun_Click(object sender, EventArgs e)
        {
            if (m_RobotDevice.HasAlarm())
            {
                m_RobotDevice.ResetAlarm();
                MessageBox.Show("HasAlarm And ResetAlarm");
                return;
            }

            m_RobotDevice.RunSelectProgram(3);

            if (m_MovePoint == null)
            {
                m_MovePoint = m_RobotDevice.GetGlobalPoint(300);
            }
        }
Exemplo n.º 9
0
        /*加载并显示当前行的全局点位*/
        private void GetRobotGlobalPoint(RobotBase robot, DataGridView dgv, int index)
        {
            cPoint pointData = robot.GetGlobalPoint(index);

            try
            {
                dgv[0, index].Value = pointData.Name;
                dgv[1, index].Value = pointData[eAxisName.X] / 1000;
                dgv[2, index].Value = pointData[eAxisName.Y] / 1000;
                dgv[3, index].Value = pointData[eAxisName.Z] / 1000;
                dgv[4, index].Value = pointData[eAxisName.RZ] / 1000;
                dgv[5, index].Value = pointData.Info.Hand;
                dgv[6, index].Value = pointData.Info.UserFrame;
                dgv[7, index].Value = pointData.Info.ToolFrame;
                dgv.Rows[index].HeaderCell.Value = String.Format("{0}", index + 1);
            }
            catch { };
        }
Exemplo n.º 10
0
        public void SetPoints(int PointIndex, PointMeas GarptPoint, PointMeas PutPoint)
        {
            if (m_MovePoint == null)
            {
                m_MovePoint = m_RobotDevice.GetGlobalPoint(300); //300是原点
            }
            const int Z_distance = 50;

            if (m_MovePoint != null)
            {
                m_MovePoint[eAxisName.X]  = GarptPoint.X * 1000;
                m_MovePoint[eAxisName.Y]  = GarptPoint.Y * 1000;
                m_MovePoint[eAxisName.Z]  = (GarptPoint.Z + Z_distance) * 1000;
                m_MovePoint[eAxisName.RZ] = GarptPoint.RZ * 1000;

                m_RobotDevice.SetGlobalPoint(PointIndex, m_MovePoint);

                m_MovePoint[eAxisName.X]  = GarptPoint.X * 1000;
                m_MovePoint[eAxisName.Y]  = GarptPoint.Y * 1000;
                m_MovePoint[eAxisName.Z]  = (GarptPoint.Z) * 1000;
                m_MovePoint[eAxisName.RZ] = GarptPoint.RZ * 1000;
                m_RobotDevice.SetGlobalPoint(PointIndex + 1, m_MovePoint);

                m_MovePoint[eAxisName.X]  = PutPoint.X * 1000;
                m_MovePoint[eAxisName.Y]  = PutPoint.Y * 1000;
                m_MovePoint[eAxisName.Z]  = (PutPoint.Z + Z_distance) * 1000;
                m_MovePoint[eAxisName.RZ] = PutPoint.RZ * 1000;
                m_RobotDevice.SetGlobalPoint(PointIndex + 2, m_MovePoint);

                m_MovePoint[eAxisName.X]  = PutPoint.X * 1000;
                m_MovePoint[eAxisName.Y]  = PutPoint.Y * 1000;
                m_MovePoint[eAxisName.Z]  = (PutPoint.Z) * 1000;
                m_MovePoint[eAxisName.RZ] = PutPoint.RZ * 1000;
                m_RobotDevice.SetGlobalPoint(PointIndex + 3, m_MovePoint);
            }
        }
Exemplo n.º 11
0
        // vec2_LineStart = cVector_2d.MakeVector(aptDefinitionPoints[iLast].x,aptDefinitionPoints[iLast].y);
        // vec2_LineEnd = cVector_2d.MakeVector(aptDefinitionPoints[i].x,aptDefinitionPoints[i].y);
        // vec2_Point = cVector_2d.MakeVector(cptPointToAdd.x,cptPointToAdd.y);
        // nDistance = cVector_2d.DistanceOfPointToLine(vec2_Point, vec2_LineStart, vec2_LineEnd);
        // vec2_VecLine = cVector_2d.VectorSubtract(vec2_LineStart, vec2_LineEnd);
        // cptIntersectionPoint = cVector_2d.GetPointVerticalIntersection(aptDefinitionPoints[i], vec2_VecLine, cptPointToAdd);

        // cVector_2d.GetPointVerticalIntersection(aptDefinitionPoints[i], vec2_VecLine, cptPointToAdd);

        // vecInputLine: vector/line between two polygon points
        // cptPointQ: Origin of vector vecInputLine, one of the two polygon points
        // cpPointP: Click point
        // Schnittpunkt zwischen Normale zu vecInputLine und cpPointP auf vecInputLine
        public static cPoint GetPointVerticalIntersection(cPoint cptPointQ, cVector_2d vecInputLine, cPoint cpPointP)
        {
            // Q: Line start/endpoint
            // P + a * vecNormalVector = Intersection = Q + b * vecInputLine
            // a = (-(Px*vy-Py*vx-Qx*vy+Qy*vx))/(nx*vy-ny*vx)
            // b = (-(Px*ny-Py*nx-Qx*ny+Qy*nx))/(nx*vy-ny*vx)

            cVector_2d vecNormalVector = GetNormalVector(vecInputLine);
            double     nDenominator    = vecNormalVector.x * vecInputLine.y - vecNormalVector.y * vecInputLine.x;


            cPoint cptIntersectionPoint = new cPoint();

            if (nDenominator == 0)
            {
                // no intersection
                cptIntersectionPoint.bHasInterSection = false;
                return(cptIntersectionPoint);
            }

            double a = (-(cpPointP.x * vecInputLine.y - cpPointP.y * vecInputLine.x - cptPointQ.x * vecInputLine.y + cptPointQ.y * vecInputLine.x)) / nDenominator;
            double b = (-(cpPointP.x * vecNormalVector.y - cpPointP.y * vecNormalVector.x - cptPointQ.x * vecNormalVector.y + cptPointQ.y * vecNormalVector.x)) / nDenominator;

            cptIntersectionPoint.bHasInterSection = true;
            cptIntersectionPoint.x = cpPointP.x + a * vecNormalVector.x;
            cptIntersectionPoint.y = cpPointP.y + a * vecNormalVector.y;

            return(cptIntersectionPoint);
        }
		public MouseStickEventArgs(int Magnitude, cPoint Direction)
		{
			dir = Direction;
			mag = Magnitude;
		}
		private void UserControl1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
		{
			if (isActive)
			{
				int x_Val,y_Val;
				//Translating mouse motion on the control
				//To a 30 x 30 cartesian grid.
				y_Val = (e.Y * 31 / this.Height) - 15;
				x_Val = (e.X * 31 / this.Width) - 15;
				y_Val = -y_Val;

				//Setting up to raise the MouseStickMoved Event
				direction = GetDirection(x_Val, y_Val);
                if (previousdirection != direction)
                {
                    previousdirection = direction;
                    MouseDirectionChanged(this, new MouseStickEventArgs(this.magnitude, this.direction));

                }

				magnitude = (int)Math.Sqrt(y_Val * y_Val + x_Val * x_Val);
//				if (magnitude > 15) magnitude = 15;
                magnitude = 15;
                mousePoint.X = e.X;
				mousePoint.Y = e.Y;
			}
			else
			{
				magnitude = 0;
				mousePoint.X = this.Width/2;
				mousePoint.Y = this.Height/2;
			}

			if(MouseStickMoved != null)
				MouseStickMoved(this, new MouseStickEventArgs(this.magnitude, this.direction));

		}