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;
using System.IO;
using System.Threading;
using System.Timers;
namespace EDP_TOOL
{
public partial class Form1 : Form
{
struct PAT_ADDRESS
{
public string name;
};
struct EDP_ADDRESS
{
public string name;
public string HAdr;
public string VAdr;
public string HFP;
public string HBP;
public string VFP;
public string VBP;
public string HSYNC;
public string VSYNC;
public string Pixel;
public string Refresh;
public string VDD;
public string MAX_VDD;
public string MIN_VDD;
public string MAX_IDD;
public string MAX_IDD_CT;
public string MIN_IDD_CT;
public string VDD_PowerOnTime;
public string VDD_PowerOffTime;
public string VBL;
public string MAX_VBL;
public string MIN_VBL;
public string MAX_IBL;
public string MAX_IBL_CT;
public string MIN_IBL_CT;
public string VBL_PowerOnTime;
public string VBL_PowerOffTime;
};
struct PAT_ADDRESS_BUF
{
public PAT_ADDRESS[] Pat_Adree;
public byte Pat_length;
public byte Pat_Pos;
};
struct EDP_ADDRESS_BUF
{
public EDP_ADDRESS[] Edp_Adree;
public byte Edp_length;
public byte Edp_Pos;
};
EDP_ADDRESS_BUF EdpAdressInit;
PAT_ADDRESS_BUF PatAdressInit;
public byte[] uart_rec_buf;
public int uart_rec_length;
public bool receflag;
public byte timeout;
public int Power_Type_VDD_VBL;
public Form1()
{
InitializeComponent();
//PAT地址成员变量初始化 最多存储30字Pat类型
PatAdressInit.Pat_length = 0;
PatAdressInit.Pat_Pos = 0;
PatAdressInit.Pat_Adree = new PAT_ADDRESS[100];
if (File.Exists("./Configure/Pat"))
{
}
for (int i = 0; i < 30; i++)
{
comboBox11.Items.Add("COM" + (i + 1).ToString());
}
comboBox11.SelectedIndex = 2; //默认串口号
comboBox2.Items.Add("D0");
comboBox2.Items.Add("D1");
comboBox2.Items.Add("D2");
comboBox2.Items.Add("D3");
comboBox2.Items.Add("A0");
comboBox2.SelectedIndex = 0;
for (int i = 0; i <= 255; i++)
{
comboBox3.Items.Add(i.ToString());
}
//comboBox5.Items.Add("255");
comboBox3.SelectedIndex = 6;
for (int i = 0; i <= 100; i++)
{
comboBox4.Items.Add(i.ToString());
}
comboBox4.SelectedIndex = 6;
for (int i = 0; i <= 100; i++)
{
comboBox5.Items.Add(i.ToString());
}
comboBox5.SelectedIndex = 6;
for (int i = 1; i <= 100; i++)
{
comboBox7.Items.Add(i.ToString());
}
comboBox7.SelectedIndex = 6;
for (int i = 1; i <= 100; i++)
{
comboBox8.Items.Add(i.ToString());
}
comboBox8.SelectedIndex = 6;
comboBox9.Items.Add("Close");
comboBox9.Items.Add("Open");
comboBox9.SelectedIndex = 0;
comboBox6.Items.Add("全屏");
comboBox6.Items.Add("1:1");
comboBox6.Items.Add("16:9");
comboBox6.Items.Add("4:3");
comboBox6.SelectedIndex = 0;
// 方法一:使用Thread类
ThreadStart ThreadStart = new ThreadStart(Calculate);//通过ThreadStart委托告诉子线程执行什么方法
Thread thread = new Thread(ThreadStart);
thread.Start();//启动新线程
uart_rec_buf = new byte[50];
uart_rec_length = 0;
timer1.Interval = 500;
timer1.Start();
receflag = false;
timeout = 0;
comboBox1.Items.Add("请选择");
comboBox1.Items.Add("VDD");
comboBox1.Items.Add("VBL");
comboBox1.SelectedIndex = 0;
//IIC地址成员变量初始化 最多存储30字iic类型
EdpAdressInit.Edp_length = 0;
EdpAdressInit.Edp_Pos = 0;
EdpAdressInit.Edp_Adree = new EDP_ADDRESS[50];
Power_Type_VDD_VBL = 0;
//判断文件是否存在
if (File.Exists("./Configure/LCDCFG.ini"))
{
StreamReader sr = new StreamReader("./Configure/LCDCFG.ini");
string line;
string[] splistring = new string[3];
while (true)
{
line = sr.ReadLine();
if ("" == line)
{
line = sr.ReadLine();
if ("" == line)
{
break;
}
}
char[] namesep = { '[', ']' };
splistring = line.Split(namesep);
EdpAdressInit.Edp_Adree[EdpAdressInit.Edp_Pos].name = splistring[1];
line = sr.ReadLine();
char[] namesep1 = { '"', '"' };
splistring = line.Split(namesep1);
EdpAdressInit.Edp_Adree[EdpAdressInit.Edp_Pos].HAdr = splistring[1];
line = sr.ReadLine();
char[] typesep = { '"', '"' };
splistring = line.Split(typesep);
EdpAdressInit.Edp_Adree[EdpAdressInit.Edp_Pos].VAdr = splistring[1];
line = sr.ReadLine();
char[] addpinsep = { '"', '"' };
splistring = line.Split(addpinsep);
EdpAdressInit.Edp_Adree[EdpAdressInit.Edp_Pos].HFP = splistring[1];
line = sr.ReadLine();
char[] addpinsep1 = { '"', '"' };
splistring = line.Split(addpinsep1);
EdpAdressInit.Edp_Adree[EdpAdressInit.Edp_Pos].HBP = splistring[1];
line = sr.ReadLine();
char[] macesep = { '"', '"' };
splistring = line.Split(macesep);
EdpAdressInit.Edp_Adree[EdpAdressInit.Edp_Pos].VFP = splistring[1];
line = sr.ReadLine();
char[] macesep1 = { '"', '"' };
splistring = line.Split(macesep1);
EdpAdressInit.Edp_Adree[EdpAdressInit.Edp_Pos].VBP = splistring[1];
line = sr.ReadLine();
char[] hdcp1_4sep = { '"', '"' };
splistring = line.Split(hdcp1_4sep);
EdpAdressInit.Edp_Adree[EdpAdressInit.Edp_Pos].HSYNC = splistring[1];
line = sr.ReadLine();
char[] hdcp2_0sep = { '"', '"' };
splistring = line.Split(hdcp2_0sep);
EdpAdressInit.Edp_Adree[EdpAdressInit.Edp_Pos].VSYNC = splistring[1];
line = sr.ReadLine();
char[] hdcp2_2sep = { '"', '"' };
splistring = line.Split(hdcp2_2sep);
EdpAdressInit.Edp_Adree[EdpAdressInit.Edp_Pos].Pixel = splistring[1];
line = sr.ReadLine();
char[] dtvsep = { '"', '"' };
splistring = line.Split(dtvsep);
EdpAdressInit.Edp_Adree[EdpAdressInit.Edp_Pos].Refresh = splistring[1];
line = sr.ReadLine();
char[] dtvsep1 = { '"', '"' };
splistring = line.Split(dtvsep1);
EdpAdressInit.Edp_Adree[EdpAdressInit.Edp_Pos].VDD = splistring[1];
line = sr.ReadLine();
char[] dtvsep2 = { '"', '"' };
splistring = line.Split(dtvsep2);
EdpAdressInit.Edp_Adree[EdpAdressInit.Edp_Pos].MAX_VDD = splistring[1];
line = sr.ReadLine();
char[] dtvsep3 = { '"', '"' };
splistring = line.Split(dtvsep3);
EdpAdressInit.Edp_Adree[EdpAdressInit.Edp_Pos].MIN_VDD = splistring[1];
line = sr.ReadLine();
char[] dtvsep4 = { '"', '"' };
splistring = line.Split(dtvsep4);
EdpAdressInit.Edp_Adree[EdpAdressInit.Edp_Pos].MAX_IDD = splistring[1];
line = sr.ReadLine();
char[] dtvsep5 = { '"', '"' };
splistring = line.Split(dtvsep5);
EdpAdressInit.Edp_Adree[EdpAdressInit.Edp_Pos].MAX_IDD_CT = splistring[1];
line = sr.ReadLine();
char[] dtvsep6 = { '"', '"' };
splistring = line.Split(dtvsep6);
EdpAdressInit.Edp_Adree[EdpAdressInit.Edp_Pos].MIN_IDD_CT = splistring[1];
line = sr.ReadLine();
char[] dtvsep7 = { '"', '"' };
splistring = line.Split(dtvsep7);
EdpAdressInit.Edp_Adree[EdpAdressInit.Edp_Pos].VDD_PowerOnTime = splistring[1];
line = sr.ReadLine();
char[] dtvsep8 = { '"', '"' };
splistring = line.Split(dtvsep8);
EdpAdressInit.Edp_Adree[EdpAdressInit.Edp_Pos].VDD_PowerOffTime = splistring[1];
line = sr.ReadLine();
char[] dtvsep9 = { '"', '"' };
splistring = line.Split(dtvsep9);
EdpAdressInit.Edp_Adree[EdpAdressInit.Edp_Pos].VBL = splistring[1];
line = sr.ReadLine();
char[] dtvsep10 = { '"', '"' };
splistring = line.Split(dtvsep10);
EdpAdressInit.Edp_Adree[EdpAdressInit.Edp_Pos].MAX_VBL = splistring[1];
line = sr.ReadLine();
char[] dtvsep11 = { '"', '"' };
splistring = line.Split(dtvsep11);
EdpAdressInit.Edp_Adree[EdpAdressInit.Edp_Pos].MIN_VBL = splistring[1];
line = sr.ReadLine();
char[] dtvsep12 = { '"', '"' };
splistring = line.Split(dtvsep12);
EdpAdressInit.Edp_Adree[EdpAdressInit.Edp_Pos].MAX_IBL = splistring[1];
line = sr.ReadLine();
char[] dtvsep13 = { '"', '"' };
splistring = line.Split(dtvsep13);
EdpAdressInit.Edp_Adree[EdpAdressInit.Edp_Pos].MAX_IBL_CT = splistring[1];
line = sr.ReadLine();
char[] dtvsep14 = { '"', '"' };
splistring = line.Split(dtvsep14);
EdpAdressInit.Edp_Adree[EdpAdressInit.Edp_Pos].MIN_IBL_CT = splistring[1];
line = sr.ReadLine();
char[] dtvsep15 = { '"', '"' };
splistring = line.Split(dtvsep15);
EdpAdressInit.Edp_Adree[EdpAdressInit.Edp_Pos].VBL_PowerOnTime = splistring[1];
line = sr.ReadLine();
char[] dtvsep16 = { '"', '"' };
splistring = line.Split(dtvsep16);
EdpAdressInit.Edp_Adree[EdpAdressInit.Edp_Pos].VBL_PowerOffTime = splistring[1];
EdpAdressInit.Edp_Pos++;
EdpAdressInit.Edp_length++;
if (EdpAdressInit.Edp_Pos >= 50) //超过存储的最长
{
EdpAdressInit.Edp_Pos = 49;
EdpAdressInit.Edp_length = 50;
}
}
comboBox12.Items.Clear();
comboBox12.Items.Add("请选择");
for (int i = 0; i < EdpAdressInit.Edp_length; i++)
{
comboBox12.Items.Add(EdpAdressInit.Edp_Adree[i].name);
}
comboBox12.SelectedIndex = 0;
}
else
{
MessageBox.Show("LCDCFG.ini 文件不存在");
}
}
public void recedisplay()
{
label33.Text = "";
for (byte i = 0; i < uart_rec_length; i++)
{
if ((i % 8 == 0) && (i != 0))
label33.Text += Convert.ToString(uart_rec_buf[i] / 16, 16) + Convert.ToString(uart_rec_buf[i] % 16, 16) + "\r\n";
else
label33.Text += Convert.ToString(uart_rec_buf[i] / 16, 16) + Convert.ToString(uart_rec_buf[i] % 16, 16) + " ";
}
}
public void Calculate()
{
while (true)
{
if (serialPort1.IsOpen)
{
try
{
serialPort1.Read(uart_rec_buf, uart_rec_length, 1);
if (receflag == false)
receflag = true;
timeout = 0;
}
catch
{
}
uart_rec_length++;
}
else
{
uart_rec_length = 0;
}
}
}
public class CRC
{
public static byte[] CRC16(byte[] data, int len)
{
// int len = data.Length;
if (len > 0)
{
ushort crc = 0xFFFF;
for (int i = 0; i < len; i++)
{
crc = (ushort)(crc ^ (data[i]));
for (int j = 0; j < 8; j++)
{
crc = (crc & 1) != 0 ? (ushort)((crc >> 1) ^ 0xA001) : (ushort)(crc >> 1);
}
}
byte hi = (byte)((crc & 0xFF00) >> 8); //高位置
byte lo = (byte)(crc & 0x00FF); //低位置
return new byte[] { hi, lo };
}
return new byte[] { 0, 0 };
}
public static UInt16 calc_crc16(UInt16 crc, byte ch)
{
UInt16 poly = 0x8408;
UInt16 v;
Int16 j;
v = (UInt16)((crc ^ ch) & 0xFF);
for (j = 0; j<8;j++)
{
v = (UInt16)( ( (v & 1)>0) ? ((v >> 1) ^ poly) : (v >> 1));
}
crc = (UInt16)((crc >> 8) ^ v);
return crc;
}
public static byte[] Crccheck(UInt16 crc, byte[] u8Buff, byte length)
{
byte i;
for (i = 0; i < (length); i++)
{
crc = calc_crc16(crc, u8Buff[i]);//No Include Header 0xff
}
return new byte[] { Convert.ToByte((crc >> 8) & 0xff), Convert.ToByte((crc >> 0) & 0xff) };
}
}
private void Send_Tx_databuf(byte[] buf, byte length )
{
label27.Text = "";
for (byte i = 0;i<length; i++)
{
serialPort1.Write(buf, i, 1);
if ((i % 8 == 0) && (i != 0))
label27.Text += Convert.ToString(buf[i] / 16, 16) + Convert.ToString(buf[i] % 16, 16) +"\r\n";
else
label27.Text += Convert.ToString(buf[i] / 16,16) + Convert.ToString(buf[i] % 16, 16) + " ";
}
}
private void textBox10_TextChanged(object sender, EventArgs e)
{
}
private void textBox14_TextChanged(object sender, EventArgs e)
{
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void Button9_Click(object sender, EventArgs e)
{
if (button9.Text.Equals("打开"))
{
serialPort1.PortName = comboBox11.SelectedItem.ToString();//串口号
serialPort1.BaudRate = Convert.ToInt32("115200");//波特率
serialPort1.StopBits = System.IO.Ports.StopBits.One; //停止位
serialPort1.Parity = System.IO.Ports.Parity.None; //校验位
serialPort1.DataBits = 8;//数据位
try
{
serialPort1.Open();
button9.Text = "断开";
pictureBox1.Image = Image.FromFile("UartCon.jpg");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "未能成功开启串口", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}
else if (button9.Text.Equals("断开"))
{
try
{
serialPort1.Close();
button9.Text = "打开";
pictureBox1.Image = Image.FromFile("UartDis.jpg");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "未能成功关闭串口", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}
}
private void Button2_Click(object sender, EventArgs e)
{
if (serialPort1.IsOpen)
{
//发送PAT
byte[] senddata = { 0xA5, 0xEA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00,0x00};
senddata[9] = Convert.ToByte(comboBox2.SelectedIndex + 1);
senddata[5] = 12-8;
byte[] crc = new byte[2];
crc = CRC.Crccheck(0,senddata, 10);
senddata[10] = crc[0];
senddata[11] = crc[1];
Send_Tx_databuf(senddata, 12);
}
else
{
MessageBox.Show("串口未打开");
}
}
private void Timer1_Tick(object sender, EventArgs e)
{
if(receflag == true)
{
timeout++;
if(timeout >= 2)//接收结束或者超时
{
recedisplay();
uart_rec_length = 0;
receflag = false;
timeout = 0;
}
}
}
private void Button3_Click(object sender, EventArgs e)
{
if (serialPort1.IsOpen)
{
//发送PAT
byte[] senddata = { 0xA5, 0xEA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00 };
senddata[9] = Convert.ToByte(comboBox3.SelectedItem.ToString());
senddata[5] = 12-8;
byte[] crc = new byte[2];
crc = CRC.Crccheck(0,senddata, 10);
senddata[10] = crc[0];
senddata[11] = crc[1];
Send_Tx_databuf(senddata, 12);
}
else
{
MessageBox.Show("串口未打开");
}
}
private void Button4_Click(object sender, EventArgs e)
{
if (serialPort1.IsOpen)
{
//发送PAT
byte[] senddata = { 0xA5, 0xEA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x52, 0x00, 0x00, 0x00 };
senddata[9] = Convert.ToByte(comboBox4.SelectedItem.ToString());
senddata[5] = 12-8;
byte[] crc = new byte[2];
crc = CRC.Crccheck(0,senddata, 10);
senddata[10] = crc[0];
senddata[11] = crc[1];
Send_Tx_databuf(senddata, 12);
}
else
{
MessageBox.Show("串口未打开");
}
}
private void Button5_Click(object sender, EventArgs e)
{
if (serialPort1.IsOpen)
{
//发送PAT
byte[] senddata = { 0xA5, 0xEA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x51, 0x00, 0x00, 0x00 };
senddata[9] = Convert.ToByte(comboBox5.SelectedItem.ToString());
senddata[5] = 12-8;
byte[] crc = new byte[2];
crc = CRC.Crccheck(0,senddata, 10);
senddata[10] = crc[0];
senddata[11] = crc[1];
Send_Tx_databuf(senddata, 12);
}
else
{
MessageBox.Show("串口未打开");
}
}
private void Button6_Click(object sender, EventArgs e)
{
if (serialPort1.IsOpen)
{
//发送PAT
byte[] senddata = { 0xA5, 0xEA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x43, 0x00, 0x00, 0x00 };
senddata[5] = 12-8;
senddata[9] = Convert.ToByte(comboBox6.SelectedIndex);
senddata[9] += 1;
byte[] crc = new byte[2];
crc = CRC.Crccheck(0,senddata, 10);
senddata[10] = crc[0];
senddata[11] = crc[1];
Send_Tx_databuf(senddata, 12);
}
else
{
MessageBox.Show("串口未打开");
}
}
private void groupBox8_Enter(object sender, EventArgs e)
{
}
private void comboBox12_SelectedIndexChanged(object sender, EventArgs e)
{
if (comboBox12.SelectedIndex == 0)
{
return;
}
else
{
}
string[] splistring = new string[2];
char[] dtvsep = { ',' };
if (EdpAdressInit.Edp_Adree[comboBox12.SelectedIndex - 1].HAdr != "")
{
textBox7.Text = EdpAdressInit.Edp_Adree[comboBox12.SelectedIndex - 1].HAdr;
}
if (EdpAdressInit.Edp_Adree[comboBox12.SelectedIndex - 1].VAdr != "")
{
textBox8.Text = EdpAdressInit.Edp_Adree[comboBox12.SelectedIndex - 1].VAdr;
}
if (EdpAdressInit.Edp_Adree[comboBox12.SelectedIndex - 1].HFP != "")
{
textBox9.Text = EdpAdressInit.Edp_Adree[comboBox12.SelectedIndex - 1].HFP;
}
if (EdpAdressInit.Edp_Adree[comboBox12.SelectedIndex - 1].VFP != "")
{
textBox10.Text = EdpAdressInit.Edp_Adree[comboBox12.SelectedIndex - 1].VFP;
}
if (EdpAdressInit.Edp_Adree[comboBox12.SelectedIndex - 1].HBP != "")
{
textBox11.Text = EdpAdressInit.Edp_Adree[comboBox12.SelectedIndex - 1].HBP;
}
if (EdpAdressInit.Edp_Adree[comboBox12.SelectedIndex - 1].VBP != "")
{
textBox12.Text = EdpAdressInit.Edp_Adree[comboBox12.SelectedIndex - 1].VBP;
}
if (EdpAdressInit.Edp_Adree[comboBox12.SelectedIndex - 1].HSYNC != "")
{
textBox13.Text = EdpAdressInit.Edp_Adree[comboBox12.SelectedIndex - 1].HSYNC;
}
if (EdpAdressInit.Edp_Adree[comboBox12.SelectedIndex - 1].VSYNC != "")
{
textBox14.Text = EdpAdressInit.Edp_Adree[comboBox12.SelectedIndex - 1].VSYNC;
}
if (EdpAdressInit.Edp_Adree[comboBox12.SelectedIndex - 1].Pixel != "")
{
textBox15.Text = EdpAdressInit.Edp_Adree[comboBox12.SelectedIndex - 1].Pixel;
}
if (EdpAdressInit.Edp_Adree[comboBox12.SelectedIndex - 1].Refresh != "")
{
textBox16.Text = EdpAdressInit.Edp_Adree[comboBox12.SelectedIndex - 1].Refresh;
}
if (Power_Type_VDD_VBL == 1)
{
if (EdpAdressInit.Edp_Adree[comboBox12.SelectedIndex - 1].VDD != "")
{
textBox1.Text = EdpAdressInit.Edp_Adree[comboBox12.SelectedIndex - 1].VDD;
}
if (EdpAdressInit.Edp_Adree[comboBox12.SelectedIndex - 1].MAX_VDD != "")
{
textBox2.Text = EdpAdressInit.Edp_Adree[comboBox12.SelectedIndex - 1].MAX_VDD;
}
if (EdpAdressInit.Edp_Adree[comboBox12.SelectedIndex - 1].MIN_VDD != "")
{
textBox3.Text = EdpAdressInit.Edp_Adree[comboBox12.SelectedIndex - 1].MIN_VDD;
}
if (EdpAdressInit.Edp_Adree[comboBox12.SelectedIndex - 1].MAX_IDD != "")
{
textBox4.Text = EdpAdressInit.Edp_Adree[comboBox12.SelectedIndex - 1].MAX_IDD;
}
if (EdpAdressInit.Edp_Adree[comboBox12.SelectedIndex - 1].MAX_IDD_CT != "")
{
// textBox13.Text = EdpAdressInit.Edp_Adree[comboBox12.SelectedIndex - 1].MAX_IDD_CT;
}
if (EdpAdressInit.Edp_Adree[comboBox12.SelectedIndex - 1].MIN_IDD_CT != "")
{
// textBox12.Text = EdpAdressInit.Edp_Adree[comboBox12.SelectedIndex - 1].MIN_IDD_CT;
}
if (EdpAdressInit.Edp_Adree[comboBox12.SelectedIndex - 1].VDD_PowerOnTime != "")
{
textBox5.Text = EdpAdressInit.Edp_Adree[comboBox12.SelectedIndex - 1].VDD_PowerOnTime;
}
if (EdpAdressInit.Edp_Adree[comboBox12.SelectedIndex - 1].VDD_PowerOffTime != "")
{
textBox6.Text = EdpAdressInit.Edp_Adree[comboBox12.SelectedIndex - 1].VDD_PowerOffTime;
}
}
else if (Power_Type_VDD_VBL == 2)
{
if (EdpAdressInit.Edp_Adree[comboBox12.SelectedIndex - 1].VBL != "")
{
textBox1.Text = EdpAdressInit.Edp_Adree[comboBox12.SelectedIndex - 1].VBL;
}
if (EdpAdressInit.Edp_Adree[comboBox12.SelectedIndex - 1].MAX_VBL != "")
{
textBox2.Text = EdpAdressInit.Edp_Adree[comboBox12.SelectedIndex - 1].MAX_VBL;
}
if (EdpAdressInit.Edp_Adree[comboBox12.SelectedIndex - 1].MIN_VBL != "")
{
textBox3.Text = EdpAdressInit.Edp_Adree[comboBox12.SelectedIndex - 1].MIN_VBL;
}
if (EdpAdressInit.Edp_Adree[comboBox12.SelectedIndex - 1].MAX_IBL != "")
{
textBox4.Text = EdpAdressInit.Edp_Adree[comboBox12.SelectedIndex - 1].MAX_IBL;
}
if (EdpAdressInit.Edp_Adree[comboBox12.SelectedIndex - 1].MAX_IBL_CT != "")
{
// textBox13.Text = EdpAdressInit.Edp_Adree[comboBox12.SelectedIndex - 1].MAX_IBL_CT;
}
if (EdpAdressInit.Edp_Adree[comboBox12.SelectedIndex - 1].MIN_IBL_CT != "")
{
// textBox12.Text = EdpAdressInit.Edp_Adree[comboBox12.SelectedIndex - 1].MIN_IBL_CT;
}
if (EdpAdressInit.Edp_Adree[comboBox12.SelectedIndex - 1].VBL_PowerOnTime != "")
{
textBox5.Text = EdpAdressInit.Edp_Adree[comboBox12.SelectedIndex - 1].VBL_PowerOnTime;
}
if (EdpAdressInit.Edp_Adree[comboBox12.SelectedIndex - 1].VBL_PowerOffTime != "")
{
textBox6.Text = EdpAdressInit.Edp_Adree[comboBox12.SelectedIndex - 1].VBL_PowerOffTime;
}
}
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
if (comboBox1.SelectedIndex == 1)
{
Power_Type_VDD_VBL = 1;
if (comboBox12.SelectedIndex == 0)
return;
if (EdpAdressInit.Edp_Adree[comboBox12.SelectedIndex - 1].VDD != "")
{
textBox1.Text = EdpAdressInit.Edp_Adree[comboBox12.SelectedIndex - 1].VDD;
}
if (EdpAdressInit.Edp_Adree[comboBox12.SelectedIndex - 1].MAX_VDD != "")
{
textBox2.Text = EdpAdressInit.Edp_Adree[comboBox12.SelectedIndex - 1].MAX_VDD;
}
if (EdpAdressInit.Edp_Adree[comboBox12.SelectedIndex - 1].MIN_VDD != "")
{
textBox3.Text = EdpAdressInit.Edp_Adree[comboBox12.SelectedIndex - 1].MIN_VDD;
}
if (EdpAdressInit.Edp_Adree[comboBox12.SelectedIndex - 1].MAX_IDD != "")
{
textBox4.Text = EdpAdressInit.Edp_Adree[comboBox12.SelectedIndex - 1].MAX_IDD;
}
if (EdpAdressInit.Edp_Adree[comboBox12.SelectedIndex - 1].MAX_IDD_CT != "")
{
// textBox13.Text = EdpAdressInit.Edp_Adree[comboBox12.SelectedIndex - 1].MAX_IDD_CT;
}
if (EdpAdressInit.Edp_Adree[comboBox12.SelectedIndex - 1].MIN_IDD_CT != "")
{
// textBox12.Text = EdpAdressInit.Edp_Adree[comboBox12.SelectedIndex - 1].MIN_IDD_CT;
}
if (EdpAdressInit.Edp_Adree[comboBox12.SelectedIndex - 1].VDD_PowerOnTime != "")
{
textBox5.Text = EdpAdressInit.Edp_Adree[comboBox12.SelectedIndex - 1].VDD_PowerOnTime;
}
if (EdpAdressInit.Edp_Adree[comboBox12.SelectedIndex - 1].VDD_PowerOffTime != "")
{
textBox6.Text = EdpAdressInit.Edp_Adree[comboBox12.SelectedIndex - 1].VDD_PowerOffTime;
}
}
else if (comboBox1.SelectedIndex == 2)
{
Power_Type_VDD_VBL = 2;
if (comboBox12.SelectedIndex == 0)
return;
if (EdpAdressInit.Edp_Adree[comboBox12.SelectedIndex - 1].VBL != "")
{
textBox1.Text = EdpAdressInit.Edp_Adree[comboBox12.SelectedIndex - 1].VBL;
}
if (EdpAdressInit.Edp_Adree[comboBox12.SelectedIndex - 1].MAX_VBL != "")
{
textBox2.Text = EdpAdressInit.Edp_Adree[comboBox12.SelectedIndex - 1].MAX_VBL;
}
if (EdpAdressInit.Edp_Adree[comboBox12.SelectedIndex - 1].MIN_VBL != "")
{
textBox3.Text = EdpAdressInit.Edp_Adree[comboBox12.SelectedIndex - 1].MIN_VBL;
}
if (EdpAdressInit.Edp_Adree[comboBox12.SelectedIndex - 1].MAX_IBL != "")
{
textBox4.Text = EdpAdressInit.Edp_Adree[comboBox12.SelectedIndex - 1].MAX_IBL;
}
if (EdpAdressInit.Edp_Adree[comboBox12.SelectedIndex - 1].MAX_IBL_CT != "")
{
// textBox13.Text = EdpAdressInit.Edp_Adree[comboBox12.SelectedIndex - 1].MAX_IBL_CT;
}
if (EdpAdressInit.Edp_Adree[comboBox12.SelectedIndex - 1].MIN_IBL_CT != "")
{
// textBox12.Text = EdpAdressInit.Edp_Adree[comboBox12.SelectedIndex - 1].MIN_IBL_CT;
}
if (EdpAdressInit.Edp_Adree[comboBox12.SelectedIndex - 1].VBL_PowerOnTime != "")
{
textBox5.Text = EdpAdressInit.Edp_Adree[comboBox12.SelectedIndex - 1].VBL_PowerOnTime;
}
if (EdpAdressInit.Edp_Adree[comboBox12.SelectedIndex - 1].VBL_PowerOffTime != "")
{
textBox6.Text = EdpAdressInit.Edp_Adree[comboBox12.SelectedIndex - 1].VBL_PowerOffTime;
}
}
}
private void button8_Click(object sender, EventArgs e)
{
if (serialPort1.IsOpen)
{
//发送PAT
byte[] senddata = { 0xA5, 0xEA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x53, 0x00, 0x00, 0x00,0x00,
0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00 };
senddata[5] = 19;
senddata[9] = Convert.ToByte((Convert.ToInt16(textBox7.Text) >> 8) & 0xff); //Convert.ToByte(comboBox6.SelectedIndex);
senddata[10] = Convert.ToByte((Convert.ToInt16(textBox7.Text) >> 0) & 0xff);
senddata[11] = Convert.ToByte((Convert.ToInt16(textBox8.Text) >> 8) & 0xff);
senddata[12] = Convert.ToByte((Convert.ToInt16(textBox8.Text) >> 0) & 0xff);
senddata[13] = Convert.ToByte((Convert.ToInt16(textBox9.Text) >> 8) & 0xff);
senddata[14] = Convert.ToByte((Convert.ToInt16(textBox9.Text) >> 0) & 0xff);
senddata[15] = Convert.ToByte((Convert.ToInt16(textBox10.Text) >> 8) & 0xff);
senddata[16] = Convert.ToByte((Convert.ToInt16(textBox10.Text) >> 0) & 0xff);
senddata[17] = Convert.ToByte((Convert.ToInt16(textBox11.Text) >> 8) & 0xff);
senddata[18] = Convert.ToByte((Convert.ToInt16(textBox11.Text) >> 0) & 0xff);
senddata[19] = Convert.ToByte((Convert.ToInt16(textBox12.Text) >> 8) & 0xff);
senddata[20] = Convert.ToByte((Convert.ToInt16(textBox12.Text) >> 0) & 0xff);
senddata[21] = Convert.ToByte((Convert.ToInt16(textBox13.Text) >> 8) & 0xff);
senddata[22] = Convert.ToByte((Convert.ToInt16(textBox13.Text) >> 0) & 0xff);
senddata[23] = Convert.ToByte((Convert.ToInt16(textBox14.Text) >> 8) & 0xff);
senddata[24] = Convert.ToByte((Convert.ToInt16(textBox14.Text) >> 0) & 0xff);
senddata[25] = Convert.ToByte((Convert.ToInt16(textBox15.Text) >> 8) & 0xff);
senddata[26] = Convert.ToByte((Convert.ToInt16(textBox15.Text) >> 0) & 0xff);
senddata[27] = Convert.ToByte((Convert.ToInt16(textBox16.Text) >> 8) & 0xff);
senddata[28] = Convert.ToByte((Convert.ToInt16(textBox16.Text) >> 0) & 0xff);
byte[] crc = new byte[2];
crc = CRC.Crccheck(0, senddata, 29);
senddata[29] = crc[0];
senddata[30] = crc[1];
Send_Tx_databuf(senddata,31);
}
else
{
MessageBox.Show("串口未打开");
}
}
private void button7_Click(object sender, EventArgs e)
{
if (serialPort1.IsOpen)
{
//发送PAT
byte[] senddata = { 0xA5, 0xEA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x41, 0x00, 0x00, 0x00, 0x00,0x00 };
senddata[5] = 6;
senddata[9] = Convert.ToByte(comboBox9.SelectedIndex);
senddata[10] = Convert.ToByte(comboBox7.SelectedItem.ToString());
senddata[11] = Convert.ToByte(comboBox8.SelectedItem.ToString());
byte[] crc = new byte[2];
crc = CRC.Crccheck(0, senddata, 12);
senddata[12] = crc[0];
senddata[13] = crc[1];
Send_Tx_databuf(senddata, 14);
}
else
{
MessageBox.Show("串口未打开");
}
}
}
}
来源:oschina
链接:https://my.oschina.net/u/4267539/blog/4473291