12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- using System;
- using System.Windows.Forms;
- using System.Collections.Generic;
- using UAS_AutoPass.ToolClass;
- namespace UAS_AutoPass
- {
- public partial class AutoPassDataCollect : Form
- {
- List<string> Data = new List<string>();
- //Queue<string> que = new Queue<string>();
- /// <summary>
- /// 一次采集运行的时间
- /// </summary>
- int SecondCount = 0;
- /// <summary>
- /// 设置是否开始采集
- /// </summary>
- bool StartCount = false;
- public AutoPassDataCollect()
- {
- InitializeComponent();
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- //dh = new DataHelper();
- AutoPastTimer.Interval = 1000;
- AutoPastTimer.Tick += AutoPastTimer_Tick;
- }
- private void AutoPastTimer_Tick(object sender, EventArgs e)
- {
- //从采集到第一个数据开始计算秒数
- if (StartCount)
- {
- SecondCount = SecondCount + 1;
- if (SecondCount == CollectTime.Value)
- {
- //停止计数
- StartCount = false;
- //重置采集时长
- SecondCount = 0;
- CreateLocalFile();
- }
- }
- }
- private void CollectData_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.KeyCode == Keys.Enter)
- {
- //设置开始计时本次采集
- if (Data.Count == 0)
- {
- StartCount = true;
- }
- if (Data.Count < CollectNum.Value)
- {
- if (CollectData.Text != "")
- Data.Add(CollectData.Text);
- }
- }
- }
- private void Start_Click(object sender, EventArgs e)
- {
- AutoPastTimer.Start();
- Status_label.Text = "运行中";
- }
- private void Stop_Click(object sender, EventArgs e)
- {
- AutoPastTimer.Stop();
- Status_label.Text = "未开始";
- }
- private void CreateLocalFile()
- {
- for (int i = 0; i < Data.Count; i++)
- {
- BaseUtil.CreateXml(Data[i], "OK");
- }
- }
- }
- }
|