/// <summary> /// 等待轴停止 /// </summary> /// <param name="card"></param> /// <param name="axis"></param> /// <returns></returns> public static short WaitAxisStop(AxisConfig axisC) { int intAxisStatus = 0; short shrResult = 0; NewCtrlCardBase Base_ = tag_NewCtrlCardBase[(int)axisC.tag_MotionCardManufacturer]; if (Base_ == null) { MessageBoxLog.Show(NewCtrlCardBase.GetManufacturerName((int)axisC.tag_MotionCardManufacturer) + "控制卡初始化失败!"); return(shrFail); } short ret = 0; do { //程序是否正常运行 if (IsExit()) { Base_.SR_AxisEmgStop(axisC.CardNum, axisC.AxisNum); return(shrFail); } //读轴状态 shrResult = Base_.SR_GetAxisStatus(axisC.CardNum, axisC.AxisNum, out intAxisStatus); if (shrResult != shrGtsSuccess) { return(shrFail); } Thread.Sleep(5); } while (intAxisStatus != 0); //运动中 return(shrSuccess); }
public static short set_io_mode(AxisConfig axisC) { 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 = Base_.SR_set_io_mode(axisC.CardNum, 0, 0); if (shrResult != shrSuccess) { return(shrFail); } return(shrResult); }
/// <summary> /// IO输出 /// </summary> /// <param name="io">IO类对象</param> /// <param name="ioValue">输出状态</param> /// <returns></returns> public static short GetOutputIoBit(IOParameter io, short ioValue) { short shrResult = 0; bool bioValue = false; if (io == null) { return(shrFail); } NewCtrlCardBase Base_ = tag_NewCtrlCardBase[(int)io.tag_MotionCardManufacturer]; if (Base_ == null) { MessageBoxLog.Show(NewCtrlCardBase.GetManufacturerName((int)io.tag_MotionCardManufacturer) + "控制卡初始化失败!"); return(shrFail); } shrResult = Base_.SR_GetOutputBit(io.CardNum, io.IOBit, out bioValue); if (shrResult != shrSuccess) { shrResult = -1; return(shrResult); } if (bioValue) { shrResult = 1; } else { shrResult = 0; } return(shrResult); }
/// <summary> /// 判断是否右轴报警 TRUE 报警 /// </summary> public bool IsAxisAlarm() { bool axio = false; //NewCtrlCardV0.GetInputIoBitStatus("", "Z1报警", out axio); if (axio) { LogOutControl.OutLog("轴报警", 0); return(true); } int CardIndex = 0; int axisIndex = 0; bool ret = false; for (MotionCardManufacturer i = 0; i < MotionCardManufacturer.MotionCardManufacturer_max; i++) { NewCtrlCardBase Base = NewCtrlCardV0.tag_NewCtrlCardBase[(int)i]; short j = 0; short n = 0; if (Base == null || NewCtrlCardIO.tag_CardHave[(int)i] == 0) { continue; } while (j < NewCtrlCardV0.tag_CardCount[(int)i]) { axisIndex = 0; while (n < NewCtrlCardV0.tag_CardAxisCount[(int)i]) { //tag_CardAxisAlarm[CardIndex] AxisConfig name = IshaveAxis((int)i, j, n); if (name != null) { if (name.tag_IoAlarmNHighEnable == 1) { if ((((int)NewCtrlCardIO.tag_CardAxisAlarm[CardIndex] & (1 << n)) > 0)) { LogOutControl.OutLog(NewCtrlCardBase.GetManufacturerName((int)i) + "第" + j + "卡" + n + "轴(" + name.AxisName + ")报警", 0); ret = true; } } else { if ((((int)NewCtrlCardIO.tag_CardAxisAlarm[CardIndex] & (1 << n)) == 0)) { LogOutControl.OutLog(NewCtrlCardBase.GetManufacturerName((int)i) + "第" + j + "卡" + n + "轴(" + name.AxisName + ")报警", 0); ret = true; } } } axisIndex++; n++; } CardIndex++; j++; } // } return(ret); }
/// <summary> /// 直线查补运动 /// </summary> /// <param name="card"></param> /// <param name="postion">目标点位</param> /// <param name="crd">坐标系</param> /// <param name="posi_mode">运动模式,1:相对坐标模式,0:绝对坐标模式</param> public static short SR_LineMulticoorMove(AxisConfig[] axisC, PointModule[] point, short crd, short posi_mode) { short shrResult = 0; NewCtrlCardBase Base_ = tag_NewCtrlCardBase[(int)axisC[0].tag_MotionCardManufacturer]; if (Base_ == null || Base_.SR_LineMulticoorMove == null) { MessageBoxLog.Show(NewCtrlCardBase.GetManufacturerName((int)axisC[0].tag_MotionCardManufacturer) + "控制卡初始化失败!"); return(shrFail); } if (Base_.SR_LineMulticoorMove != null) { if (posi_mode == 0) { posi_mode = 1; } else { posi_mode = 0; } shrResult = Base_.SR_LineMulticoorMove(axisC, point, crd, posi_mode); } if (shrResult != shrGtsSuccess) { return(shrFail); } return(shrResult); }
/// <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="card"></param> /// <param name="axis"></param> /// <returns></returns> public static short SR_AxisStop(int Cardtype, short card, short axis) { short shrResult; NewCtrlCardBase Base_ = tag_NewCtrlCardBase[Cardtype]; if (Base_ == null) { MessageBoxLog.Show(NewCtrlCardBase.GetManufacturerName((int)Cardtype) + "控制卡初始化失败!"); return(shrFail); } shrResult = Base_.SR_AxisStop(card, axis); if (shrResult != shrGtsSuccess) { return(-1); } return(0); }
/// <summary> /// 获取轴运动状态 1,运动,0 飞运动 -1异常 /// </summary> /// <param name="axisC"></param> /// <returns></returns> public static short SR_GetAxisStatus(AxisConfig axisC) { short shrResult = 0; int axisStatus = 0; NewCtrlCardBase Base_ = tag_NewCtrlCardBase[(int)axisC.tag_MotionCardManufacturer]; if (Base_ == null) { MessageBoxLog.Show(NewCtrlCardBase.GetManufacturerName((int)axisC.tag_MotionCardManufacturer) + "控制卡初始化失败!"); return(-1); } shrResult = Base_.SR_GetAxisStatus(axisC.CardNum, axisC.AxisNum, out axisStatus); if (shrResult == 1) { return(-1); } return((short)axisStatus); }
/// <summary> /// 读取板卡规划位置 /// </summary> /// <param name="card"></param> /// <param name="axis"></param> /// <param name="pos"></param> /// <param name="count"></param> /// <returns></returns> public static short SR_GetPrfPos(int Cardtype, short card, short axis, ref double pos) { short shrResult; int posV = 0; NewCtrlCardBase Base_ = tag_NewCtrlCardBase[Cardtype]; shrResult = Base_.SR_GetPrfPos(card, axis, ref pos); if (Base_ == null) { MessageBoxLog.Show(NewCtrlCardBase.GetManufacturerName((int)Cardtype) + "控制卡初始化失败!"); return(shrFail); } if (shrResult != shrGtsSuccess) { return(-1); } return(0); }
/// <summary> /// 获取单通道(Bit)输入IO状态,函数执行成功 判断status参数值 TRUE 有信号输入 FALSE无信号输入 /// </summary> /// <param name="stationName"></param> /// <param name="ioName"></param> /// <param name="status"></param> /// <returns></returns> public static short GetInputIoBitStatus(string stationName, string ioName, out bool status) { short shrResult; status = false; if (ioName == null) { status = true; return(0); } IOParameter ioP = StationManage.FindInputIo(ioName); NewCtrlCardBase Base_ = tag_NewCtrlCardBase[(int)ioP.tag_MotionCardManufacturer]; if (Base_ == null) { MessageBoxLog.Show(NewCtrlCardBase.GetManufacturerName((int)ioP.tag_MotionCardManufacturer) + "控制卡初始化失败!"); return(shrFail); } if (ioP == null) { MessageBoxLog.Show(stationName + "\r\nIO:<" + ioName + ">没有找到,请配置"); return(shrFail); } shrResult = Base_.SR_GetInputBit(ioP.CardNum, ioP.IOBit, out status); if (ioP.Logic == 0) { if (status) { status = false; } else { status = true; } } if (shrResult == -1) { return(shrFail); } return(shrSuccess); }
/// <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> /// 设定正负方向限位输入nLMT信号的模式 /// </summary> /// <param name="axisC"></param> /// <returns></returns> public static short set_pulse_mode(AxisConfig axisC) { NewCtrlCardBase Base_ = tag_NewCtrlCardBase[(int)axisC.tag_MotionCardManufacturer]; if (Base_ == null || Base_.SR_set_pulse_mode == null) { MessageBoxLog.Show(NewCtrlCardBase.GetManufacturerName((int)axisC.tag_MotionCardManufacturer) + "控制卡初始化失败!"); return(shrFail); } if (axisC == null) { return(shrFail); } short shrResult = (short)Base_.SR_set_pulse_mode((int)axisC.CardNum, (int)axisC.AxisNum, axisC.tag_CC_value, axisC.tag_CC_logic, axisC.tag_dir_logic); if (shrResult != shrSuccess) { return(shrFail); } return(shrResult); }
/// <summary> /// 设定正负方向限位输入nLMT信号的模式 /// </summary> /// <param name="axisC"></param> /// <returns></returns> public static short set_limit_mode(AxisConfig axisC) { NewCtrlCardBase Base_ = tag_NewCtrlCardBase[(int)axisC.tag_MotionCardManufacturer]; if (Base_ == null || Base_.SR_set_limit_mode == null) { MessageBoxLog.Show(NewCtrlCardBase.GetManufacturerName((int)axisC.tag_MotionCardManufacturer) + "控制卡初始化失败!"); return(shrFail); } if (axisC == null) { return(shrFail); } short shrResult = Base_.SR_set_limit_mode(axisC.CardNum, axisC.AxisNum, axisC.tag_IoLimtPEnable, axisC.tag_IoLimtNEnable, axisC.tag_IoLimtPNHighEnable); if (shrResult != shrSuccess) { return(shrFail); } return(shrResult); }
/// <summary> /// 单轴绝对运动 /// </summary> /// <param name="card"></param> /// <param name="axis"></param> /// <param name="postion">目标点位</param> /// <param name="speed">速度</param> /// <returns></returns> public static short SR_continue_move(AxisConfig axisC, PointModule point, int dir) { short shrResult = 0; if (point.dblPonitSpeed == 0) { MessageBoxLog.Show(axisC.AxisName + "速度设置位0,急停请设置"); return(-1); } NewCtrlCardBase Base_ = tag_NewCtrlCardBase[(int)axisC.tag_MotionCardManufacturer]; if (Base_ == null) { MessageBoxLog.Show(NewCtrlCardBase.GetManufacturerName((int)axisC.tag_MotionCardManufacturer) + "控制卡初始化失败!"); return(shrFail); } shrResult = Base_.SR_continue_move(axisC, point, dir); if (shrResult != shrGtsSuccess) { return(shrFail); } return(shrSuccess); }
/// <summary> /// 判断是否报警 TRUE 报警 /// </summary> public bool IsAxisLimitAlarm() { int CardIndex = 0; int axisIndex = 0; bool ret = false; for (MotionCardManufacturer i = 0; i < MotionCardManufacturer.MotionCardManufacturer_max; i++) { NewCtrlCardBase Base = NewCtrlCardV0.tag_NewCtrlCardBase[(int)i]; short j = 0; short n = 0; if (Base == null || NewCtrlCardIO.tag_CardHave[(int)i] == 0) { continue; } while (j < NewCtrlCardV0.tag_CardCount[(int)i]) { axisIndex = 0; while (n < NewCtrlCardV0.tag_CardAxisCount[(int)i]) { AxisConfig name = IshaveAxis((int)i, j, n); if (name != null) { if (name.tag_IoLimtPNHighEnable == 1) { if ((((int)NewCtrlCardIO.tag_CardAxisLimitNIO[CardIndex] & (1 << n)) > 0) && name.tag_IoLimtNEnable == 0) { LogOutControl.OutLog(NewCtrlCardBase.GetManufacturerName((int)i) + "第" + j + "卡" + n + "轴负限位(" + name.AxisName + ")报警", 0); ret = true; } if ((((int)NewCtrlCardIO.tag_CardAxisLimitPIO[CardIndex] & (1 << n)) > 0) && name.tag_IoLimtPEnable == 0) { LogOutControl.OutLog(NewCtrlCardBase.GetManufacturerName((int)i) + "第" + j + "卡" + n + "轴正限位(" + name.AxisName + ")报警", 0); ret = true; } } else { if ((((int)NewCtrlCardIO.tag_CardAxisLimitNIO[CardIndex] & (1 << n)) == 0) && name.tag_IoLimtNEnable == 0) { LogOutControl.OutLog(NewCtrlCardBase.GetManufacturerName((int)i) + "第" + j + "卡" + n + "轴负限位(" + name.AxisName + ")报警", 0); ret = true; } if ((((int)NewCtrlCardIO.tag_CardAxisLimitPIO[CardIndex] & (1 << n)) == 0) && name.tag_IoLimtPEnable == 0) { LogOutControl.OutLog(NewCtrlCardBase.GetManufacturerName((int)i) + "第" + j + "卡" + n + "轴正限位(" + name.AxisName + ")报警", 0); ret = true; } } } axisIndex++; n++; } CardIndex++; j++; } // } return(ret); }