Main_Form.cs 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  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. Bluecell_BootProtocol bluecell_BootProtocol = new Bluecell_BootProtocol();
  19. Update_Serial file = new Update_Serial();
  20. public byte Tdd_T_Sync = 0;
  21. public Main_Form()
  22. {
  23. InitializeComponent();
  24. serial.Serial_Initialize(ref comboBox_Port);
  25. }
  26. private void Firmware_Update_Click(object sender, EventArgs e)
  27. {
  28. OpenFileDialog ofd = new OpenFileDialog();
  29. //FileDownload file = new FileDownload();
  30. if (Ascii_checkBox.Checked == true)
  31. Ascii_checkBox.Checked = false;
  32. file.ShowFileOpenDialog(ref serial, ofd);
  33. }
  34. private void Crc16_Check_Click(object sender, EventArgs e)
  35. {
  36. #if false
  37. Crc16 crc16 = new Crc16();
  38. byte[] tempdata = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09,0x0A };
  39. label1.Text = crc16.CRC16_Generate(tempdata, 11).ToString();
  40. #endif
  41. this.serial.Test_Serial();
  42. }
  43. private void Button_PortOpen_Click(object sender, EventArgs e)
  44. {
  45. bool ret = false;
  46. ret = Serial_connectiondisable(serial.Serial_PortOpen(ref button_PortOpen, ref comboBox_Port));
  47. if (ret == false && timer.Enabled == false)
  48. {
  49. timer.Start(); //타이머를 발동시킨다.
  50. }
  51. else if (timer.Enabled == true)
  52. {
  53. timer.Stop(); //타이머를 멈춘다.
  54. }
  55. else
  56. {
  57. /*NOP*/
  58. }
  59. serial.Serial_Main_Form_Get(this);
  60. }
  61. private void ComboBox_Port_SelectedIndexChanged(object sender, EventArgs e)
  62. {
  63. serial.Serial_Name = comboBox_Port.SelectedItem.ToString();
  64. }
  65. private void Button_terminal_Click(object sender, EventArgs e)
  66. {
  67. serial.Serial_TerminalOpen(serial);
  68. }
  69. public bool Serial_connectiondisable(Boolean on_off)
  70. {
  71. comboBox_Port.Enabled = on_off;
  72. comboBox_baudrate.Enabled = on_off;
  73. return on_off;
  74. }
  75. private delegate void BoolSet();
  76. public void TX_Light_ON()
  77. {
  78. this.pictureBox_G_TX.Visible = true;
  79. this.pictureBox_R_TX.Visible = false;
  80. }
  81. public void TX_Light_OFF()
  82. {
  83. this.pictureBox_R_TX.Visible = true;
  84. this.pictureBox_G_TX.Visible = false;
  85. }
  86. public void RX_Light_ON()
  87. {
  88. this.pictureBox_G_RX.Visible = true;
  89. this.pictureBox_R_RX.Visible = false;
  90. }
  91. public void RX_Light_OFF()
  92. {
  93. this.pictureBox_R_RX.Visible = true;
  94. this.pictureBox_G_RX.Visible = false;
  95. }
  96. private void timer_Tick(object sender, EventArgs e)
  97. {
  98. if (this.pictureBox_G_TX.Visible == true)
  99. {
  100. TX_Light_OFF();
  101. }
  102. if(this.pictureBox_G_RX.Visible == true)
  103. {
  104. RX_Light_OFF();
  105. }
  106. }
  107. private void button_Set_Click(object sender, EventArgs e)
  108. {
  109. bluecell_BootProtocol.Bluecell_BtnSet(this.serial,this);
  110. }
  111. private void Main_Form_Load(object sender, EventArgs e)
  112. {
  113. pictureBox_PATH_1_8G_DL_ON.Visible = false;
  114. pictureBox_PATH_1_8G_UL_ON.Visible = false;
  115. pictureBox_PATH_2_1G_DL_ON.Visible = false;
  116. pictureBox_PATH_2_1G_UL_ON.Visible = false;
  117. pictureBox_PATH_3_5G_L_ON.Visible = false;
  118. pictureBox_PATH_3_5G_H_ON.Visible = false;
  119. pictureBox_PLL_ON_OFF_3_5G_L_ON.Visible = false;
  120. pictureBox_PLL_ON_OFF_3_5G_H_ON.Visible = false;
  121. pictureBox_PATH_3_5G_UL_ON.Visible = false;
  122. pictureBox_PATH_3_5G_DL_ON.Visible = false;
  123. pictureBox_G_RX.Visible = false;
  124. pictureBox_G_TX.Visible = false;
  125. /* public System.Windows.Forms.PictureBox pictureBox_PATH_3_5G_L_OFF;
  126. public System.Windows.Forms.PictureBox pictureBox_PATH_3_5G_H_OFF;
  127. public System.Windows.Forms.PictureBox pictureBox_PLL_ON_OFF_3_5G_L_OFF;
  128. public System.Windows.Forms.PictureBox pictureBox_PLL_ON_OFF_3_5G_H_OFF;
  129. public System.Windows.Forms.PictureBox pictureBox_PATH_3_5G_UL_OFF;
  130. public System.Windows.Forms.PictureBox pictureBox_PATH_3_5G_DL_OFF;
  131. public System.Windows.Forms.PictureBox pictureBox_PATH_2_1G_UL_OFF;
  132. public System.Windows.Forms.PictureBox pictureBox_PATH_2_1G_DL_OFF;
  133. public System.Windows.Forms.PictureBox pictureBox_PATH_1_8G_UL_OFF;
  134. public System.Windows.Forms.PictureBox pictureBox_PATH_1_8G_DL_OFF;
  135. public System.Windows.Forms.PictureBox pictureBox_PATH_3_5G_L_ON;
  136. public System.Windows.Forms.PictureBox pictureBox_PATH_3_5G_H_ON;
  137. public System.Windows.Forms.PictureBox pictureBox_PLL_ON_OFF_3_5G_L_ON;
  138. public System.Windows.Forms.PictureBox pictureBox_PLL_ON_OFF_3_5G_H_ON;
  139. public System.Windows.Forms.PictureBox pictureBox_PATH_3_5G_UL_ON;
  140. public System.Windows.Forms.PictureBox pictureBox_PATH_3_5G_DL_ON;
  141. public System.Windows.Forms.PictureBox pictureBox_PATH_2_1G_UL_ON;
  142. public System.Windows.Forms.PictureBox pictureBox_PATH_2_1G_DL_ON;
  143. public System.Windows.Forms.PictureBox pictureBox_PATH_1_8G_UL_ON;;*/
  144. }
  145. private void ATT_Enter(object sender, KeyEventArgs e)
  146. {
  147. if (e.KeyCode == Keys.Enter)
  148. {
  149. button_Set_Click(sender, e);
  150. //to do
  151. }
  152. else
  153. {
  154. return;
  155. }
  156. }
  157. private void TDD_T_SYNC_Click(object sender, EventArgs e)
  158. {
  159. PictureBox pictureBox = (PictureBox)sender;
  160. Tdd_T_Sync = Convert.ToByte(pictureBox.Tag);
  161. bluecell_BootProtocol.Bluecell_BtnSet(this.serial, this);
  162. pictureBox_TDD_T_SYNC_UL_ON.Visible = !pictureBox_TDD_T_SYNC_UL_ON.Visible;
  163. pictureBox_TDD_T_SYNC_DL_OFF.Visible = !pictureBox_TDD_T_SYNC_DL_OFF.Visible;
  164. }
  165. const byte PATH_1_8G_DL = 0;
  166. const byte PATH_1_8G_UL = 1;
  167. const byte PATH_2_1G_DL = 2;
  168. const byte PATH_2_1G_UL = 3;
  169. const byte PATH_3_5G_DL = 4;
  170. const byte PATH_3_5G_UL = 5;
  171. const byte PATH_3_5G_H = 6;
  172. const byte PATH_3_5G_L = 7;
  173. const byte PLL_POWER_ONOFF_3_5G_H = 8;
  174. const byte PLL_POWER_ONOFF_3_5G_L = 9;
  175. private void Power_OnOff_Set(object sender, EventArgs e)
  176. {
  177. byte temp_tag = 0;
  178. PictureBox pictureBox = (PictureBox)sender;
  179. temp_tag = Convert.ToByte(pictureBox.Tag);
  180. switch (temp_tag)
  181. {
  182. case PATH_1_8G_DL:
  183. break;
  184. case PATH_1_8G_UL:
  185. break;
  186. case PATH_2_1G_DL:
  187. break;
  188. case PATH_2_1G_UL:
  189. break;
  190. case PATH_3_5G_DL:
  191. break;
  192. case PATH_3_5G_UL:
  193. break;
  194. case PATH_3_5G_H:
  195. break;
  196. case PATH_3_5G_L:
  197. break;
  198. case PLL_POWER_ONOFF_3_5G_H:
  199. break;
  200. case PLL_POWER_ONOFF_3_5G_L:
  201. break;
  202. }
  203. pictureBox.Visible = !pictureBox.Visible;
  204. bluecell_BootProtocol.Bluecell_BtnSet(this.serial, this);
  205. }
  206. }
  207. }