Esempio n. 1
0
 private void Init(byte A)
 {
     //for (int i = 0; i < 256; i++)
     {
         //if (f.select_address[i] != 0)
         {
             byte[] array = new byte[5];
             array[0] = 0xE5;
             array[1] = (byte)num;//f.select_address[i];
             array[2] = 0x20;
             array[3] = A;
             array[4] = (byte)(0xFF - (0xFF & array[0] + array[1] + array[2] + array[3]));
             try
             {
                 if (serialPort1.IsOpen)
                 {
                     SerialPortUtil.serialPortSendData(serialPort1, array, 0, 5, 100, 2);
                     f.richTextBox2.AppendText(MainForm.ToHexString(array, 5));
                     f.richTextBox2.SelectionStart = f.richTextBox2.Text.Length;
                     f.richTextBox2.ScrollToCaret();
                 }
             }
             catch
             {
                 string ts = languageFile.ReadString("MESSAGEBOX", "M1", "串口出错!");
                 string tp = languageFile.ReadString("MESSAGEBOX", "TP", "提示");
                 MessageBox.Show(ts, tp);
             }
         }
     }
 }
Esempio n. 2
0
 private void Save_number(int A_0)//单独设置屏幕的单元序号----指令
 {
     byte[] array = new byte[9];
     array[0] = 0xE9;
     array[1] = 0xFD;
     array[2] = 0x20;
     array[3] = 0x12;
     array[4] = (byte)(A_0 >> 16);
     array[5] = 0x59;
     array[6] = (byte)(A_0 >> 8);
     array[7] = (byte)A_0;
     array[8] = (byte)(0xFF - (0xFF & array[0] + array[1] + array[2] + array[3] + array[4] + array[5] + array[6] + array[7]));
     try
     {
         //serialPort1.Write(array, 0, 11);
         SerialPortUtil.serialPortSendData(f.serialPort1, array, 0, 9, 100, 2);
         f.richTextBox2.AppendText(MainForm.ToHexString(array, 9));
         f.richTextBox2.SelectionStart = f.richTextBox2.Text.Length;
         f.richTextBox2.ScrollToCaret();
     }
     catch
     {
         //Rs232Con = false;
         if (f.Chinese_English == 1)
         {
             MessageBox.Show("    Serial error!", "Tips");
         }
         else
         {
             MessageBox.Show("    串口出错!", "提示");
         }
     }
 }
        private void button2_Click(object sender, EventArgs e)
        {
            button2.Enabled = false;
            //for (int i = 0; i <= count; i++)
            {
                byte[] array = new byte[6];
                array[0] = 0xE5;
                if (flag_ch)
                {
                    array[1] = Byte.Parse(comboBox1.Text);
                    //Console.WriteLine(array[1]);
                }
                else
                {
                    array[1] = 0xFD;
                }
                array[2] = 0x20;
                array[3] = 0x81;
                array[4] = (byte)(0xFF - (0xFF & array[0] + array[1] + array[2] + array[3]));

                try
                {
                    if (port_flag)
                    {
                        //serialPort1.Write(array, 0, 5);
                        SerialPortUtil.serialPortSendData(serialPort1, array, 0, 5, 100, 1);
                        //f.richTextBox2.AppendText(MainForm.ToHexString(array, 5));
                        //Thread.Sleep(100);
                        LogHelper.WriteLog("======操作屏幕的色彩复位设置======");
                    }
                }
                catch
                {
                    string ts = languageFile.ReadString("MESSAGEBOX", "M1", "串口出错!");
                    string tp = languageFile.ReadString("MESSAGEBOX", "TP", "提示");
                    MessageBox.Show(ts, tp);
                    return;
                }
                if (port_flag)
                {
                    this.Invoke(new MethodInvoker(delegate()
                    {
                        f.richTextBox2.AppendText(MainForm.ToHexString(array, 5));
                        f.richTextBox2.SelectionStart = f.richTextBox2.Text.Length;
                        f.richTextBox2.ScrollToCaret();
                    }));
                    Init_Data1();

                    string ts = languageFile.ReadString("MESSAGEBOX", "C4", "色彩参数调整复位成功!");
                    string tp = languageFile.ReadString("MESSAGEBOX", "TP", "提示");
                    MessageBox.Show(ts, tp);
                }
            }
        }
Esempio n. 4
0
        private void Init(byte A)
        {
            for (int i = 0; i < 128; i++)
            {
                if (f.select_address[i] != 0)
                {
                    byte[] array = new byte[5];
                    array[0] = 0xE5;
                    array[1] = f.select_address[i];
                    array[2] = 0x20;
                    array[3] = A;
                    array[4] = (byte)(0xFF - (0xFF & array[0] + array[1] + array[2] + array[3]));
                    try
                    {
                        if (f.Rs232Con)
                        {
                            if (f.TCPCOM)
                            {
                                f.TcpSendMessage(array, 0, 5);
                            }
                            else
                            {
                                SerialPortUtil.serialPortSendData(f.serialPort1, array, 0, 5, 100, 2);
                            }
                            f.richTextBox2.AppendText(MainForm.ToHexString(array, 5));
                            f.richTextBox2.SelectionStart = f.richTextBox2.Text.Length;
                            f.richTextBox2.ScrollToCaret();
                        }

                        /*
                         * this.BeginInvoke(new MethodInvoker(delegate()
                         * {
                         *  f.richTextBox2.AppendText(MainForm.ToHexString(array, 5));
                         * }));
                         */
                    }
                    catch
                    {
                        string ts = languageFile.ReadString("MESSAGEBOX", "M1", "串口出错!");
                        string tp = languageFile.ReadString("MESSAGEBOX", "TP", "提示");
                        MessageBox.Show(ts, tp);
                    }
                }
            }
        }
Esempio n. 5
0
        private void Send_Control(byte A_0)
        {
            try
            {
                byte[] array = new byte[5];
                array[0] = 0xE5;
                array[2] = 0x20;
                array[3] = A_0;
                for (int i = 0; i < 128; i++)
                {
                    if (f.select_address[i] != 0)
                    {
                        array[1] = f.select_address[i];
                        array[4] = (byte)(255 - (255 & array[0] + array[1] + array[2] + array[3]));
                        //Console.WriteLine("array[1] = " + array[1]);
                        //timer1.Interval += 50;
                        if (f.Rs232Con)
                        {
                            //serialPort1.Write(array, 0, 5);

                            if (f.TCPCOM)
                            {
                                f.TcpSendMessage(array, 0, 5);
                            }
                            else
                            {
                                SerialPortUtil.serialPortSendData(f.serialPort1, array, 0, 5, 100, 1);
                            }
                            f.richTextBox2.AppendText(MainForm.ToHexString(array, 5));
                            f.richTextBox2.SelectionStart = f.richTextBox2.Text.Length;
                            f.richTextBox2.ScrollToCaret();
                        }
                    }
                }
                //timer1.Start();
            }
            catch
            {
                string ts = languageFile.ReadString("MESSAGEBOX", "M1", "串口出错!");
                string tp = languageFile.ReadString("MESSAGEBOX", "TP", "提示");
                MessageBox.Show(ts, tp);
            }
            //f.richTextBox1.Text = f.Str;
        }
 public void ColorBelance_get3()
 {
     byte[] array = new byte[5];
     array[0] = 0xE5;
     array[1] = Byte.Parse(comboBox1.Text);
     array[2] = 0x20;
     array[3] = 0x09;
     array[4] = (byte)(0xFF - (0xFF & array[0] + array[1] + array[2] + array[3]));
     try
     {
         //serialPort1.Write(array, 0, 5);
         SerialPortUtil.serialPortSendData(serialPort1, array, 0, 5, 100, 2);
         f.richTextBox2.AppendText(MainForm.ToHexString(array, 5));
         f.richTextBox2.SelectionStart = f.richTextBox2.Text.Length;
         f.richTextBox2.ScrollToCaret();
     }
     catch
     {
         string ts = languageFile.ReadString("MESSAGEBOX", "M1", "串口出错!");
         string tp = languageFile.ReadString("MESSAGEBOX", "TP", "提示");
         MessageBox.Show(ts, tp);
     }
 }
        private void Adjust(byte A_0)
        {
            //timer1.Interval = 100;
            //for (int i = 0; i <= count; i++)
            {
                byte[] array = new byte[8];
                array[0] = 0xE8;
                if (flag_ch)
                {
                    array[1] = Byte.Parse(comboBox1.Text);
                    //Console.WriteLine(array[1]);
                }
                else
                {
                    array[1] = 0xFD;
                }
                array[2] = 32;
                array[3] = A_0;
                array[4] = 0x0;
                if (A_0 == 96)
                {
                    array[5] = (byte)Lum;
                    array[6] = 0x0;
                }
                else if (A_0 == 97)
                {
                    array[5] = (byte)Conrast;
                    array[6] = 0x0;
                }
                else if (A_0 == 98)
                {
                    array[5] = (byte)BlackL;
                    array[6] = 0x0;
                }
                else if (A_0 == 99)
                {
                    array[5] = (byte)Saturation;
                    array[6] = 0x0;
                }
                else if (A_0 == 106)
                {
                    array[5] = (byte)Clarity;
                    array[6] = 0x0;
                }
                else if (A_0 == 100)
                {
                    array[5] = (byte)B_R;
                    array[6] = 0x0;
                }
                else if (A_0 == 101)
                {
                    array[5] = (byte)B_G;
                    array[6] = 0x0;
                }
                else if (A_0 == 102)
                {
                    array[5] = (byte)B_B;
                    array[6] = 0x0;
                }
                else if (A_0 == 103)
                {
                    array[6] = (byte)(O_R % 256);
                    array[5] = (byte)(O_R / 256);
                }
                else if (A_0 == 104)
                {
                    array[6] = (byte)(O_G % 256);
                    array[5] = (byte)(O_G / 256);
                }
                else if (A_0 == 105)
                {
                    array[6] = (byte)(O_B % 256);
                    array[5] = (byte)(O_B / 256);
                }
                else
                {
                    array[5] = (byte)Lum;
                    array[6] = 0x0;
                }
                //Console.WriteLine(array[5] +","+ array[6]);
                array[7] = (byte)(0xFF - (0xFF & array[0] + array[1] + array[2] + array[3] + array[4] + array[5] + array[6]));

                try
                {
                    if (port_flag)
                    {
                        //serialPort1.Write(array, 0, 6);
                        SerialPortUtil.serialPortSendData(serialPort1, array, 0, 8, 100, 1);
                        //f.richTextBox2.AppendText(MainForm.ToHexString(array, 6));
                        //Thread.Sleep(500);
                    }
                }
                catch
                {
                    string ts = languageFile.ReadString("MESSAGEBOX", "M1", "串口出错!");
                    string tp = languageFile.ReadString("MESSAGEBOX", "TP", "提示");
                    MessageBox.Show(ts, tp);
                }
                this.Invoke(new MethodInvoker(delegate()
                {
                    f.richTextBox2.AppendText(MainForm.ToHexString(array, 8));
                    f.richTextBox2.SelectionStart = f.richTextBox2.Text.Length;
                    f.richTextBox2.ScrollToCaret();
                }));
                //if(count > 0)
                //comboBox1.SelectedIndex = i;
            }
        }