private void Install_Load(object sender, EventArgs e) { bool rtn = MotionHelper.Instance.InitCard(PathDefine.sPathCard); if (!rtn) { MessageBox.Show("轴卡初始化失败"); } SystemConfig.Load(); MotionHelper.Instance.StartMointorIO(); SpeedDefine.Load(); // 速度配置 CameraDefine.Load(); // 相机配置 IODefine.Load(); // IO配置 AxisDefine.Load(); // 轴配置 }
private void bUpdate_Click(object sender, EventArgs e) { CameraDefine.Save(); }
private void bAutoCliab1_Click(object sender, EventArgs e) { if (fm_SoftwareCliab.FindTemp == null || fm_SoftwareCliab.FindTemp.GetInvocationList().Length <= 0) { MessageBox.Show("请打开相机轴控界面!!"); return; } #region 九点标定 Task.Factory.StartNew(() => { float.TryParse(this.tXSpace.Text, out this.xspace); float.TryParse(this.tYSpace.Text, out this.yspace); List <PointF> WorldPt = new List <PointF>(); PointF start = new PointF(orgPt.X - xspace, orgPt.Y - yspace); for (int i = 0; i < 3; ++i) { for (int j = 0; j < 3; ++j) { WorldPt.Add(new PointF(start.X + i * xspace, start.Y + j * yspace)); } } // 拍照 标定 记录图像坐标 List <PointContour> ImagePt = new List <PointContour>(); var camera = CameraDefine.Instance.CameraList[this.module.Module][this.calibRatio1.SelectCam]; var entiy = SystemEntiy.Instance[this.module.Module]; for (int I = 0; I < WorldPt.Count; ++I) { entiy.XYGoPosTillStop(WorldPt[I]); // Grab Image and Calc var result = fm_SoftwareCliab.FindTemp.Invoke(this.module.Module, this.calibRatio1.SelectCam); if (result.State == VisionResultState.OK) { ImagePt.Add(result.Point); } else { MessageBox.Show("侦测失败!!"); return; } } short rtn = 0; var image = GetImage?.Invoke(); if (image == null) { MessageBox.Show("获取图片失败!!!"); return; } if (this.calibRatio1.SelectCam == Camera.Top || this.calibRatio1.SelectCam == Camera.Label) { this.AddCliab(this.module.Module, this.calibRatio1.SelectCam, 0, image, WorldPt, ImagePt); } else { if (this.calibRatio1.SelectNz == Nozzle.Nz1 || this.calibRatio1.SelectNz == Nozzle.Nz3) { this.AddCliab(this.module.Module, this.calibRatio1.SelectCam, 0, image, WorldPt, ImagePt); } else { this.AddCliab(this.module.Module, this.calibRatio1.SelectCam, 1, image, WorldPt, ImagePt); } } if (rtn == 0) { CameraDefine.Save(); MessageBox.Show("相机标定成功!!"); } else { MessageBox.Show("相机标定成功!!"); } }); #endregion }
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); }