/// <summary> /// 寻找原点 多次来回寻找,如果向负方向找到返回0,向正方向找到放回1 /// </summary> /// <param name="axisC"></param> /// <returns></returns> public short MutHomeFindHomeSinge(AxisConfig axisC1, int count) { int stepPos = (int)axisC1.intFirstFindOriginDis; if (HomeFindHomeSinge(axisC1, stepPos) == 0) { if (stepPos < 0) { return(0); } else { return(1); } } if (WorkBase.IsRestExit()) { return(-1); } if (HomeFindHomeSinge(axisC1, 0 - 2 * stepPos) == 0) { if (stepPos < 0) { return(0); } else { return(1); } } return(-1); }
private short StationRunThreadStep(object o) { WorkBase wb = (WorkBase)o; wb.tag_Manual.tag_StepName = 0; return(pointMotion.StationRun(wb.tag_stationName, wb.tag_Manual)); }
public void EventHandler(object sender, EventArgs e) { TextBox tb = (TextBox)sender; WorkBase wb = (WorkBase)tb.Tag; wb.tag_sn = tb.Text; }
/// <summary> /// 工位名 /// </summary> /// <param name="name"></param> /// <param name="_manual"></param> /// <param name="reset"></param> /// <param name="start"></param> /// <param name="stop"></param> public StationTrialRunControl(object o) { tag_object = o; tag_workBase = (WorkBase)o; tag_titleName = tag_workBase.tag_stationName;; tag_manual = tag_workBase.tag_Manual; InitializeComponent(); }
/// <summary> /// 寻找原点,一次寻找pos1 , /// </summary> /// <param name="axisC"></param> /// <returns></returns> public short HomeFindHomeSinge(AxisConfig axisC, int pos1) { short shrResult = 0; bool pIo = false; int AxisState = 0; PointModule point = new PointModule(true, false, 0, axisC.Speed, axisC.Acc, axisC.Dec, axisC.tag_accTime, axisC.tag_delTime, axisC.StartSpeed, axisC.tag_S_Time, axisC.tag_StopSpeed); point.dblPonitValue = pos1; shrResult = SR_RelativeMove(axisC, point); if (shrResult != 0) { return(-1); } Thread.Sleep(10); while (true) { if (WorkBase.IsRestExit()) { SR_AxisEmgStop(axisC.CardNum, (short)(axisC.AxisNum)); return(-1); } SR_GetOriginInput(axisC.CardNum, (short)(axisC.AxisNum), out pIo); //采集原点信号 if (!axisC.tag_homeIoHighLow) //如果信号位高电平 { if (!pIo) { SR_AxisEmgStop(axisC.CardNum, (short)(axisC.AxisNum)); //停止轴 return(0); } } else { if (pIo) { SR_AxisEmgStop(axisC.CardNum, (short)(axisC.AxisNum)); return(0); } } if (SR_GetAxisStatus(axisC.CardNum, (short)(axisC.AxisNum), out AxisState) != 0) { SR_AxisEmgStop(axisC.CardNum, (short)(axisC.AxisNum)); return(-2); } if (AxisState == 0) { SR_AxisEmgStop(axisC.CardNum, (short)(axisC.AxisNum)); return(-3); } } }
/// <summary> /// IO是否安全 /// </summary> /// <returns></returns> public bool IsafeIOInit() { foreach (object o in tag_workObject) { Type t = o.GetType(); WorkBase workBase = (WorkBase)o; workBase.tag_Manual.tag_ExePointAggregate = null; Global.WorkVar.tag_ExePointAggregate = null; } return(true); }
/// <summary> ///启动列表 /// </summary> public void startList() { foreach (object o in tag_workObject) { Type t = o.GetType(); System.Reflection.MethodInfo[] methods = t.GetMethods(); System.Reflection.PropertyInfo[] PropertyInfo = t.GetProperties(); System.Reflection.MemberInfo[] MemberInfos = t.GetMembers(); WorkBase workBase = (WorkBase)o; for (int i = 0; i < methods.Length; i++) { if (methods[i].Name == "StartThread") { if (workBase.tag_isRestStation == 0) { workBase.tag_IsWork = 0; workBase.tag_Manual.tag_StepName = 0; methods[i].Invoke(o, null); } } } } //Rc rc = Rc.Ok; //rc = (Rc)NativeMethods.LJV7IF_Initialize(); //if (rc != Rc.Ok) //{ // LogOutControl.OutLog("测量仪初始化失败", 0); //} try { _ethernetConfig.abyIpAddress = new byte[] { Convert.ToByte("192"), Convert.ToByte("168"), Convert.ToByte("1"), Convert.ToByte("111") }; _ethernetConfig.wPortNo = Convert.ToUInt16("10000"); } catch (Exception ex) { LogOutControl.OutLog(ex.Message, 0); return; } //rc = (Rc)NativeMethods.LJV7IF_EthernetOpen(0, ref _ethernetConfig); //if (rc != Rc.Ok) //{ // LogOutControl.OutLog("与测量仪连接失败", 0); //} }
/// <summary> /// 复位是否陈宫0:不成功 1 成功 /// </summary> public int restIsSuccess() { foreach (object o in tag_Work.tag_workObject) { WorkBase workBase = (WorkBase)o; if (tag_IsWork != 0) { return(0); } } return(1); }
/// <summary> /// 复位是否完成 0:未完成 1 完成 /// </summary> public int restIsComplete() { foreach (object o in tag_Work.tag_workObject) { WorkBase workBase = (WorkBase)o; if (workBase.tag_isRestStation == 1) { if (workBase.tag_IsWork == 1) { return(0); } } } return(1); }
/// <summary> /// 停止所有线程 /// </summary> /// <returns></returns> public bool threadStop() { foreach (object o in tag_workObject) { Type t = o.GetType(); System.Reflection.MethodInfo[] methods = t.GetMethods(); System.Reflection.PropertyInfo[] PropertyInfo = t.GetProperties(); System.Reflection.MemberInfo[] MemberInfos = t.GetMembers(); WorkBase workBase = (WorkBase)o; if (workBase.tag_workThread != null && workBase.tag_workThread.IsAlive) { workBase.tag_workThread.Abort(); } } return(true); }
public bool IsWork() { foreach (object o in tag_workObject) { Type t = o.GetType(); System.Reflection.MethodInfo[] methods = t.GetMethods(); System.Reflection.PropertyInfo[] PropertyInfo = t.GetProperties(); System.Reflection.MemberInfo[] MemberInfos = t.GetMembers(); WorkBase workBase = (WorkBase)o; if (workBase.tag_IsWork == 1) { LogOutControl.OutLog(workBase.tag_stationName + ":工位正在工作", 0); return(true); } } return(false); }
/// <summary> ///启动列表 /// </summary> public void startWorkInit(int isrest, int j) { foreach (object o in tag_Work.tag_workObject) { Type t = o.GetType(); System.Reflection.MethodInfo[] methods = t.GetMethods(); System.Reflection.PropertyInfo[] PropertyInfo = t.GetProperties(); System.Reflection.MemberInfo[] MemberInfos = t.GetMembers(); WorkBase workBase = (WorkBase)o; for (int i = 0; i < methods.Length; i++) { if (workBase.tag_isRestStation == isrest) { workBase.tag_IsWork = j; } } } }
/// <summary> /// 继续函数 /// </summary> /// <param name="o"></param> /// <returns></returns> public object GetStation(string stationname) { foreach (object o in tag_workObject) { Type t = o.GetType(); System.Reflection.MethodInfo[] methods = t.GetMethods(); System.Reflection.PropertyInfo[] PropertyInfo = t.GetProperties(); System.Reflection.MemberInfo[] MemberInfos = t.GetMembers(); WorkBase workBase = (WorkBase)o; for (int i = 0; i < methods.Length; i++) { if (workBase.tag_stationName == stationname) { return(workBase); } } } return(null); }
/// <summary> /// 运行第二段距离 /// </summary> /// <param name="axisC"></param> /// <returns></returns> public short HomeMoveTwoDis(AxisConfig axisC) { short shrResult = 0; int AxisState = 0; PointModule point = new PointModule(true, false, 0, axisC.Speed, axisC.Acc, axisC.Dec, axisC.tag_accTime, axisC.tag_delTime, axisC.StartSpeed, axisC.tag_S_Time, axisC.tag_StopSpeed); point.dblPonitValue = axisC.intSecondFindOriginDis; if (axisC.HomeDir == 0) { point.dblPonitValue = 0 - point.dblPonitValue; } shrResult = SR_RelativeMove(axisC, point); //单轴的相对运动 if (shrResult != 0) { return(-1); } if (point.dblPonitValue == 0) { return(-1); } Thread.Sleep(10); while (true) { if (WorkBase.IsRestExit()) { SR_AxisEmgStop(axisC.CardNum, (short)(axisC.AxisNum)); return(-1); } if (SR_GetAxisStatus(axisC.CardNum, (short)(axisC.AxisNum), out AxisState) != 0) { SR_AxisEmgStop(axisC.CardNum, (short)(axisC.AxisNum)); return(1); } if (AxisState == 0) { SR_AxisEmgStop(axisC.CardNum, (short)(axisC.AxisNum)); return(0); } } }
public void ModeSelectControl_Load(object sender, EventArgs e) { if (tag_Work == null) { return; } int x = checkBox_SnEm.Location.X + checkBox_SnEm.Size.Width + 5; int y = (this.Size.Height - checkBox_PDCA.Size.Height) / 2; checkBox_PDCA.Location = new Point(checkBox_PDCA.Location.X, y); checkBox_SnEm.Location = new Point(checkBox_SnEm.Location.X, y); int i = 0; foreach (object o in tag_Work.tag_workObject) { WorkBase wb = (WorkBase)o; if (wb.tag_isRestStation == 0) { TextBox tb = new TextBox(); Label lab = new Label(); lab.Name = wb.tag_stationName + "SN"; lab.Text = wb.tag_stationName + "SN"; y = (this.Size.Height - tb.Size.Height) / 2 + 5; lab.Location = new Point(x, y); x = x + 60; tb.Tag = wb; tb.TextChanged += EventHandler; y = (this.Size.Height - tb.Size.Height) / 2; tb.Location = new Point(x, y); tb.Name = wb.tag_stationName; tb.Text = "" /*"SN123456789" + tag_snIndex*/; tag_snIndex++; x = x + 100; tag_listObj.Add(tb); this.Controls.Add(tb); this.Controls.Add(lab); } } timer1.Start(); }
private void timer1_Tick(object sender, EventArgs e) { if (checkBox_PDCA.Checked) { foreach (TextBox tb in tag_listObj) { WorkBase wb = (WorkBase)tb.Tag; if (wb.tag_sn == null || wb.tag_sn == "") { //tb.Text = wb.tag_PDCA.GetSn(); } } } else { foreach (TextBox tb in tag_listObj) { WorkBase wb = (WorkBase)tb.Tag; tb.Text = wb.tag_sn; } } }
public short SR_GoHome(AxisConfig _acf) { if (HomeFindLimit(_acf) == 0) { if (WorkBase.IsRestExit()) { return(-1); } Thread.Sleep(1000); if (HomeMoveTwoDis(_acf) == 0) { if (WorkBase.IsRestExit()) { return(-1); } return(HomeFindHomeIO(_acf)); } } return(-5); }
/// <summary> ///启动列表 /// </summary> public void startList() { foreach (object o in tag_Work.tag_workObject) { Type t = o.GetType(); System.Reflection.MethodInfo[] methods = t.GetMethods(); System.Reflection.PropertyInfo[] PropertyInfo = t.GetProperties(); System.Reflection.MemberInfo[] MemberInfos = t.GetMembers(); WorkBase workBase = (WorkBase)o; for (int i = 0; i < methods.Length; i++) { if (methods[i].Name == "StartThread") { if (workBase.tag_isRestStation == 1) { workBase.tag_IsWork = 1; workBase.tag_Manual.tag_StepName = 0; methods[i].Invoke(o, null); } } } } }
// /// <summary> /// 单原点回原,如果第一次找不到原点即失败,第一段距离位寻找距离,第二段距离为反退距离。,第三段距离为反退距离+感应器的长度 /// </summary> /// <param name="_acf"></param> /// <returns></returns> public short SR_GoOneHome(AxisConfig _acf) { short ret = MutHomeFindHomeSinge(_acf, 16); if (ret >= 0) { if (WorkBase.IsRestExit()) { return(-1); } Thread.Sleep(1000); if (HomeMoveTwoDis(_acf) == 0) { if (WorkBase.IsRestExit()) { return(-1); } Thread.Sleep(1000); return(HomeFindOneHomeIO(_acf)); } } return(-5); }
/// <summary> /// 安全光栅是否OK /// </summary> /// <returns></returns> public bool IsafeLightOk() { //return true; if (_Config.tag_PrivateSave.tag_safeLightOffOn) { return(true); } if (_Config.tag_PrivateSave.tag_safeGateOffOn) { return(true); } foreach (object o in tag_workObject) { Type t = o.GetType(); WorkBase workBase = (WorkBase)o; if (workBase.tag_safe != null && !workBase.tag_safe(workBase)) { LogOutControl.OutLog(workBase.tag_stationName + "触发安全光栅或门限触发,急停", 0); return(false); } } return(true); }
private void StationModelPanelControl_Load(object sender, EventArgs e) { int offsetH = 0; StationTrialRunControl _stepTrialRun = null; if (tag_Work == null) { return; } foreach (object o in tag_Work.tag_workObject) { WorkBase wb = (WorkBase)o; if (o == null) { return; } _stepTrialRun = new StationTrialRunControl(o); this.Controls.Add(_stepTrialRun); _stepTrialRun.Location = new Point(0, offsetH); offsetH = _stepTrialRun.Size.Height + offsetH; } }
public short HomeFindOneHomeIO(AxisConfig axisC) { short shrResult = 0; bool pIo = false; int AxisState = 0; PointModule point = new PointModule(true, false, 0, axisC.HomeSpeed, axisC.Acc, axisC.Dec, axisC.tag_accTime, axisC.tag_delTime, axisC.StartSpeed, axisC.tag_S_Time, axisC.tag_StopSpeed); point.dblPonitValue = axisC.intThreeFindOriginDis; shrResult = SR_RelativeMove(axisC, point); if (shrResult != 0) { return(-1); } while (true) { if (WorkBase.IsRestExit()) { SR_AxisEmgStop(axisC.CardNum, (short)(axisC.AxisNum)); return(-1); } SR_GetOriginInput(axisC.CardNum, (short)(axisC.AxisNum), out pIo); if (axisC.tag_homeIoHighLow) { if (pIo) { SR_AxisEmgStop(axisC.CardNum, (short)(axisC.AxisNum)); shrResult = 0; break; } } else { if (!pIo) { SR_AxisEmgStop(axisC.CardNum, (short)(axisC.AxisNum)); shrResult = 0; break; } } if (SR_GetAxisStatus(axisC.CardNum, (short)(axisC.AxisNum), out AxisState) != 0) { SR_AxisEmgStop(axisC.CardNum, (short)(axisC.AxisNum)); return(1); } if (AxisState == 0) { SR_AxisEmgStop(axisC.CardNum, (short)(axisC.AxisNum)); return(3); } Thread.Sleep(1); } SR_AxisEmgStop(axisC.CardNum, (short)(axisC.AxisNum)); Thread.Sleep(1000); int countzeor = 30; while (countzeor >= 0) { if (WorkBase.IsRestExit()) { SR_AxisEmgStop(axisC.CardNum, (short)(axisC.AxisNum)); return(-1); } int status = 0; short r = SR_GetAxisStatus(axisC.CardNum, (short)(axisC.AxisNum), out status); if (r != 0) { return(-1); } if (status == 0) { break; } } while (countzeor >= 0) { double pos = 0; double Enc = 0; Thread.Sleep(1000); SR_GetPrfPos(axisC.CardNum, (short)(axisC.AxisNum), ref pos); SR_GetEncPos(axisC.CardNum, (short)(axisC.AxisNum), ref Enc); SR_SetPrfPos(axisC.CardNum, (short)(axisC.AxisNum), 0); SR_SetEncPos(axisC.CardNum, (short)(axisC.AxisNum), 0); SR_GetPrfPos(axisC.CardNum, (short)(axisC.AxisNum), ref pos); SR_GetEncPos(axisC.CardNum, (short)(axisC.AxisNum), ref Enc); if (pos < 5 && pos > -5 && Enc < 5 && Enc > -5) { return(0); } countzeor--; Thread.Sleep(10); } if (countzeor >= 0) { return(0); } return(-1); }
/// <summary> /// /// </summary> /// <param name="axisC"></param> /// <returns></returns> public short HomeFindLimit(AxisConfig axisC) { short shrResult = 0; bool pIo = false; int AxisState = 0; PointModule point = new PointModule(true, false, 0, axisC.Speed, axisC.Acc, axisC.Dec, axisC.tag_accTime, axisC.tag_delTime, axisC.StartSpeed, axisC.tag_S_Time, axisC.tag_StopSpeed); if (axisC.HomeDir == 1) //回零方向,默认为0 { point.dblPonitValue = 0 - axisC.intFirstFindOriginDis; //第一次找原点距离 } else { point.dblPonitValue = axisC.intFirstFindOriginDis; } if (axisC.HomeDir == 0) { SR_GetLimitPInput(axisC.CardNum, (short)(axisC.AxisNum), out pIo); //获取正限输入状态 } else { SR_GetLimitNInput(axisC.CardNum, (short)(axisC.AxisNum), out pIo); //获取负限输入状态 } if (axisC.tag_IoLimtPNHighEnable == 0) //正负限位高电平有效 { if (!pIo) { SR_AxisEmgStop(axisC.CardNum, (short)(axisC.AxisNum)); return(0); } } else { if (pIo) { SR_AxisEmgStop(axisC.CardNum, (short)(axisC.AxisNum)); return(0); } } shrResult = SR_RelativeMove(axisC, point); //单轴的相对运动 if (shrResult != 0) { CommandResult("_SR_AbsoluteMove", shrResult); return(-1); } Thread.Sleep(10); while (true) { if (WorkBase.IsRestExit()) { SR_AxisEmgStop(axisC.CardNum, (short)(axisC.AxisNum)); return(-1); } if (axisC.HomeDir == 0) { SR_GetLimitPInput(axisC.CardNum, (short)(axisC.AxisNum), out pIo); } else { SR_GetLimitNInput(axisC.CardNum, (short)(axisC.AxisNum), out pIo); } if (axisC.tag_IoLimtPNHighEnable == 0) { if (!pIo) { SR_AxisEmgStop(axisC.CardNum, (short)(axisC.AxisNum)); return(0); } } else { if (pIo) { SR_AxisEmgStop(axisC.CardNum, (short)(axisC.AxisNum)); return(0); } } if (SR_GetAxisStatus(axisC.CardNum, (short)(axisC.AxisNum), out AxisState) != 0) { SR_AxisEmgStop(axisC.CardNum, (short)(axisC.AxisNum)); return(1); } if (AxisState == 0) { SR_AxisEmgStop(axisC.CardNum, (short)(axisC.AxisNum)); if (axisC.HomeDir == 0) { SR_GetLimitPInput(axisC.CardNum, (short)(axisC.AxisNum), out pIo); } else { SR_GetLimitNInput(axisC.CardNum, (short)(axisC.AxisNum), out pIo); } if (axisC.tag_IoLimtPNHighEnable == 0) { if (!pIo) { SR_AxisEmgStop(axisC.CardNum, (short)(axisC.AxisNum)); return(0); } } else { if (pIo) { SR_AxisEmgStop(axisC.CardNum, (short)(axisC.AxisNum)); return(0); } } return(3); } } }