Main_Form.cs 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720
  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. Int64 TimerCnt = 0;
  97. private void timer_Tick(object sender, EventArgs e)
  98. {
  99. TimerCnt++;
  100. if (TimerCnt > 500)
  101. {
  102. if (this.pictureBox_G_TX.Visible == true)
  103. {
  104. TX_Light_OFF();
  105. }
  106. if (this.pictureBox_G_RX.Visible == true)
  107. {
  108. RX_Light_OFF();
  109. }
  110. }
  111. }
  112. private void Main_Form_Load(object sender, EventArgs e)
  113. {
  114. pictureBox_PATH_1_8G_DL_ON.Visible = false;
  115. pictureBox_PATH_1_8G_UL_ON.Visible = false;
  116. pictureBox_PATH_2_1G_DL_ON.Visible = false;
  117. pictureBox_PATH_2_1G_UL_ON.Visible = false;
  118. pictureBox_PATH_3_5G_L_ON.Visible = false;
  119. pictureBox_PATH_3_5G_H_ON.Visible = false;
  120. pictureBox_PLL_ON_OFF_3_5G_L_ON.Visible = false;
  121. pictureBox_PLL_ON_OFF_3_5G_H_ON.Visible = false;
  122. pictureBox_PATH_3_5G_UL_ON.Visible = false;
  123. pictureBox_PATH_3_5G_DL_ON.Visible = false;
  124. pictureBox_PATH_1_8G_DL_OFF.Visible = !false;
  125. pictureBox_PATH_1_8G_UL_OFF.Visible = !false;
  126. pictureBox_PATH_2_1G_DL_OFF.Visible = !false;
  127. pictureBox_PATH_2_1G_UL_OFF.Visible = !false;
  128. pictureBox_PATH_3_5G_L_OFF.Visible = !false;
  129. pictureBox_PATH_3_5G_H_OFF.Visible = !false;
  130. pictureBox_PLL_ON_OFF_3_5G_L_OFF.Visible = !false;
  131. pictureBox_PLL_ON_OFF_3_5G_H_OFF.Visible = !false;
  132. pictureBox_PATH_3_5G_UL_OFF.Visible = !false;
  133. pictureBox_PATH_3_5G_DL_OFF.Visible = !false;
  134. pictureBox_G_RX.Visible = !false;
  135. pictureBox_G_TX.Visible = !false;
  136. }
  137. private delegate void StringSend(object label, String str);
  138. public void ADC_Voltage_Value_Set(byte[] data)
  139. {
  140. int temp_val = 0;
  141. double Volt_Calc_val = 3.3 / 4095;
  142. double ret = 0;
  143. try
  144. {
  145. temp_val = (int)(data[(int)Bluecell_TypeIndex_t.DET_1_8G_DL_IN_H] << 8) | (data[(int)Bluecell_TypeIndex_t.DET_1_8G_DL_IN_L]);
  146. ret = temp_val * Volt_Calc_val;
  147. this.Invoke(new StringSend(Label_Text_Set), label1_8GHz_DL_IN, ret.ToString("N2") + "V");
  148. temp_val = (int)(data[(int)Bluecell_TypeIndex_t.DET_1_8G_DL_OUT_H] << 8) | (data[(int)Bluecell_TypeIndex_t.DET_1_8G_DL_OUT_L]);
  149. ret = temp_val * Volt_Calc_val;
  150. this.Invoke(new StringSend(Label_Text_Set), label1_8GHz_DL_OUT, ret.ToString("N2") + "V");
  151. temp_val = (int)(data[(int)Bluecell_TypeIndex_t.DET_1_8G_UL_IN_H] << 8) | (data[(int)Bluecell_TypeIndex_t.DET_1_8G_UL_IN_L]);
  152. ret = temp_val * Volt_Calc_val;
  153. this.Invoke(new StringSend(Label_Text_Set), label1_8GHz_UL_IN, ret.ToString("N2") + "V");
  154. temp_val = (int)(data[(int)Bluecell_TypeIndex_t.DET_1_8G_UL_OUT_H] << 8) | (data[(int)Bluecell_TypeIndex_t.DET_1_8G_UL_OUT_L]);
  155. ret = temp_val * Volt_Calc_val;
  156. this.Invoke(new StringSend(Label_Text_Set), label1_8GHz_UL_OUT, ret.ToString("N2") + "V");
  157. temp_val = (int)(data[(int)Bluecell_TypeIndex_t.DET_2_1G_DL_OUT_H] << 8) | (data[(int)Bluecell_TypeIndex_t.DET_2_1G_DL_IN_L]);
  158. ret = temp_val * Volt_Calc_val;
  159. this.Invoke(new StringSend(Label_Text_Set), label2_1GHz_DL_IN, ret.ToString("N2") + "V");
  160. temp_val = (int)(data[(int)Bluecell_TypeIndex_t.DET_2_1G_DL_OUT_H] << 8) | (data[(int)Bluecell_TypeIndex_t.DET_2_1G_DL_OUT_L]);
  161. ret = temp_val * Volt_Calc_val;
  162. this.Invoke(new StringSend(Label_Text_Set), label2_1GHz_DL_OUT, ret.ToString("N2") + "V");
  163. temp_val = (int)(data[(int)Bluecell_TypeIndex_t.DET_2_1G_UL_IN_H] << 8) | (data[(int)Bluecell_TypeIndex_t.DET_2_1G_UL_IN_L]);
  164. ret = temp_val * Volt_Calc_val;
  165. this.Invoke(new StringSend(Label_Text_Set), label2_1GHz_UL_IN, ret.ToString("N2") + "V");
  166. temp_val = (int)(data[(int)Bluecell_TypeIndex_t.DET_2_1G_UL_OUT_H] << 8) | (data[(int)Bluecell_TypeIndex_t.DET_2_1G_UL_OUT_L]);
  167. ret = temp_val * Volt_Calc_val;
  168. this.Invoke(new StringSend(Label_Text_Set), label2_1GHz_UL_OUT, ret.ToString("N2") + "V");
  169. temp_val = (int)(data[(int)Bluecell_TypeIndex_t.DET_3_5G_DL_IN_H] << 8) | (data[(int)Bluecell_TypeIndex_t.DET_3_5G_DL_IN_L]);
  170. ret = temp_val * Volt_Calc_val;
  171. this.Invoke(new StringSend(Label_Text_Set), label3_5GHz_DL_IN, ret.ToString("N2") + "V");
  172. temp_val = (int)(data[(int)Bluecell_TypeIndex_t.DET_3_5G_DL_OUT_H] << 8) | (data[(int)Bluecell_TypeIndex_t.DET_3_5G_DL_OUT_L]);
  173. ret = temp_val * Volt_Calc_val;
  174. this.Invoke(new StringSend(Label_Text_Set), label3_5GHz_DL_OUT, ret.ToString("N2") + "V");
  175. temp_val = (int)(data[(int)Bluecell_TypeIndex_t.DET_3_5G_UL_IN_H] << 8) | (data[(int)Bluecell_TypeIndex_t.DET_3_5G_UL_IN_L]);
  176. ret = temp_val * Volt_Calc_val;
  177. this.Invoke(new StringSend(Label_Text_Set), label3_5GHz_UL_IN, ret.ToString("N2") + "V");
  178. temp_val = (int)(data[(int)Bluecell_TypeIndex_t.DET_3_5G_UL_OUT_H] << 8) | (data[(int)Bluecell_TypeIndex_t.DET_3_5G_UL_OUT_L]);
  179. ret = temp_val * Volt_Calc_val;
  180. this.Invoke(new StringSend(Label_Text_Set), label3_5GHz_UL_OUT, ret.ToString("N2") + "V");
  181. temp_val = (int)(data[(int)Bluecell_TypeIndex_t.RFU_TEMP_H] << 8) | (data[(int)Bluecell_TypeIndex_t.RFU_TEMP_L]);
  182. ret = temp_val * Volt_Calc_val;
  183. this.Invoke(new StringSend(Label_Text_Set), label_RFU_Temp, ret.ToString("N2") + "V");
  184. temp_val = (int)(data[(int)Bluecell_TypeIndex_t._28V_DET_H] << 8) | (data[(int)Bluecell_TypeIndex_t._28V_DET_L]);
  185. ret = temp_val * Volt_Calc_val;
  186. this.Invoke(new StringSend(Label_Text_Set), label_28V_Det, ret.ToString("N2") + "V");
  187. if (IamSetting_Get() == false)
  188. {
  189. temp_val = data[(int)Bluecell_TypeIndex_t.ATT_1_8G_DL1];
  190. ret = bluecell_BootProtocol.Bluecell_Reverse_BDA4601_Calc(temp_val);
  191. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_1_8G_DL1, ret.ToString());
  192. temp_val = data[(int)Bluecell_TypeIndex_t.ATT_1_8G_DL2];
  193. ret = bluecell_BootProtocol.Bluecell_Reverse_BDA4601_Calc(temp_val);
  194. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_1_8G_DL2, ret.ToString());
  195. temp_val = data[(int)Bluecell_TypeIndex_t.ATT_1_8G_UL1];
  196. ret = bluecell_BootProtocol.Bluecell_Reverse_BDA4601_Calc(temp_val);
  197. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_1_8G_UL1, ret.ToString());
  198. temp_val = data[(int)Bluecell_TypeIndex_t.ATT_1_8G_UL2];
  199. ret = bluecell_BootProtocol.Bluecell_Reverse_BDA4601_Calc(temp_val);
  200. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_1_8G_UL2, ret.ToString());
  201. temp_val = data[(int)Bluecell_TypeIndex_t.ATT_1_8G_UL3];
  202. ret = bluecell_BootProtocol.Bluecell_Reverse_BDA4601_Calc(temp_val);
  203. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_1_8G_UL3, ret.ToString());
  204. temp_val = data[(int)Bluecell_TypeIndex_t.ATT_1_8G_UL4];
  205. ret = bluecell_BootProtocol.Bluecell_Reverse_BDA4601_Calc(temp_val);
  206. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_1_8G_UL4, ret.ToString());
  207. temp_val = data[(int)Bluecell_TypeIndex_t.ATT_2_1G_DL1];
  208. ret = bluecell_BootProtocol.Bluecell_Reverse_BDA4601_Calc(temp_val);
  209. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_2_1G_DL1, ret.ToString());
  210. temp_val = data[(int)Bluecell_TypeIndex_t.ATT_2_1G_DL2];
  211. ret = bluecell_BootProtocol.Bluecell_Reverse_BDA4601_Calc(temp_val);
  212. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_2_1G_DL2, ret.ToString());
  213. temp_val = data[(int)Bluecell_TypeIndex_t.ATT_2_1G_UL1];
  214. ret = bluecell_BootProtocol.Bluecell_Reverse_BDA4601_Calc(temp_val);
  215. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_2_1G_UL1, ret.ToString());
  216. temp_val = data[(int)Bluecell_TypeIndex_t.ATT_2_1G_UL2];
  217. ret = bluecell_BootProtocol.Bluecell_Reverse_BDA4601_Calc(temp_val);
  218. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_2_1G_UL2, ret.ToString());
  219. temp_val = data[(int)Bluecell_TypeIndex_t.ATT_2_1G_UL3];
  220. ret = bluecell_BootProtocol.Bluecell_Reverse_BDA4601_Calc(temp_val);
  221. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_2_1G_UL3, ret.ToString());
  222. temp_val = data[(int)Bluecell_TypeIndex_t.ATT_2_1G_UL4];
  223. ret = bluecell_BootProtocol.Bluecell_Reverse_BDA4601_Calc(temp_val);
  224. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_2_1G_UL4, ret.ToString());
  225. temp_val = data[(int)Bluecell_TypeIndex_t.ATT_3_5G_DL];
  226. ret = bluecell_BootProtocol.Bluecell_ReversePE43711_Calc(temp_val);
  227. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_3_5G_DL, ret.ToString());
  228. temp_val = data[(int)Bluecell_TypeIndex_t.ATT_3_5G_UL];
  229. ret = bluecell_BootProtocol.Bluecell_ReversePE43711_Calc(temp_val);
  230. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_3_5G_UL, ret.ToString());
  231. temp_val = data[(int)Bluecell_TypeIndex_t.ATT_3_5G_COM1];
  232. ret = bluecell_BootProtocol.Bluecell_ReversePE43711_Calc(temp_val);
  233. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_3_5G_COM1, ret.ToString());
  234. temp_val = data[(int)Bluecell_TypeIndex_t.ATT_3_5G_COM2];
  235. ret = bluecell_BootProtocol.Bluecell_ReversePE43711_Calc(temp_val);
  236. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_3_5G_COM2, ret.ToString());
  237. temp_val = data[(int)Bluecell_TypeIndex_t.ATT_3_5G_COM3];
  238. ret = bluecell_BootProtocol.Bluecell_ReversePE43711_Calc(temp_val);
  239. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_3_5G_COM3, ret.ToString());
  240. temp_val = data[(int)Bluecell_TypeIndex_t.PLL_1_8G_DL_H] << 8;
  241. temp_val = ((temp_val | data[(int)Bluecell_TypeIndex_t.PLL_1_8G_DL_L]) / 10);
  242. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_PLL_1_8G_DL, temp_val.ToString());
  243. temp_val = data[(int)Bluecell_TypeIndex_t.PLL_1_8G_UL_H] << 8;
  244. temp_val = ((temp_val | data[(int)Bluecell_TypeIndex_t.PLL_1_8G_UL_L]) / 10);
  245. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_PLL_1_8G_UL, temp_val.ToString());
  246. temp_val = data[(int)Bluecell_TypeIndex_t.PLL_2_1G_DL_H] << 8;
  247. temp_val = ((temp_val | data[(int)Bluecell_TypeIndex_t.PLL_2_1G_DL_L]) / 10);
  248. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_PLL_2_1G_DL, temp_val.ToString());
  249. temp_val = data[(int)Bluecell_TypeIndex_t.PLL_2_1G_UL_H] << 8;
  250. temp_val = ((temp_val | data[(int)Bluecell_TypeIndex_t.PLL_2_1G_UL_L]) / 10);
  251. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_PLL_2_1G_UL, temp_val.ToString());
  252. temp_val = data[(int)Bluecell_TypeIndex_t.PLL_3_5G_DL_H] << 8;
  253. temp_val = ((temp_val | data[(int)Bluecell_TypeIndex_t.PLL_3_5G_DL_L]) / 10);
  254. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_PLL_3_5G_DL, temp_val.ToString());
  255. temp_val = data[(int)Bluecell_TypeIndex_t.PLL_3_5G_UL_H] << 8;
  256. temp_val = ((temp_val | data[(int)Bluecell_TypeIndex_t.PLL_3_5G_UL_L]) / 10);
  257. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_PLL_3_5G_UL, temp_val.ToString());
  258. temp_val = data[(int)Bluecell_TypeIndex_t.DAC_VCtrl_A_H] << 8;
  259. temp_val = ((temp_val | data[(int)Bluecell_TypeIndex_t.DAC_VCtrl_A_L]) );
  260. ret = (temp_val & 0x0FFF) * 4;
  261. ret = ret / 4095;
  262. ret = Math.Round(Convert.ToDouble(ret), 1);
  263. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_DAC_VoltCtrl_A, ret.ToString());
  264. temp_val = data[(int)Bluecell_TypeIndex_t.DAC_VCtrl_B_H] << 8;
  265. temp_val = ((temp_val | data[(int)Bluecell_TypeIndex_t.DAC_VCtrl_B_L]) );
  266. ret = (temp_val & 0x0FFF) * 4;
  267. ret = ret / 4095;
  268. ret = Math.Round(Convert.ToDouble(ret), 1);
  269. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_DAC_VoltCtrl_B, ret.ToString());
  270. temp_val = data[(int)Bluecell_TypeIndex_t.DAC_VCtrl_C_H] << 8;
  271. temp_val = ((temp_val | data[(int)Bluecell_TypeIndex_t.DAC_VCtrl_C_L]) );
  272. ret = (temp_val & 0x0FFF) * 4;
  273. ret = ret / 4095;
  274. ret = Math.Round(Convert.ToDouble(ret ), 1);
  275. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_DAC_VoltCtrl_C, ret.ToString());
  276. temp_val = data[(int)Bluecell_TypeIndex_t.DAC_VCtrl_D_H] << 8;
  277. temp_val = ((temp_val | data[(int)Bluecell_TypeIndex_t.DAC_VCtrl_D_L]) );
  278. ret = (temp_val & 0x0FFF) * 4;
  279. ret = ret / 4095;
  280. ret = Math.Round(Convert.ToDouble(ret), 1);
  281. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_DAC_VoltCtrl_D, ret.ToString());
  282. temp_val = data[(int)Bluecell_TypeIndex_t.DAC_VCtrl_E_H] << 8;
  283. temp_val = ((temp_val | data[(int)Bluecell_TypeIndex_t.DAC_VCtrl_E_L]) );
  284. ret = (temp_val & 0x0FFF) * 4;
  285. ret = ret / 4095;
  286. ret = Math.Round(Convert.ToDouble(ret), 1);
  287. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_DAC_VoltCtrl_E, ret.ToString());
  288. temp_val = data[(int)Bluecell_TypeIndex_t.DAC_VCtrl_F_H] << 8;
  289. temp_val = ((temp_val | data[(int)Bluecell_TypeIndex_t.DAC_VCtrl_F_L]) );
  290. ret = (temp_val & 0x0FFF) * 4;
  291. ret = ret / 4095;
  292. ret = Math.Round(Convert.ToDouble(ret), 1);
  293. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_DAC_VoltCtrl_F, ret.ToString());
  294. temp_val = data[(int)Bluecell_TypeIndex_t.DAC_VCtrl_G_H] << 8;
  295. temp_val = ((temp_val | data[(int)Bluecell_TypeIndex_t.DAC_VCtrl_G_L]) );
  296. ret = (temp_val & 0x0FFF) * 4;
  297. ret = ret / 4095;
  298. ret = Math.Round(Convert.ToDouble(ret), 1);
  299. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_DAC_VoltCtrl_G, ret.ToString());
  300. temp_val = data[(int)Bluecell_TypeIndex_t.DAC_VCtrl_H_H] << 8;
  301. temp_val = ((temp_val | data[(int)Bluecell_TypeIndex_t.DAC_VCtrl_H_L]) );
  302. ret = (temp_val & 0x0FFF) * 4;
  303. ret = ret / 4095;
  304. ret = Math.Round(Convert.ToDouble(ret), 1);
  305. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_DAC_VoltCtrl_H, ret.ToString());
  306. PictureBox pic_on;
  307. PictureBox pic_off;
  308. pic_on = pictureBox_PATH_1_8G_DL_ON;
  309. pic_off = pictureBox_PATH_1_8G_DL_OFF;
  310. if (data[(int)Bluecell_TypeIndex_t.PATH_EN_1_8G_DL] > 0)
  311. {
  312. this.Invoke(new PictureBoxSend(PictureBox_On_OFF_Set), pic_on, pic_off, true);
  313. }
  314. else
  315. {
  316. this.Invoke(new PictureBoxSend(PictureBox_On_OFF_Set), pic_on, pic_off, false);
  317. }
  318. pic_on = pictureBox_PATH_1_8G_UL_ON;
  319. pic_off = pictureBox_PATH_1_8G_UL_OFF;
  320. if (data[(int)Bluecell_TypeIndex_t.PATH_EN_1_8G_UL] > 0)
  321. {
  322. this.Invoke(new PictureBoxSend(PictureBox_On_OFF_Set), pic_on, pic_off, true);
  323. }
  324. else
  325. {
  326. this.Invoke(new PictureBoxSend(PictureBox_On_OFF_Set), pic_on, pic_off, false);
  327. }
  328. pic_on = pictureBox_PATH_2_1G_DL_ON;
  329. pic_off = pictureBox_PATH_2_1G_DL_OFF;
  330. if (data[(int)Bluecell_TypeIndex_t.PATH_EN_2_1G_DL] > 0)
  331. {
  332. this.Invoke(new PictureBoxSend(PictureBox_On_OFF_Set), pic_on, pic_off, true);
  333. }
  334. else
  335. {
  336. this.Invoke(new PictureBoxSend(PictureBox_On_OFF_Set), pic_on, pic_off, false);
  337. }
  338. pic_on = pictureBox_PATH_2_1G_UL_ON;
  339. pic_off = pictureBox_PATH_2_1G_UL_OFF;
  340. if (data[(int)Bluecell_TypeIndex_t.PATH_EN_2_1G_UL] > 0)
  341. {
  342. this.Invoke(new PictureBoxSend(PictureBox_On_OFF_Set), pic_on, pic_off, true);
  343. }
  344. else
  345. {
  346. this.Invoke(new PictureBoxSend(PictureBox_On_OFF_Set), pic_on, pic_off, false);
  347. }
  348. pic_on = pictureBox_PATH_3_5G_DL_ON;
  349. pic_off = pictureBox_PATH_3_5G_DL_OFF;
  350. if (data[(int)Bluecell_TypeIndex_t.PATH_EN_3_5G_DL] > 0)
  351. {
  352. this.Invoke(new PictureBoxSend(PictureBox_On_OFF_Set), pic_on, pic_off, true);
  353. }
  354. else
  355. {
  356. this.Invoke(new PictureBoxSend(PictureBox_On_OFF_Set), pic_on, pic_off, false);
  357. }
  358. pic_on = pictureBox_PATH_3_5G_UL_ON;
  359. pic_off = pictureBox_PATH_3_5G_UL_OFF;
  360. if (data[(int)Bluecell_TypeIndex_t.PATH_EN_3_5G_UL] > 0)
  361. {
  362. this.Invoke(new PictureBoxSend(PictureBox_On_OFF_Set), pic_on, pic_off, true);
  363. }
  364. else
  365. {
  366. this.Invoke(new PictureBoxSend(PictureBox_On_OFF_Set), pic_on, pic_off, false);
  367. }
  368. pic_on = pictureBox_PATH_3_5G_H_ON;
  369. pic_off = pictureBox_PATH_3_5G_H_OFF;
  370. if (data[(int)Bluecell_TypeIndex_t.PATH_EN_3_5G_H] > 0)
  371. {
  372. this.Invoke(new PictureBoxSend(PictureBox_On_OFF_Set), pic_on, pic_off, true);
  373. }
  374. else
  375. {
  376. this.Invoke(new PictureBoxSend(PictureBox_On_OFF_Set), pic_on, pic_off, false);
  377. }
  378. pic_on = pictureBox_PATH_3_5G_L_ON;
  379. pic_off = pictureBox_PATH_3_5G_L_OFF;
  380. if (data[(int)Bluecell_TypeIndex_t.PATH_EN_3_5G_L] > 0)
  381. {
  382. this.Invoke(new PictureBoxSend(PictureBox_On_OFF_Set), pic_on, pic_off, true);
  383. }
  384. else
  385. {
  386. this.Invoke(new PictureBoxSend(PictureBox_On_OFF_Set), pic_on, pic_off, false);
  387. }
  388. pic_on = pictureBox_PLL_ON_OFF_3_5G_H_ON;
  389. pic_off = pictureBox_PLL_ON_OFF_3_5G_H_OFF;
  390. if (data[(int)Bluecell_TypeIndex_t.PLL_ON_OFF_3_5G_H] > 0)
  391. {
  392. this.Invoke(new PictureBoxSend(PictureBox_On_OFF_Set), pic_on, pic_off, true);
  393. }
  394. else
  395. {
  396. this.Invoke(new PictureBoxSend(PictureBox_On_OFF_Set), pic_on, pic_off, false);
  397. }
  398. pic_on = pictureBox_PLL_ON_OFF_3_5G_L_ON;
  399. pic_off = pictureBox_PLL_ON_OFF_3_5G_L_OFF;
  400. if (data[(int)Bluecell_TypeIndex_t.PLL_ON_OFF_3_5G_L] > 0)
  401. {
  402. this.Invoke(new PictureBoxSend(PictureBox_On_OFF_Set), pic_on, pic_off, true);
  403. }
  404. else
  405. {
  406. this.Invoke(new PictureBoxSend(PictureBox_On_OFF_Set), pic_on, pic_off, false);
  407. }
  408. // this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_1_8G_DL2, data[(int)Bluecell_TypeIndex_t.ATT_1_8G_DL2]);
  409. }
  410. }
  411. catch { /*MessageBox.Show("What is this?");*/ }
  412. }
  413. private delegate void PictureBoxSend(object picon, object picoff, bool set);
  414. private void PictureBox_On_OFF_Set(object pic_on,object pic_off,bool set)
  415. {
  416. PictureBox picture_on = (PictureBox)pic_on;
  417. PictureBox picture_off = (PictureBox)pic_off;
  418. picture_on.Visible = set;
  419. picture_off.Visible =!set;
  420. }
  421. public void ReSetting_Values(byte[] temp_buf)
  422. {
  423. this.numericUpDown_ATT_1_8G_DL1.Text = temp_buf[(byte)Bluecell_TypeIndex_t.ATT_1_8G_DL1].ToString();
  424. /*this.numericUpDown_ATT_1_8G_DL2.Text;
  425. this.numericUpDown_ATT_1_8G_UL1.Text;
  426. this.numericUpDown_ATT_1_8G_UL2.Text;
  427. this.numericUpDown_ATT_1_8G_UL3.Text;
  428. this.numericUpDown_ATT_1_8G_UL4.Text;
  429. this.numericUpDown_ATT_2_1G_DL1.Text;
  430. this.numericUpDown_ATT_2_1G_DL2.Text;
  431. this.numericUpDown_ATT_2_1G_UL1.Text;
  432. this.numericUpDown_ATT_2_1G_UL2.Text;
  433. this.numericUpDown_ATT_2_1G_UL3.Text;
  434. this.numericUpDown_ATT_2_1G_UL4.Text;
  435. this.numericUpDown_ATT_3_5G_DL.Text;
  436. this.numericUpDown_ATT_3_5G_UL.Text;
  437. this.numericUpDown_ATT_3_5G_COM1.Text;
  438. this.numericUpDown_ATT_3_5G_COM2.Text;
  439. this.numericUpDown_ATT_3_5G_COM3.Text;*/
  440. }
  441. private void Label_Text_Set(object label, String str)
  442. {
  443. Label Temp_label = (Label)label;
  444. Temp_label.Text = str;
  445. }
  446. private void numeric_Text_Set(object numeric, String str)
  447. {
  448. NumericUpDown Temp_numeric = (NumericUpDown)numeric;
  449. Temp_numeric.Text = str;
  450. }
  451. private void ATT_Enter(object sender, KeyEventArgs e)
  452. {
  453. if (e.KeyCode == Keys.Enter)
  454. {
  455. Button_Set_Click(sender, e);
  456. //to do
  457. }
  458. else
  459. {
  460. return;
  461. }
  462. }
  463. private void TDD_T_SYNC_Click(object sender, EventArgs e)
  464. {
  465. PictureBox pictureBox = (PictureBox)sender;
  466. Tdd_T_Sync = Convert.ToByte(pictureBox.Tag);
  467. bluecell_BootProtocol.Bluecell_BtnSet(this.serial, this);
  468. pictureBox_TDD_T_SYNC_UL_ON.Visible = !pictureBox_TDD_T_SYNC_UL_ON.Visible;
  469. pictureBox_TDD_T_SYNC_DL_OFF.Visible = !pictureBox_TDD_T_SYNC_DL_OFF.Visible;
  470. }
  471. const byte PATH_1_8G_DL_ON = 1;
  472. const byte PATH_1_8G_DL_OFF = 2;
  473. const byte PATH_1_8G_UL_ON = 3;
  474. const byte PATH_1_8G_UL_OFF = 4;
  475. const byte PATH_2_1G_DL_ON = 5;
  476. const byte PATH_2_1G_DL_OFF = 6;
  477. const byte PATH_2_1G_UL_ON = 7;
  478. const byte PATH_2_1G_UL_OFF = 8;
  479. const byte PATH_3_5G_DL_ON = 9;
  480. const byte PATH_3_5G_DL_OFF = 10;
  481. const byte PATH_3_5G_UL_ON = 11;
  482. const byte PATH_3_5G_UL_OFF = 12;
  483. const byte PATH_3_5G_H_ON = 13;
  484. const byte PATH_3_5G_H_OFF = 14;
  485. const byte PATH_3_5G_L_ON = 15;
  486. const byte PATH_3_5G_L_OFF = 16;
  487. const byte PLL_POWER_ONOFF_3_5G_H_ON = 17;
  488. const byte PLL_POWER_ONOFF_3_5G_H_OFF = 18;
  489. const byte PLL_POWER_ONOFF_3_5G_L_ON = 19;
  490. const byte PLL_POWER_ONOFF_3_5G_L_OFF = 20;
  491. private void Power_OnOff_Set(object sender, EventArgs e)
  492. {
  493. byte temp_tag = 0;
  494. PictureBox pictureBox = (PictureBox)sender;
  495. temp_tag = Convert.ToByte(pictureBox.Tag);
  496. switch (temp_tag)
  497. {
  498. case PATH_1_8G_DL_OFF:
  499. pictureBox_PATH_1_8G_DL_ON.Visible = true;
  500. break;
  501. case PATH_1_8G_DL_ON:
  502. pictureBox_PATH_1_8G_DL_OFF.Visible = true;
  503. break;
  504. case PATH_1_8G_UL_OFF:
  505. pictureBox_PATH_1_8G_UL_ON.Visible = true;
  506. break;
  507. case PATH_1_8G_UL_ON:
  508. pictureBox_PATH_1_8G_UL_OFF.Visible = true;
  509. break;
  510. case PATH_2_1G_DL_OFF:
  511. pictureBox_PATH_2_1G_DL_ON.Visible = true;
  512. break;
  513. case PATH_2_1G_DL_ON:
  514. pictureBox_PATH_2_1G_DL_OFF.Visible = true;
  515. break;
  516. case PATH_2_1G_UL_OFF:
  517. pictureBox_PATH_2_1G_UL_ON.Visible = true;
  518. break;
  519. case PATH_2_1G_UL_ON:
  520. pictureBox_PATH_2_1G_UL_OFF.Visible = true;
  521. break;
  522. case PATH_3_5G_DL_OFF:
  523. pictureBox_PATH_3_5G_DL_ON.Visible = true;
  524. break;
  525. case PATH_3_5G_DL_ON:
  526. pictureBox_PATH_3_5G_DL_OFF.Visible = true;
  527. break;
  528. case PATH_3_5G_UL_OFF:
  529. pictureBox_PATH_3_5G_UL_ON.Visible = true;
  530. break;
  531. case PATH_3_5G_UL_ON:
  532. pictureBox_PATH_3_5G_UL_OFF.Visible = true;
  533. break;
  534. case PATH_3_5G_H_OFF:
  535. pictureBox_PATH_3_5G_H_ON.Visible = true;
  536. break;
  537. case PATH_3_5G_H_ON:
  538. pictureBox_PATH_3_5G_H_OFF.Visible = true;
  539. break;
  540. case PATH_3_5G_L_OFF:
  541. pictureBox_PATH_3_5G_L_ON.Visible = true;
  542. break;
  543. case PATH_3_5G_L_ON:
  544. pictureBox_PATH_3_5G_L_OFF.Visible = true;
  545. break;
  546. case PLL_POWER_ONOFF_3_5G_H_ON:
  547. pictureBox_PLL_ON_OFF_3_5G_H_OFF.Visible = true;
  548. break;
  549. case PLL_POWER_ONOFF_3_5G_H_OFF:
  550. pictureBox_PLL_ON_OFF_3_5G_H_ON.Visible = true;
  551. break;
  552. case PLL_POWER_ONOFF_3_5G_L_ON:
  553. pictureBox_PLL_ON_OFF_3_5G_L_OFF.Visible = true;
  554. break;
  555. case PLL_POWER_ONOFF_3_5G_L_OFF:
  556. pictureBox_PLL_ON_OFF_3_5G_L_ON.Visible = true;
  557. break;
  558. }
  559. pictureBox.Visible = !pictureBox.Visible;
  560. bluecell_BootProtocol.Bluecell_BtnSet(this.serial, this);
  561. }
  562. private void button1_Click(object sender, EventArgs e)
  563. {
  564. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_1_8G_DL1, "0.0");
  565. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_1_8G_DL2, "0.0");
  566. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_1_8G_UL1, "0.0");
  567. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_1_8G_UL2, "0.0");
  568. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_1_8G_UL3, "0.0");
  569. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_1_8G_UL4, "0.0");
  570. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_2_1G_DL1, "0.0");
  571. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_2_1G_DL2, "0.0");
  572. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_2_1G_UL1, "0.0");
  573. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_2_1G_UL2, "0.0");
  574. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_2_1G_UL3, "0.0");
  575. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_2_1G_UL4, "0.0");
  576. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_3_5G_DL, "0.0");
  577. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_3_5G_UL, "0.0");
  578. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_3_5G_COM1, "0.0");
  579. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_3_5G_COM2, "0.0");
  580. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_3_5G_COM3, "0.0");
  581. Button_Set_Click(sender, e);
  582. /*Crc16 crc16 = new Crc16();
  583. byte[] temp_buf = new byte[6];
  584. temp_buf[0] = 0xbe;
  585. temp_buf[1] = 2;
  586. temp_buf[2] = 4;
  587. temp_buf[3] = 5;
  588. temp_buf[4] = crc16.STH30_CreateCrc(temp_buf, temp_buf[2]);
  589. temp_buf[5] = 0xeb;
  590. serial.Serial_DataSend(temp_buf, temp_buf[2] + 2);*/
  591. }
  592. private void Button_Set_Click(object sender, EventArgs e)
  593. {
  594. bluecell_BootProtocol.Bluecell_BtnSet(this.serial, this);
  595. }
  596. private bool IamSetting = false;
  597. private void Activi_Change__Setting(object sender, EventArgs e)
  598. {
  599. IamSetting = true;
  600. }
  601. private void Activi_Change__SettingComplete(object sender, EventArgs e)
  602. {
  603. IamSetting = false;
  604. }
  605. public bool IamSetting_Get()
  606. {
  607. return IamSetting;
  608. }
  609. private void Cusor_DeFocus(object sender, EventArgs e)
  610. {
  611. GroupBox grp = (GroupBox)sender;
  612. grp.Focus();
  613. }
  614. private void button_Save_Click(object sender, EventArgs e)
  615. {
  616. Crc16 crc16 = new Crc16();
  617. byte[] temp_buf = new byte[6];
  618. temp_buf[0] = 0xbe;
  619. temp_buf[1] = 3;
  620. temp_buf[2] = 3;
  621. temp_buf[3] = 4;
  622. temp_buf[4] = crc16.STH30_CreateCrc(temp_buf, temp_buf[2]);
  623. temp_buf[5] = 0xeb;
  624. serial.Serial_DataSend(temp_buf, temp_buf[2] + 3);
  625. }
  626. }
  627. }