Exemplo n.º 1
0
        private void ReadStructFromBuffer()
        {
            int n = serialPort1.BytesToRead;

            byte[] Buffer = new byte[1000];
            serialPort1.Read(Buffer, 0, n);
            ModBusClass.ModBus_CreatStruct(ref RXModBus, Buffer);
        }
Exemplo n.º 2
0
 private void Form1_Load(object sender, EventArgs e)
 {
     button1_Click(null, null);
     button2_Click(null, null);
     ModBusClass.ModBus_Create(ref ModBus, 0x01, 0x94, 0x7e, 0x7f);
     img = new Bitmap(pictureBox1.Width, pictureBox1.Height);
     G   = Graphics.FromImage(img);
     toolStripProgressBar1.Maximum = LCD_XSIZE;
 }
Exemplo n.º 3
0
        private void WriteScreenLine()
        {
            byte[] Buf = new byte[1000];
            ModBus.TargetAddr = ModBusClass.TargetAddr;
            ModBus.HostAddr   = ModBusClass.HostAddr;
            ModBus.MsgFlag    = (byte)MsgFlag.WriteScreenYLine;
            ModBus.MsgNum     = 1;
            ModBus.DataLength = LCD_YSIZE * 2 + 2;
            ModBus.DataFlag   = 0x01;
            ModBus.Data       = ReadPictureLine();
            int n = ModBusClass.ModBus_CreatBuf(ref ModBus, ref Buf);

            serialPort1.Write(Buf, 0, n);
            System.Threading.Thread.Sleep(50);
            ReadLine++;
            if (ReadLine >= LCD_XSIZE)
            {
                ReadLine = 0; timer1.Enabled = false; button5.BackColor = button4.BackColor;
            }
            toolStripProgressBar1.Value = ReadLine;
            toolStripStatusLabel1.Text  = (ReadLine * 100 / LCD_XSIZE).ToString() + "%";
        }