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); }
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 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(); }