using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; //Add code using System.IO; using System.IO.Ports; namespace RF_TRIO_PLL_ZIG { public partial class Main_Form : Form { Serial serial = new Serial(); // Uart Open Bluecell_BootProtocol bluecell_BootProtocol = new Bluecell_BootProtocol(); Update_Serial file = new Update_Serial(); public byte Tdd_T_Sync = 0; public Main_Form() { InitializeComponent(); serial.Serial_Initialize(ref comboBox_Port); } private void Firmware_Update_Click(object sender, EventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); //FileDownload file = new FileDownload(); if (Ascii_checkBox.Checked == true) Ascii_checkBox.Checked = false; file.ShowFileOpenDialog(ref serial, ofd); } private void Crc16_Check_Click(object sender, EventArgs e) { #if false Crc16 crc16 = new Crc16(); byte[] tempdata = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09,0x0A }; label1.Text = crc16.CRC16_Generate(tempdata, 11).ToString(); #endif this.serial.Test_Serial(); } private void Button_PortOpen_Click(object sender, EventArgs e) { bool ret = false; ret = Serial_connectiondisable(serial.Serial_PortOpen(ref button_PortOpen, ref comboBox_Port)); if (ret == false && timer.Enabled == false) { timer.Start(); //타이머를 발동시킨다. } else if (timer.Enabled == true) { timer.Stop(); //타이머를 멈춘다. } else { /*NOP*/ } serial.Serial_Main_Form_Get(this); } private void ComboBox_Port_SelectedIndexChanged(object sender, EventArgs e) { serial.Serial_Name = comboBox_Port.SelectedItem.ToString(); } private void Button_terminal_Click(object sender, EventArgs e) { serial.Serial_TerminalOpen(serial); } public bool Serial_connectiondisable(Boolean on_off) { comboBox_Port.Enabled = on_off; comboBox_baudrate.Enabled = on_off; return on_off; } private delegate void BoolSet(); public void TX_Light_ON() { this.pictureBox_G_TX.Visible = true; this.pictureBox_R_TX.Visible = false; } public void TX_Light_OFF() { this.pictureBox_R_TX.Visible = true; this.pictureBox_G_TX.Visible = false; } public void RX_Light_ON() { this.pictureBox_G_RX.Visible = true; this.pictureBox_R_RX.Visible = false; } public void RX_Light_OFF() { this.pictureBox_R_RX.Visible = true; this.pictureBox_G_RX.Visible = false; } private void timer_Tick(object sender, EventArgs e) { if (this.pictureBox_G_TX.Visible == true) { TX_Light_OFF(); } if(this.pictureBox_G_RX.Visible == true) { RX_Light_OFF(); } } private void Main_Form_Load(object sender, EventArgs e) { pictureBox_PATH_1_8G_DL_ON.Visible = !false; pictureBox_PATH_1_8G_UL_ON.Visible = !false; pictureBox_PATH_2_1G_DL_ON.Visible = !false; pictureBox_PATH_2_1G_UL_ON.Visible = !false; pictureBox_PATH_3_5G_L_ON.Visible = !false; pictureBox_PATH_3_5G_H_ON.Visible = !false; pictureBox_PLL_ON_OFF_3_5G_L_ON.Visible = !false; pictureBox_PLL_ON_OFF_3_5G_H_ON.Visible = !false; pictureBox_PATH_3_5G_UL_ON.Visible = !false; pictureBox_PATH_3_5G_DL_ON.Visible = !false; pictureBox_PATH_1_8G_DL_OFF.Visible = false; pictureBox_PATH_1_8G_UL_OFF.Visible = false; pictureBox_PATH_2_1G_DL_OFF.Visible = false; pictureBox_PATH_2_1G_UL_OFF.Visible = false; pictureBox_PATH_3_5G_L_OFF.Visible = false; pictureBox_PATH_3_5G_H_OFF.Visible = false; pictureBox_PLL_ON_OFF_3_5G_L_OFF.Visible = false; pictureBox_PLL_ON_OFF_3_5G_H_OFF.Visible = false; pictureBox_PATH_3_5G_UL_OFF.Visible = false; pictureBox_PATH_3_5G_DL_OFF.Visible = false; pictureBox_G_RX.Visible = !false; pictureBox_G_TX.Visible = !false; /* 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; public System.Windows.Forms.PictureBox pictureBox_PATH_3_5G_L_ON; public System.Windows.Forms.PictureBox pictureBox_PATH_3_5G_H_ON; public System.Windows.Forms.PictureBox pictureBox_PLL_ON_OFF_3_5G_L_ON; public System.Windows.Forms.PictureBox pictureBox_PLL_ON_OFF_3_5G_H_ON; public System.Windows.Forms.PictureBox pictureBox_PATH_3_5G_UL_ON; public System.Windows.Forms.PictureBox pictureBox_PATH_3_5G_DL_ON; public System.Windows.Forms.PictureBox pictureBox_PATH_2_1G_UL_ON; public System.Windows.Forms.PictureBox pictureBox_PATH_2_1G_DL_ON; public System.Windows.Forms.PictureBox pictureBox_PATH_1_8G_UL_ON;;*/ } private delegate void StringSend(object label, String str); public void ADC_Voltage_Value_Set(byte[] data) { int temp_val = 0; try { temp_val = (int)(data[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.DET_1_8G_DL_IN_H] << 8) | (data[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.DET_1_8G_DL_IN_L]); this.Invoke(new StringSend(Label_Text_Set), label1_8GHz_DL_IN, Convert.ToString(temp_val)); temp_val = (int)(data[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.DET_1_8G_DL_IN_H] << 8) | (data[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.DET_1_8G_DL_OUT_L]); this.Invoke(new StringSend(Label_Text_Set), label1_8GHz_DL_OUT, Convert.ToString(temp_val)); temp_val = (int)(data[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.DET_1_8G_DL_OUT_H] << 8) | (data[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.DET_1_8G_UL_IN_L]); this.Invoke(new StringSend(Label_Text_Set), label1_8GHz_UL_IN, Convert.ToString(temp_val)); temp_val = (int)(data[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.DET_1_8G_UL_IN_H] << 8) | (data[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.DET_1_8G_UL_OUT_L]); this.Invoke(new StringSend(Label_Text_Set), label1_8GHz_UL_OUT, Convert.ToString(temp_val)); temp_val = (int)(data[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.DET_1_8G_UL_OUT_H] << 8) | (data[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.DET_2_1G_DL_IN_L]); this.Invoke(new StringSend(Label_Text_Set), label2_1GHz_DL_IN, Convert.ToString(temp_val)); temp_val = (int)(data[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.DET_2_1G_DL_IN_H] << 8) | (data[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.DET_2_1G_DL_OUT_L]); this.Invoke(new StringSend(Label_Text_Set), label2_1GHz_DL_OUT, Convert.ToString(temp_val)); temp_val = (int)(data[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.DET_2_1G_DL_OUT_H] << 8) | (data[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.DET_2_1G_UL_IN_L]); this.Invoke(new StringSend(Label_Text_Set), label2_1GHz_UL_IN, Convert.ToString(temp_val)); temp_val = (int)(data[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.DET_2_1G_UL_IN_H] << 8) | (data[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.DET_2_1G_UL_OUT_L]); this.Invoke(new StringSend(Label_Text_Set), label2_1GHz_UL_OUT, Convert.ToString(temp_val)); temp_val = (int)(data[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.DET_3_5G_DL_IN_H] << 8) | (data[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.DET_3_5G_DL_IN_L]); this.Invoke(new StringSend(Label_Text_Set), label3_5GHz_DL_IN, Convert.ToString(temp_val)); temp_val = (int)(data[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.DET_3_5G_DL_OUT_H] << 8) | (data[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.DET_3_5G_DL_OUT_L]); this.Invoke(new StringSend(Label_Text_Set), label3_5GHz_DL_OUT, Convert.ToString(temp_val)); temp_val = (int)(data[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.DET_3_5G_UL_IN_H] << 8) | (data[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.DET_3_5G_UL_IN_L]); this.Invoke(new StringSend(Label_Text_Set), label3_5GHz_UL_IN, Convert.ToString(temp_val)); temp_val = (int)(data[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.DET_3_5G_UL_OUT_H] << 8) | (data[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.DET_3_5G_UL_OUT_L]); this.Invoke(new StringSend(Label_Text_Set), label3_5GHz_UL_OUT, Convert.ToString(temp_val)); } catch { } } private void Label_Text_Set(object label,String str) { Label Temp_label = (Label)label; Temp_label.Text = str; } private void ATT_Enter(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { Button_Set_Click(sender, e); //to do } else { return; } } private void TDD_T_SYNC_Click(object sender, EventArgs e) { PictureBox pictureBox = (PictureBox)sender; Tdd_T_Sync = Convert.ToByte(pictureBox.Tag); bluecell_BootProtocol.Bluecell_BtnSet(this.serial, this); pictureBox_TDD_T_SYNC_UL_ON.Visible = !pictureBox_TDD_T_SYNC_UL_ON.Visible; pictureBox_TDD_T_SYNC_DL_OFF.Visible = !pictureBox_TDD_T_SYNC_DL_OFF.Visible; } const byte PATH_1_8G_DL_ON = 1; const byte PATH_1_8G_DL_OFF = 2; const byte PATH_1_8G_UL_ON = 3; const byte PATH_1_8G_UL_OFF = 4; const byte PATH_2_1G_DL_ON = 5; const byte PATH_2_1G_DL_OFF = 6; const byte PATH_2_1G_UL_ON = 7; const byte PATH_2_1G_UL_OFF = 8; const byte PATH_3_5G_DL_ON = 9; const byte PATH_3_5G_DL_OFF = 10; const byte PATH_3_5G_UL_ON = 11; const byte PATH_3_5G_UL_OFF = 12; const byte PATH_3_5G_H_ON = 13; const byte PATH_3_5G_H_OFF = 14; const byte PATH_3_5G_L_ON = 15; const byte PATH_3_5G_L_OFF = 16; const byte PLL_POWER_ONOFF_3_5G_H_ON = 17; const byte PLL_POWER_ONOFF_3_5G_H_OFF = 18; const byte PLL_POWER_ONOFF_3_5G_L_ON = 19; const byte PLL_POWER_ONOFF_3_5G_L_OFF = 20; private void Power_OnOff_Set(object sender, EventArgs e) { byte temp_tag = 0; PictureBox pictureBox = (PictureBox)sender; temp_tag = Convert.ToByte(pictureBox.Tag); switch (temp_tag) { case PATH_1_8G_DL_OFF: pictureBox_PATH_1_8G_DL_ON.Visible = true; break; case PATH_1_8G_DL_ON: pictureBox_PATH_1_8G_DL_OFF.Visible = true; break; case PATH_1_8G_UL_OFF: pictureBox_PATH_1_8G_UL_ON.Visible = true; break; case PATH_1_8G_UL_ON: pictureBox_PATH_1_8G_UL_OFF.Visible = true; break; case PATH_2_1G_DL_OFF: pictureBox_PATH_2_1G_DL_ON.Visible = true; break; case PATH_2_1G_DL_ON: pictureBox_PATH_2_1G_DL_OFF.Visible = true; break; case PATH_2_1G_UL_OFF: pictureBox_PATH_2_1G_UL_ON.Visible = true; break; case PATH_2_1G_UL_ON: pictureBox_PATH_2_1G_UL_OFF.Visible = true; break; case PATH_3_5G_DL_OFF: pictureBox_PATH_3_5G_DL_ON.Visible = true; break; case PATH_3_5G_DL_ON: pictureBox_PATH_3_5G_DL_OFF.Visible = true; break; case PATH_3_5G_UL_OFF: pictureBox_PATH_3_5G_UL_ON.Visible = true; break; case PATH_3_5G_UL_ON: pictureBox_PATH_3_5G_UL_OFF.Visible = true; break; case PATH_3_5G_H_OFF: pictureBox_PATH_3_5G_H_ON.Visible = true; break; case PATH_3_5G_H_ON: pictureBox_PATH_3_5G_H_OFF.Visible = true; break; case PATH_3_5G_L_OFF: pictureBox_PATH_3_5G_L_ON.Visible = true; break; case PATH_3_5G_L_ON: pictureBox_PATH_3_5G_L_OFF.Visible = true; break; case PLL_POWER_ONOFF_3_5G_H_ON: pictureBox_PLL_ON_OFF_3_5G_H_OFF.Visible = true; break; case PLL_POWER_ONOFF_3_5G_H_OFF: pictureBox_PLL_ON_OFF_3_5G_H_ON.Visible = true; break; case PLL_POWER_ONOFF_3_5G_L_ON: pictureBox_PLL_ON_OFF_3_5G_L_OFF.Visible = true; break; case PLL_POWER_ONOFF_3_5G_L_OFF: pictureBox_PLL_ON_OFF_3_5G_L_ON.Visible = true; break; } pictureBox.Visible = !pictureBox.Visible; bluecell_BootProtocol.Bluecell_BtnSet(this.serial, this); } private void button1_Click(object sender, EventArgs e) { Crc16 crc16 = new Crc16(); byte[] temp_buf = new byte[6]; temp_buf[0] = 0xbe; temp_buf[1] = 2; temp_buf[2] = 4; temp_buf[3] = 5; temp_buf[4] = crc16.STH30_CreateCrc(temp_buf, temp_buf[2]); temp_buf[5] = 0xeb; serial.Serial_DataSend(temp_buf, temp_buf[2] + 2); } private void Button_Set_Click(object sender, EventArgs e) { bluecell_BootProtocol.Bluecell_BtnSet(this.serial, this); } } }