|
- 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;
-
- }
- }
- }
- }
-
- }
- }
|