Ejemplo n.º 1
0
        private void button25_Click(object sender, EventArgs e)
        {
            try
            {
                //    OperateResult write = allenBradleyNet.Write( "Array", new short[] { 101, 102, 103, 104, 105, 106 } );

                // OperateResult<short[]> readResult = allenBradleyNet.ReadInt16( "Array", 300 );

                OperateResult <byte[]> read = null;
                if (!textBox6.Text.Contains(";"))
                {
                    //MessageBox.Show( HslCommunication.BasicFramework.SoftBasic.ByteToHexString( allenBradleyNet.BuildReadCommand( new string[] { textBox6.Text }, new int[] { int.Parse(textBox9.Text) } ).Content , ' ') );
                    read = allenBradleyNet.ReadSegment(textBox6.Text, ushort.Parse(textBox12.Text), ushort.Parse(textBox9.Text));
                }
                else
                {
                    //MessageBox.Show( HslCommunication.BasicFramework.SoftBasic.ByteToHexString( allenBradleyNet.BuildReadCommand( textBox6.Text.Split( ';' ) ).Content, ' ' ) );
                    read = allenBradleyNet.Read(textBox6.Text.Split(';'));
                }

                if (read.IsSuccess)
                {
                    textBox10.Text = "Result:" + HslCommunication.BasicFramework.SoftBasic.ByteToHexString(read.Content);
                }
                else
                {
                    MessageBox.Show("Read failed:" + read.ToMessageShowString( ));
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Read failed:" + ex.Message);
            }
        }