Main_Form.cs 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. //Add code
  11. using System.IO;
  12. using System.IO.Ports;
  13. namespace RF_TRIO_PLL_ZIG
  14. {
  15. public partial class Main_Form : Form
  16. {
  17. Serial serial = new Serial(); // Uart Open
  18. Update_Serial file = new Update_Serial();
  19. public Main_Form()
  20. {
  21. InitializeComponent();
  22. serial.Serial_Initialize(ref comboBox_Port);
  23. }
  24. private void Firmware_Update_Click(object sender, EventArgs e)
  25. {
  26. OpenFileDialog ofd = new OpenFileDialog();
  27. //FileDownload file = new FileDownload();
  28. if (Ascii_checkBox.Checked == true)
  29. Ascii_checkBox.Checked = false;
  30. file.ShowFileOpenDialog(ref serial, ofd);
  31. }
  32. private void Crc16_Check_Click(object sender, EventArgs e)
  33. {
  34. #if false
  35. Crc16 crc16 = new Crc16();
  36. byte[] tempdata = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09,0x0A };
  37. label1.Text = crc16.CRC16_Generate(tempdata, 11).ToString();
  38. #endif
  39. this.serial.Test_Serial();
  40. }
  41. private void Button_PortOpen_Click(object sender, EventArgs e)
  42. {
  43. bool ret = false;
  44. ret = Serial_connectiondisable(serial.Serial_PortOpen(ref button_PortOpen, ref comboBox_Port));
  45. if (ret == true && timer.Enabled == false)
  46. {
  47. timer.Start(); //타이머를 발동시킨다.
  48. }
  49. else if (timer.Enabled == true)
  50. {
  51. timer.Stop(); //타이머를 멈춘다.
  52. }
  53. else
  54. {
  55. /*NOP*/
  56. }
  57. }
  58. private void ComboBox_Port_SelectedIndexChanged(object sender, EventArgs e)
  59. {
  60. serial.Serial_Name = comboBox_Port.SelectedItem.ToString();
  61. }
  62. private void Button_terminal_Click(object sender, EventArgs e)
  63. {
  64. serial.Serial_TerminalOpen(serial);
  65. }
  66. public bool Serial_connectiondisable(Boolean on_off)
  67. {
  68. comboBox_Port.Enabled = on_off;
  69. comboBox_baudrate.Enabled = on_off;
  70. return on_off;
  71. }
  72. private void timer_Tick(object sender, EventArgs e)
  73. {
  74. }
  75. }
  76. }