Main_Form.cs 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783
  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 (setcheck_checkBox.Checked == true)
  31. setcheck_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. /***********************DAC A Sector**********************************/
  285. temp_val = data[(int)Bluecell_TypeIndex_t.DAC_VCtrl_A_H] << 8;
  286. temp_val = ((temp_val | data[(int)Bluecell_TypeIndex_t.DAC_VCtrl_A_L]) );
  287. ret = (temp_val & 0x0FFF) * 4;
  288. ret = ret / 4095;
  289. ret = Math.Round(Convert.ToDouble(ret), 2);
  290. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_DAC_VoltCtrl_A, ret.ToString());
  291. /***********************DAC B Sector**********************************/
  292. temp_val = data[(int)Bluecell_TypeIndex_t.DAC_VCtrl_B_H] << 8;
  293. temp_val = ((temp_val | data[(int)Bluecell_TypeIndex_t.DAC_VCtrl_B_L]) );
  294. ret = (temp_val & 0x0FFF) * 4;
  295. ret = ret / 4095;
  296. ret = Math.Round(Convert.ToDouble(ret), 2);
  297. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_DAC_VoltCtrl_B, ret.ToString());
  298. /***********************DAC C Sector**********************************/
  299. temp_val = data[(int)Bluecell_TypeIndex_t.DAC_VCtrl_C_H] << 8;
  300. temp_val = ((temp_val | data[(int)Bluecell_TypeIndex_t.DAC_VCtrl_C_L]) );
  301. ret = (temp_val & 0x0FFF) * 4;
  302. ret = ret / 4095;
  303. ret = Math.Round(Convert.ToDouble(ret ), 2);
  304. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_DAC_VoltCtrl_C, ret.ToString());
  305. /***********************DAC D Sector**********************************/
  306. temp_val = data[(int)Bluecell_TypeIndex_t.DAC_VCtrl_D_H] << 8;
  307. temp_val = ((temp_val | data[(int)Bluecell_TypeIndex_t.DAC_VCtrl_D_L]) );
  308. ret = (temp_val & 0x0FFF) * 4;
  309. ret = ret / 4095;
  310. ret = Math.Round(Convert.ToDouble(ret), 2);
  311. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_DAC_VoltCtrl_D, ret.ToString());
  312. /***********************DAC E Sector**********************************/
  313. temp_val = data[(int)Bluecell_TypeIndex_t.DAC_VCtrl_E_H] << 8;
  314. temp_val = ((temp_val | data[(int)Bluecell_TypeIndex_t.DAC_VCtrl_E_L]) );
  315. ret = (temp_val & 0x0FFF) * 4;
  316. ret = ret / 4095;
  317. ret = Math.Round(Convert.ToDouble(ret), 2);
  318. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_DAC_VoltCtrl_E, ret.ToString());
  319. /***********************DAC F Sector**********************************/
  320. temp_val = data[(int)Bluecell_TypeIndex_t.DAC_VCtrl_F_H] << 8;
  321. temp_val = ((temp_val | data[(int)Bluecell_TypeIndex_t.DAC_VCtrl_F_L]) );
  322. ret = (temp_val & 0x0FFF) * 4;
  323. ret = ret / 4095;
  324. ret = Math.Round(Convert.ToDouble(ret), 2);
  325. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_DAC_VoltCtrl_F, ret.ToString());
  326. /***********************DAC G Sector**********************************/
  327. temp_val = data[(int)Bluecell_TypeIndex_t.DAC_VCtrl_G_H] << 8;
  328. temp_val = ((temp_val | data[(int)Bluecell_TypeIndex_t.DAC_VCtrl_G_L]) );
  329. ret = (temp_val & 0x0FFF) * 4;
  330. ret = ret / 4095;
  331. ret = Math.Round(Convert.ToDouble(ret), 2);
  332. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_DAC_VoltCtrl_G, ret.ToString());
  333. /***********************DAC H Sector**********************************/
  334. temp_val = data[(int)Bluecell_TypeIndex_t.DAC_VCtrl_H_H] << 8;
  335. temp_val = ((temp_val | data[(int)Bluecell_TypeIndex_t.DAC_VCtrl_H_L]) );
  336. ret = (temp_val & 0x0FFF) * 4;
  337. ret = ret / 4095;
  338. ret = Math.Round(Convert.ToDouble(ret), 2);
  339. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_DAC_VoltCtrl_H, ret.ToString());
  340. PictureBox pic_on;
  341. PictureBox pic_off;
  342. pic_on = pictureBox_PATH_1_8G_DL_ON;
  343. pic_off = pictureBox_PATH_1_8G_DL_OFF;
  344. if (data[(int)Bluecell_TypeIndex_t.PATH_EN_1_8G_DL] > 0)
  345. {
  346. this.Invoke(new PictureBoxSend(PictureBox_On_OFF_Set), pic_on, pic_off, true);
  347. }
  348. else
  349. {
  350. this.Invoke(new PictureBoxSend(PictureBox_On_OFF_Set), pic_on, pic_off, false);
  351. }
  352. pic_on = pictureBox_PATH_1_8G_UL_ON;
  353. pic_off = pictureBox_PATH_1_8G_UL_OFF;
  354. if (data[(int)Bluecell_TypeIndex_t.PATH_EN_1_8G_UL] > 0)
  355. {
  356. this.Invoke(new PictureBoxSend(PictureBox_On_OFF_Set), pic_on, pic_off, true);
  357. }
  358. else
  359. {
  360. this.Invoke(new PictureBoxSend(PictureBox_On_OFF_Set), pic_on, pic_off, false);
  361. }
  362. pic_on = pictureBox_PATH_2_1G_DL_ON;
  363. pic_off = pictureBox_PATH_2_1G_DL_OFF;
  364. if (data[(int)Bluecell_TypeIndex_t.PATH_EN_2_1G_DL] > 0)
  365. {
  366. this.Invoke(new PictureBoxSend(PictureBox_On_OFF_Set), pic_on, pic_off, true);
  367. }
  368. else
  369. {
  370. this.Invoke(new PictureBoxSend(PictureBox_On_OFF_Set), pic_on, pic_off, false);
  371. }
  372. pic_on = pictureBox_PATH_2_1G_UL_ON;
  373. pic_off = pictureBox_PATH_2_1G_UL_OFF;
  374. if (data[(int)Bluecell_TypeIndex_t.PATH_EN_2_1G_UL] > 0)
  375. {
  376. this.Invoke(new PictureBoxSend(PictureBox_On_OFF_Set), pic_on, pic_off, true);
  377. }
  378. else
  379. {
  380. this.Invoke(new PictureBoxSend(PictureBox_On_OFF_Set), pic_on, pic_off, false);
  381. }
  382. pic_on = pictureBox_PATH_3_5G_DL_ON;
  383. pic_off = pictureBox_PATH_3_5G_DL_OFF;
  384. if (data[(int)Bluecell_TypeIndex_t.PATH_EN_3_5G_DL] > 0)
  385. {
  386. this.Invoke(new PictureBoxSend(PictureBox_On_OFF_Set), pic_on, pic_off, true);
  387. }
  388. else
  389. {
  390. this.Invoke(new PictureBoxSend(PictureBox_On_OFF_Set), pic_on, pic_off, false);
  391. }
  392. pic_on = pictureBox_PATH_3_5G_UL_ON;
  393. pic_off = pictureBox_PATH_3_5G_UL_OFF;
  394. if (data[(int)Bluecell_TypeIndex_t.PATH_EN_3_5G_UL] > 0)
  395. {
  396. this.Invoke(new PictureBoxSend(PictureBox_On_OFF_Set), pic_on, pic_off, true);
  397. }
  398. else
  399. {
  400. this.Invoke(new PictureBoxSend(PictureBox_On_OFF_Set), pic_on, pic_off, false);
  401. }
  402. pic_on = pictureBox_PATH_3_5G_H_ON;
  403. pic_off = pictureBox_PATH_3_5G_H_OFF;
  404. if (data[(int)Bluecell_TypeIndex_t.PATH_EN_3_5G_H] > 0)
  405. {
  406. this.Invoke(new PictureBoxSend(PictureBox_On_OFF_Set), pic_on, pic_off, true);
  407. }
  408. else
  409. {
  410. this.Invoke(new PictureBoxSend(PictureBox_On_OFF_Set), pic_on, pic_off, false);
  411. }
  412. pic_on = pictureBox_PATH_3_5G_L_ON;
  413. pic_off = pictureBox_PATH_3_5G_L_OFF;
  414. if (data[(int)Bluecell_TypeIndex_t.PATH_EN_3_5G_L] > 0)
  415. {
  416. this.Invoke(new PictureBoxSend(PictureBox_On_OFF_Set), pic_on, pic_off, true);
  417. }
  418. else
  419. {
  420. this.Invoke(new PictureBoxSend(PictureBox_On_OFF_Set), pic_on, pic_off, false);
  421. }
  422. pic_on = pictureBox_PLL_ON_OFF_3_5G_H_ON;
  423. pic_off = pictureBox_PLL_ON_OFF_3_5G_H_OFF;
  424. if (data[(int)Bluecell_TypeIndex_t.PLL_ON_OFF_3_5G_H] > 0)
  425. {
  426. this.Invoke(new PictureBoxSend(PictureBox_On_OFF_Set), pic_on, pic_off, true);
  427. }
  428. else
  429. {
  430. this.Invoke(new PictureBoxSend(PictureBox_On_OFF_Set), pic_on, pic_off, false);
  431. }
  432. pic_on = pictureBox_PLL_ON_OFF_3_5G_L_ON;
  433. pic_off = pictureBox_PLL_ON_OFF_3_5G_L_OFF;
  434. if (data[(int)Bluecell_TypeIndex_t.PLL_ON_OFF_3_5G_L] > 0)
  435. {
  436. this.Invoke(new PictureBoxSend(PictureBox_On_OFF_Set), pic_on, pic_off, true);
  437. }
  438. else
  439. {
  440. this.Invoke(new PictureBoxSend(PictureBox_On_OFF_Set), pic_on, pic_off, false);
  441. }
  442. if (data[(int)Bluecell_TypeIndex_t.T_SYNC_DL] > 0)
  443. {
  444. TDD_T_SYNC_Get();
  445. //this.Invoke(new PictureBoxSend(PictureBox_On_OFF_Set), pic_on, pic_off, true);
  446. }
  447. else
  448. {
  449. //this.Invoke(new PictureBoxSend(PictureBox_On_OFF_Set), pic_on, pic_off, false);
  450. }
  451. // this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_1_8G_DL2, data[(int)Bluecell_TypeIndex_t.ATT_1_8G_DL2]);
  452. }
  453. }
  454. catch { /*MessageBox.Show("What is this?");*/ }
  455. }
  456. private delegate void PictureBoxSend(object picon, object picoff, bool set);
  457. private void PictureBox_On_OFF_Set(object pic_on,object pic_off,bool set)
  458. {
  459. PictureBox picture_on = (PictureBox)pic_on;
  460. PictureBox picture_off = (PictureBox)pic_off;
  461. picture_on.Visible = set;
  462. picture_off.Visible =!set;
  463. }
  464. public void ReSetting_Values(byte[] temp_buf)
  465. {
  466. this.numericUpDown_ATT_1_8G_DL1.Text = temp_buf[(byte)Bluecell_TypeIndex_t.ATT_1_8G_DL1].ToString();
  467. /*this.numericUpDown_ATT_1_8G_DL2.Text;
  468. this.numericUpDown_ATT_1_8G_UL1.Text;
  469. this.numericUpDown_ATT_1_8G_UL2.Text;
  470. this.numericUpDown_ATT_1_8G_UL3.Text;
  471. this.numericUpDown_ATT_1_8G_UL4.Text;
  472. this.numericUpDown_ATT_2_1G_DL1.Text;
  473. this.numericUpDown_ATT_2_1G_DL2.Text;
  474. this.numericUpDown_ATT_2_1G_UL1.Text;
  475. this.numericUpDown_ATT_2_1G_UL2.Text;
  476. this.numericUpDown_ATT_2_1G_UL3.Text;
  477. this.numericUpDown_ATT_2_1G_UL4.Text;
  478. this.numericUpDown_ATT_3_5G_DL.Text;
  479. this.numericUpDown_ATT_3_5G_UL.Text;
  480. this.numericUpDown_ATT_3_5G_COM1.Text;
  481. this.numericUpDown_ATT_3_5G_COM2.Text;
  482. this.numericUpDown_ATT_3_5G_COM3.Text;*/
  483. }
  484. private void Label_Text_Set(object label, String str)
  485. {
  486. Label Temp_label = (Label)label;
  487. Temp_label.Text = str;
  488. }
  489. private void numeric_Text_Set(object numeric, String str)
  490. {
  491. NumericUpDown Temp_numeric = (NumericUpDown)numeric;
  492. Temp_numeric.Text = str;
  493. }
  494. private void ATT_Enter(object sender, KeyEventArgs e)
  495. {
  496. if (e.KeyCode == Keys.Enter)
  497. {
  498. Button_Set_Click(sender, e);
  499. //to do
  500. }
  501. else
  502. {
  503. return;
  504. }
  505. }
  506. private void TDD_T_SYNC_Click(object sender, EventArgs e)
  507. {
  508. PictureBox pictureBox = (PictureBox)sender;
  509. Tdd_T_Sync = Convert.ToByte(pictureBox.Tag);
  510. bluecell_BootProtocol.Bluecell_BtnSet(this.serial, this);
  511. pictureBox_TDD_T_SYNC_UL_ON.Visible = !pictureBox_TDD_T_SYNC_UL_ON.Visible;
  512. pictureBox_TDD_T_SYNC_DL_OFF.Visible = !pictureBox_TDD_T_SYNC_DL_OFF.Visible;
  513. }
  514. private void TDD_T_SYNC_Get()
  515. {
  516. }
  517. const byte PATH_1_8G_DL_ON = 1;
  518. const byte PATH_1_8G_DL_OFF = 2;
  519. const byte PATH_1_8G_UL_ON = 3;
  520. const byte PATH_1_8G_UL_OFF = 4;
  521. const byte PATH_2_1G_DL_ON = 5;
  522. const byte PATH_2_1G_DL_OFF = 6;
  523. const byte PATH_2_1G_UL_ON = 7;
  524. const byte PATH_2_1G_UL_OFF = 8;
  525. const byte PATH_3_5G_DL_ON = 9;
  526. const byte PATH_3_5G_DL_OFF = 10;
  527. const byte PATH_3_5G_UL_ON = 11;
  528. const byte PATH_3_5G_UL_OFF = 12;
  529. const byte PATH_3_5G_H_ON = 13;
  530. const byte PATH_3_5G_H_OFF = 14;
  531. const byte PATH_3_5G_L_ON = 15;
  532. const byte PATH_3_5G_L_OFF = 16;
  533. const byte PLL_POWER_ONOFF_3_5G_H_ON = 17;
  534. const byte PLL_POWER_ONOFF_3_5G_H_OFF = 18;
  535. const byte PLL_POWER_ONOFF_3_5G_L_ON = 19;
  536. const byte PLL_POWER_ONOFF_3_5G_L_OFF = 20;
  537. private void Power_OnOff_Set(object sender, EventArgs e)
  538. {
  539. byte temp_tag = 0;
  540. PictureBox pictureBox = (PictureBox)sender;
  541. temp_tag = Convert.ToByte(pictureBox.Tag);
  542. switch (temp_tag)
  543. {
  544. case PATH_1_8G_DL_OFF:
  545. pictureBox_PATH_1_8G_DL_ON.Visible = true;
  546. break;
  547. case PATH_1_8G_DL_ON:
  548. pictureBox_PATH_1_8G_DL_OFF.Visible = true;
  549. break;
  550. case PATH_1_8G_UL_OFF:
  551. pictureBox_PATH_1_8G_UL_ON.Visible = true;
  552. break;
  553. case PATH_1_8G_UL_ON:
  554. pictureBox_PATH_1_8G_UL_OFF.Visible = true;
  555. break;
  556. case PATH_2_1G_DL_OFF:
  557. pictureBox_PATH_2_1G_DL_ON.Visible = true;
  558. break;
  559. case PATH_2_1G_DL_ON:
  560. pictureBox_PATH_2_1G_DL_OFF.Visible = true;
  561. break;
  562. case PATH_2_1G_UL_OFF:
  563. pictureBox_PATH_2_1G_UL_ON.Visible = true;
  564. break;
  565. case PATH_2_1G_UL_ON:
  566. pictureBox_PATH_2_1G_UL_OFF.Visible = true;
  567. break;
  568. case PATH_3_5G_DL_OFF:
  569. pictureBox_PATH_3_5G_DL_ON.Visible = true;
  570. break;
  571. case PATH_3_5G_DL_ON:
  572. pictureBox_PATH_3_5G_DL_OFF.Visible = true;
  573. break;
  574. case PATH_3_5G_UL_OFF:
  575. pictureBox_PATH_3_5G_UL_ON.Visible = true;
  576. break;
  577. case PATH_3_5G_UL_ON:
  578. pictureBox_PATH_3_5G_UL_OFF.Visible = true;
  579. break;
  580. case PATH_3_5G_H_OFF:
  581. pictureBox_PATH_3_5G_H_ON.Visible = true;
  582. break;
  583. case PATH_3_5G_H_ON:
  584. pictureBox_PATH_3_5G_H_OFF.Visible = true;
  585. break;
  586. case PATH_3_5G_L_OFF:
  587. pictureBox_PATH_3_5G_L_ON.Visible = true;
  588. break;
  589. case PATH_3_5G_L_ON:
  590. pictureBox_PATH_3_5G_L_OFF.Visible = true;
  591. break;
  592. case PLL_POWER_ONOFF_3_5G_H_ON:
  593. pictureBox_PLL_ON_OFF_3_5G_H_OFF.Visible = true;
  594. break;
  595. case PLL_POWER_ONOFF_3_5G_H_OFF:
  596. pictureBox_PLL_ON_OFF_3_5G_H_ON.Visible = true;
  597. break;
  598. case PLL_POWER_ONOFF_3_5G_L_ON:
  599. pictureBox_PLL_ON_OFF_3_5G_L_OFF.Visible = true;
  600. break;
  601. case PLL_POWER_ONOFF_3_5G_L_OFF:
  602. pictureBox_PLL_ON_OFF_3_5G_L_ON.Visible = true;
  603. break;
  604. }
  605. pictureBox.Visible = !pictureBox.Visible;
  606. bluecell_BootProtocol.Bluecell_BtnSet(this.serial, this);
  607. }
  608. private void button1_Click(object sender, EventArgs e)
  609. {
  610. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_1_8G_DL1, "0.0");
  611. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_1_8G_DL2, "0.0");
  612. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_1_8G_UL1, "0.0");
  613. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_1_8G_UL2, "0.0");
  614. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_1_8G_UL3, "0.0");
  615. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_1_8G_UL4, "0.0");
  616. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_2_1G_DL1, "0.0");
  617. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_2_1G_DL2, "0.0");
  618. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_2_1G_UL1, "0.0");
  619. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_2_1G_UL2, "0.0");
  620. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_2_1G_UL3, "0.0");
  621. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_2_1G_UL4, "0.0");
  622. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_3_5G_DL, "0.0");
  623. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_3_5G_UL, "0.0");
  624. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_3_5G_COM1, "0.0");
  625. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_3_5G_COM2, "0.0");
  626. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_3_5G_COM3, "0.0");
  627. Button_Set_Click(sender, e);
  628. /*Crc16 crc16 = new Crc16();
  629. byte[] temp_buf = new byte[6];
  630. temp_buf[0] = 0xbe;
  631. temp_buf[1] = 2;
  632. temp_buf[2] = 4;
  633. temp_buf[3] = 5;
  634. temp_buf[4] = crc16.STH30_CreateCrc(temp_buf, temp_buf[2]);
  635. temp_buf[5] = 0xeb;
  636. serial.Serial_DataSend(temp_buf, temp_buf[2] + 2);*/
  637. }
  638. private void Button_Set_Click(object sender, EventArgs e)
  639. {
  640. bluecell_BootProtocol.Bluecell_BtnSet(this.serial, this);
  641. }
  642. private bool IamSetting = false;
  643. private void Activi_Change__Setting(object sender, EventArgs e)
  644. {
  645. IamSetting = true;
  646. }
  647. private void Activi_Change__SettingComplete(object sender, EventArgs e)
  648. {
  649. IamSetting = false;
  650. }
  651. public bool IamSetting_Get()
  652. {
  653. return IamSetting;
  654. }
  655. private void Cusor_DeFocus(object sender, EventArgs e)
  656. {
  657. GroupBox grp = (GroupBox)sender;
  658. grp.Focus();
  659. }
  660. private void button_Save_Click(object sender, EventArgs e)
  661. {
  662. Crc16 crc16 = new Crc16();
  663. byte[] temp_buf = new byte[6];
  664. temp_buf[0] = 0xbe;
  665. temp_buf[1] = 3;
  666. temp_buf[2] = 3;
  667. temp_buf[3] = 4;
  668. temp_buf[4] = crc16.STH30_CreateCrc(temp_buf, temp_buf[2]);
  669. temp_buf[5] = 0xeb;
  670. serial.Serial_DataSend(temp_buf, temp_buf[2] + 3);
  671. }
  672. public void Message_Box_Open()
  673. {
  674. //blue_MessageBox blue_MessageBox = new Blue_MessageBox();
  675. //MessageBox.Show("Setting OK");
  676. if(setcheck_checkBox.Checked == true)
  677. MessageBox.Show("OK",
  678. "Setting",
  679. MessageBoxButtons.OK,
  680. MessageBoxIcon.None,
  681. MessageBoxDefaultButton.Button1,
  682. MessageBoxOptions.DefaultDesktopOnly);
  683. }
  684. private void comboBox_Port_MouseDown(object sender, MouseEventArgs e)
  685. {
  686. // serial.SetPortNameValues(comboBox_Port);
  687. }
  688. }
  689. }