Main_Form.cs 37 KB

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