/// <summary> /// 获取S形速度曲线运动模式 /// </summary> /// <param name="axisInfo"></param> /// <param name="isShowLog">是否显示日志到UI</param> /// <returns>错误代码</returns> public int Get_S_ProFile(AxisInfo axisInfo, bool isShowLog) { int iRtn = (int)Dmc2C80.d2c80_get_s_profile(axisInfo.AxisNumber, ref axisInfo.mS_Para); Log.GetInstance().ActionWrite(string.Format("获取[{0}]轴的S形曲线运动和S段比[{1}]", axisInfo.AxisName, axisInfo.S_Para), ((ErrorMsg)iRtn).ToString(), isShowLog); return(iRtn); }
public UserVCRAxisWorkPosConfig(AxisInfo axisInfoX, AxisInfo axisInfoZ, int workNumber) { InitializeComponent(); this.axisInfoX = axisInfoX; this.axisInfoZ = axisInfoZ; this.WorkNumber = workNumber; }
/// <summary> /// 同步停止所有轴 /// </summary> /// <param name="axisInfo"></param> /// <param name="isShowLog">是否显示日志到UI</param> /// <returns>错误代码</returns> public int SimultaneousStop(AxisInfo axisInfo, bool isShowLog) { int iRtn = (int)Dmc2C80.d2c80_simultaneous_stop(axisInfo.AxisNumber); Log.GetInstance().ActionWrite(string.Format("[{0}]轴同步停止", axisInfo.AxisName), ((ErrorMsg)iRtn).ToString(), isShowLog); return(iRtn); }
/// <summary> /// 获取T形速度曲线运动模式 /// </summary> /// <param name="axisInfo"></param> /// <param name="isShowLog">是否显示日志到UI</param> /// <returns>错误代码</returns> public int Get_T_ProFile(AxisInfo axisInfo, bool isShowLog) { int iRtn = (int)Dmc2C80.d2c80_get_profile(axisInfo.AxisNumber, ref axisInfo.mMinVel, ref axisInfo.mMaxVel, ref axisInfo.mAcc, ref axisInfo.mDec); Log.GetInstance().ActionWrite(string.Format("获取[{0}]轴的起始速度[{1}]、运行速度[{2}]、加速度[{3}]、减速度[{4}]", axisInfo.AxisName, axisInfo.MinVel, axisInfo.MaxVel, axisInfo.Acc, axisInfo.Dec), ((ErrorMsg)iRtn).ToString(), isShowLog); return(iRtn); }
/// <summary> /// 获取指定轴的脉冲输出模式 /// </summary> /// <param name="axisInfo"></param> /// <param name="isShowLog">是否显示日志到UI</param> /// <returns>错误码</returns> public override int GetPulseOutmode(AxisInfo axisInfo, bool isShowLog) { int iRtn = (int)Dmc2C80.d2c80_get_pulse_outmode(axisInfo.AxisNumber, ref axisInfo.mOutmode); Log.GetInstance().ActionWrite(string.Format("获取[{0}]轴的脉冲输出模式[{1}]", axisInfo.AxisNumber, axisInfo.Outmode), ((ErrorMsg)iRtn).ToString(), isShowLog); return(iRtn); }
/// <summary> /// 获取指定轴编码器的计数方式 /// </summary> /// <param name="axisInfo"></param> /// <param name="isShowLog">是否显示日志到UI</param> /// <returns>错误代码</returns> public override int GetCounterConfig(AxisInfo axisInfo, bool isShowLog) { int iRtn = (int)Dmc2C80.d2c80_get_counter_config(axisInfo.AxisNumber, ref axisInfo.mMode); Log.GetInstance().ActionWrite(string.Format("获取[{0}]轴的编码器计算方式[{1}]", axisInfo.AxisName, axisInfo.Mode), ((ErrorMsg)iRtn).ToString(), isShowLog); return(iRtn); }
/// <summary> /// 设置指定轴的指令脉冲位置 /// </summary> /// <param name="axisInfo"></param> /// <param name="isShowLog">是否显示日志到UI</param> /// <returns>错误代码</returns> public override int SetPosition(AxisInfo axisInfo, bool isShowLog) { int iRtn = (int)Dmc2C80.d2c80_set_position(axisInfo.AxisNumber, axisInfo.CurrentPosition); Log.GetInstance().ActionWrite(string.Format("设置[{0}]轴的指令脉冲位置为[{1}]", axisInfo.AxisName, axisInfo.CurrentPosition), ((ErrorMsg)0).ToString(), isShowLog); return(iRtn); }
/// <summary> /// 定长运动 /// </summary> /// <param name="axisInfo"></param> /// <param name="isShowLog">是否显示日志到UI</param> /// <returns>错误代码</returns> public override int Pmove(AxisInfo axisInfo, bool isShowLog) { int iRtn = (int)Dmc2C80.d2c80_pmove(axisInfo.AxisNumber, axisInfo.Dist, axisInfo.PosiMode); Log.GetInstance().ActionWrite(string.Format("[{0}]轴定长运动距离[{1}]", axisInfo.AxisName, axisInfo.Dist), ((ErrorMsg)iRtn).ToString(), isShowLog); return(iRtn); }
/// <summary> /// 设置ORG信号的有效电平 /// </summary> /// <param name="axisInfo"></param> /// <param name="isShowLog">是否显示日志到UI</param> /// <returns>错误代码</returns> public override int SetConfigHomePinLogic(AxisInfo axisInfo, bool isShowLog) { int iRtn = (int)Dmc2C80.d2c80_config_HOME_PIN_logic(axisInfo.AxisNumber, axisInfo.OrgLogic, 1); Log.GetInstance().ActionWrite(string.Format("设置[{0}]轴ORG信号的有效电平", axisInfo.AxisName), ((ErrorMsg)iRtn).ToString(), isShowLog); return(iRtn); }
/// <summary> /// 获取软件限位 /// </summary> /// <param name="axisInfo"></param> /// <param name="isShowLog">是否显示日志到UI</param> /// <returns>错误代码</returns> public override int GetConfigSoftlimit(AxisInfo axisInfo, bool isShowLog) { int iRtn = (int)Dmc2C80.d2c80_get_config_softlimit(axisInfo.AxisNumber, ref axisInfo.mON_OFF, ref axisInfo.mSourceSel, ref axisInfo.mSLAction, ref axisInfo.mNLimit, ref axisInfo.mPLimit); Log.GetInstance().ActionWrite(string.Format("获取[{0}]轴软件限位", axisInfo.AxisName), ((ErrorMsg)iRtn).ToString(), isShowLog); return(iRtn); }
public UserAxisWorkPosConfig(AxisInfo axisInfo, int workNumber) { InitializeComponent(); this.axisInfo = axisInfo; this.AxisName = axisInfo.AxisName; this.WorkNumber = workNumber; }
/// <summary> /// 设置指定轴的EZ信号的有效电平及其作用 /// </summary> /// <param name="isShowLog">是否显示日志到UI</param> /// <returns>错误代码</returns> public override int SetConfigEzPin(AxisInfo axisInfo, bool isShowLog) { int iRtn = (int)Dmc2C80.d2c80_config_EZ_PIN(axisInfo.AxisNumber, axisInfo.EzLogic, axisInfo.EzMode); Log.GetInstance().ActionWrite(string.Format("设置[{0}]轴的EZ信号的有效电平及其方式", axisInfo.AxisName), ((ErrorMsg)iRtn).ToString(), isShowLog); return(iRtn); }
/// <summary> /// 获取回原点模式 /// </summary> /// <param name="axisInfo"></param> /// <param name="isShowLog">是否显示日志到UI</param> /// <returns>错误代码</returns> public override int GetConfigHomeMode(AxisInfo axisInfo, bool isShowLog) { int iRtn = (int)Dmc2C80.d2c80_get_config_home_mode(axisInfo.AxisNumber, ref axisInfo.mHomeDir, ref axisInfo.mVel, ref axisInfo.mHomeMode, ref axisInfo.mEZCount); Log.GetInstance().ActionWrite(string.Format("获取[{0}]轴回原点模式", axisInfo.AxisName), ((ErrorMsg)iRtn).ToString(), isShowLog); return(iRtn); }
/// <summary> /// 指定轴减速停止 /// </summary> /// <param name="axisInfo"></param> /// <param name="isShowLog">是否显示日志到UI</param> /// <returns>错误码</returns> public int DecelStop(AxisInfo axisInfo, bool isShowLog) { int iRtn = (int)Dmc2C80.d2c80_decel_stop(axisInfo.AxisNumber, axisInfo.Dec); Log.GetInstance().ActionWrite(string.Format("[{0}]轴减速停止", axisInfo.AxisName), ((ErrorMsg)iRtn).ToString(), isShowLog); return(iRtn); }
/// <summary> /// 定长运动 /// </summary> /// <param name="axisinfo">轴实体</param> /// <param name="moveType">运动方向</param> public void Pmove(AxisInfo axisInfo, string moveType) { //气缸上 var fRtn = MoveExecute.SetBaffle(true); if (!fRtn) { return; } switch (moveType) { case "正": { //设置移动距离 axisInfo.Dist = Convert.ToInt32(Convert.ToInt32(txtDistance.Text) * axisInfo.Step / axisInfo.Lead); if (Global.ControlCard.GetPosition(axisInfo, true) + axisInfo.Dist > axisInfo.Step) { Log.GetInstance().WarningWrite(string.Format("[{0}]轴移动距离超出了物理正极限,自动移动到极限位置")); this.txtDistance.Text = (axisInfo.Lead / (axisInfo.Step / (axisInfo.Step - Global.ControlCard.GetPosition(axisInfo, true)))).ToString("f0"); axisInfo.Dist = Convert.ToInt32(Convert.ToInt32(txtDistance.Text) * axisInfo.Step / axisInfo.Lead); } break; } case "负": { //设置移动距离 axisInfo.Dist = Convert.ToInt32(Convert.ToInt32(txtDistance.Text) * axisInfo.Step / axisInfo.Lead * -1); if (Global.ControlCard.GetPosition(axisInfo, true) - axisInfo.Dist < 0) { Log.GetInstance().WarningWrite(string.Format("[{0}]轴移动距离超出了物理负极限,自动移动到极限位置")); txtDistance.Text = (axisInfo.Lead / (axisInfo.Step / Global.ControlCard.GetPosition(axisInfo, true))).ToString("f0"); axisInfo.Dist = Convert.ToInt32(Convert.ToInt32(txtDistance.Text) * axisInfo.Step / axisInfo.Lead * -1); } break; } default: { return; } } axisInfo.PosiMode = 0; MoveExecute.Pmove(axisInfo, true); //获取当前位置 this.txtCurrentPosition.Text = (axisInfo.Lead / (axisInfo.Step / Global.ControlCard.GetPosition(axisInfo, true))).ToString("f0"); }
/// <summary> /// 在线改变指定轴的当前运动速度。该函数只适用于单轴运动中的变速 /// </summary> /// <param name="axisInfo"></param> /// <param name="isShowLog">是否显示日志到UI</param> /// <returns>错误代码</returns> public override int ChangeSpeed(AxisInfo axisInfo, bool isShowLog) { int iRtn = (int)Dmc2C80.d2c80_change_speed(axisInfo.AxisNumber, axisInfo.CurrVel); Log.GetInstance().ActionWrite(string.Format("修改[{0}]轴的当前运动速度为[{1}]", axisInfo.AxisName , axisInfo.CurrVel), ((ErrorMsg)iRtn).ToString(), isShowLog); return(iRtn); }
/// <summary> /// 回原点运动 /// </summary> /// <param name="axisInfo"></param> /// <param name="isShowLog">是否显示日志到UI</param> /// <returns>错误代码</returns> public override int HomeMove(AxisInfo axisInfo, bool isShowLog) { int iRtn = (int)Dmc2C80.d2c80_home_move(axisInfo.AxisNumber); axisInfo.IsHome = iRtn == 0 ? true : false; Log.GetInstance().ActionWrite(string.Format("[{0}]轴回原点运动", axisInfo.AxisName), ((ErrorMsg)iRtn).ToString(), isShowLog); return(iRtn); }
/// <summary> /// 检测指定轴的运动状态 /// </summary> /// <param name="axisInfo"></param> /// <param name="isShowLog">是否显示日志到UI</param> /// <returns> 0运行,1停止</returns> public override int CheckDone(AxisInfo axisInfo, bool isShowLog) { int iRtn = (int)Dmc2C80.d2c80_check_done(axisInfo.AxisNumber); axisInfo.IsMove = iRtn == 0 ? true : false; Log.GetInstance().ActionWrite(string.Format("获取[{0}]轴运动状态{1}", axisInfo.AxisName, iRtn == 0 ? "正在运动" : "停止运动"), ((ErrorMsg)0).ToString(), isShowLog); return(iRtn); }
/// <summary> /// 获取指定轴的当前速度 /// </summary> /// <param name="axisInfo"></param> /// <param name="isShowLog">是否显示日志到UI</param> /// <returns>指定轴的速度脉冲数</returns> public override double ReadCurrentSpeed(AxisInfo axisInfo, bool isShowLog) { double dRtn = Dmc2C80.d2c80_read_current_speed(axisInfo.AxisNumber); axisInfo.CurrVel = dRtn; Log.GetInstance().ActionWrite(string.Format("获取[{0}]轴的当前速度[{1}] ", axisInfo.AxisNumber, dRtn), ((ErrorMsg)0).ToString(), isShowLog); return(dRtn); }
private void Timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { this.timerReset.Stop(); var f = MoveExecute.AllAxisReset(); AxisInfo axisInfo = Global.ListAxis.Where(info => info.AxisName == "转盘").FirstOrDefault(); if (axisInfo != null) { this.currentWorkPos = axisInfo.WorkPos1; } }
/// <summary> /// 获取速度曲线运动模式 /// </summary> /// <param name="axisInfo"></param> /// <param name="proFileType"></param> /// <param name="isShowLog">是否显示日志到UI</param> /// <returns>错误代码</returns> public override int GetProFile(AxisInfo axisInfo, ProFileType proFileType, bool isShowLog) { int iRtn = 0; if (proFileType == ProFileType.T) { iRtn = this.Get_T_ProFile(axisInfo, isShowLog); } else if (proFileType == ProFileType.S) { iRtn = this.Get_S_ProFile(axisInfo, isShowLog); } return(iRtn); }
/// <summary> /// 停止轴运动 /// </summary> /// <param name="axisInfo"></param> /// <param name="axisStopType"></param> /// <param name="isShowLog">是否显示日志到UI</param> /// <returns>错误代码</returns> public override int AxisStop(AxisInfo axisInfo, AxisStopType axisStopType, bool isShowLog) { int iRtn = 0; if (axisStopType == AxisStopType.DecelStop) { iRtn = this.DecelStop(axisInfo, isShowLog); } else if (axisStopType == AxisStopType.SimultaneousStop) { iRtn = this.SimultaneousStop(axisInfo, isShowLog); } else if (axisStopType == AxisStopType.ImdStop) { iRtn = this.ImdStop(axisInfo, isShowLog); } else if (axisStopType == AxisStopType.EmgStop) { iRtn = this.EmgStop(isShowLog); } return(iRtn); }
/// <summary> /// 获取指定轴的指令脉冲位置 /// </summary> /// <param name="axisInfo"></param> /// <param name="isShowLog">是否显示日志到UI</param> /// <returns>指定运动轴的命令脉冲数</returns> public virtual int GetPosition(AxisInfo axisInfo, bool isShowLog) { throw new System.NotImplementedException(); }
/// <summary> /// 获取回原点模式 /// </summary> /// <param name="axisInfo"></param> /// <param name="isShowLog">是否显示日志到UI</param> /// <returns>错误代码</returns> public virtual int GetConfigHomeMode(AxisInfo axisInfo, bool isShowLog) { throw new System.NotImplementedException(); }
/// <summary> /// 检测指定轴的运动状态 /// </summary> /// <param name="axisInfo"></param> /// <param name="isShowLog">是否显示日志到UI</param> /// <returns>0运行,1停止</returns> public virtual int CheckDone(AxisInfo axisInfo, bool isShowLog) { throw new System.NotImplementedException(); }
/// <summary> /// 加载项目配置信息 /// </summary> /// <returns></returns> public static bool LoadSettings(string productName) { try { if (!System.IO.File.Exists(Global.ProductSettingPath)) { Log.GetInstance().ErrorWrite(string.Format("项目:'{0}'没有配置文件,路径:'{1}'", productName, Global.ProductSettingPath)); return(false); } //初始化时,添加轴信息 if (Global.ListAxis.Count == 0) { AxisInfo axisInfo = null; foreach (var kvp in Global.DictAxis) { axisInfo = new AxisInfo(); axisInfo.AxisName = kvp.Value; axisInfo.AxisNumber = (ushort)Convert.ToInt32(kvp.Key); axisInfo.Step = Convert.ToInt32(IniFile.IniReadValue(axisInfo.AxisName, "Step", Global.ProductSettingPath)); axisInfo.Lead = Convert.ToInt32(IniFile.IniReadValue(axisInfo.AxisName, "Lead", Global.ProductSettingPath)); axisInfo.MinVel = Convert.ToInt32(IniFile.IniReadValue(axisInfo.AxisName, "Speed", Global.ProductSettingPath)); axisInfo.MaxLimit = Convert.ToInt32(IniFile.IniReadValue(axisInfo.AxisName, "MaxLimitmm", Global.ProductSettingPath)); axisInfo.WorkPos1 = Convert.ToInt32(IniFile.IniReadValue(axisInfo.AxisName, "WorkPos1", Global.ProductSettingPath)); axisInfo.WorkPos2 = Convert.ToInt32(IniFile.IniReadValue(axisInfo.AxisName, "WorkPos2", Global.ProductSettingPath)); axisInfo.WorkPos3 = Convert.ToInt32(IniFile.IniReadValue(axisInfo.AxisName, "WorkPos3", Global.ProductSettingPath)); axisInfo.WorkPos4 = Convert.ToInt32(IniFile.IniReadValue(axisInfo.AxisName, "WorkPos4", Global.ProductSettingPath)); axisInfo.MaxVel = axisInfo.MinVel * 10; axisInfo.Dec = 10000; axisInfo.Acc = 10000; axisInfo.Vel = axisInfo.MaxVel; axisInfo.Outmode = 0; axisInfo.OrgLogic = 0; axisInfo.EzLogic = 0; axisInfo.EzMode = 1; axisInfo.HomeDir = 1; axisInfo.Vel = 0; axisInfo.HomeMode = 1; axisInfo.EZCount = 1; axisInfo.PosiMode = 0; Global.ListAxis.Add(axisInfo); } } //切换项目时,修改轴信息 else { foreach (var axisInfo in Global.ListAxis) { axisInfo.Step = Convert.ToInt32(IniFile.IniReadValue(axisInfo.AxisName, "Step", Global.ProductSettingPath)); axisInfo.Lead = Convert.ToInt32(IniFile.IniReadValue(axisInfo.AxisName, "Lead", Global.ProductSettingPath)); axisInfo.MinVel = Convert.ToInt32(IniFile.IniReadValue(axisInfo.AxisName, "Speed", Global.ProductSettingPath)); axisInfo.MaxLimit = Convert.ToInt32(IniFile.IniReadValue(axisInfo.AxisName, "MaxLimitmm", Global.ProductSettingPath)); axisInfo.WorkPos1 = Convert.ToInt32(IniFile.IniReadValue(axisInfo.AxisName, "WorkPos1", Global.ProductSettingPath)); axisInfo.WorkPos2 = Convert.ToInt32(IniFile.IniReadValue(axisInfo.AxisName, "WorkPos2", Global.ProductSettingPath)); axisInfo.WorkPos3 = Convert.ToInt32(IniFile.IniReadValue(axisInfo.AxisName, "WorkPos3", Global.ProductSettingPath)); axisInfo.WorkPos4 = Convert.ToInt32(IniFile.IniReadValue(axisInfo.AxisName, "WorkPos4", Global.ProductSettingPath)); axisInfo.MaxVel = axisInfo.MinVel * 10; axisInfo.Dec = 10000; axisInfo.Acc = 10000; axisInfo.Vel = axisInfo.MaxVel; axisInfo.Outmode = 0; axisInfo.OrgLogic = 0; axisInfo.EzLogic = 0; axisInfo.EzMode = 1; axisInfo.HomeDir = 1; axisInfo.Vel = 0; axisInfo.HomeMode = 1; axisInfo.EZCount = 1; axisInfo.PosiMode = 0; } } return(true); } catch (Exception ex) { Log.WriterExceptionLog(ex.ToString()); return(false); } }
/// <summary> /// 轴定长运动 /// </summary> /// <param name="axisInfo"></param> /// <param name="isShowLog"></param> /// <returns></returns> public static bool Pmove(AxisInfo axisInfo, bool isShowLog) { try { if (isShowLog) { Log.GetInstance().NormalWrite(string.Format("[{0}]轴开始定长运动......", axisInfo.AxisName)); } axisInfo.Outmode = 0; //设置脉冲输出模式 int iRtn = Global.ControlCard.SetPulseOutmode(axisInfo, isShowLog); if (iRtn != 0) { return(false); } //设置运动模式 iRtn = Global.ControlCard.SetProFile(axisInfo, ProFileType.T, isShowLog); if (iRtn != 0) { return(false); } //定长运动 iRtn = Global.ControlCard.Pmove(axisInfo, isShowLog); if (iRtn != 0) { return(false); } int waitTime = 0; //检查是否移动到位 while (true) { if (waitTime == Global.CardWaitTime) { //报警提示 Global.ControlCard.WriteOutbit(28, 1); //亮红灯 Global.ControlCard.WriteOutbit((ushort)Global.GetIOPortNoByName("红灯"), 1); Log.GetInstance().WarningWrite(string.Format("[{0}]轴定长运动超时", axisInfo.AxisName)); Log.GetInstance().WarningWrite(string.Format("[{0}]轴强制停止运动,需复位后重新开始检测", axisInfo.AxisName)); //停止轴运动 Global.ControlCard.AxisStop(axisInfo, AxisStopType.ImdStop, isShowLog); return(false); } if (axisInfo.AxisName == "转盘") { //轴停止并且收到运动到位指令 if (Global.ControlCard.CheckDone(axisInfo, isShowLog) == 1 && Global.IoCard.ReadInBit(24) == 1) { return(true); } } else if (axisInfo.AxisName == "VCR-X") { if (Global.ControlCard.CheckDone(axisInfo, isShowLog) == 1 && Global.IoCard.ReadInBit(25) == 1) { return(true); } } else if (axisInfo.AxisName == "VCR-Z") { if (Global.ControlCard.CheckDone(axisInfo, isShowLog) == 1 && Global.IoCard.ReadInBit(26) == 1) { return(true); } } else if (axisInfo.AxisName == "检测相机#1") { if (Global.ControlCard.CheckDone(axisInfo, isShowLog) == 1 && Global.IoCard.ReadInBit(27) == 1) { return(true); } } else if (axisInfo.AxisName == "检测相机#2") { if (Global.ControlCard.CheckDone(axisInfo, isShowLog) == 1 && Global.IoCard.ReadInBit(28) == 1) { return(true); } } else if (axisInfo.AxisName == "检测相机#3") { if (Global.ControlCard.CheckDone(axisInfo, isShowLog) == 1 && Global.IoCard.ReadInBit(29) == 1) { return(true); } } else if (axisInfo.AxisName == "复检相机#1") { if (Global.ControlCard.CheckDone(axisInfo, isShowLog) == 1 && Global.IoCard.ReadInBit(30) == 1) { return(true); } } else if (axisInfo.AxisName == "复检相机#2") { if (Global.ControlCard.CheckDone(axisInfo, isShowLog) == 1 && Global.IoCard.ReadInBit(31) == 1) { return(true); } } else if (axisInfo.AxisName == "复检相机#3") { if (Global.ControlCard.CheckDone(axisInfo, isShowLog) == 1 && Global.IoCard.ReadInBit(32) == 1) { return(true); } } waitTime++; Thread.Sleep(1000); } } catch (Exception ex) { Log.WriterExceptionLog(ex.ToString()); return(false); } finally { if (isShowLog) { Log.GetInstance().NormalWrite(string.Format("[{0}]轴定长运动结束", axisInfo.AxisName)); } } }
/// <summary> /// 轴回原点 /// </summary> /// <param name="axisInfo"></param> /// <param name="isShowLog"></param> /// <returns></returns> public static bool HomeMove(AxisInfo axisInfo, bool isShowLog) { bool f = false; try { if (isShowLog) { Log.GetInstance().NormalWrite(string.Format("[{0}]轴开始回原点运动......", axisInfo.AxisName)); } axisInfo.Outmode = 0; axisInfo.OrgLogic = 0; axisInfo.EzLogic = 0; axisInfo.EzMode = 1; axisInfo.HomeDir = 1; axisInfo.Vel = axisInfo.MaxVel; axisInfo.HomeMode = 3; axisInfo.EZCount = 1; //设置脉冲输出模式 int iRtn = Global.ControlCard.SetPulseOutmode(axisInfo, isShowLog); if (iRtn != 0) { return(false); } //设置ORG信号的有效电平 iRtn = Global.ControlCard.SetConfigHomePinLogic(axisInfo, isShowLog); if (iRtn != 0) { return(false); } //设置指定轴的EZ信号的有效电平及其作用 iRtn = Global.ControlCard.SetConfigEzPin(axisInfo, isShowLog); if (iRtn != 0) { return(false); } //设置回原点模式 iRtn = Global.ControlCard.SetConfigHomeMode(axisInfo, isShowLog); if (iRtn != 0) { return(false); } //设置运动模式 iRtn = Global.ControlCard.SetProFile(axisInfo, ProFileType.T, isShowLog); if (iRtn != 0) { return(false); } //回原点 iRtn = Global.ControlCard.HomeMove(axisInfo, isShowLog); if (iRtn != 0) { return(false); } int waitTime = 0; //等待轴停止运动 while (true) { if (waitTime == Global.CardWaitTime) { //报警提示 Global.ControlCard.WriteOutbit(28, 1); //亮红灯 Global.ControlCard.WriteOutbit((ushort)Global.GetIOPortNoByName("红灯"), 1); Log.GetInstance().WarningWrite(string.Format("[{0}]轴回原点运动超时", axisInfo.AxisName)); Log.GetInstance().WarningWrite(string.Format("[{0}]轴强制停止运动,需复位后重新开始检测", axisInfo.AxisName)); //停止轴运动 Global.ControlCard.AxisStop(axisInfo, AxisStopType.ImdStop, isShowLog); return(false); } if (Global.ControlCard.CheckDone(axisInfo, isShowLog) == 1) { f = true; return(true); } waitTime++; Thread.Sleep(1000); } } catch (Exception ex) { Log.WriterExceptionLog(ex.ToString()); return(false); } finally { if (isShowLog) { if (f) { Log.GetInstance().NormalWrite(string.Format("[{0}]轴回原点成功,请移动到工作位置1", axisInfo.AxisName)); } else { Log.GetInstance().ErrorWrite(string.Format("[{0}]轴回原点失败,请重启设备", axisInfo.AxisName)); } Log.GetInstance().NormalWrite(string.Format("[{0}]轴回原点运动结束", axisInfo.AxisName)); } } }
/// <summary> /// 停止轴运动 /// </summary> /// <param name="axisInfo"></param> /// <param name="axisStopType"></param> /// <param name="isShowLog">是否显示日志到UI</param> /// <returns>错误代码</returns> public virtual int AxisStop(AxisInfo axisInfo, AxisStopType axisStopType, bool isShowLog) { throw new System.NotImplementedException(); }
/// <summary> /// 设置指定轴的EZ信号的有效电平及其作用 /// </summary> /// <param name="isShowLog">是否显示日志到UI</param> /// <returns>错误代码</returns> public virtual int SetConfigEzPin(AxisInfo axisInfo, bool isShowLog) { throw new System.NotImplementedException(); }