UcConsole.cs 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Drawing;
  5. using System.Data;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. namespace Fietsclient.User_Controls
  11. {
  12. public partial class UcConsole : UserControl
  13. {
  14. public UcConsole()
  15. {
  16. InitializeComponent();
  17. KettlerBikeComm.IncomingDataEvent += HandleBikeData;
  18. KettlerBikeComm.IncomingDebugLineEvent += addTextToLog;
  19. }
  20. private void addTextToLog(string text)
  21. {
  22. if (this.InvokeRequired)
  23. {
  24. this.Invoke((new Action(() => addTextToLog(text))));
  25. return;
  26. }
  27. tbConsole.AppendText(text + "\n");
  28. }
  29. private void HandleBikeData(string[] data)
  30. {
  31. addTextToLog("Pulse: " + data[0] + ", Rpm: " + data[1] + ", Speed: " + data[2] + ", Distance: " + data[3] +
  32. ", Requestedpower: " + data[4] + ", Energy: " + data[5] + ", Time: " + data[6] + ", Actualpower: " + data[7]);
  33. }
  34. }
  35. }