/** occasionally builds a line and prints to output window */ void Instrument() { if (--_timeToPrint <= 0) { _timeToPrint = 20; _sb.Clear(); _sb.Append("pos="); _sb.Append(_talon.GetPosition()); _sb.Append(" vel="); _sb.Append(_talon.GetSpeed()); _sb.Append(" err="); _sb.Append(_talon.GetClosedLoopError()); _sb.Append(" out%="); _sb.Append(_talon.GetOutputVoltage() * 100.0f / 12.0f); Debug.Print(_sb.ToString()); } }
public static void Process(CTRE.TalonSrx talon) { /* simple timeout to reduce printed lines */ if (++_instrumLoops1 > 10) { _instrumLoops1 = 0; /* get closed loop info */ float pos = talon.GetPosition(); float spd = talon.GetSpeed(); int err = talon.GetClosedLoopError(); /* build the string */ _sb.Clear(); _sb.Append(pos); if (_sb.Length < 16) { _sb.Append(' ', 16 - _sb.Length); } _sb.Append(spd); if (_sb.Length < 32) { _sb.Append(' ', 32 - _sb.Length); } _sb.Append(err); if (_sb.Length < 48) { _sb.Append(' ', 48 - _sb.Length); } Debug.Print(_sb.ToString()); /* print data row */ if (++_instrumLoops2 > 8) { _instrumLoops2 = 0; _sb.Clear(); _sb.Append("Position"); if (_sb.Length < 16) { _sb.Append(' ', 16 - _sb.Length); } _sb.Append("Velocity"); if (_sb.Length < 32) { _sb.Append(' ', 32 - _sb.Length); } _sb.Append("Error"); if (_sb.Length < 48) { _sb.Append(' ', 48 - _sb.Length); } Debug.Print(_sb.ToString()); /* print columns */ } } }