|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197 |
- using FryPot_DosingSystem.AGV;
- using FryPot_DosingSystem.ViewModel;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Data;
- using System.Windows.Documents;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Animation;
- using System.Windows.Media.Imaging;
- using System.Windows.Navigation;
- using System.Windows.Shapes;
-
- namespace FryPot_DosingSystem.View
- {
- /// <summary>
- /// AgvView.xaml 的交互逻辑
- /// </summary>
- public partial class AgvView : UserControl
- {
- public AgvView()
- {
- InitializeComponent();
- this.DataContext = AgvViewModel.GetInstance();
- 控制命令.ItemsSource = AgvViewModel.GetInstance().GetCommand();
- }
-
- private void Button_Click(object sender, RoutedEventArgs e)
- {
- int id = 1;
- if (sender is Button)
- {
- byte[] data;
- bool istrue = false;
- Button button = sender as Button;
- if (button.Tag != null)
- {
- switch (button.Tag.ToString())
- {
- case "设置有车":
- try
- {
- id=int.Parse(tcz_text.Text.ToString());
- }
- catch (Exception ex)
- {
- MessageBox.Show("只能输入 1-5 的数字!");
- return;
- }
- AgvViewModel.GetInstance().Set停车桩(id, IsBool.Yes);
- break;
- case "设置无车":
-
- try
- {
- id = int.Parse(tcz_text.Text.ToString());
- }
- catch (Exception ex)
- {
- MessageBox.Show("只能输入 1-5 的数字!");
- return;
- }
- AgvViewModel.GetInstance().Set停车桩(id, IsBool.No);
- break;
- case "启动":
- try
- {
- id = int.Parse(liaotong_text.Text.ToString());
- }
- catch (Exception ex)
- {
- MessageBox.Show("只能输入 1-4 的数字!");
- return;
- }
- AgvViewModel.GetInstance().Set滚筒线状态(id, IsRun.Start);
- break;
- case "停止":
- try
- {
- id = int.Parse(liaotong_text.Text.ToString());
- }
- catch (Exception ex)
- {
- MessageBox.Show("只能输入 1-4 的数字!");
- return;
- }
- AgvViewModel.GetInstance().Set滚筒线状态(id, IsRun.Stop);
- break;
- case "设置物料":
- try
- {
- id = int.Parse(liaotongwuliao_text.Text.ToString());
- }
- catch (Exception ex)
- {
- MessageBox.Show("只能输入 1-8 的数字!");
- return;
- }
- AgvViewModel.GetInstance().Set滚筒线上数量(id, liaotongwuliaoshuliang_text.Text);
- break;
- case "小车停止":
- try
- {
- id = int.Parse(xiaoche_text.Text.ToString());
- }
- catch (Exception ex)
- {
- MessageBox.Show("只能输入 1-4 的数字!");
- return;
- }
- AgvViewModel.GetInstance().Set小车停止(id);
- break;
- case "运行小车":
- try
- {
- id = int.Parse(xiaoche_text.Text.ToString());
- }
- catch (Exception ex)
- {
- MessageBox.Show("只能输入 1-4 的数字!");
- return;
- }
- AgvViewModel.GetInstance().Set小车运动(id, AgvViewModel.GetInstance().GetCommandValue(控制命令.Text));
- break;
- case "有菜和碗":
- try
- {
- id = int.Parse(xiaochewuping_text.Text.ToString());
- }
- catch (Exception ex)
- {
- MessageBox.Show("只能输入 1-4 的数字!");
- return;
- }
- AgvViewModel.GetInstance().Set小车是否承载物品(id, IsBool.Yes);
- break;
- case "只有碗":
- try
- {
- id = int.Parse(xiaochewuping_text.Text.ToString());
- }
- catch (Exception ex)
- {
- MessageBox.Show("只能输入 1-4 的数字!");
- return;
- }
- AgvViewModel.GetInstance().Set小车是否承载物品(id, IsBool.OnllYes);
- break;
- case "无物品":
- try
- {
- id = int.Parse(xiaochewuping_text.Text.ToString());
- }
- catch (Exception ex)
- {
- MessageBox.Show("只能输入 1-4 的数字!");
- return;
- }
- AgvViewModel.GetInstance().Set小车是否承载物品(id, IsBool.No);
- break;
- case "启动炒锅":
- try
- {
- id = int.Parse(guntongchaoguo_text.Text.ToString());
- }
- catch (Exception ex)
- {
- MessageBox.Show("只能输入 1-4 的数字!");
- return;
- }
- AgvViewModel.GetInstance().Set启动或停止炒锅(id, IsRun.Start);
- break;
- case "停止炒锅":
- try
- {
- id = int.Parse(guntongchaoguo_text.Text.ToString());
- }
- catch (Exception ex)
- {
- MessageBox.Show("只能输入 1-4 的数字!");
- return;
- }
- AgvViewModel.GetInstance().Set启动或停止炒锅(id, IsRun.Stop);
- break;
-
- }
- }
- }
- }
-
- }
- }
|