示例#1
0
 private void frm_IOConfig_Load(object sender, EventArgs e)
 {
     //IO
     //IO2
     //123
     IODefine.Load();
     this.propertyGrid1.SelectedObject = IODefine.Instance.MachineIO[Module.Front];
     this.propertyGrid2.SelectedObject = IODefine.Instance.MachineIO[Module.After];
     this.propertyGrid3.SelectedObject = IODefine.Instance.TrackIO[Config.Track.ForntTrack];
     this.propertyGrid4.SelectedObject = IODefine.Instance.TrackIO[Config.Track.AfterTrack];
     this.propertyGrid5.SelectedObject = IODefine.Instance.OtherIO;
 }
        private void bWrite_Click(object sender, EventArgs e)
        {
            string s = Interaction.InputBox("请输入权限密码进行该操作", "提示", "*****", -1, -1);  //-1表示在屏幕的中间

            if (s == "admin")
            {
                this.ioStateControl1.WriteText();
                IODefine.Save();
                this.bWrite.BackColor = Color.LightGreen;
                MessageBox.Show("操作成功!!!");
            }
            else
            {
                MessageBox.Show("操作失败!!!");
            }
        }
示例#3
0
        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();   // 轴配置
        }
示例#4
0
 private void bUpdate_Click(object sender, EventArgs e)
 {
     IODefine.Save();
 }
        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);
        }