AutoPassDataCollect.cs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. using System;
  2. using System.Windows.Forms;
  3. using BenQGuru.eMES.DLLService;
  4. using System.Collections.Generic;
  5. using UAS_AutoPass.ToolClass;
  6. namespace UAS_AutoPass
  7. {
  8. public partial class AutoPassDataCollect : Form
  9. {
  10. MESHelper helper;
  11. DataHelper dh;
  12. List<string> Data = new List<string>();
  13. //Queue<string> que = new Queue<string>();
  14. /// <summary>
  15. /// 一次采集运行的时间
  16. /// </summary>
  17. int SecondCount = 0;
  18. /// <summary>
  19. /// 设置是否开始采集
  20. /// </summary>
  21. bool StartCount = false;
  22. public AutoPassDataCollect()
  23. {
  24. InitializeComponent();
  25. }
  26. private void Form1_Load(object sender, EventArgs e)
  27. {
  28. //dh = new DataHelper();
  29. helper = new MESHelper();
  30. AutoPastTimer.Interval = 1000;
  31. AutoPastTimer.Tick += AutoPastTimer_Tick;
  32. }
  33. private void AutoPastTimer_Tick(object sender, EventArgs e)
  34. {
  35. //从采集到第一个数据开始计算秒数
  36. if (StartCount)
  37. {
  38. SecondCount = SecondCount + 1;
  39. if (SecondCount == CollectTime.Value)
  40. {
  41. //停止计数
  42. StartCount = false;
  43. //重置采集时长
  44. SecondCount = 0;
  45. CreateLocalFile();
  46. }
  47. }
  48. }
  49. private void CollectData_KeyDown(object sender, KeyEventArgs e)
  50. {
  51. if (e.KeyCode == Keys.Enter)
  52. {
  53. //设置开始计时本次采集
  54. if (Data.Count == 0)
  55. {
  56. StartCount = true;
  57. }
  58. if (Data.Count < CollectNum.Value)
  59. {
  60. if (CollectData.Text != "")
  61. Data.Add(CollectData.Text);
  62. }
  63. }
  64. }
  65. private void Start_Click(object sender, EventArgs e)
  66. {
  67. AutoPastTimer.Start();
  68. Status_label.Text = "运行中";
  69. }
  70. private void Stop_Click(object sender, EventArgs e)
  71. {
  72. AutoPastTimer.Stop();
  73. Status_label.Text = "未开始";
  74. }
  75. private void CreateLocalFile()
  76. {
  77. for (int i = 0; i < Data.Count; i++)
  78. {
  79. BaseUtil.CreateXml(Data[i], "OK");
  80. }
  81. }
  82. }
  83. }