private static void line(object a1) //public static void XY_move(double x_p,double y_p,double z_p, double Vel,double AccDec) { int i = 0; Global.Cdefault l_data = a1 as Global.Cdefault; l_data.Aposition[0] = l_data.Aposition[0] * Global.X.dEquiv; l_data.Aposition[1] = l_data.Aposition[1] * Global.Y.dEquiv; l_data.Aposition[2] = l_data.Aposition[2] * Global.Z.dEquiv; Global.Ccard1.Vector(l_data); var res = Global.Ccard1.dmc_check_done_multicoor(); while (res != 1) //stop :1 run : 0 { res = Global.Ccard1.dmc_check_done_multicoor(); i++; // textBox1.Text = "直线运动前检测" + i; Application.DoEvents(); } Global.Ccard1.dmc_line_unit(l_data); Thread.Sleep(0); var res1 = Global.Ccard1.dmc_check_done_multicoor(); while (res1 != 1) { i++; res1 = Global.Ccard1.dmc_check_done_multicoor(); Application.DoEvents(); } }
private static void MovePoint(object a) //public static void XY_move(double x_p,double y_p,double z_p, double Vel,double AccDec) { int xy_code = 0; //创建传参 拆包 Global.Cdefault data = a as Global.Cdefault; Global.Z.dMaxVel = data.vel; Global.X.dMaxVel = data.vel; Global.Y.dMaxVel = data.vel; Global.Z.Pmove(0, data.vel, data.Ade, 1); Global.Z.ORG(); // Thread.Sleep(0); while (Global.Z.IsRun) //检测完成 { // Thread.Sleep(1000); Application.DoEvents(); } while (Global.X.IsRun | Global.Y.IsRun) //检测完成 { // Thread.Sleep(1000); Application.DoEvents(); } //double[] target = { data.x_position, data.y_position, data.z_position }; // 拆出位置 Global.X.Pmove(data.Aposition[0], data.vel, data.Ade, 1); //发命令 Global.Y.Pmove(data.Aposition[1], data.vel, data.Ade, 1); Thread.Sleep(1); while (Global.X.IsRun | Global.Y.IsRun) //检测完成 { // Thread.Sleep(1000); Application.DoEvents(); } Global.Z.Pmove(data.Aposition[2], data.vel, data.Ade, 1); Thread.Sleep(1); while (Global.Z.IsRun) { // Thread.Sleep(1000); // Application.DoEvents(); } }
private static void Arc(object a) //public static void XY_move(double x_p,double y_p,double z_p, double Vel,double AccDec) { short Arc_co = 0; int i = 0; Global.Cdefault data = a as Global.Cdefault; double[] mid = { data.Aposition[0] * Global.X.dEquiv, data.Aposition[1] * Global.Y.dEquiv, data.Aposition[2] * Global.Z.dEquiv }; double[] target = { data.Bposition[0] * Global.X.dEquiv, data.Bposition[1] * Global.Y.dEquiv, data.Bposition[2] * Global.Y.dEquiv };; ushort AxisNum = 3; int cricle = -1; //圈数: #region // 负数:表示此时执行的为空间圆弧插补 // 该值的绝对减 1表示空间圆弧的圈数。如, 表示空间圆弧的圈数。如, -1即表示 0圈 空间圆弧, -2即表示 1圈空间圆弧… // 自然数:表示此时执行的为圆柱螺旋线插补 // 该值表示螺旋线的圈数。如, 0即表示 0圈螺旋线插补, 1即表示 1圈螺旋线插补… // posi_mode 运动模式, 0: //相对坐标模式, 1: #endregion while (LTDMC.dmc_check_done_multicoor(Global.Ccard1.CarNum, 0) == 0) { i++; Application.DoEvents(); } //卡号 轴数 轴号 目标位置, 圈数 模式0:相对 1:绝对 Arc_co = LTDMC.dmc_arc_move_3points_unit(Global.Ccard1.CarNum, 0, AxisNum, new ushort[] { Global.X.axis, Global.Y.axis, Global.Z.axis }, target, mid, cricle, 1); i = 0; Thread.Sleep(1); while (LTDMC.dmc_check_done_multicoor(Global.Ccard1.CarNum, 0) == 0) { i++; Application.DoEvents(); } }
public static void MotionFun(object ot) { double X_position; double Y_position; double Z_position; double Vel; double ade; Global.Cdefault pa = ot as Global.Cdefault; int Tsetup = pa.setup; string[,] data = pa.table; Global.Cdefault data1 = new Global.Cdefault(); Global.Cdefault line_data = new Global.Cdefault(); Global.Cdefault Arc_data = new Global.Cdefault(); try { switch (data[Tsetup, 1])// 读取指定轴状态机 { case "Disabled": break; case "Point": X_position = Convert.ToDouble(data[Tsetup, 2]); Y_position = Convert.ToDouble(data[Tsetup, 3]); Z_position = Convert.ToDouble(data[Tsetup, 4]); Vel = Convert.ToDouble(data[Tsetup, 5]); ade = Convert.ToDouble(data[Tsetup, 6]); data1.Aposition = new double[3]; data1.Aposition[0] = X_position; data1.Aposition[1] = Y_position; data1.Aposition[2] = Z_position; data1.vel = Vel; data1.Ade = ade; // mess_textBox.AppendText(DateTime.Now.ToString("HH:mm:ss :") + "Call MotionStartpoint" + "\n"); Task task = Task.Run(() => { MovePoint(data1); }); task.Wait(); break; case "Wait": int dela = Convert.ToInt16(data[Tsetup, 9]); // mess_textBox.AppendText(DateTime.Now.ToString("HH:mm:ss :") + "Call Delay" + "\n"); Thread.Sleep(dela); break; case "Line": X_position = Convert.ToDouble(data[Tsetup, 2]); Y_position = Convert.ToDouble(data[Tsetup, 3]); Z_position = Convert.ToDouble(data[Tsetup, 4]); Vel = Convert.ToDouble(data[Tsetup, 5]); ade = Convert.ToDouble(data[Tsetup, 6]); line_data.Aposition = new double[3] { X_position, Y_position, Z_position }; line_data.vel = Vel; line_data.Ade = ade; // mess_textBox.AppendText(DateTime.Now.ToString("HH:mm:ss :") + "Call LineMotion" + "\n"); Task task1 = Task.Run(() => { line(line_data); }); task1.Wait(); break; case "Arc_Mid": X_position = Convert.ToDouble(data[Tsetup, 2]); Y_position = Convert.ToDouble(data[Tsetup, 3]); Z_position = Convert.ToDouble(data[Tsetup, 4]); Vel = Convert.ToDouble(data[Tsetup, 5]); ade = Convert.ToDouble(data[Tsetup, 6]); Arc_data.Aposition = new double[3] { X_position, Y_position, Z_position }; Arc_data.vel = Vel; Arc_data.Ade = ade; double X_mid_position = Convert.ToDouble(data[Tsetup + 1, 2]); double Y_mid_position = Convert.ToDouble(data[Tsetup + 1, 3]); double Z_mid_position = Convert.ToDouble(data[Tsetup + 1, 4]); // mess_textBox.AppendText(DateTime.Now.ToString("HH:mm:ss :") + "Call ArcMotion" + "\n"); Arc_data.Bposition = new double[3] { X_mid_position, Y_mid_position, Z_mid_position }; //ActionThread = new Thread(new ParameterizedThreadStart(Arc)); //ActionThread.Start(a); //ActionThread.Join(); Arc(Arc_data); break; case "Dipensing": if (!pa.tryRun) //不带料模式 { double Q = Convert.ToDouble(data[Tsetup, 7]); double time = Convert.ToDouble(data[Tsetup, 8]); Global.Pumpdata.Calculation(Q, time, Global.A.Position); if (ts != null) { if (Global.Pumpdata.IsReset) { ReDispensing(); ts = Task.Run(() => { Dispensing(Global.Pumpdata); }); } if (!ts.IsCompleted) { ts.Wait(); Dispensing(Global.Pumpdata); } } ts = Task.Run(() => { Dispensing(Global.Pumpdata); }); } break; case "Dipensed": if (!pa.tryRun) { if (ts != null) { ts.Wait(); } } break; case "ReDispensing": if (!pa.tryRun) { if (!ts.IsCompleted) { ts.Wait(); } ts = Task.Run(() => { ReDispensing(); }); } break; default: break; } ; } catch (Exception ex) { Global.frmMain.PushMess(ex.ToString()); } }
public void Vector(Global.Cdefault l_data) { LTDMC.dmc_set_vector_profile_unit(CarNum, 0, 10, l_data.vel, l_data.Ade, l_data.Ade, 0); }
public void dmc_line_unit(Global.Cdefault l_data) { LTDMC.dmc_line_unit(CarNum, 0, 3, new ushort[] { 0, 1, 2 }, l_data.Aposition, 1); }