AutoPassDataCollect.cs 2.4 KB

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