Esempio n. 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);
     }
 }
Esempio n. 2
0
 private void OnProcess(EcgPacket packet)
 {
     if (Processed != null)
         Processed(packet);
 }
Esempio n. 3
0
 private void Context_Processed(EcgPacket packet)
 {
     foreach (var data in packet.Data)
         ecgQueue.Enqueue(data);
 }
Esempio n. 4
0
 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();
 }
Esempio n. 5
0
 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();
     }));
 }
Esempio n. 6
0
 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();
 }