Esempio n. 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);
 }
Esempio n. 2
0
        public void Update()
        {
            DataRecord    rdr  = null;
            DataRecordRaw rdrr = null;

            if (Globals.datbuf.bufgui.Count > 100)
            {
                Console.WriteLine("Buffer: " + Globals.datbuf.bufgui.Count.ToString());
                while (Globals.datbuf.bufgui.Count > 100)
                {
                    Globals.datbuf.Pop(RawDataBuffer.ConsumerName.GUI);
                }
            }
            do
            {
                rdr = Globals.datbuf.Pop(RawDataBuffer.ConsumerName.GUI);
                if (rdr != null)
                {
                    rdrr = new DataRecordRaw(rdr);
                }
                foreach (var p in panellistraw)
                {
                    p.Draw(rdrr);
                }
            } while (Globals.datbuf.bufgui.Count > 0);
        }
Esempio n. 3
0
 public void Draw(DataRecordRaw rec)
 {
     boundingbox.targetleft  = boundingbox.origleft * Globals.panelanimationratio;
     boundingbox.targetright = boundingbox.origright * Globals.panelanimationratio;
     DrawBorder();
     if (enablestencil)
     {
         RendererWrapper.SetStencil(boundingbox, true);
     }
     DrawContents(rec);
     RendererWrapper.SetStencil(boundingbox, false);
 }
Esempio n. 4
0
 public override void DrawContents(DataRecordRaw rec)
 {
     if (rec != null)
     {
         chplaterec[0] = rec.accelmeter[0, 0];
         chplaterec[1] = rec.accelmeter[0, 1];
         chplaterec[2] = rec.accelmeter[1, 0];
         chplaterec[3] = rec.accelmeter[1, 1];
         dispch1.Push(new PanelMotionData {
             accel = new short[3] {
                 rec.accelmeter[0, 0], rec.accelmeter[0, 1], rec.accelmeter[0, 2],
             },
             gyro = new short[3] {
                 rec.gyro[0, 0], rec.gyro[0, 1], rec.gyro[0, 2]
             }
         });
         dispch2.Push(new PanelMotionData {
             accel = new short[3] {
                 rec.accelmeter[1, 0], rec.accelmeter[1, 1], rec.accelmeter[1, 2],
             },
             gyro = new short[3] {
                 rec.gyro[1, 0], rec.gyro[1, 1], rec.gyro[1, 2]
             }
         });
     }
     for (int i = 0; i < 4; i++)
     {
         chplatedisp[i] = 0.9 * chplatedisp[i] + 0.1 * 0.2 * chplaterec[i];
     }
     RendererWrapper.Set3D(new RectangleBox(boundingbox.left, boundingbox.left + boundingbox.Width * 0.5, boundingbox.bottom + boundingbox.Height * 0.3, boundingbox.top));
     RendererWrapper.DrawPlate3D(0.0, 0, chplatedisp[0], 0, chplatedisp[1], Globals.emgchannelcols[0]);
     RendererWrapper.Set2D();
     RendererWrapper.Set3D(new RectangleBox(boundingbox.left + boundingbox.Width * 0.5, boundingbox.right, boundingbox.bottom + boundingbox.Height * 0.3, boundingbox.top));
     RendererWrapper.DrawPlate3D(0.0, 0, chplatedisp[2], 0, chplatedisp[3], Globals.emgchannelcols[0]);
     RendererWrapper.Set2D();
     RendererWrapper.DrawGyroChannel(new RectangleBox(
                                         boundingbox.left + 20, boundingbox.left + boundingbox.Width * 0.5 - 20,
                                         boundingbox.bottom, boundingbox.bottom + boundingbox.Height * 0.3
                                         )
                                     , 0, boundingbox.Height * 0.25, ref dispch1);
     RendererWrapper.DrawGyroChannel(new RectangleBox(
                                         boundingbox.left + boundingbox.Width * 0.5 + 20, boundingbox.right - 20,
                                         boundingbox.bottom, boundingbox.bottom + boundingbox.Height * 0.3
                                         )
                                     , 0, boundingbox.Height * 0.25, ref dispch2);
 }
        public void Update()
        {
            DataRecord    rdr  = null;
            DataRecordRaw rdrr = null;

            do
            {
                rdr = Globals.datbuf.Pop(RawDataBuffer.ConsumerName.GUI);
                if (rdr != null)
                {
                    rdrr = new DataRecordRaw(rdr);
                }
                foreach (var p in panellistraw)
                {
                    p.Draw(rdrr);
                }
            } while (Globals.datbuf.bufgui.Count > 0);
        }
Esempio n. 6
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();
        }
Esempio n. 7
0
 public abstract void DrawContents(DataRecordRaw rec);