public void SystemExit() { MotionHelper.Instance.bSystemExit = true; TrackManager.Instance.TrackExit(Config.Track.ForntTrack); TrackManager.Instance.TrackExit(Config.Track.AfterTrack); Thread.Sleep(100); MotionHelper.Instance.ResetAllOuput(); Thread.Sleep(100); Axis_Advantech.CardClose(); }
private void frm_AxisConfig_Load(object sender, EventArgs e) { this.cb_CardList.Items.AddRange(Axis_Advantech.GetCard().ToArray()); this.propertyGrid1.SelectedObject = AxisDefine.Instance.MachineAxis[Module.Front]; this.propertyGrid2.SelectedObject = AxisDefine.Instance.MachineAxis[Module.After]; }
public int SystemInit() { try { if (!SystemConfig.Load()) { throw new Exception("系统配置文件"); } if (!SpeedDefine.Load()) { throw new Exception("速度配置文件"); } if (!CameraDefine.Load()) { throw new Exception("相机配置文件"); } if (!IODefine.Load()) { throw new Exception("IO配置文件"); } if (!FeederDefine.Load()) { throw new Exception("Feeder配置文件"); } if (!HardwareOrgHelper.Load()) { throw new Exception("机械校验文件"); } if (!AxisDefine.Load()) { throw new Exception("轴卡配置文件"); } } catch (Exception ex) { return(Error.Invoke(new SystemErrorEventArg { Error = $"加载参数失败:[{ex.Message}]!!!" })); } bool rtn = MotionHelper.Instance.InitCard(PathDefine.sPathCard); if (!rtn) { return(Error.Invoke(new SystemErrorEventArg { Error = "轴卡初始化失败!!!" })); } Task <string> result = Task <string> .Factory.StartNew(() => { return(CameraDefine.Instance.CameraConnected()); }); Axis_Advantech.DisableCamDO(); MotionHelper.Instance.ResetAllOuput(); MotionHelper.Instance.StartMointorIO(); Track.TrackManager.Instance.TrackInit(); Thread.Sleep(100); if (MotionHelper.Instance.bServoWarning) { return(Error.Invoke(new SystemErrorEventArg { Error = "伺服报警,请重新上电再复位!!!" })); } if (MotionHelper.Instance.bEmg) { return(Error.Invoke(new SystemErrorEventArg { Error = "急停按下,请打开急停重新上电再复位!!!" })); } // 初始化实例 for (Module module = Module.Front; module <= Module.After; ++module) { Entiys.Add(module, new MachineEntiy(module)); this.FlowMachine.Add(module, new StateMachine(module)); Module index = module; Task.Factory.StartNew(() => { IODefine.Instance.MachineIO[index].Init(); IODefine.Instance.TrackIO[(Config.Track)(index)].Init(); if (index == Module.Front) { IODefine.Instance.OtherIO.Init(); } }); } result.Wait(); if (result.Result != string.Empty) { return(Error.Invoke(new SystemErrorEventArg { Error = result.Result })); } else { MotionHelper.Instance.MachineIOMointor.Tick += Entiys[Module.Front].MachineIOMointor; MotionHelper.Instance.MachineIOMointor.Tick += Entiys[Module.After].MachineIOMointor; } return(0); }
private void Install_FormClosed(object sender, FormClosedEventArgs e) { MotionHelper.Instance.bSystemExit = true; Thread.Sleep(200); Axis_Advantech.CardClose(); }