예제 #1
0
        /// <summary>
        /// 开始 清理
        /// </summary>
        /// <param name="selectedID"></param>
        private void StartClean(RailID selectedID)
        {
            bool isSuccess = MachinePortal.StartAutoClean(selectedID);

            if (isSuccess)
            {
                // 更新开始按钮图片
                this.startBtn.BackgroundImage = global::CleanSys.Properties.Resources.NewPauseBtn;

                //更新八角形UI:轨道颜色
                this.railsControler.Start();

                // 启动界面更新线程,更新进度百分比,更新模拟小车,
                this.CleanDistance = 0;
                this.InitProcessBar();

                // 重置三个计时器
                this.RenewTimer(true);
                this.timerThread1.Start(new TimeSpan(0, 0, 0));

                // 重置更新UI 线程
                this.updateUiThread = new Thread(this.getter.GetStatus);
                this.updateUiThread.IsBackground = true;
                this.updateUiThread.Start();

                this.CurrentCleanStep = CleanSteps.CleanRail;
                this.CurrentStatus    = "running";
                this.GunDongFont.Text = this.GetGunDongText(selectedID, this.CurrentStatus);
            }
            else
            {
                MessageBox.Show("发送“清理”请求失败,检查网络情况!");
            }
        }
예제 #2
0
 private void stopBtn_Click(object sender, EventArgs e)
 {
     if (!this.railsControler.IsAllStoped)
     {
         DialogResult result = MessageBox.Show("确实终止清理", "确认", MessageBoxButtons.OKCancel);
         if (result == DialogResult.OK)
         {
             RailID id        = this.railsControler.WorkingNum;
             bool   isSuccess = MachinePortal.StopAutoClean(id);
             if (!isSuccess)
             {
                 MessageBox.Show("终止清理失败!");
             }
             else
             {
                 this.railsControler.Stop();
                 this.CurrentCleanStep = CleanSteps.UnSupported;
                 this.saveSpendTimeDic.Clear();
                 this.updateUiThread.Abort();
                 this.timerThread1.Abort();
                 this.timerThread2.Abort();
                 this.timerThread3.Abort();
                 this.startBtn.BackgroundImage = global::CleanSys.Properties.Resources.NewStartBtn;
                 this.InitProcessBar();
                 this.RenewTimer(true);
                 this.CurrentStatus    = "ready";
                 this.GunDongFont.Text = this.GetGunDongText(id, this.CurrentStatus);
             }
         }
     }
     else
     {
         MessageBox.Show("清理没有进行,无需终止!");
     }
 }
예제 #3
0
        private void backward_Click(object sender, EventArgs args)
        {
            if (!this.railsControler.IsSelected)
            {
                MessageBox.Show("请先选择要清理的轨道!");
            }
            else if (this.cleanStep == CleanSteps.UnSupported)
            {
                MessageBox.Show("请先选择清理步骤!");
            }
            else if (!this.isWorking)
            {
                bool success = MachinePortal.Backward(this.railsControler.SelectedRailNum, this.cleanStep);
                if (success)
                {
                    this.isWorking = true;
                    this.railsControler.SetRailStatus(RailStatus.Running);
                    this.backfowrdBtn.BackgroundImage = global::CleanSys.Properties.Resources.backwardBtnDown;

                    this.updateUiThread = new Thread(this.getter.GetStatus);
                    this.updateUiThread.IsBackground = true;
                    this.updateUiThread.Start();
                }
                else
                {
                    MessageBox.Show("发送清理命令失败,请检查网络连接!");
                }
            }
            else
            {
                this.PauseManual();
            }
        }
예제 #4
0
 private void stopBtn_Click(object sender, EventArgs e)
 {
     if (!this.railsControler.IsAllStoped)
     {
         DialogResult result = MessageBox.Show("确实终止清理", "确认", MessageBoxButtons.OKCancel);
         if (result == DialogResult.OK)
         {
             RailID id        = this.railsControler.WorkingNum;
             bool   isSuccess = MachinePortal.StopManualClean(id);
             if (!isSuccess)
             {
                 MessageBox.Show("终止清理失败!");
             }
             else
             {
                 this.railsControler.Stop();
                 this.cleanStep = CleanSteps.UnSupported;
                 this.UpdateUpArrowLocation(0);
                 this.ClearStepBtns();
                 this.PauseManual();
             }
         }
     }
     else
     {
         MessageBox.Show("清理没有进行,无需终止!");
     }
 }
예제 #5
0
        private void ContinueClean(RailID selectedID)
        {
            bool isSuccess = MachinePortal.ContinueAutoClean(selectedID);

            if (isSuccess)
            {
                // 更新开始按钮图片
                this.startBtn.BackgroundImage = global::CleanSys.Properties.Resources.NewPauseBtn;

                //更新八角形UI
                this.railsControler.Continue();

                this.RenewTimer(false);

                //继续计时器
                TimeSpan span = this.saveSpendTimeDic[this.CurrentCleanStep];
                switch (this.CurrentCleanStep)
                {
                case CleanSteps.CleanRail:
                    this.timerThread1.Start(span);
                    break;

                case CleanSteps.CoveredWithGrease:
                    this.timerThread2.Start(span);
                    break;

                case CleanSteps.DropAlcohol:
                    this.timerThread3.Start(span);
                    break;
                }

                // 启动界面更新线程,更新进度百分比,更新模拟小车, 更新轨道颜色。
                this.updateUiThread = new Thread(this.getter.GetStatus);
                this.updateUiThread.IsBackground = true;
                this.updateUiThread.Start();

                //清除记录
                this.saveSpendTimeDic.Clear();
                this.CurrentStatus    = "running";
                this.GunDongFont.Text = this.GetGunDongText(selectedID, this.CurrentStatus);
            }
            else
            {
                MessageBox.Show("发送“清理”请求失败,检查网络情况!");
            }
        }
예제 #6
0
        /// <summary>
        /// 当第二次单击 前进后者后退的时候,就相当于暂停状态
        /// 只是发送 停止命令,并且杀死 更新UI进程,并不改变 轨道,清理步骤 和模拟小车的状态
        /// </summary>
        private void PauseManual()
        {
            bool success = MachinePortal.StopManualClean(this.railsControler.WorkingNum);

            if (success)
            {
                this.updateUiThread.Abort();
                this.isWorking            = false;
                this.forwardBtn.Enabled   = true;
                this.backfowrdBtn.Enabled = true;
                this.railsControler.SetRailStatus(RailStatus.Ready);
                this.forwardBtn.BackgroundImage   = global::CleanSys.Properties.Resources.forwardBtn;
                this.backfowrdBtn.BackgroundImage = global::CleanSys.Properties.Resources.backwardBtn;
            }
            else
            {
                MessageBox.Show("发送暂停前进命令失败,请检查网络连接!");
            }
        }
예제 #7
0
        private void PauseClean(RailID selectedID)
        {
            // send pause cmd;
            bool isSuccess = MachinePortal.PauseAutoClean(selectedID);

            if (isSuccess)
            {
                //保存 当前状态
                switch (this.CurrentCleanStep)
                {
                case CleanSteps.CleanRail:
                    this.saveSpendTimeDic.Add(this.CurrentCleanStep, this.CleanRailSpan);
                    break;

                case CleanSteps.CoveredWithGrease:
                    this.saveSpendTimeDic.Add(this.CurrentCleanStep, this.CoveredWithGreaseSpan);
                    break;

                case CleanSteps.DropAlcohol:
                    this.saveSpendTimeDic.Add(this.CurrentCleanStep, this.DropAlcoholSpan);
                    break;
                }

                // 更新开始按钮图片
                this.startBtn.BackgroundImage = global::CleanSys.Properties.Resources.NewStartBtn;

                //更新八角形UI
                this.railsControler.Pause();

                // 杀死界面更新程序
                this.updateUiThread.Abort();
                this.timerThread1.Abort();
                this.timerThread2.Abort();
                this.timerThread3.Abort();
                this.CurrentStatus    = "pause";
                this.GunDongFont.Text = this.GetGunDongText(selectedID, this.CurrentStatus);
            }
            else
            {
                MessageBox.Show("发送“清理”请求失败,检查网络情况!");
            }
        }