PatientForm.cs 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.IO.Ports;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using System.Windows.Forms;
  11. namespace FietsClientV2
  12. {
  13. public partial class PatientForm : Form
  14. {
  15. private PatientModel patienModel;
  16. public PatientForm()
  17. {
  18. InitializeComponent();
  19. patienModel = PatientModel.patientModel;
  20. patienModel.patientform = this;
  21. }
  22. private void Form1_Load(object sender, EventArgs e)
  23. {
  24. string[] ports = SerialPort.GetPortNames();
  25. toolStripComboBox1.Items.AddRange(ports);
  26. }
  27. private void requestDataToolStripMenuItem_Click(object sender, EventArgs e)
  28. {
  29. patienModel.startAskingData();
  30. }
  31. private void closePortToolStripMenuItem_Click(object sender, EventArgs e)
  32. {
  33. patienModel.closeComPort();
  34. }
  35. private void openPortToolStripMenuItem_Click(object sender, EventArgs e)
  36. {
  37. patienModel.startComPort(toolStripComboBox1.SelectedItem.ToString());
  38. requestDataToolStripMenuItem.Enabled = true;
  39. closePortToolStripMenuItem.Enabled = true;
  40. }
  41. private void confirmDistanceBox_Click(object sender, EventArgs e)
  42. {
  43. int n;
  44. if (int.TryParse(distanceBox.Text, out n))
  45. {
  46. patienModel.setDistanceMode(distanceBox.Text);
  47. }
  48. else
  49. {
  50. MessageBox.Show("Distance is not a valid number.");
  51. }
  52. }
  53. private void confirmTimeBox_Click(object sender, EventArgs e)
  54. {
  55. int minutes, seconds;
  56. bool isNumericS = int.TryParse(minuteBox.Text, out minutes);
  57. bool isNumericM = int.TryParse(secondBox.Text, out seconds);
  58. if (isNumericM)
  59. {
  60. if (isNumericS)
  61. patienModel.setTimeMode(minutes + ":" + seconds);
  62. else MessageBox.Show("Minutes is not a valid number.");
  63. }
  64. else MessageBox.Show("Seconds is not a valid number.");
  65. }
  66. private void stopTrainingToolStripMenuItem_Click(object sender, EventArgs e)
  67. {
  68. patienModel.reset();
  69. }
  70. private void setPower_Click(object sender, EventArgs e)
  71. {
  72. int n;
  73. if (int.TryParse(powerBox.Text, out n))
  74. patienModel.setPower(powerBox.Text);
  75. else
  76. MessageBox.Show("Power is not a valid number.");
  77. }
  78. }
  79. }