//选择回零轴 private void button_home_Click(object sender, EventArgs e) { Global.WorkVar.tag_isFangDaiJieChu = false; if (!Work.IsMove(1)) { return; } if (CBChoiceAxis.Text == "") { MessageBoxLog.Show("选择轴位不能为空"); return; } AxisConfig acg; acg = StationManage.FindAxis(CBStnChioce.Text, CBChoiceAxis.Text); if (acg == null) { MessageBoxLog.Show("查找轴失败"); return; } GoHomeParameterUI gohome = new GoHomeParameterUI(acg); gohome.ShowDialog(); }
/// <summary> /// 伺服电机回原函数 /// </summary> /// <param name="stationName"></param> /// <param name="axisName"></param> /// <returns></returns> public static short GoHome(string stationName, string axisName) { AxisConfig axisC = StationManage.FindAxis(stationName, axisName); NewCtrlCardBase Base_ = tag_NewCtrlCardBase[(int)axisC.tag_MotionCardManufacturer]; if (Base_ == null) { MessageBoxLog.Show(NewCtrlCardBase.GetManufacturerName((int)axisC.tag_MotionCardManufacturer) + "控制卡初始化失败!"); return(shrFail); } short ret = 0; if (axisC == null) { return(shrFail); } short shrResult = -1; switch (axisC.GoHomeType) { case 0: shrResult = Base_.SR_GoHome(axisC); break; case 1: shrResult = Base_.SR_GoHome(axisC); break; case 2: shrResult = Base_.SR_GoOneHome(axisC); break; case 3: shrResult = Base_.SR_GoOneHomeOrg(axisC); break; default: shrResult = Base_.SR_GoHome(axisC); break; } if (shrResult != shrSuccess) { return(shrFail); } return(shrResult); }
/// <summary> /// 轴绝对运动 /// </summary> /// <param name="stationName"></param> /// <param name="axisName"></param> /// <param name="pointName"></param> /// <returns></returns> public static short AxisAbsoluteMove(string stationName, string axisName, string pointName, int asxisIndex) { StationModule stationM = StationManage.FindStation(stationName); if (stationM == null) { return(shrFail); } AxisConfig axisC = StationManage.FindAxis(stationM, axisName); if (axisC == null) { return(shrFail); } PointAggregate pointA = StationManage.FindPoint(stationM, pointName); if (pointA == null) { return(shrFail); } NewCtrlCardBase Base_ = tag_NewCtrlCardBase[(int)axisC.tag_MotionCardManufacturer]; if (Base_ == null) { MessageBoxLog.Show(NewCtrlCardBase.GetManufacturerName((int)axisC.tag_MotionCardManufacturer) + "控制卡初始化失败!"); return(shrFail); } short shrResult = 0; if (pointA.tag_motionType == 0) { shrResult = Base_.SR_AbsoluteMove(axisC, pointA.arrPoint[asxisIndex]); } else { shrResult = Base_.SR_RelativeMove(axisC, pointA.arrPoint[asxisIndex]); } if (shrResult != shrSuccess) { return(shrFail); } return(shrSuccess); }
/// <summary> /// 轴运动并等待停止并判断位置 /// </summary> /// <param name="stationName"></param> /// <param name="axisName"></param> /// <param name="pointName"></param> /// <param name="asxisIndex"></param> /// <returns></returns> public static short AxisAbsoluteMoveAndWaitStopVrf(string stationName, string axisName, string pointName, int asxisIndex) { if (AxisAbsoluteMove(stationName, axisName, pointName, asxisIndex) != 0) { Global.WorkVar.tag_StopState = 2; if (MessageBoxLog.Show("工位:\r\n" + stationName + "\r\n轴名:\r\n" + axisName + "\t移动异常,请检查伺服驱动!") == DialogResult.OK) { } return(shrFail); } StationModule stationM = StationManage.FindStation(stationName); if (stationM == null) { return(shrFail); } PointAggregate pointA = StationManage.FindPoint(stationM, pointName); if (pointA == null) { return(shrFail); } AxisConfig axisC = StationManage.FindAxis(stationM, axisName); if (WaitAxisStop(axisC) != 0) { return(shrFail); } double pos_loadY = 0; short ret = SR_GetPrfPos((int)axisC.tag_MotionCardManufacturer, axisC.CardNum, axisC.AxisNum, ref pos_loadY); if (Global.WorkVar.tag_SuspendState == 1 || (Global.WorkVar.bSuspendState_L && axisC.AxisName == "左Y轴") || (Global.WorkVar.bSuspendState_R && axisC.AxisName == "右Y轴")) { } else if (pos_loadY / axisC.Eucf < pointA.arrPoint[asxisIndex].dblPonitValue - 1 || pos_loadY / axisC.Eucf > pointA.arrPoint[asxisIndex].dblPonitValue + 1) { return(shrFail); } return(shrSuccess); }