123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace RF_TRIO_PLL_ZIG
- {
- public enum Bluepro_t
- {
- bluecell_header0 = 0,
- bluecell_header1,
- bluecell_header2,
- bluecell_header3,
- bluecell_type,
- bluecell_length_h,
- bluecell_length_l,
- bluecell_updatecnt_h,
- bluecell_updatecnt_l,
- bluecell_data,
- };
- public enum Updateseq
- {
- Bluecell_Reset = 0,
- Bluecell_Firmupdate_start,
- Bluecell_Firmupdate_sending,
- Bluecell_Firmupdate_end,
- };
- enum Bluecell_ProtIndex_p
- {
- Bluecell_Header = 0,
- Bluecell_Type,
- Bluecell_Length,
- Bluecell_CrcIndex,
- Bluecell_data,
- }
- enum Bluecell_Prot_t{
- TYPE_BLUECELL_RESET = 0,
- TYPE_BLUECELL_SET = 1,
- TYPE_BLUECELL_GET = 2,
- TYPE_BLUECELL_SAVE = 3,
- TYPE_BLUECELL_ACK = 4,
- TYPE_BLUECELL_ERROR = 5,
- };
- enum Bluecell_TypeIndex_t
- {
- BLUE_HEADER = 0,
- BLUE_TYPE,
- BLUE_LENGTH,
- BLUE_CRCINDEX,
- ATT_1_8G_DL1,
- ATT_1_8G_DL2,
- ATT_1_8G_UL1,
- ATT_1_8G_UL2,
- ATT_1_8G_UL3,
- ATT_1_8G_UL4,
- ATT_2_1G_DL1,
- ATT_2_1G_DL2,
- ATT_2_1G_UL1,
- ATT_2_1G_UL2,
- ATT_2_1G_UL3,
- ATT_2_1G_UL4,
- ATT_3_5G_LOW1,
- ATT_3_5G_HIGH1,
- ATT_3_5G_COM1,
- ATT_3_5G_LOW2,
- ATT_3_5G_HIGH2,
- ATT_3_5G_COM2,
- PLL_1_8G_DL_H,
- PLL_1_8G_DL_L,
- PLL_1_8G_UL_H,
- PLL_1_8G_UL_L,
- PLL_2_1G_DL_H,
- PLL_2_1G_DL_L,
- PLL_2_1G_UL_H,
- PLL_2_1G_UL_L,
- PLL_3_5G_LOW_H,
- PLL_3_5G_LOW_M,
- PLL_3_5G_LOW_L,
- PLL_3_5G_HIGH_H,
- PLL_3_5G_HIGH_M,
- PLL_3_5G_HIGH_L,
- PLL_LD_6_BIT,
- DET_1_8G_DL_IN_H,
- DET_1_8G_DL_IN_L,
- DET_1_8G_DL_OUT_H,
- DET_1_8G_DL_OUT_L,
- DET_1_8G_UL_IN_H,
- DET_1_8G_UL_IN_L,
- DET_1_8G_UL_OUT_H,
- DET_1_8G_UL_OUT_L,
- DET_2_1G_DL_IN_H,
- DET_2_1G_DL_IN_L,
- DET_2_1G_DL_OUT_H,
- DET_2_1G_DL_OUT_L,
- DET_2_1G_UL_IN_H,
- DET_2_1G_UL_IN_L,
- DET_2_1G_UL_OUT_H,
- DET_2_1G_UL_OUT_L,
- DET_3_5G_DL_IN_H,
- DET_3_5G_DL_IN_L,
- DET_3_5G_DL_OUT_H,
- DET_3_5G_DL_OUT_L,
- DET_3_5G_UL_IN_H,
- DET_3_5G_UL_IN_L,
- DET_3_5G_UL_OUT_H,
- DET_3_5G_UL_OUT_L,
- RFU_TEMP_H,
- RFU_TEMP_L,
- _28V_DET_H,
- _28V_DET_L,
- ALARM_AC,
- ALARM_DC,
- PATH_EN_1_8G_DL,
- PATH_EN_1_8G_UL,
- PATH_EN_2_1G_DL,
- PATH_EN_2_1G_UL,
- PATH_EN_3_5G_DL,
- PATH_EN_3_5G_UL,
- PATH_EN_3_5G_H,
- PATH_EN_3_5G_L,
- PLL_ON_OFF_3_5G_H,
- PLL_ON_OFF_3_5G_L,
- T_SYNC_DL,
- _T_SYNC_DL,
- T_SYNC_UL,
- _T_SYNC_UL,
- DAC_VCtrl_A_H,
- DAC_VCtrl_A_L,
- DAC_VCtrl_B_H,
- DAC_VCtrl_B_L,
- DAC_VCtrl_C_H,
- DAC_VCtrl_C_L,
- DAC_VCtrl_D_H,
- DAC_VCtrl_D_L,
- DAC_VCtrl_E_H,
- DAC_VCtrl_E_L,
- DAC_VCtrl_F_H,
- DAC_VCtrl_F_L,
- DAC_VCtrl_G_H,
- DAC_VCtrl_G_L,
- DAC_VCtrl_H_H,
- DAC_VCtrl_H_L,
- };
- class Bluecell_BootProtocol
- {
- Serial serial;
- /*bluecell Header*/
- public const byte Bluecell_Header0 = 0x42;//ASCII : B
- public const byte Bluecell_Header1 = 0x4C;//ASCII : L
- public const byte Bluecell_Header2 = 0x55;//ASCII : U
- public const byte Bluecell_Header3 = 0x45;//ASCII : E
- /*bluecell type*/
- public const int bluecell_Firmupdate_sendlength = 1024;
-
- Crc16 crc16 = new Crc16();
- public const byte BLUECELL_HEADER = 0xBE;
- public const byte BLUECELL_TAILER = 0xEB;
- const byte BLUECELL_RESET_LENGTH = 6;
- const byte BLUECELL_FIX_DATA_LENGTH = 3;
- public void Bluecell_Reset(object serial)
- {
- this.serial = (Serial)serial;
- byte[] temp_buf = new byte[BLUECELL_RESET_LENGTH];
- temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_Header] = BLUECELL_HEADER;
- temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_Type] = (byte)Bluecell_Prot_t.TYPE_BLUECELL_RESET;
- temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_Length] = BLUECELL_RESET_LENGTH - BLUECELL_FIX_DATA_LENGTH;
- temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_CrcIndex] = (byte)Bluecell_ProtIndex_p.Bluecell_data;
- temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data] = crc16.STH30_CreateCrc(temp_buf, BLUECELL_RESET_LENGTH - 3);
- temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + 1] = BLUECELL_TAILER;
- this.serial.Serial_DataSend(temp_buf, temp_buf.Length);
- }
- private byte Bluecell_BDA4601_Calc(double data)
- {
- byte ret = 0;
-
- if (data == 31.5)
- ret = 0x3F;
- if (data >= 16) {
- ret |= 0x01;
- data -= 16;
- }
- if (data >= 8)
- {
- ret |= 0x02;
- data -= 8;
- }
- if (data >= 4)
- {
- ret |= 0x04;
- data -= 4;
- }
- if (data >= 2)
- {
- ret |= 0x08;
- data -= 2;
- }
- if (data >= 1)
- {
- ret |= 0x10;
- data -= 1;
- }
- if (data >= 0.5)
- {
- ret |= 0x20;
- data -= 0.5;
- }
- return ret;
- }
- public double Bluecell_Reverse_BDA4601_Calc(int data)
- {
- double ret = 0;
- if (data == 0x3F)
- ret = 31.5;
- if ((data & 0x01) > 0)
- {
- ret += 16;
- }
- if ((data & 0x02) > 0)
- {
- ret += 8;
- }
- if ((data & 0x04) > 0)
- {
- ret += 4;
- }
- if ((data & 0x08) > 0)
- {
- ret += 2;
- }
- if ((data & 0x10) > 0)
- {
- ret += 1;
- }
- if ((data & 0x20) > 0)
- {
- ret += 0.5;
- }
- return ret;
- }
- private byte Bluecell_PE43711_Calc(double data)
- {
- byte ret = 0;
- if (data == 31.75)
- ret = 0x7F;
- if (data >= 16)
- {
- ret |= 0x40;
- data -= 16;
- }
- if (data >= 8)
- {
- ret |= 0x20;
- data -= 8;
- }
- if (data >= 4)
- {
- ret |= 0x10;
- data -= 4;
- }
- if (data >= 2)
- {
- ret |= 0x08;
- data -= 2;
- }
- if (data >= 1)
- {
- ret |= 0x04;
- data -= 1;
- }
- if (data >= 0.5)
- {
- ret |= 0x02;
- data -= 0.5;
- }
- if (data >= 0.25)
- {
- ret |= 0x01;
- data -= 0.25;
- }
- return ret;
- }
- public double Bluecell_ReversePE43711_Calc(int data)
- {
- double ret = 0;
- if (data == 0x7F)
- ret = 31.75;
- if ((data & 0x40) > 0)
- {
- ret += 16;
- }
- if ((data & 0x20) > 0)
- {
- ret += 8;
- }
- if ((data & 0x10) > 0)
- {
- ret += 4;
- }
- if ((data & 0x08) > 0)
- {
- ret += 2;
- }
- if ((data & 0x04) > 0)
- {
- ret += 1;
- }
- if ((data & 0x02) > 0)
- {
- ret += 0.5;
- }
- if ((data & 0x01) > 0)
- {
- ret += 0.25;
- }
- return ret;
- }
- const byte BLUECELL_DATA_SET_LENGTH = (byte)Bluecell_TypeIndex_t.DAC_VCtrl_H_L + 2 + 1;
- Main_Form main_Form;
- public void Bluecell_BtnSet(object serial, object main_form)
- {
- this.main_Form = (Main_Form)main_form;
- this.serial = (Serial)serial;
- byte[] temp_buf = new byte[BLUECELL_DATA_SET_LENGTH];
- UInt32 temp_val = 0;
- double temp_ret = 0;
- /* * * * * * FIX DATA * * * * * */
- temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_Header] = BLUECELL_HEADER;
- temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_Type] = (byte)Bluecell_Prot_t.TYPE_BLUECELL_SET;
- temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_Length] = BLUECELL_DATA_SET_LENGTH - BLUECELL_FIX_DATA_LENGTH;
- temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_CrcIndex] = (byte)BLUECELL_DATA_SET_LENGTH - 2;
- //temp_buf[(int)Bluecell_TypeIndex_t.ATT_1_8G_DL1] = Bluecell_BDA4601_Calc(Convert.ToDouble(main_Form.numericUpDown_ATT_1_8G_DL1.Text));
- //temp_buf[(int)Bluecell_TypeIndex_t.ATT_1_8G_DL2] = Bluecell_BDA4601_Calc(Convert.ToDouble(main_Form.numericUpDown_ATT_1_8G_DL2.Text));
- //temp_buf[(int)Bluecell_TypeIndex_t.ATT_1_8G_UL1] = Bluecell_BDA4601_Calc(Convert.ToDouble(main_Form.numericUpDown_ATT_1_8G_UL1.Text));
- //temp_buf[(int)Bluecell_TypeIndex_t.ATT_1_8G_UL2] = Bluecell_BDA4601_Calc(Convert.ToDouble(main_Form.numericUpDown_ATT_1_8G_UL2.Text));
- //temp_buf[(int)Bluecell_TypeIndex_t.ATT_1_8G_UL3] = Bluecell_BDA4601_Calc(Convert.ToDouble(main_Form.numericUpDown_ATT_1_8G_UL3.Text));
- //temp_buf[(int)Bluecell_TypeIndex_t.ATT_1_8G_UL4] = Bluecell_BDA4601_Calc(Convert.ToDouble(main_Form.numericUpDown_ATT_1_8G_UL4.Text));
- //temp_buf[(int)Bluecell_TypeIndex_t.ATT_2_1G_DL1] = Bluecell_BDA4601_Calc(Convert.ToDouble(main_Form.numericUpDown_ATT_2_1G_DL1.Text));
- //temp_buf[(int)Bluecell_TypeIndex_t.ATT_2_1G_DL2] = Bluecell_BDA4601_Calc(Convert.ToDouble(main_Form.numericUpDown_ATT_2_1G_DL2.Text));
- //temp_buf[(int)Bluecell_TypeIndex_t.ATT_2_1G_UL1] = Bluecell_BDA4601_Calc(Convert.ToDouble(main_Form.numericUpDown_ATT_2_1G_UL1.Text));
- //temp_buf[(int)Bluecell_TypeIndex_t.ATT_2_1G_UL2] = Bluecell_BDA4601_Calc(Convert.ToDouble(main_Form.numericUpDown_ATT_2_1G_UL2.Text));
- //temp_buf[(int)Bluecell_TypeIndex_t.ATT_2_1G_UL3] = Bluecell_BDA4601_Calc(Convert.ToDouble(main_Form.numericUpDown_ATT_2_1G_UL3.Text));
- //temp_buf[(int)Bluecell_TypeIndex_t.ATT_2_1G_UL4] = Bluecell_BDA4601_Calc(Convert.ToDouble(main_Form.numericUpDown_ATT_2_1G_UL4.Text));
- temp_buf[(int)Bluecell_TypeIndex_t.ATT_3_5G_LOW1] = Bluecell_PE43711_Calc(Convert.ToDouble(main_Form.numericUpDown_ATT_3_5G_LOW1.Text));
- temp_buf[(int)Bluecell_TypeIndex_t.ATT_3_5G_HIGH1] = Bluecell_PE43711_Calc(Convert.ToDouble(main_Form.numericUpDown_ATT_3_5G_HIGH1.Text));
- temp_buf[(int)Bluecell_TypeIndex_t.ATT_3_5G_COM1] = Bluecell_PE43711_Calc(Convert.ToDouble(main_Form.numericUpDown_ATT_3_5G_COM1.Text));
- temp_buf[(int)Bluecell_TypeIndex_t.ATT_3_5G_LOW2] = Bluecell_PE43711_Calc(Convert.ToDouble(main_Form.numericUpDown_ATT_3_5G_LOW2.Text));
- temp_buf[(int)Bluecell_TypeIndex_t.ATT_3_5G_HIGH2] = Bluecell_PE43711_Calc(Convert.ToDouble(main_Form.numericUpDown_ATT_3_5G_HIGH2.Text));
- temp_buf[(int)Bluecell_TypeIndex_t.ATT_3_5G_COM2] = Bluecell_PE43711_Calc(Convert.ToDouble(main_Form.numericUpDown_ATT_3_5G_COM2.Text));
- //if (Convert.ToDouble(main_Form.numericUpDown_PLL_1_8G_DL.Text) > 0)
- //{
- // temp_val = (Convert.ToUInt32((Convert.ToDouble(main_Form.numericUpDown_PLL_1_8G_DL.Text) - 215) * 10));
- //}
- //else
- //{
- // temp_val = 0;
- //}
- //temp_buf[(int)Bluecell_TypeIndex_t.PLL_1_8G_DL_H] = Convert.ToByte((temp_val & 0xFF00) >> 8);
- //temp_buf[(int)Bluecell_TypeIndex_t.PLL_1_8G_DL_L] = Convert.ToByte((temp_val & 0x00FF));
- //if (Convert.ToDouble(main_Form.numericUpDown_PLL_1_8G_UL.Text) > 0)
- //{
- // temp_val = (Convert.ToUInt32((Convert.ToDouble(main_Form.numericUpDown_PLL_1_8G_UL.Text) - 276.5) * 10));
- //}
- //else
- //{
- // temp_val = 0;
- //}
- //temp_buf[(int)Bluecell_TypeIndex_t.PLL_1_8G_UL_H] = Convert.ToByte((temp_val & 0xFF00) >> 8);
- //temp_buf[(int)Bluecell_TypeIndex_t.PLL_1_8G_UL_L] = Convert.ToByte((temp_val & 0x00FF));
- //if (Convert.ToDouble(main_Form.numericUpDown_PLL_2_1G_DL.Text) > 0)
- //{
- // temp_val = (Convert.ToUInt32((Convert.ToDouble(main_Form.numericUpDown_PLL_2_1G_DL.Text) - 153.6) * 10));
- //}
- //else
- //{
- // temp_val = 0;
- //}
- //temp_buf[(int)Bluecell_TypeIndex_t.PLL_2_1G_DL_H] = Convert.ToByte((temp_val & 0xFF00) >> 8);
- //temp_buf[(int)Bluecell_TypeIndex_t.PLL_2_1G_DL_L] = Convert.ToByte((temp_val & 0x00FF));
- //if(Convert.ToDouble(main_Form.numericUpDown_PLL_2_1G_UL.Text) > 0)
- //{
- // temp_val = (Convert.ToUInt32((Convert.ToDouble(main_Form.numericUpDown_PLL_2_1G_UL.Text) + 337.9) * 10));
- //}
- //else
- //{
- // temp_val = 0;
- //}
- temp_buf[(int)Bluecell_TypeIndex_t.PLL_2_1G_UL_H] = Convert.ToByte((temp_val & 0xFF00) >> 8);
- temp_buf[(int)Bluecell_TypeIndex_t.PLL_2_1G_UL_L] = Convert.ToByte((temp_val & 0x00FF));
- if (Convert.ToDouble(main_Form.numericUpDown_PLL_3_5G_LOW.Text) > 0)
- {
- temp_val = Convert.ToUInt32(Convert.ToDouble(main_Form.numericUpDown_PLL_3_5G_LOW.Text) * 100);
- }
- else
- {
- temp_val = 0;
- }
- temp_buf[(int)Bluecell_TypeIndex_t.PLL_3_5G_LOW_H] = Convert.ToByte((temp_val & 0xFF0000) >> 16);
- temp_buf[(int)Bluecell_TypeIndex_t.PLL_3_5G_LOW_M] = Convert.ToByte((temp_val & 0x00FF00) >> 8);
- temp_buf[(int)Bluecell_TypeIndex_t.PLL_3_5G_LOW_L] = Convert.ToByte((temp_val & 0x0000FF));
- if (Convert.ToDouble(main_Form.numericUpDown_PLL_3_5G_HIGH.Text) > 0)
- {
- temp_val = Convert.ToUInt32(Convert.ToDouble(main_Form.numericUpDown_PLL_3_5G_HIGH.Text) * 100);
- }
- else
- {
- temp_val = 0;
- }
- temp_buf[(int)Bluecell_TypeIndex_t.PLL_3_5G_HIGH_H] = Convert.ToByte((temp_val & 0xFF0000) >> 16);
- temp_buf[(int)Bluecell_TypeIndex_t.PLL_3_5G_HIGH_M] = Convert.ToByte((temp_val & 0x00FF00) >> 8);
- temp_buf[(int)Bluecell_TypeIndex_t.PLL_3_5G_HIGH_L] = Convert.ToByte((temp_val & 0x0000FF));
- temp_buf[(int)Bluecell_TypeIndex_t.PLL_LD_6_BIT] = 0;//Convert.ToByte(main_Form.numericUpDown_ATT_3_5G_COM1.Text);
- temp_buf[(int)Bluecell_TypeIndex_t.DET_1_8G_DL_IN_H] = 0;// Convert.ToByte(main_Form.numericUpDown_ATT_3_5G_COM1.Text);
- temp_buf[(int)Bluecell_TypeIndex_t.DET_1_8G_DL_IN_L] = 0;// Convert.ToByte(main_Form.numericUpDown_ATT_3_5G_COM1.Text);
- temp_buf[(int)Bluecell_TypeIndex_t.DET_1_8G_DL_OUT_H] = 0;
- temp_buf[(int)Bluecell_TypeIndex_t.DET_1_8G_DL_OUT_L] = 0;
- temp_buf[(int)Bluecell_TypeIndex_t.DET_1_8G_UL_IN_H] = 0;
- temp_buf[(int)Bluecell_TypeIndex_t.DET_1_8G_UL_IN_L] = 0;
- temp_buf[(int)Bluecell_TypeIndex_t.DET_1_8G_UL_OUT_H] = 0;
- temp_buf[(int)Bluecell_TypeIndex_t.DET_1_8G_UL_OUT_L] = 0;
- temp_buf[(int)Bluecell_TypeIndex_t.DET_2_1G_DL_IN_H] = 0;
- temp_buf[(int)Bluecell_TypeIndex_t.DET_2_1G_DL_IN_L] = 0;
- temp_buf[(int)Bluecell_TypeIndex_t.DET_2_1G_DL_OUT_H] = 0;
- temp_buf[(int)Bluecell_TypeIndex_t.DET_2_1G_DL_OUT_L] = 0;
- temp_buf[(int)Bluecell_TypeIndex_t.DET_2_1G_UL_IN_H] = 0;
- temp_buf[(int)Bluecell_TypeIndex_t.DET_2_1G_UL_IN_L] = 0;
- temp_buf[(int)Bluecell_TypeIndex_t.DET_2_1G_UL_OUT_H] = 0;
- temp_buf[(int)Bluecell_TypeIndex_t.DET_2_1G_UL_OUT_L] = 0;
- temp_buf[(int)Bluecell_TypeIndex_t.DET_3_5G_DL_IN_H] = 0;
- temp_buf[(int)Bluecell_TypeIndex_t.DET_3_5G_DL_IN_L] = 0;
- temp_buf[(int)Bluecell_TypeIndex_t.DET_3_5G_DL_OUT_L] = 0;
- temp_buf[(int)Bluecell_TypeIndex_t.DET_3_5G_DL_OUT_H] = 0;
- temp_buf[(int)Bluecell_TypeIndex_t.DET_3_5G_UL_IN_H] = 0;
- temp_buf[(int)Bluecell_TypeIndex_t.DET_3_5G_UL_IN_L] = 0;
- temp_buf[(int)Bluecell_TypeIndex_t.DET_3_5G_UL_OUT_H] = 0;
- temp_buf[(int)Bluecell_TypeIndex_t.DET_3_5G_UL_OUT_L] = 0;
- temp_buf[(int)Bluecell_TypeIndex_t.RFU_TEMP_H] = 0;
- temp_buf[(int)Bluecell_TypeIndex_t.RFU_TEMP_L] = 0;
- temp_buf[(int)Bluecell_TypeIndex_t._28V_DET_H] = 0;
- temp_buf[(int)Bluecell_TypeIndex_t._28V_DET_L] = 0;
- temp_buf[(int)Bluecell_TypeIndex_t.ALARM_AC] = 0;
- temp_buf[(int)Bluecell_TypeIndex_t.ALARM_DC] = 0;
- temp_buf[(int)Bluecell_TypeIndex_t.PATH_EN_1_8G_DL] = Convert.ToByte(PATH_1_8G_DL_Get_Func());
- temp_buf[(int)Bluecell_TypeIndex_t.PATH_EN_1_8G_UL] = Convert.ToByte(PATH_1_8G_UL_Get_Func());
- temp_buf[(int)Bluecell_TypeIndex_t.PATH_EN_2_1G_DL] = Convert.ToByte(PATH_2_1G_DL_Get_Func());
- temp_buf[(int)Bluecell_TypeIndex_t.PATH_EN_2_1G_UL] = Convert.ToByte(PATH_2_1G_UL_Get_Func());
- temp_buf[(int)Bluecell_TypeIndex_t.PATH_EN_3_5G_L] = Convert.ToByte(Path_3_5G_L_Get_Func());
- temp_buf[(int)Bluecell_TypeIndex_t.PATH_EN_3_5G_H] = Convert.ToByte(Path_3_5G_H_Get_Func());
- temp_buf[(int)Bluecell_TypeIndex_t.PATH_EN_3_5G_DL] = Convert.ToByte(PATH_3_5G_DL_Get_Func());
- temp_buf[(int)Bluecell_TypeIndex_t.PATH_EN_3_5G_UL] = Convert.ToByte(PATH_3_5G_UL_Get_Func());
- temp_buf[(int)Bluecell_TypeIndex_t.PLL_ON_OFF_3_5G_H] = Convert.ToByte(PLL_ON_OFF_3_5G_H_Get_Func());
- temp_buf[(int)Bluecell_TypeIndex_t.PLL_ON_OFF_3_5G_L] = Convert.ToByte(PLL_ON_OFF_3_5G_L_Get_Func());
- temp_buf[(int)Bluecell_TypeIndex_t.T_SYNC_DL] = main_Form.Tdd_T_Sync;//Convert.ToByte(PATH_3_5G_DL_Get_Func());
- temp_buf[(int)Bluecell_TypeIndex_t._T_SYNC_DL] = main_Form.Tdd_T_Sync;//Convert.ToByte(PATH_3_5G_DL_Get_Func());
- temp_buf[(int)Bluecell_TypeIndex_t.T_SYNC_UL] = main_Form.Tdd_T_Sync;//Convert.ToByte(PLL_ON_OFF_3_5G_H_Get_Func());
- temp_buf[(int)Bluecell_TypeIndex_t._T_SYNC_UL] = main_Form.Tdd_T_Sync;//Convert.ToByte(PLL_ON_OFF_3_5G_L_Get_Func());
- /***********************DAC A Sector**********************************/
- double double_temp = Convert.ToDouble(main_Form.numericUpDown_DAC_VoltCtrl_A.Text) * 4095;
- UInt16 temp = Convert.ToUInt16(double_temp / 4);
- temp = Convert.ToUInt16(temp & 0x0FFF);
- temp_buf[(int)Bluecell_TypeIndex_t.DAC_VCtrl_A_H]
- = Convert.ToByte(0x00 + Convert.ToByte((temp & 0xFF00) >> 8));
- temp_buf[(int)Bluecell_TypeIndex_t.DAC_VCtrl_A_L]
- = Convert.ToByte(Convert.ToUInt16(temp) & 0x00FF);
- /***********************DAC B Sector**********************************/
- double_temp = Convert.ToDouble(main_Form.numericUpDown_DAC_VoltCtrl_B.Text) * 4095;
- temp = Convert.ToUInt16(double_temp / 4);
- temp = Convert.ToUInt16(temp & 0x0FFF);
- temp_buf[(int)Bluecell_TypeIndex_t.DAC_VCtrl_B_H]
- = Convert.ToByte(0x10 + Convert.ToByte((temp & 0xFF00) >> 8));
- temp_buf[(int)Bluecell_TypeIndex_t.DAC_VCtrl_B_L]
- = Convert.ToByte(Convert.ToUInt16(temp) & 0x00FF);
- /***********************DAC C Sector**********************************/
- double_temp = Convert.ToDouble(main_Form.numericUpDown_DAC_VoltCtrl_C.Text) * 4095;
- temp = Convert.ToUInt16(double_temp / 4);
- temp = Convert.ToUInt16(temp & 0x0FFF);
- temp_buf[(int)Bluecell_TypeIndex_t.DAC_VCtrl_C_H]
- = Convert.ToByte(0x20 + Convert.ToByte((temp & 0xFF00) >> 8));
- temp_buf[(int)Bluecell_TypeIndex_t.DAC_VCtrl_C_L]
- = Convert.ToByte(Convert.ToUInt16(temp) & 0x00FF);
- /***********************DAC D Sector**********************************/
- double_temp = Convert.ToDouble(main_Form.numericUpDown_DAC_VoltCtrl_D.Text) * 4095;
- temp = Convert.ToUInt16(double_temp / 4);
- temp = Convert.ToUInt16(temp & 0x0FFF);
- temp_buf[(int)Bluecell_TypeIndex_t.DAC_VCtrl_D_H]
- = Convert.ToByte(0x30 + Convert.ToByte((temp & 0xFF00) >> 8));
- temp_buf[(int)Bluecell_TypeIndex_t.DAC_VCtrl_D_L]
- = Convert.ToByte(Convert.ToUInt16(temp) & 0x00FF);
- /***********************DAC E Sector**********************************/
- double_temp = Convert.ToDouble(main_Form.numericUpDown_DAC_VoltCtrl_E.Text) * 4095;
- temp = Convert.ToUInt16(double_temp / 4);
- temp = Convert.ToUInt16(temp & 0x0FFF);
- temp_buf[(int)Bluecell_TypeIndex_t.DAC_VCtrl_E_H]
- = Convert.ToByte(0x40 + Convert.ToByte((temp & 0xFF00) >> 8));
- temp_buf[(int)Bluecell_TypeIndex_t.DAC_VCtrl_E_L]
- = Convert.ToByte(Convert.ToUInt16(temp) & 0x00FF);
- /***********************DAC F Sector**********************************/
- double_temp = Convert.ToDouble(main_Form.numericUpDown_DAC_VoltCtrl_F.Text) * 4095;
- temp = Convert.ToUInt16(double_temp / 4);
- temp = Convert.ToUInt16(temp & 0x0FFF);
- temp_buf[(int)Bluecell_TypeIndex_t.DAC_VCtrl_F_H]
- = Convert.ToByte(0x50 + Convert.ToByte((temp & 0xFF00) >> 8));
- temp_buf[(int)Bluecell_TypeIndex_t.DAC_VCtrl_F_L]
- = Convert.ToByte(Convert.ToUInt16(temp) & 0x00FF);
- /***********************DAC G Sector**********************************/
- double_temp = Convert.ToDouble(main_Form.numericUpDown_DAC_VoltCtrl_G.Text) * 4095;
- temp = Convert.ToUInt16(double_temp / 4);
- temp = Convert.ToUInt16(temp & 0x0FFF);
- temp_buf[(int)Bluecell_TypeIndex_t.DAC_VCtrl_G_H]
- = Convert.ToByte(0x60 + Convert.ToByte((temp & 0xFF00) >> 8));
- temp_buf[(int)Bluecell_TypeIndex_t.DAC_VCtrl_G_L]
- = Convert.ToByte(Convert.ToUInt16(temp) & 0x00FF);
- /***********************DAC H Sector**********************************/
- double_temp = Convert.ToDouble(main_Form.numericUpDown_DAC_VoltCtrl_H.Text) * 4095;
- temp = Convert.ToUInt16(double_temp / 4);
- temp = Convert.ToUInt16(temp & 0x0FFF);
-
- temp_buf[(int)Bluecell_TypeIndex_t.DAC_VCtrl_H_H]
- = Convert.ToByte(0x70 + Convert.ToByte((temp & 0xFF00) >> 8));
- temp_buf[(int)Bluecell_TypeIndex_t.DAC_VCtrl_H_L]
- = Convert.ToByte(Convert.ToUInt16(temp) & 0x00FF);
- /* * * * * * FIX DATA * * * * * */
- temp_buf[(int)Bluecell_TypeIndex_t.DAC_VCtrl_H_L + 1]
- = crc16.STH30_CreateCrc(temp_buf, BLUECELL_DATA_SET_LENGTH - 3);
- temp_buf[(int)Bluecell_TypeIndex_t.DAC_VCtrl_H_L + 2]
- = BLUECELL_TAILER;
- this.serial.Serial_DataSend(temp_buf, temp_buf.Length);
- }
- int[] RF_Status = new int[BLUECELL_DATA_SET_LENGTH];
- private delegate void StringSend(string Text);
- private delegate void ByteSend(byte[] Text);
- public void Bluecell_RF_Status_Get(object serial, object main_form,byte[] temp_buf)
- {
- this.main_Form = (Main_Form)main_form;
- this.serial = (Serial)serial;
- byte type = temp_buf[(byte)Bluecell_TypeIndex_t.BLUE_TYPE];
- // main_Form.Invoke(new ByteSend(this.main_Form.ReSetting_Values),(temp_buf));
- switch (type)
- {
- case (byte)Bluecell_Prot_t.TYPE_BLUECELL_GET:
- this.main_Form.ADC_Voltage_Value_Set(temp_buf);
- break;
- case (byte)Bluecell_Prot_t.TYPE_BLUECELL_ACK:
- this.main_Form.Message_Box_Open();
- break;
- case (byte)Bluecell_Prot_t.TYPE_BLUECELL_ERROR:
- this.main_Form.Message_Box_Error_Open(temp_buf);
- break;
- }
- //Debug.Invoke(new StringSend(Debug.Data_Recv_Str), data);
- //main_Form.label1_8GHz_DL_OUT.Text = Convert.ToString(temp_val);
- }
- public void Bluecell_RF_Status_Req(object serial)
- {
- Crc16 crc16 = new Crc16();
- this.serial = (Serial)serial;
- byte[] temp_buf = new byte[6];
- temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_Header] = BLUECELL_HEADER;
- temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_Type] = 2;
- temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_Length] = Convert.ToByte(temp_buf.Length - 3);
- temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_CrcIndex] = Convert.ToByte(temp_buf.Length - 2);
- temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + 0] = crc16.STH30_CreateCrc(temp_buf, temp_buf[2]);
- temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + 1] = BLUECELL_TAILER;
- this.serial.Serial_DataSend(temp_buf, temp_buf.Length);
- }
- bool PATH_1_8G_UL_Get_Func()
- {
- bool ret = false;
- /* if (this.main_Form.pictureBox_PATH_1_8G_UL_OFF.Visible == true)
- ret = false;
- else
- ret = true;*/
- return ret;
- }
- bool PATH_1_8G_DL_Get_Func()
- {
- bool ret = false;
- //if (this.main_Form.pictureBox_PATH_1_8G_DL_OFF.Visible == true)
- // ret = false;
- //else
- // ret = true;
- return ret;
- }
- bool PATH_2_1G_UL_Get_Func()
- {
- bool ret = false;
- //if (this.main_Form.pictureBox_PATH_2_1G_UL_OFF.Visible == true)
- // ret = false;
- //else
- // ret = true;
- return ret;
- }
- bool PATH_2_1G_DL_Get_Func()
- {
- bool ret = false;
- //if (this.main_Form.pictureBox_PATH_2_1G_DL_OFF.Visible == true)
- // ret = false;
- //else
- // ret = true;
- return ret;
- }
- bool Path_3_5G_L_Get_Func()
- {
- bool ret = false;
- if (this.main_Form.pictureBox_PATH_3_5G_L_OFF.Visible == true)
- ret = false;
- else
- ret = true;
- return ret;
- }
- bool Path_3_5G_H_Get_Func()
- {
- bool ret = false;
- if (this.main_Form.pictureBox_PATH_3_5G_H_OFF.Visible == true)
- ret = false;
- else
- ret = true;
- return ret;
- }
- bool PLL_ON_OFF_3_5G_L_Get_Func()
- {
- bool ret = false;
- /*if (this.main_Form.pictureBox_PLL_ON_OFF_3_5G_L_OFF.Visible == true)
- ret = false;
- else
- ret = true;*/
- return ret;
- }
- bool PLL_ON_OFF_3_5G_H_Get_Func()
- {
- bool ret = false;
- /* if (this.main_Form.pictureBox_PLL_ON_OFF_3_5G_H_OFF.Visible == true)
- ret = false;
- else
- ret = true;*/
- return ret;
- }
- bool PATH_3_5G_UL_Get_Func()
- {
- bool ret = false;
- if (this.main_Form.pictureBox_PATH_3_5G_UL_OFF.Visible == true)
- ret = false;
- else
- ret = true;
- return ret;
- }
- bool PATH_3_5G_DL_Get_Func()
- {
- bool ret = false;
- if (this.main_Form.pictureBox_PATH_3_5G_DL_OFF.Visible == true)
- ret = false;
- else
- ret = true;
- return ret;
- }
-
- /* public System.Windows.Forms.PictureBox pictureBox_PATH_3_5G_L_OFF;
- public System.Windows.Forms.PictureBox pictureBox_PATH_3_5G_H_OFF;
- public System.Windows.Forms.PictureBox pictureBox_PLL_ON_OFF_3_5G_L_OFF;
- public System.Windows.Forms.PictureBox pictureBox_PLL_ON_OFF_3_5G_H_OFF;
- public System.Windows.Forms.PictureBox pictureBox_PATH_3_5G_UL_OFF;
- public System.Windows.Forms.PictureBox pictureBox_PATH_3_5G_DL_OFF;
- public System.Windows.Forms.PictureBox pictureBox_PATH_2_1G_UL_OFF;
- public System.Windows.Forms.PictureBox pictureBox_PATH_2_1G_DL_OFF;
- public System.Windows.Forms.PictureBox pictureBox_PATH_1_8G_UL_OFF;
- public System.Windows.Forms.PictureBox pictureBox_PATH_1_8G_DL_OFF;
- */
- #if false
- public int Bluecell_Firmupdate_sendlength() {
- return bluecell_Firmupdate_sendlength;
- }
- private void BootHeaderput(ref byte[] fix_data)
- {
- fix_data[(int)Bluepro_t.bluecell_header0] = Bluecell_Header0;
- fix_data[(int)Bluepro_t.bluecell_header1] = Bluecell_Header1;
- fix_data[(int)Bluepro_t.bluecell_header2] = Bluecell_Header2;
- fix_data[(int)Bluepro_t.bluecell_header3] = Bluecell_Header3;
- }
- public byte[] Boot_Reset(object serial,byte[] Updatedata)
- {
- this.serial = (Serial)serial;
- byte[] fix_data = new byte[11];
- //Array.Clear(data, 0, data.Length);
- BootHeaderput(ref fix_data);
- fix_data[(int)Bluepro_t.bluecell_type] = (byte)Updateseq.Bluecell_Reset;
- fix_data[(int)Bluepro_t.bluecell_length_h] = 0;
- fix_data[(int)Bluepro_t.bluecell_length_l] = 5;
- fix_data[(int)Bluepro_t.bluecell_updatecnt_h] = Convert.ToByte((Updatedata.Length & 0xFF00) >> 8);
- fix_data[(int)Bluepro_t.bluecell_updatecnt_l] = Convert.ToByte((Updatedata.Length & 0x00FF));
- fix_data[(int)Bluepro_t.bluecell_data + 0] = Convert.ToByte((crc16.CRC16_Generate(fix_data, fix_data.Length - 4) & 0xFF00) >> 8);
- fix_data[(int)Bluepro_t.bluecell_data + 1] = Convert.ToByte((crc16.CRC16_Generate(fix_data, fix_data.Length - 4) & 0x00FF));
- this.serial.Serial_DataSend(fix_data, fix_data.Length);
- return fix_data;
- }
-
- public byte[] Boot_DataSending(byte[] update_data,UInt16 length, UInt16 updatacnt)
- {
- //Array.Clear(data, 0, data.Length);
- byte[] fix_data = new byte[bluecell_Firmupdate_sendlength];
- //BootHeaderput(ref fix_data);
- //length += 5;
- Array.Copy(update_data, (int)Bluepro_t.bluecell_data, fix_data, (int)Bluepro_t.bluecell_data, length);
- BootHeaderput(ref fix_data);
- fix_data[(int)Bluepro_t.bluecell_type] = (byte)Updateseq.Bluecell_Firmupdate_sending;
- fix_data[(int)Bluepro_t.bluecell_length_h] = Convert.ToByte((length & 0xFF00) >> 8);
- fix_data[(int)Bluepro_t.bluecell_length_l] = Convert.ToByte((length & 0x00FF));
- fix_data[(int)Bluepro_t.bluecell_updatecnt_h] = Convert.ToByte((updatacnt & 0xFF00) >> 8);
- fix_data[(int)Bluepro_t.bluecell_updatecnt_l] = Convert.ToByte((updatacnt & 0x00FF));
- //Array.Copy(update_data, 0, fix_data, (int)Bluepro_t.bluecell_data, length-3);
- fix_data[length + 9] = Convert.ToByte((crc16.CRC16_Generate(fix_data, length + 5) & 0xFF00) >> 8);
- fix_data[length + 10] = Convert.ToByte(crc16.CRC16_Generate(fix_data, length + 5) & 0x00FF);
- return fix_data;
- }
- public byte[] Boot_DataEnd(byte[] update_data, int length)
- {
- //Array.Clear(data, 0, data.Length);
- byte[] fix_data = new byte[11];
- Array.Copy(update_data, (int)Bluepro_t.bluecell_data, fix_data, (int)Bluepro_t.bluecell_data, length);
- BootHeaderput(ref fix_data);
- fix_data[(int)Bluepro_t.bluecell_type] = (byte)Updateseq.Bluecell_Firmupdate_end;
- fix_data[(int)Bluepro_t.bluecell_length_h] = Convert.ToByte((length & 0xFF00) >> 8);
- fix_data[(int)Bluepro_t.bluecell_length_l] = Convert.ToByte((length & 0x00FF));
- fix_data[(int)Bluepro_t.bluecell_updatecnt_h] = 0;
- fix_data[(int)Bluepro_t.bluecell_updatecnt_l] = 0;
- //Array.Copy(update_data, 0, fix_data, (int)Bluepro_t.bluecell_data, length-3);
- fix_data[length + 9] = Convert.ToByte((crc16.CRC16_Generate(fix_data, length + 5) & 0xFF00) >> 8);
- fix_data[length + 10] = Convert.ToByte(crc16.CRC16_Generate(fix_data, length + 5) & 0x00FF);
- return fix_data;
- }
- #endif
- }
- }
|