Main_Form.cs 35 KB

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