Exemplo n.º 1
0
        private void ListBoxSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ListBoxItem item = ListBox.SelectedItem as ListBoxItem;

            Home.Background = new SolidColorBrush(Colors.Transparent);
            MyFrame.BackStack.Clear();
            MyFrame.Navigate(typeof(HomePage), this, new SuppressNavigationTransitionInfo());
            if (Home.IsSelected)
            {
                HomeEvent?.Invoke();
            }

            else if (Today.IsSelected)
            {
                TodayEvent?.Invoke();
            }

            else if (Upcoming.IsSelected)
            {
                UpcomingEvent?.Invoke();
            }
            else if (Delayed.IsSelected)
            {
                DelayedEvent?.Invoke();
            }
            else if (AssignedToOthers.IsSelected)
            {
                AssignedToOthersEvent?.Invoke();
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 机器开始回零点
        /// </summary>
        /// <returns></returns>
        public Task <short> MachineHome()
        {
            return(Task <short> .Factory.StartNew(() => {
                #region 回零
                this.MachineIO.ResetBtnLight.SetIO(true);
                Thread.Sleep(1000);
                HomeEvent?.Invoke(this, new HomeEventArgs(30, "机器开始回零...."));
                MachineIO.TrunServoOn.SetIO(true);
                HomeEvent?.Invoke(this, new HomeEventArgs(40, "Z轴开始回零"));;

                short rtn = 0;
                Task <short> task1 = Task <short> .Factory.StartNew(() =>
                {
                    return this.MachineAxis.Z[0].GoHome(ConstDefine.iHomeTime, SpeedDefine.Instance[Module][Shceme.GoLimit, GeneralAxis.Z],
                                                        SpeedDefine.Instance[Module][Shceme.Home, GeneralAxis.Z], this.MachineIO.Limit[0]);
                });

                Task <short> task2 = Task <short> .Factory.StartNew(() =>
                {
                    return this.MachineAxis.Z[2].GoHome(ConstDefine.iHomeTime, SpeedDefine.Instance[Module][Shceme.GoLimit, GeneralAxis.Z],
                                                        SpeedDefine.Instance[Module][Shceme.Home, GeneralAxis.Z], this.MachineIO.Limit[1]);
                });

                // U轴回原点
                Task <short>[] tasks = new Task <short> [4];
                for (int i = 0; i < 4; ++i)
                {
                    int nz = i;
                    tasks[i] = Task <short> .Factory.StartNew(() =>
                    {
                        return this.MachineAxis.R[nz].GoHome(ConstDefine.iHomeTime, SpeedDefine.Instance[Module][Shceme.GoLimit, GeneralAxis.U],
                                                             SpeedDefine.Instance[Module][Shceme.Home, GeneralAxis.U], false);
                    });
                }

                task1.Wait();
                task2.Wait();

                HomeEvent?.Invoke(this, new HomeEventArgs(45, "Z轴回零完成,到安全高度中..."));;
                Thread.Sleep(200);
                this.MachineAxis.Z[0].ZeroAxis();
                this.MachineAxis.Z[2].ZeroAxis();
                Thread.Sleep(100);
                if (task1.Result != 0)
                {
                    MsgHelper.Instance.WriteLog(MsgLevel.Error, "Z1轴 回原点失败,请检查,Z1轴感应器");
                    return task1.Result;
                }
                else if (task2.Result != 0)
                {
                    MsgHelper.Instance.WriteLog(MsgLevel.Error, "Z3轴 回原点失败,请检查,Z2轴感应器");
                    return task2.Result;
                }
                else
                {
                    MsgHelper.Instance.WriteLog(MsgLevel.Info, "Z轴 回原点成功");
                }

                Thread.Sleep(500);
                // Z轴到安全高度
                rtn += this.ZGoSafeTillStop(Shceme.ManualNormal);
                if (rtn != 0)
                {
                    HomeEvent?.Invoke(this, new HomeEventArgs(100, "Z轴到安全高度失败"));
                    return rtn;
                }
                else
                {
                    HomeEvent?.Invoke(this, new HomeEventArgs(40, "Z轴到安全高度成功"));
                }

                // X轴回原点
                rtn += MachineAxis.X.GoHome(ConstDefine.iHomeTime, SpeedDefine.Instance[Module][Shceme.GoLimit, GeneralAxis.X],
                                            SpeedDefine.Instance[Module][Shceme.Home, GeneralAxis.X]);
                if (rtn != 0)
                {
                    HomeEvent?.Invoke(this, new HomeEventArgs(100, "X轴回原点失败"));
                    return rtn;
                }
                else
                {
                    HomeEvent?.Invoke(this, new HomeEventArgs(50, "X轴回原点成功"));
                }

                // 翻转轴回原点
                rtn += MachineAxis.Trun.GoHome(ConstDefine.iHomeTime, SpeedDefine.Instance[Module][Shceme.GoLimit, GeneralAxis.TRUN],
                                               SpeedDefine.Instance[Module][Shceme.Home, GeneralAxis.TRUN]);
                if (rtn != 0)
                {
                    HomeEvent?.Invoke(this, new HomeEventArgs(100, "翻转轴回原点失败"));
                    return rtn;
                }
                else
                {
                    HomeEvent?.Invoke(this, new HomeEventArgs(60, "翻转轴回原点成功"));
                }

                // 翻转轴到水平位置
                rtn += MachineAxis.Trun.GoPosTillStop(ConstDefine.iHomeTime, MachineConfig.TrunSuckAngle, SpeedDefine.Instance[Module][Shceme.ManualNormal, GeneralAxis.TRUN]);
                if (rtn != 0)
                {
                    HomeEvent?.Invoke(this, new HomeEventArgs(100, "翻转轴到水平位置失败"));
                    return rtn;
                }
                else
                {
                    HomeEvent?.Invoke(this, new HomeEventArgs(70, "翻转轴到水平位置成功"));
                }

                // Y轴回原点
                rtn += MachineAxis.Y.GoHome(ConstDefine.iHomeTime, SpeedDefine.Instance[Module][Shceme.GoLimit, GeneralAxis.Y],
                                            SpeedDefine.Instance[Module][Shceme.Home, GeneralAxis.Y]);
                if (rtn != 0)
                {
                    HomeEvent?.Invoke(this, new HomeEventArgs(100, "Y轴回原点失败"));
                    return rtn;
                }
                else
                {
                    HomeEvent?.Invoke(this, new HomeEventArgs(80, "Y轴到回原点成功"));
                }

                if (!Task.WaitAll(tasks, 2000))
                {
                    HomeEvent?.Invoke(this, new HomeEventArgs(100, "U轴回原点失败"));
                    return -1;
                }
                else
                {
                    HomeEvent?.Invoke(this, new HomeEventArgs(90, "U轴回原点成功"));
                }

                HomeEvent?.Invoke(this, new HomeEventArgs(100, "机器回零成功"));
                return rtn;

                #endregion
            }));
        }