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;
using System.Reflection;
using System.Globalization;
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);
System.Version assemblyVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
//DateTime buildDate = new DateTime(2000, 1, 1).AddDays(assemblyVersion.Build).AddSeconds(assemblyVersion.Revision * 2);
DateTime buildDate = getBuildDateTime();
this.label_Build.Text = buildDate.ToString("yyyy/MM/dd hh:mm:ss");
//this.label_Build.Text = "Ver." + Assembly.GetExecutingAssembly().GetName().Version.ToString();
}
///
/// Version Text로부터 Build된 일시를 구합니다.
///
///
/*public DateTime getBuildDateTime()
{
//1. Assembly.GetExecutingAssembly().FullName의 값은
//'ApplicationName, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'
//와 같다.
string strVersionText = Assembly.GetExecutingAssembly().FullName
.Split(',')[1]
.Trim()
.Split('=')[1];
//2. Version Text의 세번째 값(Build Number)은 2000년 1월 1일부터
//Build된 날짜까지의 총 일(Days) 수 이다.
int intDays = Convert.ToInt32(strVersionText.Split('.')[2]);
DateTime refDate = new DateTime(2000, 1, 1);
DateTime dtBuildDate = refDate.AddDays(intDays);
//3. Verion Text의 네번째 값(Revision NUmber)은 자정으로부터 Build된
//시간까지의 지나간 초(Second) 값 이다.
int intSeconds = Convert.ToInt32(strVersionText.Split('.')[3]);
intSeconds = intSeconds * 2;
dtBuildDate = dtBuildDate.AddSeconds(intSeconds);
//4. 시차조정
DaylightTime daylingTime = TimeZone.CurrentTimeZone
.GetDaylightChanges(dtBuildDate.Year);
if (TimeZone.IsDaylightSavingTime(dtBuildDate, daylingTime))
dtBuildDate = dtBuildDate.Add(daylingTime.Delta);
return dtBuildDate;
}*/
///
/// Assembly의 Build된 일시를 구합니다.
///
///
public DateTime getBuildDateTime()
{
Assembly assembly = Assembly.GetExecutingAssembly();
return System.IO.File.GetLastWriteTime(assembly.Location);
}
private void Firmware_Update_Click(object sender, EventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
//FileDownload file = new FileDownload();
if (setcheck_checkBox.Checked == true)
setcheck_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;
}
Int64 Timer_Cnt = 0;
Int32 ReqTimer_Cnt = 0;
public bool TX_RX_Light = false;
private void timer_Tick(object sender, EventArgs e)
{
Update_Serial update_Serial = null;
bool req_set = false;
if(update_Serial == null)
{
update_Serial = (Update_Serial)serial.FileDownloadClass_Get();
if (update_Serial == null)
req_set = true;
else if(update_Serial.Update_ready == false)
req_set = true;
}
if (req_set)
{
ReqTimer_Cnt++;
}
if (TX_RX_Light == true)
{
Timer_Cnt++;
}
if (Timer_Cnt < 1000)
{
if (this.pictureBox_G_TX.Visible == true)
{
TX_Light_OFF();
}
if (this.pictureBox_G_RX.Visible == true)
{
RX_Light_OFF();
}
Timer_Cnt = 0;
TX_RX_Light = false;
}
if(ReqTimer_Cnt > 6)
{
bluecell_BootProtocol.Bluecell_RF_Status_Req(serial);
ReqTimer_Cnt = 0;
}
}
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;
}
private delegate void StringSend(object label, String str);
public void ADC_Voltage_Value_Set(byte[] data)
{
int temp_val = 0;
double Volt_Calc_val = 3.3 / 4095;
double ret = 0;
try
{
//temp_val = (int)(data[(int)Bluecell_TypeIndex_t.DET_1_8G_DL_IN_H] << 8) | (data[(int)Bluecell_TypeIndex_t.DET_1_8G_DL_IN_L]);
//ret = temp_val * Volt_Calc_val;
//this.Invoke(new StringSend(Label_Text_Set), label1_8GHz_DL_IN, ret.ToString("N2") + "V");
//temp_val = (int)(data[(int)Bluecell_TypeIndex_t.DET_1_8G_DL_OUT_H] << 8) | (data[(int)Bluecell_TypeIndex_t.DET_1_8G_DL_OUT_L]);
//ret = temp_val * Volt_Calc_val;
//this.Invoke(new StringSend(Label_Text_Set), label1_8GHz_DL_OUT, ret.ToString("N2") + "V");
//temp_val = (int)(data[(int)Bluecell_TypeIndex_t.DET_1_8G_UL_IN_H] << 8) | (data[(int)Bluecell_TypeIndex_t.DET_1_8G_UL_IN_L]);
//ret = temp_val * Volt_Calc_val;
//this.Invoke(new StringSend(Label_Text_Set), label1_8GHz_UL_IN, ret.ToString("N2") + "V");
//temp_val = (int)(data[(int)Bluecell_TypeIndex_t.DET_1_8G_UL_OUT_H] << 8) | (data[(int)Bluecell_TypeIndex_t.DET_1_8G_UL_OUT_L]);
//ret = temp_val * Volt_Calc_val;
//this.Invoke(new StringSend(Label_Text_Set), label1_8GHz_UL_OUT, ret.ToString("N2") + "V");
//temp_val = (int)(data[(int)Bluecell_TypeIndex_t.DET_2_1G_DL_OUT_H] << 8) | (data[(int)Bluecell_TypeIndex_t.DET_2_1G_DL_IN_L]);
//ret = temp_val * Volt_Calc_val;
//this.Invoke(new StringSend(Label_Text_Set), label2_1GHz_DL_IN, ret.ToString("N2") + "V");
//temp_val = (int)(data[(int)Bluecell_TypeIndex_t.DET_2_1G_DL_OUT_H] << 8) | (data[(int)Bluecell_TypeIndex_t.DET_2_1G_DL_OUT_L]);
//ret = temp_val * Volt_Calc_val;
//this.Invoke(new StringSend(Label_Text_Set), label2_1GHz_DL_OUT, ret.ToString("N2") + "V");
//temp_val = (int)(data[(int)Bluecell_TypeIndex_t.DET_2_1G_UL_IN_H] << 8) | (data[(int)Bluecell_TypeIndex_t.DET_2_1G_UL_IN_L]);
//ret = temp_val * Volt_Calc_val;
//this.Invoke(new StringSend(Label_Text_Set), label2_1GHz_UL_IN, ret.ToString("N2") + "V");
//temp_val = (int)(data[(int)Bluecell_TypeIndex_t.DET_2_1G_UL_OUT_H] << 8) | (data[(int)Bluecell_TypeIndex_t.DET_2_1G_UL_OUT_L]);
//ret = temp_val * Volt_Calc_val;
//this.Invoke(new StringSend(Label_Text_Set), label2_1GHz_UL_OUT, ret.ToString("N2") + "V");
temp_val = (int)(data[(int)Bluecell_TypeIndex_t.DET_3_5G_DL_IN_H] << 8) | (data[(int)Bluecell_TypeIndex_t.DET_3_5G_DL_IN_L]);
ret = temp_val * Volt_Calc_val;
this.Invoke(new StringSend(Label_Text_Set), textBox3_5GHz_DL_IN, ret.ToString("N2") + "V");
temp_val = (int)(data[(int)Bluecell_TypeIndex_t.DET_3_5G_DL_OUT_H] << 8) | (data[(int)Bluecell_TypeIndex_t.DET_3_5G_DL_OUT_L]);
ret = temp_val * Volt_Calc_val;
this.Invoke(new StringSend(Label_Text_Set), textBox3_5GHz_DL_OUT, ret.ToString("N2") + "V");
temp_val = (int)(data[(int)Bluecell_TypeIndex_t.DET_3_5G_UL_IN_H] << 8) | (data[(int)Bluecell_TypeIndex_t.DET_3_5G_UL_IN_L]);
ret = temp_val * Volt_Calc_val;
this.Invoke(new StringSend(Label_Text_Set), textBox3_5GHz_UL_IN, ret.ToString("N2") + "V");
temp_val = (int)(data[(int)Bluecell_TypeIndex_t.DET_3_5G_UL_OUT_H] << 8) | (data[(int)Bluecell_TypeIndex_t.DET_3_5G_UL_OUT_L]);
ret = temp_val * Volt_Calc_val;
this.Invoke(new StringSend(Label_Text_Set), textBox3_5GHz_UL_OUT, ret.ToString("N2") + "V");
temp_val = (int)(data[(int)Bluecell_TypeIndex_t.RFU_TEMP_H] << 8) | (data[(int)Bluecell_TypeIndex_t.RFU_TEMP_L]);
ret = temp_val * Volt_Calc_val;
this.Invoke(new StringSend(Label_Text_Set), textBox_RFU_Temp, ret.ToString("N2") + "V");
temp_val = (int)(data[(int)Bluecell_TypeIndex_t._28V_DET_H] << 8) | (data[(int)Bluecell_TypeIndex_t._28V_DET_L]);
ret = temp_val * Volt_Calc_val;
this.Invoke(new StringSend(Label_Text_Set), textBox_28V_Det, ret.ToString("N2") + "V");
if (IamSetting_Get() == false)
{
temp_val = data[(int)Bluecell_TypeIndex_t.ATT_1_8G_DL1];
ret = bluecell_BootProtocol.Bluecell_Reverse_BDA4601_Calc(temp_val);
//this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_1_8G_DL1, ret.ToString());
temp_val = data[(int)Bluecell_TypeIndex_t.ATT_1_8G_DL2];
ret = bluecell_BootProtocol.Bluecell_Reverse_BDA4601_Calc(temp_val);
//this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_1_8G_DL2, ret.ToString());
temp_val = data[(int)Bluecell_TypeIndex_t.ATT_1_8G_UL1];
ret = bluecell_BootProtocol.Bluecell_Reverse_BDA4601_Calc(temp_val);
//this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_1_8G_UL1, ret.ToString());
temp_val = data[(int)Bluecell_TypeIndex_t.ATT_1_8G_UL2];
ret = bluecell_BootProtocol.Bluecell_Reverse_BDA4601_Calc(temp_val);
//this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_1_8G_UL2, ret.ToString());
temp_val = data[(int)Bluecell_TypeIndex_t.ATT_1_8G_UL3];
ret = bluecell_BootProtocol.Bluecell_Reverse_BDA4601_Calc(temp_val);
//this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_1_8G_UL3, ret.ToString());
temp_val = data[(int)Bluecell_TypeIndex_t.ATT_1_8G_UL4];
ret = bluecell_BootProtocol.Bluecell_Reverse_BDA4601_Calc(temp_val);
//this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_1_8G_UL4, ret.ToString());
temp_val = data[(int)Bluecell_TypeIndex_t.ATT_2_1G_DL1];
ret = bluecell_BootProtocol.Bluecell_Reverse_BDA4601_Calc(temp_val);
//this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_2_1G_DL1, ret.ToString());
temp_val = data[(int)Bluecell_TypeIndex_t.ATT_2_1G_DL2];
ret = bluecell_BootProtocol.Bluecell_Reverse_BDA4601_Calc(temp_val);
//this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_2_1G_DL2, ret.ToString());
temp_val = data[(int)Bluecell_TypeIndex_t.ATT_2_1G_UL1];
ret = bluecell_BootProtocol.Bluecell_Reverse_BDA4601_Calc(temp_val);
//this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_2_1G_UL1, ret.ToString());
temp_val = data[(int)Bluecell_TypeIndex_t.ATT_2_1G_UL2];
ret = bluecell_BootProtocol.Bluecell_Reverse_BDA4601_Calc(temp_val);
//this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_2_1G_UL2, ret.ToString());
temp_val = data[(int)Bluecell_TypeIndex_t.ATT_2_1G_UL3];
ret = bluecell_BootProtocol.Bluecell_Reverse_BDA4601_Calc(temp_val);
//this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_2_1G_UL3, ret.ToString());
temp_val = data[(int)Bluecell_TypeIndex_t.ATT_2_1G_UL4];
ret = bluecell_BootProtocol.Bluecell_Reverse_BDA4601_Calc(temp_val);
// this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_2_1G_UL4, ret.ToString());
temp_val = data[(int)Bluecell_TypeIndex_t.ATT_3_5G_LOW1];
ret = bluecell_BootProtocol.Bluecell_ReversePE43711_Calc(temp_val);
this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_3_5G_LOW1, ret.ToString());
temp_val = data[(int)Bluecell_TypeIndex_t.ATT_3_5G_HIGH1];
ret = bluecell_BootProtocol.Bluecell_ReversePE43711_Calc(temp_val);
this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_3_5G_HIGH1, ret.ToString());
temp_val = data[(int)Bluecell_TypeIndex_t.ATT_3_5G_COM1];
ret = bluecell_BootProtocol.Bluecell_ReversePE43711_Calc(temp_val);
this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_3_5G_COM1, ret.ToString());
temp_val = data[(int)Bluecell_TypeIndex_t.ATT_3_5G_LOW2];
ret = bluecell_BootProtocol.Bluecell_ReversePE43711_Calc(temp_val);
this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_3_5G_LOW2, ret.ToString());
temp_val = data[(int)Bluecell_TypeIndex_t.ATT_3_5G_HIGH2];
ret = bluecell_BootProtocol.Bluecell_ReversePE43711_Calc(temp_val);
this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_3_5G_HIGH2, ret.ToString());
temp_val = data[(int)Bluecell_TypeIndex_t.ATT_3_5G_COM2];
ret = bluecell_BootProtocol.Bluecell_ReversePE43711_Calc(temp_val);
this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_3_5G_COM2, ret.ToString());
temp_val = data[(int)Bluecell_TypeIndex_t.PLL_1_8G_DL_H] << 8;
ret = ((double)(temp_val | data[(int)Bluecell_TypeIndex_t.PLL_1_8G_DL_L]) / 10);
if(ret != 0)
ret = ret + 215;
//this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_PLL_1_8G_DL, ret.ToString());
temp_val = data[(int)Bluecell_TypeIndex_t.PLL_1_8G_UL_H] << 8;
ret = ((double)(temp_val | data[(int)Bluecell_TypeIndex_t.PLL_1_8G_UL_L]) / 10);
if (ret != 0)
ret = ret + 276.5;
//this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_PLL_1_8G_UL, ret.ToString());
temp_val = data[(int)Bluecell_TypeIndex_t.PLL_2_1G_DL_H] << 8;
ret = ((temp_val | data[(int)Bluecell_TypeIndex_t.PLL_2_1G_DL_L]) );
if (ret != 0)
// ret = (ret + 1536)/10;
//this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_PLL_2_1G_DL, ret.ToString());
temp_val = data[(int)Bluecell_TypeIndex_t.PLL_2_1G_UL_H] << 8;
ret = ((double)(temp_val | data[(int)Bluecell_TypeIndex_t.PLL_2_1G_UL_L]) / 10);
if (ret != 0)
ret = ret - 337.9;
//this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_PLL_2_1G_UL, ret.ToString());
temp_val = data[(int)Bluecell_TypeIndex_t.PLL_3_5G_LOW_H] << 16;
temp_val = temp_val | data[(int)Bluecell_TypeIndex_t.PLL_3_5G_LOW_M] << 8;
ret = ((double)(temp_val | data[(int)Bluecell_TypeIndex_t.PLL_3_5G_LOW_L]) / 100);
this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_PLL_3_5G_LOW, ret.ToString());
temp_val = data[(int)Bluecell_TypeIndex_t.PLL_3_5G_HIGH_H] << 16;
temp_val = temp_val | data[(int)Bluecell_TypeIndex_t.PLL_3_5G_HIGH_M] << 8;
ret = ((double)(temp_val | data[(int)Bluecell_TypeIndex_t.PLL_3_5G_HIGH_L]) / 100);
this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_PLL_3_5G_HIGH, ret.ToString());
/***********************DAC A Sector**********************************/
temp_val = data[(int)Bluecell_TypeIndex_t.DAC_VCtrl_A_H] << 8;
temp_val = ((temp_val | data[(int)Bluecell_TypeIndex_t.DAC_VCtrl_A_L]) );
ret = (temp_val & 0x0FFF) * 4;
ret = ret / 4095;
ret = Math.Round(Convert.ToDouble(ret), 2);
this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_DAC_VoltCtrl_A, ret.ToString());
/***********************DAC B Sector**********************************/
temp_val = data[(int)Bluecell_TypeIndex_t.DAC_VCtrl_B_H] << 8;
temp_val = ((temp_val | data[(int)Bluecell_TypeIndex_t.DAC_VCtrl_B_L]) );
ret = (temp_val & 0x0FFF) * 4;
ret = ret / 4095;
ret = Math.Round(Convert.ToDouble(ret), 2);
this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_DAC_VoltCtrl_B, ret.ToString());
/***********************DAC C Sector**********************************/
temp_val = data[(int)Bluecell_TypeIndex_t.DAC_VCtrl_C_H] << 8;
temp_val = ((temp_val | data[(int)Bluecell_TypeIndex_t.DAC_VCtrl_C_L]) );
ret = (temp_val & 0x0FFF) * 4;
ret = ret / 4095;
ret = Math.Round(Convert.ToDouble(ret ), 2);
this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_DAC_VoltCtrl_C, ret.ToString());
/***********************DAC D Sector**********************************/
temp_val = data[(int)Bluecell_TypeIndex_t.DAC_VCtrl_D_H] << 8;
temp_val = ((temp_val | data[(int)Bluecell_TypeIndex_t.DAC_VCtrl_D_L]) );
ret = (temp_val & 0x0FFF) * 4;
ret = ret / 4095;
ret = Math.Round(Convert.ToDouble(ret), 2);
this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_DAC_VoltCtrl_D, ret.ToString());
/***********************DAC E Sector**********************************/
temp_val = data[(int)Bluecell_TypeIndex_t.DAC_VCtrl_E_H] << 8;
temp_val = ((temp_val | data[(int)Bluecell_TypeIndex_t.DAC_VCtrl_E_L]) );
ret = (temp_val & 0x0FFF) * 4;
ret = ret / 4095;
ret = Math.Round(Convert.ToDouble(ret), 2);
this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_DAC_VoltCtrl_E, ret.ToString());
/***********************DAC F Sector**********************************/
temp_val = data[(int)Bluecell_TypeIndex_t.DAC_VCtrl_F_H] << 8;
temp_val = ((temp_val | data[(int)Bluecell_TypeIndex_t.DAC_VCtrl_F_L]) );
ret = (temp_val & 0x0FFF) * 4;
ret = ret / 4095;
ret = Math.Round(Convert.ToDouble(ret), 2);
this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_DAC_VoltCtrl_F, ret.ToString());
/***********************DAC G Sector**********************************/
temp_val = data[(int)Bluecell_TypeIndex_t.DAC_VCtrl_G_H] << 8;
temp_val = ((temp_val | data[(int)Bluecell_TypeIndex_t.DAC_VCtrl_G_L]) );
ret = (temp_val & 0x0FFF) * 4;
ret = ret / 4095;
ret = Math.Round(Convert.ToDouble(ret), 2);
this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_DAC_VoltCtrl_G, ret.ToString());
/***********************DAC H Sector**********************************/
temp_val = data[(int)Bluecell_TypeIndex_t.DAC_VCtrl_H_H] << 8;
temp_val = ((temp_val | data[(int)Bluecell_TypeIndex_t.DAC_VCtrl_H_L]) );
ret = (temp_val & 0x0FFF) * 4;
ret = ret / 4095;
ret = Math.Round(Convert.ToDouble(ret), 2);
this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_DAC_VoltCtrl_H, ret.ToString());
PictureBox pic_on;
PictureBox pic_off;
//pic_on = pictureBox_PATH_1_8G_DL_ON;
//pic_off = pictureBox_PATH_1_8G_DL_OFF;
// if (data[(int)Bluecell_TypeIndex_t.PATH_EN_1_8G_DL] > 0)
// {
// this.Invoke(new PictureBoxSend(PictureBox_On_OFF_Set), pic_on, pic_off, true);
// }
// else
// {
// this.Invoke(new PictureBoxSend(PictureBox_On_OFF_Set), pic_on, pic_off, false);
// }
// //pic_on = pictureBox_PATH_1_8G_UL_ON;
// //pic_off = pictureBox_PATH_1_8G_UL_OFF;
// if (data[(int)Bluecell_TypeIndex_t.PATH_EN_1_8G_UL] > 0)
// {
// this.Invoke(new PictureBoxSend(PictureBox_On_OFF_Set), pic_on, pic_off, true);
// }
// else
// {
// this.Invoke(new PictureBoxSend(PictureBox_On_OFF_Set), pic_on, pic_off, false);
// }
// //pic_on = pictureBox_PATH_2_1G_DL_ON;
// //pic_off = pictureBox_PATH_2_1G_DL_OFF;
// if (data[(int)Bluecell_TypeIndex_t.PATH_EN_2_1G_DL] > 0)
// {
// this.Invoke(new PictureBoxSend(PictureBox_On_OFF_Set), pic_on, pic_off, true);
// }
// else
// {
// this.Invoke(new PictureBoxSend(PictureBox_On_OFF_Set), pic_on, pic_off, false);
// }
// // pic_on = pictureBox_PATH_2_1G_UL_ON;
//// pic_off = pictureBox_PATH_2_1G_UL_OFF;
// if (data[(int)Bluecell_TypeIndex_t.PATH_EN_2_1G_UL] > 0)
// {
// this.Invoke(new PictureBoxSend(PictureBox_On_OFF_Set), pic_on, pic_off, true);
// }
// else
// {
// this.Invoke(new PictureBoxSend(PictureBox_On_OFF_Set), pic_on, pic_off, false);
// }
pic_on = pictureBox_PATH_3_5G_DL_ON;
pic_off = pictureBox_PATH_3_5G_DL_OFF;
if (data[(int)Bluecell_TypeIndex_t.PATH_EN_3_5G_DL] > 0)
{
this.Invoke(new PictureBoxSend(PictureBox_On_OFF_Set), pic_on, pic_off, true);
}
else
{
this.Invoke(new PictureBoxSend(PictureBox_On_OFF_Set), pic_on, pic_off, false);
}
pic_on = pictureBox_PATH_3_5G_UL_ON;
pic_off = pictureBox_PATH_3_5G_UL_OFF;
if (data[(int)Bluecell_TypeIndex_t.PATH_EN_3_5G_UL] > 0)
{
this.Invoke(new PictureBoxSend(PictureBox_On_OFF_Set), pic_on, pic_off, true);
}
else
{
this.Invoke(new PictureBoxSend(PictureBox_On_OFF_Set), pic_on, pic_off, false);
}
pic_on = pictureBox_PATH_3_5G_H_ON;
pic_off = pictureBox_PATH_3_5G_H_OFF;
if (data[(int)Bluecell_TypeIndex_t.PATH_EN_3_5G_H] > 0)
{
this.Invoke(new PictureBoxSend(PictureBox_On_OFF_Set), pic_on, pic_off, true);
}
else
{
this.Invoke(new PictureBoxSend(PictureBox_On_OFF_Set), pic_on, pic_off, false);
}
pic_on = pictureBox_PATH_3_5G_L_ON;
pic_off = pictureBox_PATH_3_5G_L_OFF;
if (data[(int)Bluecell_TypeIndex_t.PATH_EN_3_5G_L] > 0)
{
this.Invoke(new PictureBoxSend(PictureBox_On_OFF_Set), pic_on, pic_off, true);
}
else
{
this.Invoke(new PictureBoxSend(PictureBox_On_OFF_Set), pic_on, pic_off, false);
}
// pic_on = pictureBox_PLL_ON_OFF_3_5G_H_ON;
// pic_off = pictureBox_PLL_ON_OFF_3_5G_H_OFF;
if (data[(int)Bluecell_TypeIndex_t.PLL_ON_OFF_3_5G_H] > 0)
{
this.Invoke(new PictureBoxSend(PictureBox_On_OFF_Set), pic_on, pic_off, true);
}
else
{
this.Invoke(new PictureBoxSend(PictureBox_On_OFF_Set), pic_on, pic_off, false);
}
// pic_on = pictureBox_PLL_ON_OFF_3_5G_L_ON;
// pic_off = pictureBox_PLL_ON_OFF_3_5G_L_OFF;
if (data[(int)Bluecell_TypeIndex_t.PLL_ON_OFF_3_5G_L] > 0)
{
this.Invoke(new PictureBoxSend(PictureBox_On_OFF_Set), pic_on, pic_off, true);
}
else
{
this.Invoke(new PictureBoxSend(PictureBox_On_OFF_Set), pic_on, pic_off, false);
}
if (data[(int)Bluecell_TypeIndex_t.T_SYNC_DL] > 0)
{
TDD_T_SYNC_Get();
//this.Invoke(new PictureBoxSend(PictureBox_On_OFF_Set), pic_on, pic_off, true);
}
else
{
//this.Invoke(new PictureBoxSend(PictureBox_On_OFF_Set), pic_on, pic_off, false);
}
// this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_1_8G_DL2, data[(int)Bluecell_TypeIndex_t.ATT_1_8G_DL2]);
}
}
catch { /*MessageBox.Show("What is this?");*/ }
}
private delegate void PictureBoxSend(object picon, object picoff, bool set);
private void PictureBox_On_OFF_Set(object pic_on,object pic_off,bool set)
{
PictureBox picture_on = (PictureBox)pic_on;
PictureBox picture_off = (PictureBox)pic_off;
picture_on.Visible = set;
picture_off.Visible =!set;
}
public void ReSetting_Values(byte[] temp_buf)
{
//this.numericUpDown_ATT_1_8G_DL1.Text = temp_buf[(byte)Bluecell_TypeIndex_t.ATT_1_8G_DL1].ToString();
}
private void Label_Text_Set(object label, String str)
{
TextBox Temp_label = (TextBox)label;
Temp_label.Text = str;
}
private void numeric_Text_Set(object numeric, String str)
{
NumericUpDown Temp_numeric = (NumericUpDown)numeric;
Temp_numeric.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;
}
private void TDD_T_SYNC_Get()
{
}
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)
{
/*this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_1_8G_DL1, "0.0");
this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_1_8G_DL2, "0.0");
this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_1_8G_UL1, "0.0");
this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_1_8G_UL2, "0.0");
this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_1_8G_UL3, "0.0");
this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_1_8G_UL4, "0.0");
this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_2_1G_DL1, "0.0");
this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_2_1G_DL2, "0.0");
this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_2_1G_UL1, "0.0");
this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_2_1G_UL2, "0.0");
this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_2_1G_UL3, "0.0");
this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_2_1G_UL4, "0.0");*/
this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_3_5G_LOW1, "0.0");
this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_3_5G_HIGH1, "0.0");
this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_3_5G_COM1, "0.0");
this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_3_5G_LOW2, "0.0");
this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_3_5G_HIGH2, "0.0");
this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_3_5G_COM2, "0.0");
Button_Set_Click(sender, 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);
}
private bool IamSetting = false;
private void Activi_Change__Setting(object sender, EventArgs e)
{
IamSetting = true;
}
private void Activi_Change__SettingComplete(object sender, EventArgs e)
{
IamSetting = false;
}
public bool IamSetting_Get()
{
return IamSetting;
}
private void Cusor_DeFocus(object sender, EventArgs e)
{
GroupBox grp = (GroupBox)sender;
grp.Focus();
}
private void button_Save_Click(object sender, EventArgs e)
{
Crc16 crc16 = new Crc16();
DialogResult ret;
byte[] temp_buf = new byte[6];
ret = MessageBox.Show("저장 하시겠습니까?",
"Setting",
MessageBoxButtons.YesNo,
MessageBoxIcon.Question,
MessageBoxDefaultButton.Button1,
MessageBoxOptions.DefaultDesktopOnly);
if (ret == DialogResult.Yes)
{
temp_buf[0] = 0xbe;
temp_buf[1] = 3;
temp_buf[2] = 3;
temp_buf[3] = 4;
temp_buf[4] = crc16.STH30_CreateCrc(temp_buf, temp_buf[2]);
temp_buf[5] = 0xeb;
serial.Serial_DataSend(temp_buf, temp_buf[2] + 3);
}
else
{
this.BringToFront();
}
}
public void Message_Box_Open()
{
//blue_MessageBox blue_MessageBox = new Blue_MessageBox();
//MessageBox.Show("Setting OK");
if(setcheck_checkBox.Checked == true)
MessageBox.Show("OK",
"Setting",
MessageBoxButtons.OK,
MessageBoxIcon.None,
MessageBoxDefaultButton.Button1,
MessageBoxOptions.DefaultDesktopOnly);
}
public void Message_Box_Error_Open(byte[] data)
{
byte type = data[(byte)Bluecell_TypeIndex_t.BLUE_CRCINDEX + 1];
string str = "";
if (type == 0)
str = "PLL 1.8 DL Error";
else if (type == 1)
str = "PLL 1.8 UL Error";
else if (type == 2)
str = "PLL 2.1 DL Error";
else if (type == 3)
str = "PLL 2.1 UL Error";
else
str = "Error!!!";
//blue_MessageBox blue_MessageBox = new Blue_MessageBox();
//MessageBox.Show("Setting OK");
if (setcheck_checkBox.Checked == true)
MessageBox.Show(str,
"Setting",
MessageBoxButtons.OK,
MessageBoxIcon.Error,
MessageBoxDefaultButton.Button1,
MessageBoxOptions.DefaultDesktopOnly);
}
private void comboBox_Port_MouseDown(object sender, MouseEventArgs e)
{
// serial.SetPortNameValues(comboBox_Port);
}
}
}