Main_Form.cs 38 KB

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