示例#1
0
 private void worker_DoWork(object sender, DoWorkEventArgs e)
 {
     while(!worker.CancellationPending)
     {
         if (analyzedQueue.Count >= 12)
         {
             var data = analyzedQueue.Take(12).ToArray();
             EcgPacket packet = new EcgPacket() { Data = data };
             OnProcess(packet);
             analyzedQueue.RemoveRange(12);
         }
         Thread.Sleep(2);
     }
 }
示例#2
0
 private void OnProcess(EcgPacket packet)
 {
     if (Processed != null)
         Processed(packet);
 }
示例#3
0
 private void Context_Processed(EcgPacket packet)
 {
     foreach (var data in packet.Data)
         ecgQueue.Enqueue(data);
 }
示例#4
0
文件: Main.cs 项目: mpguard/BtHeart
 private void Redraw(EcgPacket ecgPacket)
 {
     foreach (var data in ecgPacket.Data)
     {
         double y = data;
         if (ChartHeart.Series[0].Points.Count < xPoints)
         {
             ChartHeart.Series[0].Points.AddXY(x, y);
             x += delta;
         }
         else
         {
             ChartHeart.Series[0].Points[pIndex++].YValues[0] = y;
             pIndex = pIndex >= xPoints ? 0 : pIndex;
         }
     }
     ChartHeart.Invalidate();
 }
示例#5
0
文件: Main.cs 项目: mpguard/BtHeart
 private void HeartContext_Processed(EcgPacket ecgPacket)
 {
     if (!this.IsHandleCreated)
         return;
     this.BeginInvoke(new Action(() =>
     {
         if (rbRedraw.Checked)
             Redraw(ecgPacket);
         else if (rbFeedPaper.Checked)
             FeedPaper(ecgPacket);
         ChartHeart.ChartAreas[0].RecalculateAxesScale();
     }));
 }
示例#6
0
文件: Main.cs 项目: mpguard/BtHeart
 private void FeedPaper(EcgPacket ecgPacket)
 {
     foreach (var data in ecgPacket.Data)
     {
         double y = data;
         ChartHeart.Series[0].Points.AddXY(x, y);
         x += delta;
     }
     if (ChartHeart.Series[0].Points.Count >= xPoints)
     {
         for (int i = 0; i < 12; i++)
             ChartHeart.Series[0].Points.RemoveAt(0);
         ChartHeart.ChartAreas[0].AxisX.Minimum += 12 * delta;
         ChartHeart.ChartAreas[0].AxisX.Maximum = 2 + ChartHeart.ChartAreas[0].AxisX.Minimum; // 2s
     }
     ChartHeart.Invalidate();
 }