AGVSingleControl.cs 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using AGV_WPF.Models;
  10. using AGV_WPF_Global;
  11. using AGV_WPF.Tools;
  12. namespace AGV_WPF
  13. {
  14. public partial class AGVSingleControl : Form
  15. {
  16. Timer timer = new Timer();
  17. public AGVSingleControl()
  18. {
  19. InitializeComponent();
  20. }
  21. private void AGVSingleControl_Load(object sender, EventArgs e)
  22. {
  23. int AGVNUM_MAX = Convert.ToByte(System.Configuration.ConfigurationManager.AppSettings["AGVNUM_MAX"]);
  24. for (int i = 1; i <= AGVNUM_MAX; i++)
  25. {
  26. comboBox2.Items.Add(i);
  27. }
  28. comboBox2.SelectedIndex=0;
  29. comboBox1.Items.Add("休眠"); comboBox1.Items.Add("唤醒");
  30. comboBox1.Items.Add("启动"); comboBox1.Items.Add("停止");
  31. comboBox1.SelectedIndex = 0;
  32. timer.Interval = 1000;
  33. timer.Enabled = true;
  34. timer.Tick += Timer_Tick;
  35. }
  36. private void Timer_Tick(object sender, EventArgs e)
  37. {
  38. label3.Text = GlobalPara.SWInfo;
  39. }
  40. private void button1_Click(object sender, EventArgs e)
  41. {
  42. string btnHeader = comboBox1.Text;
  43. int ActionCode = 0;
  44. if (btnHeader.ToString().Contains("休眠"))
  45. {
  46. ActionCode = 0x20;
  47. GlobalPara.isSingleControl = true;
  48. GlobalPara.SingleSWAGVNum = int.Parse(comboBox2.Text);
  49. }
  50. else if (btnHeader.ToString().Contains("唤醒"))
  51. {
  52. ActionCode = 0x30;
  53. GlobalPara.isSingleControl = true;
  54. GlobalPara.SingleSWAGVNum = int.Parse(comboBox2.Text);
  55. }
  56. else if (btnHeader.ToString().Contains("启动"))
  57. {
  58. ActionCode = 0x40;
  59. }
  60. else if (btnHeader.ToString().Contains("停止"))
  61. {
  62. ActionCode = 0x50;
  63. }
  64. GlobalPara.SWInfo = "";
  65. DispatcherTool.ControlAllAgv(ActionCode, 0, int.Parse(comboBox2.Text), true);
  66. }
  67. }
  68. }