示例#1
0
 public override void DrawContents(DataRecordRaw rec)
 {
     if (rec != null)
     {
         int reccount = 0;
         foreach (var data in rec.rawdata)
         {
             dispbuf.Push(data);
             offsetsamps += 1.0;
             reccount++;
         }
         interpolaterate = 0.999 * interpolaterate + 0.001 * reccount;
         if (offsetsamps > 0)
         {
             offsetsamps      = 0;
             interpolaterate *= 1.1;
         }
         if (offsetsamps < -50.0)
         {
             offsetsamps      = -50.0;
             interpolaterate *= 0.9;
         }
         //for (int i = 0; i < dispbuf.maxlen; i++)
         //    Console.Write(dispbuf[i]);
         //Console.WriteLine();
     }
     else
     {
         interpolaterate = 0.999 * interpolaterate + 0.001 * 0.0;
     }
     offsetsamps -= interpolaterate;
     RendererWrapper.DrawBaseline(boundingbox, boundingbox.Height / 2, baselinecol);
     RendererWrapper.DrawRawChannel(boundingbox, offsetsamps * samplelen, boundingbox.Height / 2, Globals.emgchannelcols[0], ref dispbuf);
 }
示例#2
0
        public override void DrawContents(DataRecordRaw rec)
        {
            if (rec != null)
            {
                dispbuf.Push(new PanelEMGData {
                    amp = rec.emgamplitude, freq = rec.emgfrequency
                });
                offsetsamps += 1.0;
                if (offsetsamps > 0)
                {
                    offsetsamps      = 0;
                    interpolaterate *= 1.1;
                }
                if (offsetsamps < -2.0)
                {
                    offsetsamps      = -2.0;
                    interpolaterate *= 0.99;
                }
                interpolaterate = 0.995 * interpolaterate + 0.005 * 1.0;
                //Console.WriteLine(interpolaterate);
                //Console.WriteLine(offsetsamps);
            }
            else
            {
                interpolaterate = 0.995 * interpolaterate + 0.005 * 0.0;
            }
            offsetsamps -= interpolaterate;
            for (int i = 1; i <= 8; i++)
            {
                RendererWrapper.DrawBaseline(boundingbox, boundingbox.Height - boundingbox.Height * i / 9.0, baselinecol);
                RendererWrapper.DrawEMGChannel(boundingbox, offsetsamps * samplelen, boundingbox.Height - boundingbox.Height * i / 9.0,
                                               Globals.emgchannelcols[i - 1], ref dispbuf, i - 1, i == 1);

                bool excited = dispbuf[dispbuf.maxlen - 1].amp[i - 1] > 0;
                RendererWrapper.DrawChannelLabel(boundingbox, 35, boundingbox.Height - boundingbox.Height * i / 9.0,
                                                 Globals.emgchannelcols[i - 1], "CH" + i.ToString(), excited);

                if (excited)
                {
                    effectstrengthslow[i - 1] = 0.9 * effectstrengthslow[i - 1] + 0.1 * 0.5;
                    if (0.2 * dispbuf[dispbuf.maxlen - 1].amp[i - 1] / 255.0 > effectstrengthfast[i - 1])
                    {
                        effectstrengthfast[i - 1] = 0.5 * effectstrengthfast[i - 1] + 0.5 * 0.3 * dispbuf[dispbuf.maxlen - 1].amp[i - 1] / 255.0;
                    }
                }
                else
                {
                    effectstrengthslow[i - 1] = 0.99 * effectstrengthslow[i - 1];
                }
                effectstrengthfast[i - 1] = 0.9 * effectstrengthfast[i - 1];
                RendererWrapper.DrawEffectExcitation(
                    new RectangleBox(
                        boundingbox.left,
                        boundingbox.right,
                        boundingbox.bottom + boundingbox.Height * (9 - i) / 9.0 - boundingbox.Height / 18.0,
                        boundingbox.bottom + boundingbox.Height * (10 - i) / 9.0 - boundingbox.Height / 18.0
                        ),
                    new RGBAColor(0, 122.0 / 255, 204.0 / 255, 0.7),
                    effectstrengthslow[i - 1]);
                RendererWrapper.DrawEffectExcitation(
                    new RectangleBox(
                        boundingbox.left,
                        boundingbox.right,
                        boundingbox.bottom + boundingbox.Height * (9 - i) / 9.0 - boundingbox.Height / 18.0,
                        boundingbox.bottom + boundingbox.Height * (10 - i) / 9.0 - boundingbox.Height / 18.0
                        ),
                    new RGBAColor(1, 1, 1, 0.9),
                    effectstrengthfast[i - 1]);
                //Console.Write(dispbuf[0].amp[i-1].ToString()+" ");
            }

            /*if (rec != null) {
             *  for (int i = 0; i < 256; i++)
             *      Console.Write(dispbuf[i].amp[0].ToString());
             *  Console.WriteLine();
             * }*/
            //Console.WriteLine();
        }