예제 #1
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            long   pos, pos2;
            int    checkStauts;
            string str_DisplayPos;

            pos            = Dmc2610.d2610_get_position(0);//读取指定轴的当前位置
            str_DisplayPos = "X=" + Convert.ToString(pos) + "     " + (!Convert.ToBoolean(Dmc2610.d2610_check_done((ushort)AxisID.XAxis)) ? "...Run..." : "...Stop...");
            pos            = Dmc2610.d2610_get_position(1);
            str_DisplayPos = str_DisplayPos + "   Y=" + Convert.ToString(pos) + "     " + (!Convert.ToBoolean(Dmc2610.d2610_check_done((ushort)AxisID.YAxis)) ? "...Run..." : "...Stop...");

            str_DisplayPos += "\n";

            pos2           = Dmc2610.d2610_get_position(2);
            str_DisplayPos = str_DisplayPos + "Z=" + Convert.ToString(pos2) + "     " + (!Convert.ToBoolean(Dmc2610.d2610_check_done((ushort)AxisID.ZAxis)) ? "...Run..." : "...Stop...");
            pos2           = Dmc2610.d2610_get_position(3);
            str_DisplayPos = str_DisplayPos + "   U=" + Convert.ToString(pos2) + "     " + (!Convert.ToBoolean(Dmc2610.d2610_check_done((ushort)AxisID.UAxis)) ? "...Run..." : "...Stop...");


            //str_DisplayPos += "\n"  + ((Motion2610Control.GetAxisIsORGON(XAxis)) ? "X ORG IS ON" : "X ORG IS OFF");
            str_DisplayPos += "\n" + ((Motion2610Control.GetAxisIsORGON(XAxis)) ? "X ORG IS ON" : "X ORG IS OFF") + "   " + ((Motion2610Control.GetAxisIsORGON(YAxis)) ? "Y ORG IS ON" : "Y ORG IS OFF") + "   " + ((Motion2610Control.GetAxisIsORGON(CAxis)) ? "C ORG IS ON" : "C ORG IS OFF") + "   " + ((Motion2610Control.GetAxisIsORGON(LAxis)) ? "L ORG IS ON" : "L ORG IS OFF");

            str_DisplayPos += "\n" + ((Motion2610Control.GetAxisIsNELON(XAxis)) ? "X EL- IS ON" : "X EL- IS OFF") + "   " + ((Motion2610Control.GetAxisIsNELON(YAxis)) ? "Y EL- IS ON" : "Y EL- IS OFF") + "   " + ((Motion2610Control.GetAxisIsNELON(CAxis)) ? "C EL- IS ON" : "C EL- IS OFF") + "   " + ((Motion2610Control.GetAxisIsNELON(LAxis)) ? "L EL- IS ON" : "L EL- IS OFF");

            str_DisplayPos += "\n" + ((Motion2610Control.GetAxisIsPELON(XAxis)) ? "X EL+ IS ON" : "X EL+ IS OFF") + "   " + ((Motion2610Control.GetAxisIsPELON(YAxis)) ? "Y EL+ IS ON" : "Y EL+ IS OFF") + "   " + ((Motion2610Control.GetAxisIsPELON(CAxis)) ? "C EL+ IS ON" : "C EL+ IS OFF") + "   " + ((Motion2610Control.GetAxisIsPELON(LAxis)) ? "L EL+ IS ON" : "L EL+ IS OFF");

            str_DisplayPos += "\n\n" + ((Motion2610Control.GetAxisIsINPON(XAxis)) ? "X INP IS ON" : "X INP IS OFF") +
                              "   " + ((Motion2610Control.GetAxisIsINPON(YAxis)) ? "Y INP IS ON" : "Y INP IS OFF");

            Label_POSITION.Text = str_DisplayPos;//显示位置信

            StringBuilder axisStautsDetail = new StringBuilder();

            foreach (Axis axis in AxisGroup)
            {
                if (!Motion2610Control.AxisQueryStatus(axis))
                {
                    while (axis.AxisStatusStack.Count > 0)
                    {
                        axisStautsDetail.Append(axis.AxisStatusStack.Pop());
                    }
                }
            }
            if (axisStautsDetail.Length <= 0)
            {
                lbAxisStatus.Text = "Axis Status : \n" + "Every Axis is OK!";
            }
            else
            {
                lbAxisStatus.Text = "Axis Status : \n" + axisStautsDetail;
            }

            StringBuilder sb2 = new StringBuilder();

            for (int i = 0; i < 2; i++)
            {
                if (Motion2610Control.ReadInputKey((ushort)(i + 1)) != InputiskeyDown[i])
                {
                    InputiskeyDown[i] = Motion2610Control.ReadInputKey((ushort)(i + 1));
                    if (InputiskeyDown[i] != InputinitStatus[i])
                    {
                        inputstartTime[i] = DateTime.Now;
                        string str1 = "input  " + i.ToString() + ": StartTime= " + inputstartTime[i].ToString();
                        sb2.AppendLine(str1);
                    }
                    else
                    {
                        InputEndTime[i] = DateTime.Now;

                        string str1 = "input  " + i.ToString() + ": EndTime = " + InputEndTime[i].ToString();


                        sb2.AppendLine(str1);
                    }
                }
            }

            this.tbinputsig.Text += sb2.ToString();
        }
예제 #2
0
        private void btnLoadAxisPara_Click(object sender, EventArgs e)
        {
            // DMC2610卡的函数调用

            nCard = Dmc2610.d2610_board_init(); //'为控制卡分配系统资源,并初始化控制卡。
            if (nCard <= 0)                     //DMC1000控制卡初始化
            {
                MessageBox.Show("未找到DMC2610控制卡!", "警告");
                return;//退出当前程序
            }

            string connectionString = @"Data Source=.\AOI;Initial Catalog=aoi5sys;Integrated Security=True";

            SqlConnection connection = new SqlConnection(connectionString);
            //string sql=@"SELECT * FROM AXIS_PARAM WHERE NAME='#1HOST'";
            string sql = @"SELECT [NAME]
      ,[AXIS]
      ,[AXIS_ID]
      ,[PULSE_MODE]
      ,[MAX_DIST]
      ,[ORG_POSITION]
      ,[RESET_SPEED]
      ,[START_SPEED]
      ,[MAX_SPEED]
      ,[ADD_SPEED]
      ,[ADD_MODE]
      ,[PULSE_PER_MM]
  FROM [aoi5sys].[dbo].[AXIS_PARAM]
  WHERE	NAME='#1HOST'";

            try
            {
                connection.Open();

                SqlCommand cmd = new SqlCommand(sql, connection);

                SqlDataReader dataReader = cmd.ExecuteReader();


                AxisGroup = new List <Axis>();

                while (dataReader.Read())
                {
                    string           tempstr  = dataReader.GetValue(1).ToString();
                    AxisPulseOutMode PoutMode = dataReader.GetInt32(3) == 0
                              ? AxisPulseOutMode.PM_PLDL
                              : AxisPulseOutMode.PM_PHDHPHDH;
                    double     pulseOfMilMeter   = Convert.ToDouble(dataReader.GetValue(11).ToString());
                    long       maxRouterDistance = Convert.ToInt64(dataReader.GetValue(4));
                    long       logicOrgPosition  = Convert.ToInt64(dataReader.GetValue(5));
                    AxisINPSIG axisInpsig        = AxisINPSIG.Enable;

                    double ResetVelocity = Convert.ToDouble(dataReader.GetValue(6));
                    double startVelocity = Convert.ToDouble(dataReader.GetValue(7));
                    double maxVelocity   = Convert.ToDouble(dataReader.GetValue(8));
                    double accVelocity   = Convert.ToDouble(dataReader.GetValue(9));
                    double decVelocity   = Convert.ToDouble(dataReader.GetValue(9));
                    float  scale         = (float)0.75;

                    if (tempstr.Contains("X_"))
                    {
                        this.XAxis = new Axis(AxisID.XAxis, PoutMode, pulseOfMilMeter, maxRouterDistance, logicOrgPosition, axisInpsig);
                        XAxis.AxisSetResetMoveParameters(ResetVelocity / 2, ResetVelocity, ResetVelocity / 2, ResetVelocity / 2);
                        XAxis.AxisSetTMoveParameters(startVelocity, maxVelocity, accVelocity, decVelocity);
                        XAxis.AxisSetSPMoveParameters(startVelocity, maxVelocity, accVelocity, decVelocity, scale);
                        XAxis.AxisSetSTMoveParameters(startVelocity, maxVelocity, accVelocity, decVelocity, scale);
                        // XAxis.AxisSetVectorMoveParameters(startVelocity, maxVelocity, accVelocity, decVelocity, (float)0.6);
                        AxisGroup.Add(XAxis);
                    }
                    if (tempstr.Contains("Y_"))
                    {
                        this.YAxis = new Axis(AxisID.YAxis, PoutMode, pulseOfMilMeter, maxRouterDistance, logicOrgPosition, axisInpsig);
                        YAxis.AxisSetResetMoveParameters(ResetVelocity / 2, ResetVelocity, ResetVelocity / 2, ResetVelocity / 2);
                        YAxis.AxisSetTMoveParameters(startVelocity, maxVelocity, accVelocity, decVelocity);
                        YAxis.AxisSetSPMoveParameters(startVelocity, maxVelocity, accVelocity, decVelocity, scale);
                        YAxis.AxisSetSTMoveParameters(startVelocity, maxVelocity, accVelocity, decVelocity, scale);
                        // YAxis.AxisSetVectorMoveParameters(startVelocity, maxVelocity, accVelocity, decVelocity, (float)0.6);
                        AxisGroup.Add(YAxis);
                    }
                    if (tempstr.Contains("C_"))
                    {
                        this.CAxis = new Axis(AxisID.ZAxis, PoutMode, pulseOfMilMeter, maxRouterDistance, logicOrgPosition, axisInpsig);
                        CAxis.AxisSetResetMoveParameters(ResetVelocity / 2, ResetVelocity, ResetVelocity / 2, ResetVelocity / 2);
                        CAxis.AxisSetTMoveParameters(startVelocity, maxVelocity, accVelocity, decVelocity);
                        CAxis.AxisSetSPMoveParameters(startVelocity, maxVelocity, accVelocity, decVelocity, scale);
                        CAxis.AxisSetSTMoveParameters(startVelocity, maxVelocity, accVelocity, decVelocity, scale);
                        //CAxis.AxisSetVectorMoveParameters(startVelocity, maxVelocity, accVelocity, decVelocity, (float)0.6);
                        AxisGroup.Add(CAxis);
                    }
                    if (tempstr.Contains("L_"))
                    {
                        this.LAxis = new Axis(AxisID.UAxis, PoutMode, pulseOfMilMeter, maxRouterDistance, logicOrgPosition, axisInpsig);
                        LAxis.AxisSetResetMoveParameters(ResetVelocity / 2, ResetVelocity, ResetVelocity / 2, ResetVelocity / 2);
                        LAxis.AxisSetTMoveParameters(startVelocity, maxVelocity, accVelocity, decVelocity);
                        LAxis.AxisSetSPMoveParameters(startVelocity, maxVelocity, accVelocity, decVelocity, scale);
                        LAxis.AxisSetSTMoveParameters(startVelocity, maxVelocity, accVelocity, decVelocity, scale);
                        // LAxis.AxisSetVectorMoveParameters(startVelocity, maxVelocity, accVelocity, decVelocity, (float)0.6);
                        AxisGroup.Add(LAxis);
                    }
                }
                timer1.Enabled = true;
            }
            catch (DataException dataException)
            {
                MessageBox.Show(dataException.ToString());
            }
            finally
            {
                connection.Close();
                this.btnLoadAxisPara.Enabled = false;
            }

            for (int i = 0; i < 2; i++)
            {
                InputinitStatus[i] = Motion2610Control.ReadInputKey((ushort)(i + 1));
                InputiskeyDown[i]  = InputinitStatus[i];
            }
        }