Main_Form.cs 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808
  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. using System.Reflection;
  14. namespace RF_TRIO_PLL_ZIG
  15. {
  16. public partial class Main_Form : Form
  17. {
  18. Serial serial = new Serial(); // Uart Open
  19. Bluecell_BootProtocol bluecell_BootProtocol = new Bluecell_BootProtocol();
  20. Update_Serial file = new Update_Serial();
  21. public byte Tdd_T_Sync = 0;
  22. public Main_Form()
  23. {
  24. InitializeComponent();
  25. serial.Serial_Initialize(ref comboBox_Port);
  26. System.Version assemblyVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
  27. DateTime buildDate = new DateTime(2000, 1, 1).AddDays(assemblyVersion.Build).AddSeconds(assemblyVersion.Revision * 2);
  28. this.label_Build.Text = "Ver." + Assembly.GetExecutingAssembly().GetName().Version.ToString();
  29. }
  30. private void Firmware_Update_Click(object sender, EventArgs e)
  31. {
  32. OpenFileDialog ofd = new OpenFileDialog();
  33. //FileDownload file = new FileDownload();
  34. if (setcheck_checkBox.Checked == true)
  35. setcheck_checkBox.Checked = false;
  36. file.ShowFileOpenDialog(ref serial, ofd);
  37. }
  38. private void Crc16_Check_Click(object sender, EventArgs e)
  39. {
  40. #if false
  41. Crc16 crc16 = new Crc16();
  42. byte[] tempdata = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09,0x0A };
  43. label1.Text = crc16.CRC16_Generate(tempdata, 11).ToString();
  44. #endif
  45. this.serial.Test_Serial();
  46. }
  47. private void Button_PortOpen_Click(object sender, EventArgs e)
  48. {
  49. bool ret = false;
  50. ret = Serial_connectiondisable(serial.Serial_PortOpen(ref button_PortOpen, ref comboBox_Port));
  51. if (ret == false && timer.Enabled == false)
  52. {
  53. timer.Start(); //타이머를 발동시킨다.
  54. }
  55. else if (timer.Enabled == true)
  56. {
  57. timer.Stop(); //타이머를 멈춘다.
  58. }
  59. else
  60. {
  61. /*NOP*/
  62. }
  63. serial.Serial_Main_Form_Get(this);
  64. }
  65. private void ComboBox_Port_SelectedIndexChanged(object sender, EventArgs e)
  66. {
  67. serial.Serial_Name = comboBox_Port.SelectedItem.ToString();
  68. }
  69. private void Button_terminal_Click(object sender, EventArgs e)
  70. {
  71. serial.Serial_TerminalOpen(serial);
  72. }
  73. public bool Serial_connectiondisable(Boolean on_off)
  74. {
  75. comboBox_Port.Enabled = on_off;
  76. comboBox_baudrate.Enabled = on_off;
  77. return on_off;
  78. }
  79. private delegate void BoolSet();
  80. public void TX_Light_ON()
  81. {
  82. this.pictureBox_G_TX.Visible = true;
  83. this.pictureBox_R_TX.Visible = false;
  84. }
  85. public void TX_Light_OFF()
  86. {
  87. this.pictureBox_R_TX.Visible = true;
  88. this.pictureBox_G_TX.Visible = false;
  89. }
  90. public void RX_Light_ON()
  91. {
  92. this.pictureBox_G_RX.Visible = true;
  93. this.pictureBox_R_RX.Visible = false;
  94. }
  95. public void RX_Light_OFF()
  96. {
  97. this.pictureBox_R_RX.Visible = true;
  98. this.pictureBox_G_RX.Visible = false;
  99. }
  100. Int64 Timer_Cnt = 0;
  101. Int32 ReqTimer_Cnt = 0;
  102. public bool TX_RX_Light = false;
  103. private void timer_Tick(object sender, EventArgs e)
  104. {
  105. Update_Serial update_Serial = null;
  106. bool req_set = false;
  107. if(update_Serial == null)
  108. {
  109. update_Serial = (Update_Serial)serial.FileDownloadClass_Get();
  110. if (update_Serial == null)
  111. req_set = true;
  112. else if(update_Serial.Update_ready == false)
  113. req_set = true;
  114. }
  115. if (req_set)
  116. {
  117. ReqTimer_Cnt++;
  118. }
  119. if (TX_RX_Light == true)
  120. {
  121. Timer_Cnt++;
  122. }
  123. if (Timer_Cnt < 1000)
  124. {
  125. if (this.pictureBox_G_TX.Visible == true)
  126. {
  127. TX_Light_OFF();
  128. }
  129. if (this.pictureBox_G_RX.Visible == true)
  130. {
  131. RX_Light_OFF();
  132. }
  133. Timer_Cnt = 0;
  134. TX_RX_Light = false;
  135. }
  136. if(ReqTimer_Cnt > 6)
  137. {
  138. bluecell_BootProtocol.Bluecell_RF_Status_Req(serial);
  139. ReqTimer_Cnt = 0;
  140. }
  141. }
  142. private void Main_Form_Load(object sender, EventArgs e)
  143. {
  144. pictureBox_PATH_1_8G_DL_ON.Visible = false;
  145. pictureBox_PATH_1_8G_UL_ON.Visible = false;
  146. pictureBox_PATH_2_1G_DL_ON.Visible = false;
  147. pictureBox_PATH_2_1G_UL_ON.Visible = false;
  148. pictureBox_PATH_3_5G_L_ON.Visible = false;
  149. pictureBox_PATH_3_5G_H_ON.Visible = false;
  150. pictureBox_PLL_ON_OFF_3_5G_L_ON.Visible = false;
  151. pictureBox_PLL_ON_OFF_3_5G_H_ON.Visible = false;
  152. pictureBox_PATH_3_5G_UL_ON.Visible = false;
  153. pictureBox_PATH_3_5G_DL_ON.Visible = false;
  154. pictureBox_PATH_1_8G_DL_OFF.Visible = !false;
  155. pictureBox_PATH_1_8G_UL_OFF.Visible = !false;
  156. pictureBox_PATH_2_1G_DL_OFF.Visible = !false;
  157. pictureBox_PATH_2_1G_UL_OFF.Visible = !false;
  158. pictureBox_PATH_3_5G_L_OFF.Visible = !false;
  159. pictureBox_PATH_3_5G_H_OFF.Visible = !false;
  160. pictureBox_PLL_ON_OFF_3_5G_L_OFF.Visible = !false;
  161. pictureBox_PLL_ON_OFF_3_5G_H_OFF.Visible = !false;
  162. pictureBox_PATH_3_5G_UL_OFF.Visible = !false;
  163. pictureBox_PATH_3_5G_DL_OFF.Visible = !false;
  164. pictureBox_G_RX.Visible = !false;
  165. pictureBox_G_TX.Visible = !false;
  166. }
  167. private delegate void StringSend(object label, String str);
  168. public void ADC_Voltage_Value_Set(byte[] data)
  169. {
  170. int temp_val = 0;
  171. double Volt_Calc_val = 3.3 / 4095;
  172. double ret = 0;
  173. try
  174. {
  175. 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]);
  176. ret = temp_val * Volt_Calc_val;
  177. this.Invoke(new StringSend(Label_Text_Set), label1_8GHz_DL_IN, ret.ToString("N2") + "V");
  178. 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]);
  179. ret = temp_val * Volt_Calc_val;
  180. this.Invoke(new StringSend(Label_Text_Set), label1_8GHz_DL_OUT, ret.ToString("N2") + "V");
  181. 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]);
  182. ret = temp_val * Volt_Calc_val;
  183. this.Invoke(new StringSend(Label_Text_Set), label1_8GHz_UL_IN, ret.ToString("N2") + "V");
  184. 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]);
  185. ret = temp_val * Volt_Calc_val;
  186. this.Invoke(new StringSend(Label_Text_Set), label1_8GHz_UL_OUT, ret.ToString("N2") + "V");
  187. 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]);
  188. ret = temp_val * Volt_Calc_val;
  189. this.Invoke(new StringSend(Label_Text_Set), label2_1GHz_DL_IN, ret.ToString("N2") + "V");
  190. 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]);
  191. ret = temp_val * Volt_Calc_val;
  192. this.Invoke(new StringSend(Label_Text_Set), label2_1GHz_DL_OUT, ret.ToString("N2") + "V");
  193. 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]);
  194. ret = temp_val * Volt_Calc_val;
  195. this.Invoke(new StringSend(Label_Text_Set), label2_1GHz_UL_IN, ret.ToString("N2") + "V");
  196. 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]);
  197. ret = temp_val * Volt_Calc_val;
  198. this.Invoke(new StringSend(Label_Text_Set), label2_1GHz_UL_OUT, ret.ToString("N2") + "V");
  199. 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]);
  200. ret = temp_val * Volt_Calc_val;
  201. this.Invoke(new StringSend(Label_Text_Set), label3_5GHz_DL_IN, ret.ToString("N2") + "V");
  202. 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]);
  203. ret = temp_val * Volt_Calc_val;
  204. this.Invoke(new StringSend(Label_Text_Set), label3_5GHz_DL_OUT, ret.ToString("N2") + "V");
  205. 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]);
  206. ret = temp_val * Volt_Calc_val;
  207. this.Invoke(new StringSend(Label_Text_Set), label3_5GHz_UL_IN, ret.ToString("N2") + "V");
  208. 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]);
  209. ret = temp_val * Volt_Calc_val;
  210. this.Invoke(new StringSend(Label_Text_Set), label3_5GHz_UL_OUT, ret.ToString("N2") + "V");
  211. temp_val = (int)(data[(int)Bluecell_TypeIndex_t.RFU_TEMP_H] << 8) | (data[(int)Bluecell_TypeIndex_t.RFU_TEMP_L]);
  212. ret = temp_val * Volt_Calc_val;
  213. this.Invoke(new StringSend(Label_Text_Set), label_RFU_Temp, ret.ToString("N2") + "V");
  214. temp_val = (int)(data[(int)Bluecell_TypeIndex_t._28V_DET_H] << 8) | (data[(int)Bluecell_TypeIndex_t._28V_DET_L]);
  215. ret = temp_val * Volt_Calc_val;
  216. this.Invoke(new StringSend(Label_Text_Set), label_28V_Det, ret.ToString("N2") + "V");
  217. if (IamSetting_Get() == false)
  218. {
  219. temp_val = data[(int)Bluecell_TypeIndex_t.ATT_1_8G_DL1];
  220. ret = bluecell_BootProtocol.Bluecell_Reverse_BDA4601_Calc(temp_val);
  221. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_1_8G_DL1, ret.ToString());
  222. temp_val = data[(int)Bluecell_TypeIndex_t.ATT_1_8G_DL2];
  223. ret = bluecell_BootProtocol.Bluecell_Reverse_BDA4601_Calc(temp_val);
  224. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_1_8G_DL2, ret.ToString());
  225. temp_val = data[(int)Bluecell_TypeIndex_t.ATT_1_8G_UL1];
  226. ret = bluecell_BootProtocol.Bluecell_Reverse_BDA4601_Calc(temp_val);
  227. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_1_8G_UL1, ret.ToString());
  228. temp_val = data[(int)Bluecell_TypeIndex_t.ATT_1_8G_UL2];
  229. ret = bluecell_BootProtocol.Bluecell_Reverse_BDA4601_Calc(temp_val);
  230. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_1_8G_UL2, ret.ToString());
  231. temp_val = data[(int)Bluecell_TypeIndex_t.ATT_1_8G_UL3];
  232. ret = bluecell_BootProtocol.Bluecell_Reverse_BDA4601_Calc(temp_val);
  233. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_1_8G_UL3, ret.ToString());
  234. temp_val = data[(int)Bluecell_TypeIndex_t.ATT_1_8G_UL4];
  235. ret = bluecell_BootProtocol.Bluecell_Reverse_BDA4601_Calc(temp_val);
  236. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_1_8G_UL4, ret.ToString());
  237. temp_val = data[(int)Bluecell_TypeIndex_t.ATT_2_1G_DL1];
  238. ret = bluecell_BootProtocol.Bluecell_Reverse_BDA4601_Calc(temp_val);
  239. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_2_1G_DL1, ret.ToString());
  240. temp_val = data[(int)Bluecell_TypeIndex_t.ATT_2_1G_DL2];
  241. ret = bluecell_BootProtocol.Bluecell_Reverse_BDA4601_Calc(temp_val);
  242. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_2_1G_DL2, ret.ToString());
  243. temp_val = data[(int)Bluecell_TypeIndex_t.ATT_2_1G_UL1];
  244. ret = bluecell_BootProtocol.Bluecell_Reverse_BDA4601_Calc(temp_val);
  245. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_2_1G_UL1, ret.ToString());
  246. temp_val = data[(int)Bluecell_TypeIndex_t.ATT_2_1G_UL2];
  247. ret = bluecell_BootProtocol.Bluecell_Reverse_BDA4601_Calc(temp_val);
  248. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_2_1G_UL2, ret.ToString());
  249. temp_val = data[(int)Bluecell_TypeIndex_t.ATT_2_1G_UL3];
  250. ret = bluecell_BootProtocol.Bluecell_Reverse_BDA4601_Calc(temp_val);
  251. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_2_1G_UL3, ret.ToString());
  252. temp_val = data[(int)Bluecell_TypeIndex_t.ATT_2_1G_UL4];
  253. ret = bluecell_BootProtocol.Bluecell_Reverse_BDA4601_Calc(temp_val);
  254. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_2_1G_UL4, ret.ToString());
  255. temp_val = data[(int)Bluecell_TypeIndex_t.ATT_3_5G_LOW1];
  256. ret = bluecell_BootProtocol.Bluecell_ReversePE43711_Calc(temp_val);
  257. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_3_5G_LOW1, ret.ToString());
  258. temp_val = data[(int)Bluecell_TypeIndex_t.ATT_3_5G_HIGH1];
  259. ret = bluecell_BootProtocol.Bluecell_ReversePE43711_Calc(temp_val);
  260. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_3_5G_HIGH1, ret.ToString());
  261. temp_val = data[(int)Bluecell_TypeIndex_t.ATT_3_5G_COM1];
  262. ret = bluecell_BootProtocol.Bluecell_ReversePE43711_Calc(temp_val);
  263. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_3_5G_COM1, ret.ToString());
  264. temp_val = data[(int)Bluecell_TypeIndex_t.ATT_3_5G_LOW2];
  265. ret = bluecell_BootProtocol.Bluecell_ReversePE43711_Calc(temp_val);
  266. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_3_5G_LOW2, ret.ToString());
  267. temp_val = data[(int)Bluecell_TypeIndex_t.ATT_3_5G_HIGH2];
  268. ret = bluecell_BootProtocol.Bluecell_ReversePE43711_Calc(temp_val);
  269. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_3_5G_HIGH2, ret.ToString());
  270. temp_val = data[(int)Bluecell_TypeIndex_t.ATT_3_5G_COM2];
  271. ret = bluecell_BootProtocol.Bluecell_ReversePE43711_Calc(temp_val);
  272. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_3_5G_COM2, ret.ToString());
  273. temp_val = data[(int)Bluecell_TypeIndex_t.PLL_1_8G_DL_H] << 8;
  274. ret = ((double)(temp_val | data[(int)Bluecell_TypeIndex_t.PLL_1_8G_DL_L]) / 10);
  275. if(ret != 0)
  276. ret = ret + 220;
  277. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_PLL_1_8G_DL, ret.ToString());
  278. temp_val = data[(int)Bluecell_TypeIndex_t.PLL_1_8G_UL_H] << 8;
  279. ret = ((double)(temp_val | data[(int)Bluecell_TypeIndex_t.PLL_1_8G_UL_L]) / 10);
  280. if (ret != 0)
  281. ret = ret + 270;
  282. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_PLL_1_8G_UL, ret.ToString());
  283. temp_val = data[(int)Bluecell_TypeIndex_t.PLL_2_1G_DL_H] << 8;
  284. ret = ((temp_val | data[(int)Bluecell_TypeIndex_t.PLL_2_1G_DL_L]) / 10);
  285. if (ret != 0)
  286. ret = ret + 145;
  287. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_PLL_2_1G_DL, ret.ToString());
  288. temp_val = data[(int)Bluecell_TypeIndex_t.PLL_2_1G_UL_H] << 8;
  289. ret = ((double)(temp_val | data[(int)Bluecell_TypeIndex_t.PLL_2_1G_UL_L]) / 10);
  290. if (ret != 0)
  291. ret = ret - 345;
  292. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_PLL_2_1G_UL, ret.ToString());
  293. temp_val = data[(int)Bluecell_TypeIndex_t.ATT_3_5G_LOW_H] << 8;
  294. ret = ((double)(temp_val | data[(int)Bluecell_TypeIndex_t.ATT_3_5G_LOW_L]) / 10);
  295. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_PLL_3_5G_LOW, ret.ToString());
  296. temp_val = data[(int)Bluecell_TypeIndex_t.ATT_3_5G_HIGH_H] << 8;
  297. ret = ((double)(temp_val | data[(int)Bluecell_TypeIndex_t.ATT_3_5G_HIGH_L]) / 10);
  298. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_PLL_3_5G_HIGH, ret.ToString());
  299. /***********************DAC A Sector**********************************/
  300. temp_val = data[(int)Bluecell_TypeIndex_t.DAC_VCtrl_A_H] << 8;
  301. temp_val = ((temp_val | data[(int)Bluecell_TypeIndex_t.DAC_VCtrl_A_L]) );
  302. ret = (temp_val & 0x0FFF) * 4;
  303. ret = ret / 4095;
  304. ret = Math.Round(Convert.ToDouble(ret), 2);
  305. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_DAC_VoltCtrl_A, ret.ToString());
  306. /***********************DAC B Sector**********************************/
  307. temp_val = data[(int)Bluecell_TypeIndex_t.DAC_VCtrl_B_H] << 8;
  308. temp_val = ((temp_val | data[(int)Bluecell_TypeIndex_t.DAC_VCtrl_B_L]) );
  309. ret = (temp_val & 0x0FFF) * 4;
  310. ret = ret / 4095;
  311. ret = Math.Round(Convert.ToDouble(ret), 2);
  312. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_DAC_VoltCtrl_B, ret.ToString());
  313. /***********************DAC C Sector**********************************/
  314. temp_val = data[(int)Bluecell_TypeIndex_t.DAC_VCtrl_C_H] << 8;
  315. temp_val = ((temp_val | data[(int)Bluecell_TypeIndex_t.DAC_VCtrl_C_L]) );
  316. ret = (temp_val & 0x0FFF) * 4;
  317. ret = ret / 4095;
  318. ret = Math.Round(Convert.ToDouble(ret ), 2);
  319. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_DAC_VoltCtrl_C, ret.ToString());
  320. /***********************DAC D Sector**********************************/
  321. temp_val = data[(int)Bluecell_TypeIndex_t.DAC_VCtrl_D_H] << 8;
  322. temp_val = ((temp_val | data[(int)Bluecell_TypeIndex_t.DAC_VCtrl_D_L]) );
  323. ret = (temp_val & 0x0FFF) * 4;
  324. ret = ret / 4095;
  325. ret = Math.Round(Convert.ToDouble(ret), 2);
  326. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_DAC_VoltCtrl_D, ret.ToString());
  327. /***********************DAC E Sector**********************************/
  328. temp_val = data[(int)Bluecell_TypeIndex_t.DAC_VCtrl_E_H] << 8;
  329. temp_val = ((temp_val | data[(int)Bluecell_TypeIndex_t.DAC_VCtrl_E_L]) );
  330. ret = (temp_val & 0x0FFF) * 4;
  331. ret = ret / 4095;
  332. ret = Math.Round(Convert.ToDouble(ret), 2);
  333. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_DAC_VoltCtrl_E, ret.ToString());
  334. /***********************DAC F Sector**********************************/
  335. temp_val = data[(int)Bluecell_TypeIndex_t.DAC_VCtrl_F_H] << 8;
  336. temp_val = ((temp_val | data[(int)Bluecell_TypeIndex_t.DAC_VCtrl_F_L]) );
  337. ret = (temp_val & 0x0FFF) * 4;
  338. ret = ret / 4095;
  339. ret = Math.Round(Convert.ToDouble(ret), 2);
  340. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_DAC_VoltCtrl_F, ret.ToString());
  341. /***********************DAC G Sector**********************************/
  342. temp_val = data[(int)Bluecell_TypeIndex_t.DAC_VCtrl_G_H] << 8;
  343. temp_val = ((temp_val | data[(int)Bluecell_TypeIndex_t.DAC_VCtrl_G_L]) );
  344. ret = (temp_val & 0x0FFF) * 4;
  345. ret = ret / 4095;
  346. ret = Math.Round(Convert.ToDouble(ret), 2);
  347. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_DAC_VoltCtrl_G, ret.ToString());
  348. /***********************DAC H Sector**********************************/
  349. temp_val = data[(int)Bluecell_TypeIndex_t.DAC_VCtrl_H_H] << 8;
  350. temp_val = ((temp_val | data[(int)Bluecell_TypeIndex_t.DAC_VCtrl_H_L]) );
  351. ret = (temp_val & 0x0FFF) * 4;
  352. ret = ret / 4095;
  353. ret = Math.Round(Convert.ToDouble(ret), 2);
  354. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_DAC_VoltCtrl_H, ret.ToString());
  355. PictureBox pic_on;
  356. PictureBox pic_off;
  357. pic_on = pictureBox_PATH_1_8G_DL_ON;
  358. pic_off = pictureBox_PATH_1_8G_DL_OFF;
  359. if (data[(int)Bluecell_TypeIndex_t.PATH_EN_1_8G_DL] > 0)
  360. {
  361. this.Invoke(new PictureBoxSend(PictureBox_On_OFF_Set), pic_on, pic_off, true);
  362. }
  363. else
  364. {
  365. this.Invoke(new PictureBoxSend(PictureBox_On_OFF_Set), pic_on, pic_off, false);
  366. }
  367. pic_on = pictureBox_PATH_1_8G_UL_ON;
  368. pic_off = pictureBox_PATH_1_8G_UL_OFF;
  369. if (data[(int)Bluecell_TypeIndex_t.PATH_EN_1_8G_UL] > 0)
  370. {
  371. this.Invoke(new PictureBoxSend(PictureBox_On_OFF_Set), pic_on, pic_off, true);
  372. }
  373. else
  374. {
  375. this.Invoke(new PictureBoxSend(PictureBox_On_OFF_Set), pic_on, pic_off, false);
  376. }
  377. pic_on = pictureBox_PATH_2_1G_DL_ON;
  378. pic_off = pictureBox_PATH_2_1G_DL_OFF;
  379. if (data[(int)Bluecell_TypeIndex_t.PATH_EN_2_1G_DL] > 0)
  380. {
  381. this.Invoke(new PictureBoxSend(PictureBox_On_OFF_Set), pic_on, pic_off, true);
  382. }
  383. else
  384. {
  385. this.Invoke(new PictureBoxSend(PictureBox_On_OFF_Set), pic_on, pic_off, false);
  386. }
  387. pic_on = pictureBox_PATH_2_1G_UL_ON;
  388. pic_off = pictureBox_PATH_2_1G_UL_OFF;
  389. if (data[(int)Bluecell_TypeIndex_t.PATH_EN_2_1G_UL] > 0)
  390. {
  391. this.Invoke(new PictureBoxSend(PictureBox_On_OFF_Set), pic_on, pic_off, true);
  392. }
  393. else
  394. {
  395. this.Invoke(new PictureBoxSend(PictureBox_On_OFF_Set), pic_on, pic_off, false);
  396. }
  397. pic_on = pictureBox_PATH_3_5G_DL_ON;
  398. pic_off = pictureBox_PATH_3_5G_DL_OFF;
  399. if (data[(int)Bluecell_TypeIndex_t.PATH_EN_3_5G_DL] > 0)
  400. {
  401. this.Invoke(new PictureBoxSend(PictureBox_On_OFF_Set), pic_on, pic_off, true);
  402. }
  403. else
  404. {
  405. this.Invoke(new PictureBoxSend(PictureBox_On_OFF_Set), pic_on, pic_off, false);
  406. }
  407. pic_on = pictureBox_PATH_3_5G_UL_ON;
  408. pic_off = pictureBox_PATH_3_5G_UL_OFF;
  409. if (data[(int)Bluecell_TypeIndex_t.PATH_EN_3_5G_UL] > 0)
  410. {
  411. this.Invoke(new PictureBoxSend(PictureBox_On_OFF_Set), pic_on, pic_off, true);
  412. }
  413. else
  414. {
  415. this.Invoke(new PictureBoxSend(PictureBox_On_OFF_Set), pic_on, pic_off, false);
  416. }
  417. pic_on = pictureBox_PATH_3_5G_H_ON;
  418. pic_off = pictureBox_PATH_3_5G_H_OFF;
  419. if (data[(int)Bluecell_TypeIndex_t.PATH_EN_3_5G_H] > 0)
  420. {
  421. this.Invoke(new PictureBoxSend(PictureBox_On_OFF_Set), pic_on, pic_off, true);
  422. }
  423. else
  424. {
  425. this.Invoke(new PictureBoxSend(PictureBox_On_OFF_Set), pic_on, pic_off, false);
  426. }
  427. pic_on = pictureBox_PATH_3_5G_L_ON;
  428. pic_off = pictureBox_PATH_3_5G_L_OFF;
  429. if (data[(int)Bluecell_TypeIndex_t.PATH_EN_3_5G_L] > 0)
  430. {
  431. this.Invoke(new PictureBoxSend(PictureBox_On_OFF_Set), pic_on, pic_off, true);
  432. }
  433. else
  434. {
  435. this.Invoke(new PictureBoxSend(PictureBox_On_OFF_Set), pic_on, pic_off, false);
  436. }
  437. pic_on = pictureBox_PLL_ON_OFF_3_5G_H_ON;
  438. pic_off = pictureBox_PLL_ON_OFF_3_5G_H_OFF;
  439. if (data[(int)Bluecell_TypeIndex_t.PLL_ON_OFF_3_5G_H] > 0)
  440. {
  441. this.Invoke(new PictureBoxSend(PictureBox_On_OFF_Set), pic_on, pic_off, true);
  442. }
  443. else
  444. {
  445. this.Invoke(new PictureBoxSend(PictureBox_On_OFF_Set), pic_on, pic_off, false);
  446. }
  447. pic_on = pictureBox_PLL_ON_OFF_3_5G_L_ON;
  448. pic_off = pictureBox_PLL_ON_OFF_3_5G_L_OFF;
  449. if (data[(int)Bluecell_TypeIndex_t.PLL_ON_OFF_3_5G_L] > 0)
  450. {
  451. this.Invoke(new PictureBoxSend(PictureBox_On_OFF_Set), pic_on, pic_off, true);
  452. }
  453. else
  454. {
  455. this.Invoke(new PictureBoxSend(PictureBox_On_OFF_Set), pic_on, pic_off, false);
  456. }
  457. if (data[(int)Bluecell_TypeIndex_t.T_SYNC_DL] > 0)
  458. {
  459. TDD_T_SYNC_Get();
  460. //this.Invoke(new PictureBoxSend(PictureBox_On_OFF_Set), pic_on, pic_off, true);
  461. }
  462. else
  463. {
  464. //this.Invoke(new PictureBoxSend(PictureBox_On_OFF_Set), pic_on, pic_off, false);
  465. }
  466. // this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_1_8G_DL2, data[(int)Bluecell_TypeIndex_t.ATT_1_8G_DL2]);
  467. }
  468. }
  469. catch { /*MessageBox.Show("What is this?");*/ }
  470. }
  471. private delegate void PictureBoxSend(object picon, object picoff, bool set);
  472. private void PictureBox_On_OFF_Set(object pic_on,object pic_off,bool set)
  473. {
  474. PictureBox picture_on = (PictureBox)pic_on;
  475. PictureBox picture_off = (PictureBox)pic_off;
  476. picture_on.Visible = set;
  477. picture_off.Visible =!set;
  478. }
  479. public void ReSetting_Values(byte[] temp_buf)
  480. {
  481. this.numericUpDown_ATT_1_8G_DL1.Text = temp_buf[(byte)Bluecell_TypeIndex_t.ATT_1_8G_DL1].ToString();
  482. }
  483. private void Label_Text_Set(object label, String str)
  484. {
  485. Label Temp_label = (Label)label;
  486. Temp_label.Text = str;
  487. }
  488. private void numeric_Text_Set(object numeric, String str)
  489. {
  490. NumericUpDown Temp_numeric = (NumericUpDown)numeric;
  491. Temp_numeric.Text = str;
  492. }
  493. private void ATT_Enter(object sender, KeyEventArgs e)
  494. {
  495. if (e.KeyCode == Keys.Enter)
  496. {
  497. Button_Set_Click(sender, e);
  498. //to do
  499. }
  500. else
  501. {
  502. return;
  503. }
  504. }
  505. private void TDD_T_SYNC_Click(object sender, EventArgs e)
  506. {
  507. PictureBox pictureBox = (PictureBox)sender;
  508. Tdd_T_Sync = Convert.ToByte(pictureBox.Tag);
  509. bluecell_BootProtocol.Bluecell_BtnSet(this.serial, this);
  510. pictureBox_TDD_T_SYNC_UL_ON.Visible = !pictureBox_TDD_T_SYNC_UL_ON.Visible;
  511. pictureBox_TDD_T_SYNC_DL_OFF.Visible = !pictureBox_TDD_T_SYNC_DL_OFF.Visible;
  512. }
  513. private void TDD_T_SYNC_Get()
  514. {
  515. }
  516. const byte PATH_1_8G_DL_ON = 1;
  517. const byte PATH_1_8G_DL_OFF = 2;
  518. const byte PATH_1_8G_UL_ON = 3;
  519. const byte PATH_1_8G_UL_OFF = 4;
  520. const byte PATH_2_1G_DL_ON = 5;
  521. const byte PATH_2_1G_DL_OFF = 6;
  522. const byte PATH_2_1G_UL_ON = 7;
  523. const byte PATH_2_1G_UL_OFF = 8;
  524. const byte PATH_3_5G_DL_ON = 9;
  525. const byte PATH_3_5G_DL_OFF = 10;
  526. const byte PATH_3_5G_UL_ON = 11;
  527. const byte PATH_3_5G_UL_OFF = 12;
  528. const byte PATH_3_5G_H_ON = 13;
  529. const byte PATH_3_5G_H_OFF = 14;
  530. const byte PATH_3_5G_L_ON = 15;
  531. const byte PATH_3_5G_L_OFF = 16;
  532. const byte PLL_POWER_ONOFF_3_5G_H_ON = 17;
  533. const byte PLL_POWER_ONOFF_3_5G_H_OFF = 18;
  534. const byte PLL_POWER_ONOFF_3_5G_L_ON = 19;
  535. const byte PLL_POWER_ONOFF_3_5G_L_OFF = 20;
  536. private void Power_OnOff_Set(object sender, EventArgs e)
  537. {
  538. byte temp_tag = 0;
  539. PictureBox pictureBox = (PictureBox)sender;
  540. temp_tag = Convert.ToByte(pictureBox.Tag);
  541. switch (temp_tag)
  542. {
  543. case PATH_1_8G_DL_OFF:
  544. pictureBox_PATH_1_8G_DL_ON.Visible = true;
  545. break;
  546. case PATH_1_8G_DL_ON:
  547. pictureBox_PATH_1_8G_DL_OFF.Visible = true;
  548. break;
  549. case PATH_1_8G_UL_OFF:
  550. pictureBox_PATH_1_8G_UL_ON.Visible = true;
  551. break;
  552. case PATH_1_8G_UL_ON:
  553. pictureBox_PATH_1_8G_UL_OFF.Visible = true;
  554. break;
  555. case PATH_2_1G_DL_OFF:
  556. pictureBox_PATH_2_1G_DL_ON.Visible = true;
  557. break;
  558. case PATH_2_1G_DL_ON:
  559. pictureBox_PATH_2_1G_DL_OFF.Visible = true;
  560. break;
  561. case PATH_2_1G_UL_OFF:
  562. pictureBox_PATH_2_1G_UL_ON.Visible = true;
  563. break;
  564. case PATH_2_1G_UL_ON:
  565. pictureBox_PATH_2_1G_UL_OFF.Visible = true;
  566. break;
  567. case PATH_3_5G_DL_OFF:
  568. pictureBox_PATH_3_5G_DL_ON.Visible = true;
  569. break;
  570. case PATH_3_5G_DL_ON:
  571. pictureBox_PATH_3_5G_DL_OFF.Visible = true;
  572. break;
  573. case PATH_3_5G_UL_OFF:
  574. pictureBox_PATH_3_5G_UL_ON.Visible = true;
  575. break;
  576. case PATH_3_5G_UL_ON:
  577. pictureBox_PATH_3_5G_UL_OFF.Visible = true;
  578. break;
  579. case PATH_3_5G_H_OFF:
  580. pictureBox_PATH_3_5G_H_ON.Visible = true;
  581. break;
  582. case PATH_3_5G_H_ON:
  583. pictureBox_PATH_3_5G_H_OFF.Visible = true;
  584. break;
  585. case PATH_3_5G_L_OFF:
  586. pictureBox_PATH_3_5G_L_ON.Visible = true;
  587. break;
  588. case PATH_3_5G_L_ON:
  589. pictureBox_PATH_3_5G_L_OFF.Visible = true;
  590. break;
  591. case PLL_POWER_ONOFF_3_5G_H_ON:
  592. pictureBox_PLL_ON_OFF_3_5G_H_OFF.Visible = true;
  593. break;
  594. case PLL_POWER_ONOFF_3_5G_H_OFF:
  595. pictureBox_PLL_ON_OFF_3_5G_H_ON.Visible = true;
  596. break;
  597. case PLL_POWER_ONOFF_3_5G_L_ON:
  598. pictureBox_PLL_ON_OFF_3_5G_L_OFF.Visible = true;
  599. break;
  600. case PLL_POWER_ONOFF_3_5G_L_OFF:
  601. pictureBox_PLL_ON_OFF_3_5G_L_ON.Visible = true;
  602. break;
  603. }
  604. pictureBox.Visible = !pictureBox.Visible;
  605. bluecell_BootProtocol.Bluecell_BtnSet(this.serial, this);
  606. }
  607. private void button1_Click(object sender, EventArgs e)
  608. {
  609. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_1_8G_DL1, "0.0");
  610. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_1_8G_DL2, "0.0");
  611. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_1_8G_UL1, "0.0");
  612. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_1_8G_UL2, "0.0");
  613. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_1_8G_UL3, "0.0");
  614. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_1_8G_UL4, "0.0");
  615. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_2_1G_DL1, "0.0");
  616. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_2_1G_DL2, "0.0");
  617. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_2_1G_UL1, "0.0");
  618. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_2_1G_UL2, "0.0");
  619. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_2_1G_UL3, "0.0");
  620. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_2_1G_UL4, "0.0");
  621. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_3_5G_LOW1, "0.0");
  622. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_3_5G_HIGH1, "0.0");
  623. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_3_5G_COM1, "0.0");
  624. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_3_5G_LOW2, "0.0");
  625. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_3_5G_HIGH2, "0.0");
  626. this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_3_5G_COM2, "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. public void Message_Box_Error_Open(byte[] data)
  685. {
  686. byte type = data[(byte)Bluecell_TypeIndex_t.BLUE_CRCINDEX + 1];
  687. string str = "";
  688. if (type == 0)
  689. str = "PLL 1.8 DL Error";
  690. else if (type == 1)
  691. str = "PLL 1.8 UL Error";
  692. else if (type == 2)
  693. str = "PLL 2.1 DL Error";
  694. else if (type == 3)
  695. str = "PLL 2.1 UL Error";
  696. else
  697. str = "Error!!!";
  698. //blue_MessageBox blue_MessageBox = new Blue_MessageBox();
  699. //MessageBox.Show("Setting OK");
  700. if (setcheck_checkBox.Checked == true)
  701. MessageBox.Show(str,
  702. "Setting",
  703. MessageBoxButtons.OK,
  704. MessageBoxIcon.Error,
  705. MessageBoxDefaultButton.Button1,
  706. MessageBoxOptions.DefaultDesktopOnly);
  707. }
  708. private void comboBox_Port_MouseDown(object sender, MouseEventArgs e)
  709. {
  710. // serial.SetPortNameValues(comboBox_Port);
  711. }
  712. }
  713. }