Bluecell_BootProtocol.cs 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. namespace RF_TRIO_PLL_ZIG
  7. {
  8. public enum Bluepro_t
  9. {
  10. bluecell_header0 = 0,
  11. bluecell_header1,
  12. bluecell_header2,
  13. bluecell_header3,
  14. bluecell_type,
  15. bluecell_length_h,
  16. bluecell_length_l,
  17. bluecell_updatecnt_h,
  18. bluecell_updatecnt_l,
  19. bluecell_data,
  20. };
  21. public enum Updateseq
  22. {
  23. Bluecell_Reset = 0,
  24. Bluecell_Firmupdate_start,
  25. Bluecell_Firmupdate_sending,
  26. Bluecell_Firmupdate_end,
  27. };
  28. enum Bluecell_ProtIndex_p
  29. {
  30. Bluecell_Header = 0,
  31. Bluecell_Type,
  32. Bluecell_Length,
  33. Bluecell_CrcIndex,
  34. Bluecell_data,
  35. }
  36. enum Bluecell_Prot_t{
  37. TYPE_BLUECELL_RESET = 0,
  38. TYPE_BLUECELL_SET = 1,
  39. TYPE_BLUECELL_GET = 2,
  40. };
  41. enum Bluecell_TypeIndex_t
  42. {
  43. BLUE_HEADER = 0,
  44. BLUE_TYPE,
  45. BLUE_LENGTH,
  46. BLUE_CRCINDEX,
  47. ATT_1_8G_DL1,
  48. ATT_1_8G_DL2,
  49. ATT_1_8G_UL1,
  50. ATT_1_8G_UL2,
  51. ATT_1_8G_UL3,
  52. ATT_1_8G_UL4,
  53. ATT_2_1G_DL1,
  54. ATT_2_1G_DL2,
  55. ATT_2_1G_UL1,
  56. ATT_2_1G_UL2,
  57. ATT_2_1G_UL3,
  58. ATT_2_1G_UL4,
  59. ATT_3_5G_DL,
  60. ATT_3_5G_UL,
  61. ATT_3_5G_COM1,
  62. ATT_3_5G_COM2,
  63. ATT_3_5G_COM3,
  64. PLL_1_8G_DL_H,
  65. PLL_1_8G_DL_L,
  66. PLL_1_8G_UL_H,
  67. PLL_1_8G_UL_L,
  68. PLL_2_1G_DL_H,
  69. PLL_2_1G_DL_L,
  70. PLL_2_1G_UL_H,
  71. PLL_2_1G_UL_L,
  72. PLL_3_5G_DL_H,
  73. PLL_3_5G_DL_L,
  74. PLL_3_5G_UL_H,
  75. PLL_3_5G_UL_L,
  76. PLL_LD_6_BIT,
  77. DET_1_8G_DL_IN_H,
  78. DET_1_8G_DL_IN_L,
  79. DET_1_8G_DL_OUT_H,
  80. DET_1_8G_DL_OUT_L,
  81. DET_1_8G_UL_IN_H,
  82. DET_1_8G_UL_IN_L,
  83. DET_1_8G_UL_OUT_H,
  84. DET_1_8G_UL_OUT_L,
  85. DET_2_1G_DL_IN_H,
  86. DET_2_1G_DL_IN_L,
  87. DET_2_1G_DL_OUT_H,
  88. DET_2_1G_DL_OUT_L,
  89. DET_2_1G_UL_IN_H,
  90. DET_2_1G_UL_IN_L,
  91. DET_2_1G_UL_OUT_H,
  92. DET_2_1G_UL_OUT_L,
  93. DET_3_5G_DL_IN_H,
  94. DET_3_5G_DL_IN_L,
  95. DET_3_5G_DL_OUT_H,
  96. DET_3_5G_DL_OUT_L,
  97. DET_3_5G_UL_IN_H,
  98. DET_3_5G_UL_IN_L,
  99. DET_3_5G_UL_OUT_H,
  100. DET_3_5G_UL_OUT_L,
  101. RFU_TEMP_H,
  102. RFU_TEMP_L,
  103. _28V_DET_H,
  104. _28V_DET_L,
  105. ALARM_AC,
  106. ALARM_DC,
  107. PATH_EN_1_8G_DL,
  108. PATH_EN_1_8G_UL,
  109. PATH_EN_2_1G_DL,
  110. PATH_EN_2_1G_UL,
  111. PATH_EN_3_5G_DL,
  112. PATH_EN_3_5G_UL,
  113. PATH_EN_3_5G_H,
  114. PATH_EN_3_5G_L,
  115. PLL_ON_OFF_3_5G_H,
  116. PLL_ON_OFF_3_5G_L,
  117. T_SYNC_DL,
  118. _T_SYNC_DL,
  119. T_SYNC_UL,
  120. _T_SYNC_UL,
  121. DAC_VCtrl_A_H,
  122. DAC_VCtrl_A_L,
  123. DAC_VCtrl_B_H,
  124. DAC_VCtrl_B_L,
  125. DAC_VCtrl_C_H,
  126. DAC_VCtrl_C_L,
  127. DAC_VCtrl_D_H,
  128. DAC_VCtrl_D_L,
  129. DAC_VCtrl_E_H,
  130. DAC_VCtrl_E_L,
  131. DAC_VCtrl_F_H,
  132. DAC_VCtrl_F_L,
  133. DAC_VCtrl_G_H,
  134. DAC_VCtrl_G_L,
  135. DAC_VCtrl_H_H,
  136. DAC_VCtrl_H_L,
  137. };
  138. class Bluecell_BootProtocol
  139. {
  140. Serial serial;
  141. /*bluecell Header*/
  142. public const byte Bluecell_Header0 = 0x42;//ASCII : B
  143. public const byte Bluecell_Header1 = 0x4C;//ASCII : L
  144. public const byte Bluecell_Header2 = 0x55;//ASCII : U
  145. public const byte Bluecell_Header3 = 0x45;//ASCII : E
  146. /*bluecell type*/
  147. public const int bluecell_Firmupdate_sendlength = 1024;
  148. Crc16 crc16 = new Crc16();
  149. public const byte BLUECELL_HEADER = 0xBE;
  150. public const byte BLUECELL_TAILER = 0xEB;
  151. const byte BLUECELL_RESET_LENGTH = 6;
  152. const byte BLUECELL_FIX_DATA_LENGTH = 3;
  153. public void Bluecell_Reset(object serial)
  154. {
  155. this.serial = (Serial)serial;
  156. byte[] temp_buf = new byte[BLUECELL_RESET_LENGTH];
  157. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_Header] = BLUECELL_HEADER;
  158. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_Type] = (byte)Bluecell_Prot_t.TYPE_BLUECELL_RESET;
  159. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_Length] = BLUECELL_RESET_LENGTH - BLUECELL_FIX_DATA_LENGTH;
  160. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_CrcIndex] = (byte)Bluecell_ProtIndex_p.Bluecell_data;
  161. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data] = crc16.STH30_CreateCrc(temp_buf, BLUECELL_RESET_LENGTH - 3);
  162. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + 1] = BLUECELL_TAILER;
  163. this.serial.Serial_DataSend(temp_buf, temp_buf.Length);
  164. }
  165. private byte Bluecell_BDA4601_Calc(double data)
  166. {
  167. byte ret = 0;
  168. if (data == 31.5)
  169. ret = 0x3F;
  170. if (data >= 16) {
  171. ret |= 0x01;
  172. data -= 16;
  173. }
  174. if (data >= 8)
  175. {
  176. ret |= 0x02;
  177. data -= 8;
  178. }
  179. if (data >= 4)
  180. {
  181. ret |= 0x04;
  182. data -= 4;
  183. }
  184. if (data >= 2)
  185. {
  186. ret |= 0x08;
  187. data -= 2;
  188. }
  189. if (data >= 1)
  190. {
  191. ret |= 0x10;
  192. data -= 1;
  193. }
  194. if (data >= 0.5)
  195. {
  196. ret |= 0x20;
  197. data -= 0.5;
  198. }
  199. return ret;
  200. }
  201. public double Bluecell_Reverse_BDA4601_Calc(int data)
  202. {
  203. double ret = 0;
  204. if (data == 0x3F)
  205. ret = 31.5;
  206. if ((data & 0x01) > 0)
  207. {
  208. ret += 16;
  209. }
  210. if ((data & 0x02) > 0)
  211. {
  212. ret += 8;
  213. }
  214. if ((data & 0x04) > 0)
  215. {
  216. ret += 4;
  217. }
  218. if ((data & 0x08) > 0)
  219. {
  220. ret += 2;
  221. }
  222. if ((data & 0x10) > 0)
  223. {
  224. ret += 1;
  225. }
  226. if ((data & 0x20) > 0)
  227. {
  228. ret += 0.5;
  229. }
  230. return ret;
  231. }
  232. private byte Bluecell_PE43711_Calc(double data)
  233. {
  234. byte ret = 0;
  235. if (data == 31.75)
  236. ret = 0x7F;
  237. if (data >= 16)
  238. {
  239. ret |= 0x40;
  240. data -= 16;
  241. }
  242. if (data >= 8)
  243. {
  244. ret |= 0x20;
  245. data -= 8;
  246. }
  247. if (data >= 4)
  248. {
  249. ret |= 0x10;
  250. data -= 4;
  251. }
  252. if (data >= 2)
  253. {
  254. ret |= 0x08;
  255. data -= 2;
  256. }
  257. if (data >= 1)
  258. {
  259. ret |= 0x04;
  260. data -= 1;
  261. }
  262. if (data >= 0.5)
  263. {
  264. ret |= 0x02;
  265. data -= 0.5;
  266. }
  267. if (data >= 0.25)
  268. {
  269. ret |= 0x01;
  270. data -= 0.25;
  271. }
  272. return ret;
  273. }
  274. public double Bluecell_ReversePE43711_Calc(int data)
  275. {
  276. double ret = 0;
  277. if (data == 0x7F)
  278. ret = 31.75;
  279. if ((data & 0x40) > 0)
  280. {
  281. ret += 16;
  282. }
  283. if ((data & 0x20) > 0)
  284. {
  285. ret += 8;
  286. }
  287. if ((data & 0x10) > 0)
  288. {
  289. ret += 4;
  290. }
  291. if ((data & 0x08) > 0)
  292. {
  293. ret += 2;
  294. }
  295. if ((data & 0x04) > 0)
  296. {
  297. ret += 1;
  298. }
  299. if ((data & 0x02) > 0)
  300. {
  301. ret += 0.5;
  302. }
  303. if ((data & 0x01) > 0)
  304. {
  305. ret += 0.25;
  306. }
  307. return ret;
  308. }
  309. const byte BLUECELL_DATA_SET_LENGTH = (byte)Bluecell_TypeIndex_t.DAC_VCtrl_H_L + 2 + 1;
  310. Main_Form main_Form;
  311. public void Bluecell_BtnSet(object serial, object main_form)
  312. {
  313. this.main_Form = (Main_Form)main_form;
  314. this.serial = (Serial)serial;
  315. byte[] temp_buf = new byte[BLUECELL_DATA_SET_LENGTH];
  316. UInt32 temp_val = 0;
  317. /* * * * * * FIX DATA * * * * * */
  318. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_Header] = BLUECELL_HEADER;
  319. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_Type] = (byte)Bluecell_Prot_t.TYPE_BLUECELL_SET;
  320. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_Length] = BLUECELL_DATA_SET_LENGTH - BLUECELL_FIX_DATA_LENGTH;
  321. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_CrcIndex] = (byte)BLUECELL_DATA_SET_LENGTH - 2;
  322. temp_buf[(int)Bluecell_TypeIndex_t.ATT_1_8G_DL1] = Bluecell_BDA4601_Calc(Convert.ToDouble(main_Form.numericUpDown_ATT_1_8G_DL1.Text));
  323. temp_buf[(int)Bluecell_TypeIndex_t.ATT_1_8G_DL2] = Bluecell_BDA4601_Calc(Convert.ToDouble(main_Form.numericUpDown_ATT_1_8G_DL2.Text));
  324. temp_buf[(int)Bluecell_TypeIndex_t.ATT_1_8G_UL1] = Bluecell_BDA4601_Calc(Convert.ToDouble(main_Form.numericUpDown_ATT_1_8G_UL1.Text));
  325. temp_buf[(int)Bluecell_TypeIndex_t.ATT_1_8G_UL2] = Bluecell_BDA4601_Calc(Convert.ToDouble(main_Form.numericUpDown_ATT_1_8G_UL2.Text));
  326. temp_buf[(int)Bluecell_TypeIndex_t.ATT_1_8G_UL3] = Bluecell_BDA4601_Calc(Convert.ToDouble(main_Form.numericUpDown_ATT_1_8G_UL3.Text));
  327. temp_buf[(int)Bluecell_TypeIndex_t.ATT_1_8G_UL4] = Bluecell_BDA4601_Calc(Convert.ToDouble(main_Form.numericUpDown_ATT_1_8G_UL4.Text));
  328. temp_buf[(int)Bluecell_TypeIndex_t.ATT_2_1G_DL1] = Bluecell_BDA4601_Calc(Convert.ToDouble(main_Form.numericUpDown_ATT_2_1G_DL1.Text));
  329. temp_buf[(int)Bluecell_TypeIndex_t.ATT_2_1G_DL2] = Bluecell_BDA4601_Calc(Convert.ToDouble(main_Form.numericUpDown_ATT_2_1G_DL2.Text));
  330. temp_buf[(int)Bluecell_TypeIndex_t.ATT_2_1G_UL1] = Bluecell_BDA4601_Calc(Convert.ToDouble(main_Form.numericUpDown_ATT_2_1G_UL1.Text));
  331. temp_buf[(int)Bluecell_TypeIndex_t.ATT_2_1G_UL2] = Bluecell_BDA4601_Calc(Convert.ToDouble(main_Form.numericUpDown_ATT_2_1G_UL2.Text));
  332. temp_buf[(int)Bluecell_TypeIndex_t.ATT_2_1G_UL3] = Bluecell_BDA4601_Calc(Convert.ToDouble(main_Form.numericUpDown_ATT_2_1G_UL3.Text));
  333. temp_buf[(int)Bluecell_TypeIndex_t.ATT_2_1G_UL4] = Bluecell_BDA4601_Calc(Convert.ToDouble(main_Form.numericUpDown_ATT_2_1G_UL4.Text));
  334. temp_buf[(int)Bluecell_TypeIndex_t.ATT_3_5G_DL] = Bluecell_PE43711_Calc(Convert.ToDouble(main_Form.numericUpDown_ATT_3_5G_DL.Text));
  335. temp_buf[(int)Bluecell_TypeIndex_t.ATT_3_5G_UL] = Bluecell_PE43711_Calc(Convert.ToDouble(main_Form.numericUpDown_ATT_3_5G_UL.Text));
  336. temp_buf[(int)Bluecell_TypeIndex_t.ATT_3_5G_COM1] = Bluecell_PE43711_Calc(Convert.ToDouble(main_Form.numericUpDown_ATT_3_5G_COM1.Text));
  337. temp_buf[(int)Bluecell_TypeIndex_t.ATT_3_5G_COM2] = Bluecell_PE43711_Calc(Convert.ToDouble(main_Form.numericUpDown_ATT_3_5G_COM2.Text));
  338. temp_buf[(int)Bluecell_TypeIndex_t.ATT_3_5G_COM3] = Bluecell_PE43711_Calc(Convert.ToDouble(main_Form.numericUpDown_ATT_3_5G_COM3.Text));
  339. temp_val = Convert.ToUInt32(Convert.ToDouble(main_Form.numericUpDown_PLL_1_8G_DL.Text) * 10);
  340. temp_buf[(int)Bluecell_TypeIndex_t.PLL_1_8G_DL_H] = Convert.ToByte((temp_val & 0xFF00) >> 8);
  341. temp_buf[(int)Bluecell_TypeIndex_t.PLL_1_8G_DL_L] = Convert.ToByte((temp_val & 0x00FF));
  342. temp_val = Convert.ToUInt32(Convert.ToDouble(main_Form.numericUpDown_PLL_1_8G_UL.Text) * 10);
  343. temp_buf[(int)Bluecell_TypeIndex_t.PLL_1_8G_UL_H] = Convert.ToByte((temp_val & 0xFF00) >> 8);
  344. temp_buf[(int)Bluecell_TypeIndex_t.PLL_1_8G_UL_L] = Convert.ToByte((temp_val & 0x00FF));
  345. temp_val = Convert.ToUInt32(Convert.ToDouble(main_Form.numericUpDown_PLL_2_1G_DL.Text) * 10);
  346. temp_buf[(int)Bluecell_TypeIndex_t.PLL_2_1G_DL_H] = Convert.ToByte((temp_val & 0xFF00) >> 8);
  347. temp_buf[(int)Bluecell_TypeIndex_t.PLL_2_1G_DL_L] = Convert.ToByte((temp_val & 0x00FF));
  348. temp_val = Convert.ToUInt32(Convert.ToDouble(main_Form.numericUpDown_PLL_2_1G_UL.Text) * 10);
  349. temp_buf[(int)Bluecell_TypeIndex_t.PLL_2_1G_UL_H] = Convert.ToByte((temp_val & 0xFF00) >> 8);
  350. temp_buf[(int)Bluecell_TypeIndex_t.PLL_2_1G_UL_L] = Convert.ToByte((temp_val & 0x00FF));
  351. temp_val = Convert.ToUInt32(Convert.ToDouble(main_Form.numericUpDown_PLL_3_5G_DL.Text) * 10);
  352. temp_buf[(int)Bluecell_TypeIndex_t.PLL_3_5G_DL_H] = Convert.ToByte((temp_val & 0xFF00) >> 8);
  353. temp_buf[(int)Bluecell_TypeIndex_t.PLL_3_5G_DL_L] = Convert.ToByte((temp_val & 0x00FF));
  354. temp_val = Convert.ToUInt32(Convert.ToDouble(main_Form.numericUpDown_PLL_3_5G_UL.Text) * 10);
  355. temp_buf[(int)Bluecell_TypeIndex_t.PLL_3_5G_UL_H] = Convert.ToByte((temp_val & 0xFF00) >> 8);
  356. temp_buf[(int)Bluecell_TypeIndex_t.PLL_3_5G_UL_L] = Convert.ToByte((temp_val & 0x00FF));
  357. temp_buf[(int)Bluecell_TypeIndex_t.PLL_LD_6_BIT] = 0;//Convert.ToByte(main_Form.numericUpDown_ATT_3_5G_COM1.Text);
  358. temp_buf[(int)Bluecell_TypeIndex_t.DET_1_8G_DL_IN_H] = 0;// Convert.ToByte(main_Form.numericUpDown_ATT_3_5G_COM1.Text);
  359. temp_buf[(int)Bluecell_TypeIndex_t.DET_1_8G_DL_IN_L] = 0;// Convert.ToByte(main_Form.numericUpDown_ATT_3_5G_COM1.Text);
  360. temp_buf[(int)Bluecell_TypeIndex_t.DET_1_8G_DL_OUT_H] = 0;
  361. temp_buf[(int)Bluecell_TypeIndex_t.DET_1_8G_DL_OUT_L] = 0;
  362. temp_buf[(int)Bluecell_TypeIndex_t.DET_1_8G_UL_IN_H] = 0;
  363. temp_buf[(int)Bluecell_TypeIndex_t.DET_1_8G_UL_IN_L] = 0;
  364. temp_buf[(int)Bluecell_TypeIndex_t.DET_1_8G_UL_OUT_H] = 0;
  365. temp_buf[(int)Bluecell_TypeIndex_t.DET_1_8G_UL_OUT_L] = 0;
  366. temp_buf[(int)Bluecell_TypeIndex_t.DET_2_1G_DL_IN_H] = 0;
  367. temp_buf[(int)Bluecell_TypeIndex_t.DET_2_1G_DL_IN_L] = 0;
  368. temp_buf[(int)Bluecell_TypeIndex_t.DET_2_1G_DL_OUT_H] = 0;
  369. temp_buf[(int)Bluecell_TypeIndex_t.DET_2_1G_DL_OUT_L] = 0;
  370. temp_buf[(int)Bluecell_TypeIndex_t.DET_2_1G_UL_IN_H] = 0;
  371. temp_buf[(int)Bluecell_TypeIndex_t.DET_2_1G_UL_IN_L] = 0;
  372. temp_buf[(int)Bluecell_TypeIndex_t.DET_2_1G_UL_OUT_H] = 0;
  373. temp_buf[(int)Bluecell_TypeIndex_t.DET_2_1G_UL_OUT_L] = 0;
  374. temp_buf[(int)Bluecell_TypeIndex_t.DET_3_5G_DL_IN_H] = 0;
  375. temp_buf[(int)Bluecell_TypeIndex_t.DET_3_5G_DL_IN_L] = 0;
  376. temp_buf[(int)Bluecell_TypeIndex_t.DET_3_5G_DL_OUT_L] = 0;
  377. temp_buf[(int)Bluecell_TypeIndex_t.DET_3_5G_DL_OUT_H] = 0;
  378. temp_buf[(int)Bluecell_TypeIndex_t.DET_3_5G_UL_IN_H] = 0;
  379. temp_buf[(int)Bluecell_TypeIndex_t.DET_3_5G_UL_IN_L] = 0;
  380. temp_buf[(int)Bluecell_TypeIndex_t.DET_3_5G_UL_OUT_H] = 0;
  381. temp_buf[(int)Bluecell_TypeIndex_t.DET_3_5G_UL_OUT_L] = 0;
  382. temp_buf[(int)Bluecell_TypeIndex_t.RFU_TEMP_H] = 0;
  383. temp_buf[(int)Bluecell_TypeIndex_t.RFU_TEMP_L] = 0;
  384. temp_buf[(int)Bluecell_TypeIndex_t._28V_DET_H] = 0;
  385. temp_buf[(int)Bluecell_TypeIndex_t._28V_DET_L] = 0;
  386. temp_buf[(int)Bluecell_TypeIndex_t.ALARM_AC] = 0;
  387. temp_buf[(int)Bluecell_TypeIndex_t.ALARM_DC] = 0;
  388. temp_buf[(int)Bluecell_TypeIndex_t.PATH_EN_1_8G_DL] = Convert.ToByte(PATH_1_8G_DL_Get_Func());
  389. temp_buf[(int)Bluecell_TypeIndex_t.PATH_EN_1_8G_UL] = Convert.ToByte(PATH_1_8G_UL_Get_Func());
  390. temp_buf[(int)Bluecell_TypeIndex_t.PATH_EN_2_1G_DL] = Convert.ToByte(PATH_2_1G_DL_Get_Func());
  391. temp_buf[(int)Bluecell_TypeIndex_t.PATH_EN_2_1G_UL] = Convert.ToByte(PATH_2_1G_UL_Get_Func());
  392. temp_buf[(int)Bluecell_TypeIndex_t.PATH_EN_3_5G_L] = Convert.ToByte(Path_3_5G_L_Get_Func());
  393. temp_buf[(int)Bluecell_TypeIndex_t.PATH_EN_3_5G_H] = Convert.ToByte(Path_3_5G_H_Get_Func());
  394. temp_buf[(int)Bluecell_TypeIndex_t.PATH_EN_3_5G_DL] = Convert.ToByte(PATH_3_5G_DL_Get_Func());
  395. temp_buf[(int)Bluecell_TypeIndex_t.PATH_EN_3_5G_UL] = Convert.ToByte(PATH_3_5G_UL_Get_Func());
  396. temp_buf[(int)Bluecell_TypeIndex_t.PLL_ON_OFF_3_5G_H] = Convert.ToByte(PLL_ON_OFF_3_5G_H_Get_Func());
  397. temp_buf[(int)Bluecell_TypeIndex_t.PLL_ON_OFF_3_5G_L] = Convert.ToByte(PLL_ON_OFF_3_5G_L_Get_Func());
  398. temp_buf[(int)Bluecell_TypeIndex_t.T_SYNC_DL] = main_Form.Tdd_T_Sync;//Convert.ToByte(PATH_3_5G_DL_Get_Func());
  399. temp_buf[(int)Bluecell_TypeIndex_t._T_SYNC_DL] = main_Form.Tdd_T_Sync;//Convert.ToByte(PATH_3_5G_DL_Get_Func());
  400. temp_buf[(int)Bluecell_TypeIndex_t.T_SYNC_UL] = main_Form.Tdd_T_Sync;//Convert.ToByte(PLL_ON_OFF_3_5G_H_Get_Func());
  401. temp_buf[(int)Bluecell_TypeIndex_t._T_SYNC_UL] = main_Form.Tdd_T_Sync;//Convert.ToByte(PLL_ON_OFF_3_5G_L_Get_Func());
  402. double double_temp = Convert.ToDouble(main_Form.numericUpDown_DAC_VoltCtrl_A.Text) * 4095;
  403. UInt16 temp = Convert.ToUInt16(double_temp / 4);
  404. temp = Convert.ToUInt16(temp & 0x0FFF);
  405. temp_buf[(int)Bluecell_TypeIndex_t.DAC_VCtrl_A_H]
  406. = Convert.ToByte(0x00 + Convert.ToByte((temp & 0xFF00) >> 8));
  407. temp_buf[(int)Bluecell_TypeIndex_t.DAC_VCtrl_A_L]
  408. = Convert.ToByte(Convert.ToUInt16((Convert.ToDouble(main_Form.numericUpDown_DAC_VoltCtrl_A.Text) * 4095) / 4) & 0x00FF);
  409. double_temp = Convert.ToDouble(main_Form.numericUpDown_DAC_VoltCtrl_B.Text) * 4095;
  410. temp = Convert.ToUInt16(double_temp / 4);
  411. temp = Convert.ToUInt16(temp & 0x0FFF);
  412. temp_buf[(int)Bluecell_TypeIndex_t.DAC_VCtrl_B_H]
  413. = Convert.ToByte(0x10 + Convert.ToByte((temp & 0xFF00) >> 8));
  414. temp_buf[(int)Bluecell_TypeIndex_t.DAC_VCtrl_B_L]
  415. = Convert.ToByte(Convert.ToUInt16((Convert.ToDouble(main_Form.numericUpDown_DAC_VoltCtrl_B.Text) * 4095) / 4) & 0x00FF);
  416. double_temp = Convert.ToDouble(main_Form.numericUpDown_DAC_VoltCtrl_C.Text) * 4095;
  417. temp = Convert.ToUInt16(double_temp / 4);
  418. temp = Convert.ToUInt16(temp & 0x0FFF);
  419. temp_buf[(int)Bluecell_TypeIndex_t.DAC_VCtrl_C_H]
  420. = Convert.ToByte(0x20 + Convert.ToByte((temp & 0xFF00) >> 8));
  421. temp_buf[(int)Bluecell_TypeIndex_t.DAC_VCtrl_C_L]
  422. = Convert.ToByte(Convert.ToUInt16((Convert.ToDouble(main_Form.numericUpDown_DAC_VoltCtrl_C.Text) * 4095) / 4) & 0x00FF);
  423. double_temp = Convert.ToDouble(main_Form.numericUpDown_DAC_VoltCtrl_D.Text) * 4095;
  424. temp = Convert.ToUInt16(double_temp / 4);
  425. temp = Convert.ToUInt16(temp & 0x0FFF);
  426. temp_buf[(int)Bluecell_TypeIndex_t.DAC_VCtrl_D_H]
  427. = Convert.ToByte(0x30 + Convert.ToByte((temp & 0xFF00) >> 8));
  428. temp_buf[(int)Bluecell_TypeIndex_t.DAC_VCtrl_D_L]
  429. = Convert.ToByte(Convert.ToUInt16((Convert.ToDouble(main_Form.numericUpDown_DAC_VoltCtrl_D.Text) * 4095) / 4) & 0x00FF); ;
  430. double_temp = Convert.ToDouble(main_Form.numericUpDown_DAC_VoltCtrl_E.Text) * 4095;
  431. temp = Convert.ToUInt16(double_temp / 4);
  432. temp = Convert.ToUInt16(temp & 0x0FFF);
  433. temp_buf[(int)Bluecell_TypeIndex_t.DAC_VCtrl_E_H]
  434. = Convert.ToByte(0x40 + Convert.ToByte((temp & 0xFF00) >> 8));
  435. temp_buf[(int)Bluecell_TypeIndex_t.DAC_VCtrl_E_L]
  436. = Convert.ToByte(Convert.ToUInt16((Convert.ToDouble(main_Form.numericUpDown_DAC_VoltCtrl_E.Text) * 4095) / 4) & 0x00FF);
  437. double_temp = Convert.ToDouble(main_Form.numericUpDown_DAC_VoltCtrl_F.Text) * 4095;
  438. temp = Convert.ToUInt16(double_temp / 4);
  439. temp = Convert.ToUInt16(temp & 0x0FFF);
  440. temp_buf[(int)Bluecell_TypeIndex_t.DAC_VCtrl_F_H]
  441. = Convert.ToByte(0x50 + Convert.ToByte((temp & 0xFF00) >> 8));
  442. temp_buf[(int)Bluecell_TypeIndex_t.DAC_VCtrl_F_L]
  443. = Convert.ToByte(Convert.ToUInt16((Convert.ToDouble(main_Form.numericUpDown_DAC_VoltCtrl_F.Text) * 4095) / 4) & 0x00FF);
  444. double_temp = Convert.ToDouble(main_Form.numericUpDown_DAC_VoltCtrl_G.Text) * 4095;
  445. temp = Convert.ToUInt16(double_temp / 4);
  446. temp = Convert.ToUInt16(temp & 0x0FFF);
  447. temp_buf[(int)Bluecell_TypeIndex_t.DAC_VCtrl_G_H]
  448. = Convert.ToByte(0x60 + Convert.ToByte((temp & 0xFF00) >> 8));
  449. temp_buf[(int)Bluecell_TypeIndex_t.DAC_VCtrl_G_L]
  450. = Convert.ToByte(Convert.ToUInt16((Convert.ToDouble(main_Form.numericUpDown_DAC_VoltCtrl_G.Text) * 4095) / 4) & 0x00FF);
  451. double_temp = Convert.ToDouble(main_Form.numericUpDown_DAC_VoltCtrl_H.Text) * 4095;
  452. temp = Convert.ToUInt16(double_temp / 4);
  453. temp = Convert.ToUInt16(temp & 0x0FFF);
  454. temp_buf[(int)Bluecell_TypeIndex_t.DAC_VCtrl_H_H]
  455. = Convert.ToByte(0x70 + Convert.ToByte((temp & 0xFF00) >> 8));
  456. temp_buf[(int)Bluecell_TypeIndex_t.DAC_VCtrl_H_L]
  457. = Convert.ToByte(Convert.ToUInt16((Convert.ToDouble(main_Form.numericUpDown_DAC_VoltCtrl_H.Text) * 4095) / 4) & 0x00FF);
  458. /* * * * * * FIX DATA * * * * * */
  459. temp_buf[(int)Bluecell_TypeIndex_t.DAC_VCtrl_H_L + 1]
  460. = crc16.STH30_CreateCrc(temp_buf, BLUECELL_DATA_SET_LENGTH - 3);
  461. temp_buf[(int)Bluecell_TypeIndex_t.DAC_VCtrl_H_L + 2]
  462. = BLUECELL_TAILER;
  463. this.serial.Serial_DataSend(temp_buf, temp_buf.Length);
  464. }
  465. int[] RF_Status = new int[BLUECELL_DATA_SET_LENGTH];
  466. private delegate void StringSend(string Text);
  467. private delegate void ByteSend(byte[] Text);
  468. public void Bluecell_RF_Status_Get(object serial, object main_form,byte[] temp_buf)
  469. {
  470. this.main_Form = (Main_Form)main_form;
  471. this.serial = (Serial)serial;
  472. // main_Form.Invoke(new ByteSend(this.main_Form.ReSetting_Values),(temp_buf));
  473. this.main_Form.ADC_Voltage_Value_Set(temp_buf);
  474. //Debug.Invoke(new StringSend(Debug.Data_Recv_Str), data);
  475. //main_Form.label1_8GHz_DL_OUT.Text = Convert.ToString(temp_val);
  476. }
  477. public void Bluecell_RF_Status_Req(object serial)
  478. {
  479. Crc16 crc16 = new Crc16();
  480. this.serial = (Serial)serial;
  481. byte[] temp_buf = new byte[6];
  482. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_Header] = BLUECELL_HEADER;
  483. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_Type] = 2;
  484. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_Length] = Convert.ToByte(temp_buf.Length - 3);
  485. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_CrcIndex] = 5;
  486. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_CrcIndex + 1] = crc16.STH30_CreateCrc(temp_buf, temp_buf[2]);
  487. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_CrcIndex + 2] = BLUECELL_TAILER;
  488. this.serial.Serial_DataSend(temp_buf, temp_buf.Length);
  489. }
  490. bool PATH_1_8G_UL_Get_Func()
  491. {
  492. bool ret = false;
  493. if (this.main_Form.pictureBox_PATH_1_8G_UL_OFF.Visible == true)
  494. ret = false;
  495. else
  496. ret = true;
  497. return ret;
  498. }
  499. bool PATH_1_8G_DL_Get_Func()
  500. {
  501. bool ret = false;
  502. if (this.main_Form.pictureBox_PATH_1_8G_DL_OFF.Visible == true)
  503. ret = false;
  504. else
  505. ret = true;
  506. return ret;
  507. }
  508. bool PATH_2_1G_UL_Get_Func()
  509. {
  510. bool ret = false;
  511. if (this.main_Form.pictureBox_PATH_2_1G_UL_OFF.Visible == true)
  512. ret = false;
  513. else
  514. ret = true;
  515. return ret;
  516. }
  517. bool PATH_2_1G_DL_Get_Func()
  518. {
  519. bool ret = false;
  520. if (this.main_Form.pictureBox_PATH_2_1G_DL_OFF.Visible == true)
  521. ret = false;
  522. else
  523. ret = true;
  524. return ret;
  525. }
  526. bool Path_3_5G_L_Get_Func()
  527. {
  528. bool ret = false;
  529. if (this.main_Form.pictureBox_PATH_3_5G_L_OFF.Visible == true)
  530. ret = false;
  531. else
  532. ret = true;
  533. return ret;
  534. }
  535. bool Path_3_5G_H_Get_Func()
  536. {
  537. bool ret = false;
  538. if (this.main_Form.pictureBox_PATH_3_5G_H_OFF.Visible == true)
  539. ret = false;
  540. else
  541. ret = true;
  542. return ret;
  543. }
  544. bool PLL_ON_OFF_3_5G_L_Get_Func()
  545. {
  546. bool ret = false;
  547. if (this.main_Form.pictureBox_PLL_ON_OFF_3_5G_L_OFF.Visible == true)
  548. ret = false;
  549. else
  550. ret = true;
  551. return ret;
  552. }
  553. bool PLL_ON_OFF_3_5G_H_Get_Func()
  554. {
  555. bool ret = false;
  556. if (this.main_Form.pictureBox_PLL_ON_OFF_3_5G_H_OFF.Visible == true)
  557. ret = false;
  558. else
  559. ret = true;
  560. return ret;
  561. }
  562. bool PATH_3_5G_UL_Get_Func()
  563. {
  564. bool ret = false;
  565. if (this.main_Form.pictureBox_PATH_3_5G_UL_OFF.Visible == true)
  566. ret = false;
  567. else
  568. ret = true;
  569. return ret;
  570. }
  571. bool PATH_3_5G_DL_Get_Func()
  572. {
  573. bool ret = false;
  574. if (this.main_Form.pictureBox_PATH_3_5G_DL_OFF.Visible == true)
  575. ret = false;
  576. else
  577. ret = true;
  578. return ret;
  579. }
  580. /* public System.Windows.Forms.PictureBox pictureBox_PATH_3_5G_L_OFF;
  581. public System.Windows.Forms.PictureBox pictureBox_PATH_3_5G_H_OFF;
  582. public System.Windows.Forms.PictureBox pictureBox_PLL_ON_OFF_3_5G_L_OFF;
  583. public System.Windows.Forms.PictureBox pictureBox_PLL_ON_OFF_3_5G_H_OFF;
  584. public System.Windows.Forms.PictureBox pictureBox_PATH_3_5G_UL_OFF;
  585. public System.Windows.Forms.PictureBox pictureBox_PATH_3_5G_DL_OFF;
  586. public System.Windows.Forms.PictureBox pictureBox_PATH_2_1G_UL_OFF;
  587. public System.Windows.Forms.PictureBox pictureBox_PATH_2_1G_DL_OFF;
  588. public System.Windows.Forms.PictureBox pictureBox_PATH_1_8G_UL_OFF;
  589. public System.Windows.Forms.PictureBox pictureBox_PATH_1_8G_DL_OFF;
  590. */
  591. #if false
  592. public int Bluecell_Firmupdate_sendlength() {
  593. return bluecell_Firmupdate_sendlength;
  594. }
  595. private void BootHeaderput(ref byte[] fix_data)
  596. {
  597. fix_data[(int)Bluepro_t.bluecell_header0] = Bluecell_Header0;
  598. fix_data[(int)Bluepro_t.bluecell_header1] = Bluecell_Header1;
  599. fix_data[(int)Bluepro_t.bluecell_header2] = Bluecell_Header2;
  600. fix_data[(int)Bluepro_t.bluecell_header3] = Bluecell_Header3;
  601. }
  602. public byte[] Boot_Reset(object serial,byte[] Updatedata)
  603. {
  604. this.serial = (Serial)serial;
  605. byte[] fix_data = new byte[11];
  606. //Array.Clear(data, 0, data.Length);
  607. BootHeaderput(ref fix_data);
  608. fix_data[(int)Bluepro_t.bluecell_type] = (byte)Updateseq.Bluecell_Reset;
  609. fix_data[(int)Bluepro_t.bluecell_length_h] = 0;
  610. fix_data[(int)Bluepro_t.bluecell_length_l] = 5;
  611. fix_data[(int)Bluepro_t.bluecell_updatecnt_h] = Convert.ToByte((Updatedata.Length & 0xFF00) >> 8);
  612. fix_data[(int)Bluepro_t.bluecell_updatecnt_l] = Convert.ToByte((Updatedata.Length & 0x00FF));
  613. fix_data[(int)Bluepro_t.bluecell_data + 0] = Convert.ToByte((crc16.CRC16_Generate(fix_data, fix_data.Length - 4) & 0xFF00) >> 8);
  614. fix_data[(int)Bluepro_t.bluecell_data + 1] = Convert.ToByte((crc16.CRC16_Generate(fix_data, fix_data.Length - 4) & 0x00FF));
  615. this.serial.Serial_DataSend(fix_data, fix_data.Length);
  616. return fix_data;
  617. }
  618. public byte[] Boot_DataSending(byte[] update_data,UInt16 length, UInt16 updatacnt)
  619. {
  620. //Array.Clear(data, 0, data.Length);
  621. byte[] fix_data = new byte[bluecell_Firmupdate_sendlength];
  622. //BootHeaderput(ref fix_data);
  623. //length += 5;
  624. Array.Copy(update_data, (int)Bluepro_t.bluecell_data, fix_data, (int)Bluepro_t.bluecell_data, length);
  625. BootHeaderput(ref fix_data);
  626. fix_data[(int)Bluepro_t.bluecell_type] = (byte)Updateseq.Bluecell_Firmupdate_sending;
  627. fix_data[(int)Bluepro_t.bluecell_length_h] = Convert.ToByte((length & 0xFF00) >> 8);
  628. fix_data[(int)Bluepro_t.bluecell_length_l] = Convert.ToByte((length & 0x00FF));
  629. fix_data[(int)Bluepro_t.bluecell_updatecnt_h] = Convert.ToByte((updatacnt & 0xFF00) >> 8);
  630. fix_data[(int)Bluepro_t.bluecell_updatecnt_l] = Convert.ToByte((updatacnt & 0x00FF));
  631. //Array.Copy(update_data, 0, fix_data, (int)Bluepro_t.bluecell_data, length-3);
  632. fix_data[length + 9] = Convert.ToByte((crc16.CRC16_Generate(fix_data, length + 5) & 0xFF00) >> 8);
  633. fix_data[length + 10] = Convert.ToByte(crc16.CRC16_Generate(fix_data, length + 5) & 0x00FF);
  634. return fix_data;
  635. }
  636. public byte[] Boot_DataEnd(byte[] update_data, int length)
  637. {
  638. //Array.Clear(data, 0, data.Length);
  639. byte[] fix_data = new byte[11];
  640. Array.Copy(update_data, (int)Bluepro_t.bluecell_data, fix_data, (int)Bluepro_t.bluecell_data, length);
  641. BootHeaderput(ref fix_data);
  642. fix_data[(int)Bluepro_t.bluecell_type] = (byte)Updateseq.Bluecell_Firmupdate_end;
  643. fix_data[(int)Bluepro_t.bluecell_length_h] = Convert.ToByte((length & 0xFF00) >> 8);
  644. fix_data[(int)Bluepro_t.bluecell_length_l] = Convert.ToByte((length & 0x00FF));
  645. fix_data[(int)Bluepro_t.bluecell_updatecnt_h] = 0;
  646. fix_data[(int)Bluepro_t.bluecell_updatecnt_l] = 0;
  647. //Array.Copy(update_data, 0, fix_data, (int)Bluepro_t.bluecell_data, length-3);
  648. fix_data[length + 9] = Convert.ToByte((crc16.CRC16_Generate(fix_data, length + 5) & 0xFF00) >> 8);
  649. fix_data[length + 10] = Convert.ToByte(crc16.CRC16_Generate(fix_data, length + 5) & 0x00FF);
  650. return fix_data;
  651. }
  652. #endif
  653. }
  654. }