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("清理没有进行,无需终止!"); } }
public static bool SendCMD(RailID railID, CleanCommand cmd, CleanSteps step) { switch (cmd) { case CleanCommand.Forward: mockReceiver.Forward(railID, step); break; case CleanCommand.ContinueForward: mockReceiver.ContinueForward(railID, step); break; case CleanCommand.Backward: mockReceiver.Backward(railID, step); break; case CleanCommand.ContinueBackword: mockReceiver.ContinueBackword(railID, step); break; case CleanCommand.PauseManualClean: mockReceiver.PauseManualClean(railID); break; case CleanCommand.StopManualClean: mockReceiver.StopManualClean(railID); break; } return(true); }
/// <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("发送“清理”请求失败,检查网络情况!"); } }
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("清理没有进行,无需终止!"); } }
/// <summary> /// 设置当前工作轨道的清理进度 /// </summary> /// <param name="step"></param> public bool SetRailProgress(CleanSteps step) { RailMode mode = GetWorkingRail(); if (mode == null) { return(false); } switch (step) { case CleanSteps.CleanRail: mode.Progress = RailProgress.CleanRail; break; case CleanSteps.DropAlcohol: mode.Progress = RailProgress.DropAlcohol; break; case CleanSteps.CoveredWithGrease: mode.Progress = RailProgress.DropAlcohol; break; case CleanSteps.Done: mode.Progress = RailProgress.Done; mode.Status = RailStatus.Ready; break; } return(true); }
public void ContinueBackword(RailID id, CleanSteps step) { this.startTime = DateTime.Now; this.id = id; this.isPause = false; this.currentStep = (int)step; }
public ManualCleanFrm() { InitializeComponent(); this.saveSpendTimeDic = new Dictionary <CleanSteps, TimeSpan>(); getter = new DataStatusSyncer(); getter.UpdateUIDelegate += this.UpdateProcessUI; getter.TaskCallBack += this.DoneClean; this.isWorking = false; this.cleanStep = CleanSteps.UnSupported; }
public void Backward(RailID id, CleanSteps step) { this.startTime = DateTime.Now; this.isAuto = false; this.isForward = false; this.id = id; this.isPause = false; this.currentStep = (int)step; this.isDone = false; }
private void AutoCleanFrm_Load(object sender, EventArgs e) { int x = (System.Windows.Forms.SystemInformation.WorkingArea.Width - this.Size.Width) / 2; int y = (System.Windows.Forms.SystemInformation.WorkingArea.Height - this.Size.Height) / 2; this.StartPosition = FormStartPosition.Manual; //窗体的位置由Location属性决定 myData.myPossition = new Size(x, y); this.Location = (Point)myData.myPossition; //窗体的起始位置为(x,y) DataLabel.Text = myData.MiddleTitle(); TimeLabel.Text = myData.RightTime(); this.timerThread1 = new Thread(new ParameterizedThreadStart(this.Thread1_Tick)); this.timerThread2 = new Thread(new ParameterizedThreadStart(this.Thread2_Tick)); this.timerThread3 = new Thread(new ParameterizedThreadStart(this.Thread3_Tick)); this.timerThread1.IsBackground = true; this.timerThread2.IsBackground = true; this.timerThread3.IsBackground = true; this.process1.BackgroundImage = ((System.Drawing.Image)Resources.ResourceManager.GetObject("stepOne")); this.process2.BackgroundImage = ((System.Drawing.Image)Resources.ResourceManager.GetObject("stepTwo")); this.process3.BackgroundImage = ((System.Drawing.Image)Resources.ResourceManager.GetObject("stepThree")); this.BackgroundImage = ((System.Drawing.Image)(Resources.ResourceManager.GetObject("backgroud2"))); this.railsControler = new RailControler(this.eightAngle1.ImgList); this.InitProcessBar(); this.CurrentCleanStep = CleanSteps.UnSupported; this.eightAngle1.ImgOne.BackgroundImage = ((System.Drawing.Image)(Resources.ResourceManager.GetObject(this.angleOne + this.stepZeroGray))); this.eightAngle1.ImgTwo.BackgroundImage = ((System.Drawing.Image)(Resources.ResourceManager.GetObject(this.angleTwo + this.stepZeroGray))); this.eightAngle1.ImgThree.BackgroundImage = ((System.Drawing.Image)(Resources.ResourceManager.GetObject(this.angleThre + this.stepZeroGray))); this.eightAngle1.ImgFour.BackgroundImage = ((System.Drawing.Image)(Resources.ResourceManager.GetObject(this.angleFour + this.stepZeroGray))); }
private void StepThree_Click(object sender, EventArgs args) { if (this.isWorking) { if (this.cleanStep != CleanSteps.DropAlcohol) { MessageBox.Show("请先停掉当前清理工作,再选择清理步骤!"); return; } else { //取消选中,停止清理? } } else { this.cleanStep = CleanSteps.DropAlcohol; this.stepThreeBtn.BackgroundImage = global::CleanSys.Properties.Resources.StepThreeDown; ///改变另外两个颜色,颜色变浅变灰 this.stepTwoBtn.BackgroundImage = global::CleanSys.Properties.Resources.stepTwo; this.stepOneBtn.BackgroundImage = global::CleanSys.Properties.Resources.stepOne; } }
private void Update(SyncStatusMode status) { CheckForIllegalCrossThreadCalls = false; if (status.IsError) { MessageBox.Show(status.ErrorMsg); } else { //过滤掉非法数据 float progress = status.ProgressRate > 100 ? 100 : status.ProgressRate < 0 ? 0 : status.ProgressRate; switch (status.CleanSteps) { case CleanSteps.CleanRail: this.CleanRailStepRate = progress; // AutoCleanFrm.RailLength; this.CurrentCleanStep = CleanSteps.CleanRail; this.GunDongFont.Text = this.GetGunDongText(status.CurrentRailID, this.CurrentStatus); break; case CleanSteps.DropAlcohol: this.CleanRailStepRate = 100; this.timerThread1.Abort(); if (this.CurrentCleanStep != CleanSteps.DropAlcohol) { this.timerThread2.Start(new TimeSpan(0, 0, 0)); } this.CoveredWithGreaseStepRate = progress; // AutoCleanFrm.RailLength; this.CurrentCleanStep = CleanSteps.DropAlcohol; this.GunDongFont.Text = this.GetGunDongText(status.CurrentRailID, this.CurrentStatus); break; case CleanSteps.CoveredWithGrease: this.CleanRailStepRate = 100; this.timerThread1.Abort(); this.CoveredWithGreaseStepRate = 100; this.timerThread2.Abort(); if (this.CurrentCleanStep != CleanSteps.CoveredWithGrease) { this.timerThread3.Start(new TimeSpan(0, 0, 0)); } this.DropAlcoholStepRate = progress; // AutoCleanFrm.RailLength; this.CurrentCleanStep = CleanSteps.CoveredWithGrease; this.GunDongFont.Text = this.GetGunDongText(status.CurrentRailID, this.CurrentStatus); break; case CleanSteps.Done: this.CleanRailStepRate = 100; this.timerThread1.Abort(); this.CoveredWithGreaseStepRate = 100; this.timerThread2.Abort(); this.DropAlcoholStepRate = 100; this.timerThread3.Abort(); this.CurrentCleanStep = CleanSteps.Done; int num = (int)this.railsControler.WorkingNum; string numZh = this.ConvertNumToChinese(num); this.startBtn.BackgroundImage = global::CleanSys.Properties.Resources.NewStartBtn; MessageBox.Show($"{numZh}轨道清理完毕!"); this.GunDongFont.Text = this.GetGunDongText(status.CurrentRailID, this.CurrentStatus); break; } this.UpdateUpArrowLocation(progress); this.railsControler.SetRailProgress(status.CleanSteps); } }
public static bool Backward(RailID railID, CleanSteps steps) { return(MachineSender.SendCMD(railID, CleanCommand.Backward, steps)); }