using System; using System.Windows.Forms; using System.Collections.Generic; using UAS_AutoPass.ToolClass; namespace UAS_AutoPass { public partial class AutoPassDataCollect : Form { List Data = new List(); //Queue que = new Queue(); /// /// 一次采集运行的时间 /// int SecondCount = 0; /// /// 设置是否开始采集 /// 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"); } } } }