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]; } }