Bluecell_BootProtocol.cs 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545
  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. ATT_1_8G_DL1 = 0,
  44. ATT_1_8G_DL2,
  45. ATT_1_8G_UL1,
  46. ATT_1_8G_UL2,
  47. ATT_1_8G_UL3,
  48. ATT_1_8G_UL4,
  49. ATT_2_1G_DL1,
  50. ATT_2_1G_DL2,
  51. ATT_2_1G_UL1,
  52. ATT_2_1G_UL2,
  53. ATT_2_1G_UL3,
  54. ATT_2_1G_UL4,
  55. ATT_3_5G_DL,
  56. ATT_3_5G_UL,
  57. ATT_3_5G_COM1,
  58. ATT_3_5G_COM2,
  59. ATT_3_5G_COM3,
  60. PLL_1_8G_DL_H,
  61. PLL_1_8G_DL_L,
  62. PLL_1_8G_UL_H,
  63. PLL_1_8G_UL_L,
  64. PLL_2_1G_DL_H,
  65. PLL_2_1G_DL_L,
  66. PLL_2_1G_UL_H,
  67. PLL_2_1G_UL_L,
  68. PLL_3_5G_DL_H,
  69. PLL_3_5G_DL_L,
  70. PLL_3_5G_UL_H,
  71. PLL_3_5G_UL_L,
  72. PLL_LD_6_BIT,
  73. DET_1_8G_DL_IN_H,
  74. DET_1_8G_DL_IN_L,
  75. DET_1_8G_DL_OUT_H,
  76. DET_1_8G_DL_OUT_L,
  77. DET_1_8G_UL_IN_H,
  78. DET_1_8G_UL_IN_L,
  79. DET_1_8G_UL_OUT_H,
  80. DET_1_8G_UL_OUT_L,
  81. DET_2_1G_DL_IN_H,
  82. DET_2_1G_DL_IN_L,
  83. DET_2_1G_DL_OUT_H,
  84. DET_2_1G_DL_OUT_L,
  85. DET_2_1G_UL_IN_H,
  86. DET_2_1G_UL_IN_L,
  87. DET_2_1G_UL_OUT_H,
  88. DET_2_1G_UL_OUT_L,
  89. DET_3_5G_DL_IN_H,
  90. DET_3_5G_DL_IN_L,
  91. DET_3_5G_DL_OUT_L,
  92. DET_3_5G_DL_OUT_H,
  93. DET_3_5G_UL_IN_H,
  94. DET_3_5G_UL_IN_L,
  95. DET_3_5G_UL_OUT_H,
  96. DET_3_5G_UL_OUT_L,
  97. RFU_TEMP_H,
  98. RFU_TEMP_L,
  99. _28V_DET_H,
  100. _28V_DET_L,
  101. ALARM_AC,
  102. ALARM_DC,
  103. PATH_EN_1_8G_DL,
  104. PATH_EN_1_8G_UL,
  105. PATH_EN_2_1G_DL,
  106. PATH_EN_2_1G_UL,
  107. PATH_EN_3_5G_L,
  108. PATH_EN_3_5G_H,
  109. PATH_EN_3_5G_DL,
  110. PATH_EN_3_5G_UL,
  111. PLL_ON_OFF_3_5G_H,
  112. PLL_ON_OFF_3_5G_L,
  113. T_SYNC_DL,
  114. _T_SYNC_DL,
  115. T_SYNC_UL,
  116. _T_SYNC_UL,
  117. };
  118. class Bluecell_BootProtocol
  119. {
  120. Serial serial;
  121. /*bluecell Header*/
  122. public const byte Bluecell_Header0 = 0x42;//ASCII : B
  123. public const byte Bluecell_Header1 = 0x4C;//ASCII : L
  124. public const byte Bluecell_Header2 = 0x55;//ASCII : U
  125. public const byte Bluecell_Header3 = 0x45;//ASCII : E
  126. /*bluecell type*/
  127. public const int bluecell_Firmupdate_sendlength = 1024;
  128. Crc16 crc16 = new Crc16();
  129. public const byte BLUECELL_HEADER = 0xBE;
  130. public const byte BLUECELL_TAILER = 0xEB;
  131. const byte BLUECELL_RESET_LENGTH = 6;
  132. const byte BLUECELL_FIX_DATA_LENGTH = 3;
  133. public void Bluecell_Reset(object serial)
  134. {
  135. this.serial = (Serial)serial;
  136. byte[] temp_buf = new byte[BLUECELL_RESET_LENGTH];
  137. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_Header] = BLUECELL_HEADER;
  138. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_Type] = (byte)Bluecell_Prot_t.TYPE_BLUECELL_RESET;
  139. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_Length] = BLUECELL_RESET_LENGTH - BLUECELL_FIX_DATA_LENGTH;
  140. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_CrcIndex] = (byte)Bluecell_ProtIndex_p.Bluecell_data;
  141. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data] = crc16.STH30_CreateCrc(temp_buf, BLUECELL_RESET_LENGTH - 3);
  142. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + 1] = BLUECELL_TAILER;
  143. this.serial.Serial_DataSend(temp_buf, temp_buf.Length);
  144. }
  145. private byte Bluecell_BDA4601_Calc(double data)
  146. {
  147. byte ret = 0;
  148. if (data == 31.5)
  149. ret = 0x3F;
  150. if (data >= 16) {
  151. ret |= 0x01;
  152. data -= 16;
  153. }
  154. if (data >= 8)
  155. {
  156. ret |= 0x02;
  157. data -= 8;
  158. }
  159. if (data >= 4)
  160. {
  161. ret |= 0x04;
  162. data -= 4;
  163. }
  164. if (data >= 2)
  165. {
  166. ret |= 0x08;
  167. data -= 2;
  168. }
  169. if (data >= 1)
  170. {
  171. ret |= 0x10;
  172. data -= 1;
  173. }
  174. if (data >= 0.5)
  175. {
  176. ret |= 0x20;
  177. data -= 0.5;
  178. }
  179. return ret;
  180. }
  181. private byte Bluecell_PE43711_Calc(double data)
  182. {
  183. byte ret = 0;
  184. if (data == 31.75)
  185. ret = 0x7F;
  186. if (data >= 16)
  187. {
  188. ret |= 0x40;
  189. data -= 16;
  190. }
  191. if (data >= 8)
  192. {
  193. ret |= 0x20;
  194. data -= 8;
  195. }
  196. if (data >= 4)
  197. {
  198. ret |= 0x10;
  199. data -= 4;
  200. }
  201. if (data >= 2)
  202. {
  203. ret |= 0x08;
  204. data -= 2;
  205. }
  206. if (data >= 1)
  207. {
  208. ret |= 0x04;
  209. data -= 1;
  210. }
  211. if (data >= 0.5)
  212. {
  213. ret |= 0x02;
  214. data -= 0.5;
  215. }
  216. if (data >= 0.25)
  217. {
  218. ret |= 0x01;
  219. data -= 0.25;
  220. }
  221. return ret;
  222. }
  223. const byte BLUECELL_DATA_SET_LENGTH = 80;
  224. Main_Form main_Form;
  225. public void Bluecell_BtnSet(object serial, object main_form)
  226. {
  227. this.main_Form = (Main_Form)main_form;
  228. this.serial = (Serial)serial;
  229. byte[] temp_buf = new byte[BLUECELL_DATA_SET_LENGTH];
  230. UInt32 temp_val = 0;
  231. /* * * * * * FIX DATA * * * * * */
  232. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_Header] = BLUECELL_HEADER;
  233. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_Type] = (byte)Bluecell_Prot_t.TYPE_BLUECELL_SET;
  234. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_Length] = BLUECELL_DATA_SET_LENGTH - BLUECELL_FIX_DATA_LENGTH;
  235. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_CrcIndex] = (byte)BLUECELL_DATA_SET_LENGTH - 2;
  236. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.ATT_1_8G_DL1] = Bluecell_BDA4601_Calc(Convert.ToDouble(main_Form.numericUpDown_ATT_1_8G_DL1.Text));
  237. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.ATT_1_8G_DL2] = Bluecell_BDA4601_Calc(Convert.ToDouble(main_Form.numericUpDown_ATT_1_8G_DL2.Text));
  238. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.ATT_1_8G_UL1] = Bluecell_BDA4601_Calc(Convert.ToDouble(main_Form.numericUpDown_ATT_1_8G_UL1.Text));
  239. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.ATT_1_8G_UL2] = Bluecell_BDA4601_Calc(Convert.ToDouble(main_Form.numericUpDown_ATT_1_8G_UL2.Text));
  240. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.ATT_1_8G_UL3] = Bluecell_BDA4601_Calc(Convert.ToDouble(main_Form.numericUpDown_ATT_1_8G_UL3.Text));
  241. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.ATT_1_8G_UL4] = Bluecell_BDA4601_Calc(Convert.ToDouble(main_Form.numericUpDown_ATT_1_8G_UL4.Text));
  242. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.ATT_2_1G_DL1] = Bluecell_BDA4601_Calc(Convert.ToDouble(main_Form.numericUpDown_ATT_2_1G_DL1.Text));
  243. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.ATT_2_1G_DL2] = Bluecell_BDA4601_Calc(Convert.ToDouble(main_Form.numericUpDown_ATT_2_1G_DL2.Text));
  244. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.ATT_2_1G_UL1] = Bluecell_BDA4601_Calc(Convert.ToDouble(main_Form.numericUpDown_ATT_2_1G_UL1.Text));
  245. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.ATT_2_1G_UL2] = Bluecell_BDA4601_Calc(Convert.ToDouble(main_Form.numericUpDown_ATT_2_1G_UL2.Text));
  246. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.ATT_2_1G_UL3] = Bluecell_BDA4601_Calc(Convert.ToDouble(main_Form.numericUpDown_ATT_2_1G_UL3.Text));
  247. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.ATT_2_1G_UL4] = Bluecell_BDA4601_Calc(Convert.ToDouble(main_Form.numericUpDown_ATT_2_1G_UL4.Text));
  248. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.ATT_3_5G_DL] = Bluecell_PE43711_Calc(Convert.ToDouble(main_Form.numericUpDown_ATT_3_5G_DL.Text));
  249. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.ATT_3_5G_UL] = Bluecell_PE43711_Calc(Convert.ToDouble(main_Form.numericUpDown_ATT_3_5G_UL.Text));
  250. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.ATT_3_5G_COM1] = Bluecell_PE43711_Calc(Convert.ToDouble(main_Form.numericUpDown_ATT_3_5G_COM1.Text));
  251. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.ATT_3_5G_COM2] = Bluecell_PE43711_Calc(Convert.ToDouble(main_Form.numericUpDown_ATT_3_5G_COM2.Text));
  252. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.ATT_3_5G_COM3] = Bluecell_PE43711_Calc(Convert.ToDouble(main_Form.numericUpDown_ATT_3_5G_COM3.Text));
  253. temp_val = Convert.ToUInt32(Convert.ToDouble(main_Form.numericUpDown_PLL_1_8G_DL.Text) * 10);
  254. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.PLL_1_8G_DL_H] = Convert.ToByte((temp_val & 0xFF00) >> 8);
  255. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.PLL_1_8G_DL_L] = Convert.ToByte((temp_val & 0x00FF));
  256. temp_val = Convert.ToUInt32(Convert.ToDouble(main_Form.numericUpDown_PLL_1_8G_UL.Text) * 10);
  257. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.PLL_1_8G_UL_H] = Convert.ToByte((temp_val & 0xFF00) >> 8);
  258. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.PLL_1_8G_UL_L] = Convert.ToByte((temp_val & 0x00FF));
  259. temp_val = Convert.ToUInt32(Convert.ToDouble(main_Form.numericUpDown_PLL_2_1G_DL.Text) * 10);
  260. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.PLL_2_1G_DL_H] = Convert.ToByte((temp_val & 0xFF00) >> 8);
  261. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.PLL_2_1G_DL_L] = Convert.ToByte((temp_val & 0x00FF));
  262. temp_val = Convert.ToUInt32(Convert.ToDouble(main_Form.numericUpDown_PLL_2_1G_UL.Text) * 10);
  263. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.PLL_2_1G_UL_H] = Convert.ToByte((temp_val & 0xFF00) >> 8);
  264. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.PLL_2_1G_UL_L] = Convert.ToByte((temp_val & 0x00FF));
  265. temp_val = Convert.ToUInt32(Convert.ToDouble(main_Form.numericUpDown_PLL_3_5G_DL.Text) * 10);
  266. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.PLL_3_5G_DL_H] = Convert.ToByte((temp_val & 0xFF00) >> 8);
  267. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.PLL_3_5G_DL_L] = Convert.ToByte((temp_val & 0x00FF));
  268. temp_val = Convert.ToUInt32(Convert.ToDouble(main_Form.numericUpDown_PLL_3_5G_UL.Text) * 10);
  269. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.PLL_3_5G_UL_H] = Convert.ToByte((temp_val & 0xFF00) >> 8);
  270. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.PLL_3_5G_UL_L] = Convert.ToByte((temp_val & 0x00FF));
  271. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.PLL_LD_6_BIT] = 0;//Convert.ToByte(main_Form.numericUpDown_ATT_3_5G_COM1.Text);
  272. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.DET_1_8G_DL_IN_H] = 0;// Convert.ToByte(main_Form.numericUpDown_ATT_3_5G_COM1.Text);
  273. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.DET_1_8G_DL_IN_L] = 0;// Convert.ToByte(main_Form.numericUpDown_ATT_3_5G_COM1.Text);
  274. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.DET_1_8G_DL_OUT_H] = 0;
  275. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.DET_1_8G_DL_OUT_L] = 0;
  276. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.DET_1_8G_UL_IN_H] = 0;
  277. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.DET_1_8G_UL_IN_L] = 0;
  278. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.DET_1_8G_UL_OUT_H] = 0;
  279. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.DET_1_8G_UL_OUT_L] = 0;
  280. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.DET_2_1G_DL_IN_H] = 0;
  281. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.DET_2_1G_DL_IN_L] = 0;
  282. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.DET_2_1G_DL_OUT_H] = 0;
  283. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.DET_2_1G_DL_OUT_L] = 0;
  284. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.DET_2_1G_UL_IN_H] = 0;
  285. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.DET_2_1G_UL_IN_L] = 0;
  286. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.DET_2_1G_UL_OUT_H] = 0;
  287. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.DET_2_1G_UL_OUT_L] = 0;
  288. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.DET_3_5G_DL_IN_H] = 0;
  289. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.DET_3_5G_DL_IN_L] = 0;
  290. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.DET_3_5G_DL_OUT_L] = 0;
  291. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.DET_3_5G_DL_OUT_H] = 0;
  292. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.DET_3_5G_UL_IN_H] = 0;
  293. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.DET_3_5G_UL_IN_L] = 0;
  294. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.DET_3_5G_UL_OUT_H] = 0;
  295. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.DET_3_5G_UL_OUT_L] = 0;
  296. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.RFU_TEMP_H] = 0;
  297. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.RFU_TEMP_L] = 0;
  298. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t._28V_DET_H] = 0;
  299. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t._28V_DET_L] = 0;
  300. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.ALARM_AC] = 0;
  301. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.ALARM_DC] = 0;
  302. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.PATH_EN_1_8G_DL] = Convert.ToByte(PATH_1_8G_DL_Get_Func());
  303. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.PATH_EN_1_8G_UL] = Convert.ToByte(PATH_1_8G_UL_Get_Func());
  304. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.PATH_EN_2_1G_DL] = Convert.ToByte(PATH_2_1G_DL_Get_Func());
  305. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.PATH_EN_2_1G_UL] = Convert.ToByte(PATH_2_1G_UL_Get_Func());
  306. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.PATH_EN_3_5G_L] = Convert.ToByte(Path_3_5G_L_Get_Func());
  307. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.PATH_EN_3_5G_H] = Convert.ToByte(Path_3_5G_H_Get_Func());
  308. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.PATH_EN_3_5G_DL] = Convert.ToByte(PATH_3_5G_DL_Get_Func());
  309. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.PATH_EN_3_5G_UL] = Convert.ToByte(PATH_3_5G_DL_Get_Func());
  310. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.PLL_ON_OFF_3_5G_H] = Convert.ToByte(PLL_ON_OFF_3_5G_H_Get_Func());
  311. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.PLL_ON_OFF_3_5G_L] = Convert.ToByte(PLL_ON_OFF_3_5G_L_Get_Func());
  312. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.T_SYNC_DL] = main_Form.Tdd_T_Sync;//Convert.ToByte(PATH_3_5G_DL_Get_Func());
  313. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t._T_SYNC_DL] = main_Form.Tdd_T_Sync;//Convert.ToByte(PATH_3_5G_DL_Get_Func());
  314. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.T_SYNC_UL] = main_Form.Tdd_T_Sync;//Convert.ToByte(PLL_ON_OFF_3_5G_H_Get_Func());
  315. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t._T_SYNC_UL] = main_Form.Tdd_T_Sync;//Convert.ToByte(PLL_ON_OFF_3_5G_L_Get_Func());
  316. /* * * * * * FIX DATA * * * * * */
  317. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t._T_SYNC_UL + 1] = crc16.STH30_CreateCrc(temp_buf, BLUECELL_DATA_SET_LENGTH - 3);
  318. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t._T_SYNC_UL + 2] = BLUECELL_TAILER;
  319. this.serial.Serial_DataSend(temp_buf, temp_buf.Length);
  320. }
  321. bool PATH_1_8G_UL_Get_Func()
  322. {
  323. bool ret = false;
  324. if (this.main_Form.pictureBox_PATH_1_8G_UL_OFF.Visible == true)
  325. ret = false;
  326. else
  327. ret = true;
  328. return ret;
  329. }
  330. bool PATH_1_8G_DL_Get_Func()
  331. {
  332. bool ret = false;
  333. if (this.main_Form.pictureBox_PATH_1_8G_DL_OFF.Visible == true)
  334. ret = false;
  335. else
  336. ret = true;
  337. return ret;
  338. }
  339. bool PATH_2_1G_UL_Get_Func()
  340. {
  341. bool ret = false;
  342. if (this.main_Form.pictureBox_PATH_2_1G_UL_OFF.Visible == true)
  343. ret = false;
  344. else
  345. ret = true;
  346. return ret;
  347. }
  348. bool PATH_2_1G_DL_Get_Func()
  349. {
  350. bool ret = false;
  351. if (this.main_Form.pictureBox_PATH_2_1G_DL_OFF.Visible == true)
  352. ret = false;
  353. else
  354. ret = true;
  355. return ret;
  356. }
  357. bool Path_3_5G_L_Get_Func()
  358. {
  359. bool ret = false;
  360. if (this.main_Form.pictureBox_PATH_3_5G_L_OFF.Visible == true)
  361. ret = false;
  362. else
  363. ret = true;
  364. return ret;
  365. }
  366. bool Path_3_5G_H_Get_Func()
  367. {
  368. bool ret = false;
  369. if (this.main_Form.pictureBox_PATH_3_5G_H_OFF.Visible == true)
  370. ret = false;
  371. else
  372. ret = true;
  373. return ret;
  374. }
  375. bool PLL_ON_OFF_3_5G_L_Get_Func()
  376. {
  377. bool ret = false;
  378. if (this.main_Form.pictureBox_PLL_ON_OFF_3_5G_L_OFF.Visible == true)
  379. ret = false;
  380. else
  381. ret = true;
  382. return ret;
  383. }
  384. bool PLL_ON_OFF_3_5G_H_Get_Func()
  385. {
  386. bool ret = false;
  387. if (this.main_Form.pictureBox_PLL_ON_OFF_3_5G_H_OFF.Visible == true)
  388. ret = false;
  389. else
  390. ret = true;
  391. return ret;
  392. }
  393. bool PATH_3_5G_UL_Get_Func()
  394. {
  395. bool ret = false;
  396. if (this.main_Form.pictureBox_PATH_3_5G_UL_OFF.Visible == true)
  397. ret = false;
  398. else
  399. ret = true;
  400. return ret;
  401. }
  402. bool PATH_3_5G_DL_Get_Func()
  403. {
  404. bool ret = false;
  405. if (this.main_Form.pictureBox_PATH_3_5G_DL_OFF.Visible == true)
  406. ret = false;
  407. else
  408. ret = true;
  409. return ret;
  410. }
  411. /* public System.Windows.Forms.PictureBox pictureBox_PATH_3_5G_L_OFF;
  412. public System.Windows.Forms.PictureBox pictureBox_PATH_3_5G_H_OFF;
  413. public System.Windows.Forms.PictureBox pictureBox_PLL_ON_OFF_3_5G_L_OFF;
  414. public System.Windows.Forms.PictureBox pictureBox_PLL_ON_OFF_3_5G_H_OFF;
  415. public System.Windows.Forms.PictureBox pictureBox_PATH_3_5G_UL_OFF;
  416. public System.Windows.Forms.PictureBox pictureBox_PATH_3_5G_DL_OFF;
  417. public System.Windows.Forms.PictureBox pictureBox_PATH_2_1G_UL_OFF;
  418. public System.Windows.Forms.PictureBox pictureBox_PATH_2_1G_DL_OFF;
  419. public System.Windows.Forms.PictureBox pictureBox_PATH_1_8G_UL_OFF;
  420. public System.Windows.Forms.PictureBox pictureBox_PATH_1_8G_DL_OFF;
  421. */
  422. #if false
  423. public int Bluecell_Firmupdate_sendlength() {
  424. return bluecell_Firmupdate_sendlength;
  425. }
  426. private void BootHeaderput(ref byte[] fix_data)
  427. {
  428. fix_data[(int)Bluepro_t.bluecell_header0] = Bluecell_Header0;
  429. fix_data[(int)Bluepro_t.bluecell_header1] = Bluecell_Header1;
  430. fix_data[(int)Bluepro_t.bluecell_header2] = Bluecell_Header2;
  431. fix_data[(int)Bluepro_t.bluecell_header3] = Bluecell_Header3;
  432. }
  433. public byte[] Boot_Reset(object serial,byte[] Updatedata)
  434. {
  435. this.serial = (Serial)serial;
  436. byte[] fix_data = new byte[11];
  437. //Array.Clear(data, 0, data.Length);
  438. BootHeaderput(ref fix_data);
  439. fix_data[(int)Bluepro_t.bluecell_type] = (byte)Updateseq.Bluecell_Reset;
  440. fix_data[(int)Bluepro_t.bluecell_length_h] = 0;
  441. fix_data[(int)Bluepro_t.bluecell_length_l] = 5;
  442. fix_data[(int)Bluepro_t.bluecell_updatecnt_h] = Convert.ToByte((Updatedata.Length & 0xFF00) >> 8);
  443. fix_data[(int)Bluepro_t.bluecell_updatecnt_l] = Convert.ToByte((Updatedata.Length & 0x00FF));
  444. fix_data[(int)Bluepro_t.bluecell_data + 0] = Convert.ToByte((crc16.CRC16_Generate(fix_data, fix_data.Length - 4) & 0xFF00) >> 8);
  445. fix_data[(int)Bluepro_t.bluecell_data + 1] = Convert.ToByte((crc16.CRC16_Generate(fix_data, fix_data.Length - 4) & 0x00FF));
  446. this.serial.Serial_DataSend(fix_data, fix_data.Length);
  447. return fix_data;
  448. }
  449. public byte[] Boot_DataSending(byte[] update_data,UInt16 length, UInt16 updatacnt)
  450. {
  451. //Array.Clear(data, 0, data.Length);
  452. byte[] fix_data = new byte[bluecell_Firmupdate_sendlength];
  453. //BootHeaderput(ref fix_data);
  454. //length += 5;
  455. Array.Copy(update_data, (int)Bluepro_t.bluecell_data, fix_data, (int)Bluepro_t.bluecell_data, length);
  456. BootHeaderput(ref fix_data);
  457. fix_data[(int)Bluepro_t.bluecell_type] = (byte)Updateseq.Bluecell_Firmupdate_sending;
  458. fix_data[(int)Bluepro_t.bluecell_length_h] = Convert.ToByte((length & 0xFF00) >> 8);
  459. fix_data[(int)Bluepro_t.bluecell_length_l] = Convert.ToByte((length & 0x00FF));
  460. fix_data[(int)Bluepro_t.bluecell_updatecnt_h] = Convert.ToByte((updatacnt & 0xFF00) >> 8);
  461. fix_data[(int)Bluepro_t.bluecell_updatecnt_l] = Convert.ToByte((updatacnt & 0x00FF));
  462. //Array.Copy(update_data, 0, fix_data, (int)Bluepro_t.bluecell_data, length-3);
  463. fix_data[length + 9] = Convert.ToByte((crc16.CRC16_Generate(fix_data, length + 5) & 0xFF00) >> 8);
  464. fix_data[length + 10] = Convert.ToByte(crc16.CRC16_Generate(fix_data, length + 5) & 0x00FF);
  465. return fix_data;
  466. }
  467. public byte[] Boot_DataEnd(byte[] update_data, int length)
  468. {
  469. //Array.Clear(data, 0, data.Length);
  470. byte[] fix_data = new byte[11];
  471. Array.Copy(update_data, (int)Bluepro_t.bluecell_data, fix_data, (int)Bluepro_t.bluecell_data, length);
  472. BootHeaderput(ref fix_data);
  473. fix_data[(int)Bluepro_t.bluecell_type] = (byte)Updateseq.Bluecell_Firmupdate_end;
  474. fix_data[(int)Bluepro_t.bluecell_length_h] = Convert.ToByte((length & 0xFF00) >> 8);
  475. fix_data[(int)Bluepro_t.bluecell_length_l] = Convert.ToByte((length & 0x00FF));
  476. fix_data[(int)Bluepro_t.bluecell_updatecnt_h] = 0;
  477. fix_data[(int)Bluepro_t.bluecell_updatecnt_l] = 0;
  478. //Array.Copy(update_data, 0, fix_data, (int)Bluepro_t.bluecell_data, length-3);
  479. fix_data[length + 9] = Convert.ToByte((crc16.CRC16_Generate(fix_data, length + 5) & 0xFF00) >> 8);
  480. fix_data[length + 10] = Convert.ToByte(crc16.CRC16_Generate(fix_data, length + 5) & 0x00FF);
  481. return fix_data;
  482. }
  483. #endif
  484. }
  485. }