コード例 #1
0
        private async void but_brokenline_ClickAsync(object sender, EventArgs e)
        {
            try
            {
                var constant = new BrokenLineChart(txt_address.Text);
                constant.Show();
                while (!constant.IsDisposed)
                {
                    await Task.Delay(800);

                    dynamic result = null;
                    if (rd_bit.Checked)
                    {
                        result = client.ReadBoolean(txt_address.Text);
                    }
                    else if (rd_short.Checked)
                    {
                        result = client.ReadInt16(txt_address.Text);
                    }
                    else if (rd_ushort.Checked)
                    {
                        result = client.ReadUInt16(txt_address.Text);
                    }
                    else if (rd_int.Checked)
                    {
                        result = client.ReadInt32(txt_address.Text);
                    }
                    else if (rd_uint.Checked)
                    {
                        result = client.ReadUInt32(txt_address.Text);
                    }
                    else if (rd_long.Checked)
                    {
                        result = client.ReadInt64(txt_address.Text);
                    }
                    else if (rd_ulong.Checked)
                    {
                        result = client.ReadUInt64(txt_address.Text);
                    }
                    else if (rd_float.Checked)
                    {
                        result = client.ReadFloat(txt_address.Text);
                    }
                    else if (rd_double.Checked)
                    {
                        result = client.ReadDouble(txt_address.Text);
                    }
                    if (result.IsSucceed)
                    {
                        constant.AddData(result.Value);
                    }
                }
            }
            catch (Exception)
            { }
        }
コード例 #2
0
        private async void but_brokenline_ClickAsync(object sender, EventArgs e)
        {
            try
            {
                byte.TryParse(txt_stationNumber.Text?.Trim(), out byte stationNumber);

                var constant = new BrokenLineChart(txt_address.Text);
                constant.Show();
                while (!constant.IsDisposed)
                {
                    await Task.Delay(800);

                    dynamic result = null;
                    if (rd_coil.Checked)
                    {
                        result = client.ReadCoil(txt_address.Text, stationNumber);
                    }
                    else if (rd_short.Checked)
                    {
                        result = client.ReadInt16(txt_address.Text, stationNumber);
                    }
                    else if (rd_ushort.Checked)
                    {
                        result = client.ReadUInt16(txt_address.Text, stationNumber);
                    }
                    else if (rd_int.Checked)
                    {
                        result = client.ReadInt32(txt_address.Text, stationNumber);
                    }
                    else if (rd_uint.Checked)
                    {
                        result = client.ReadUInt32(txt_address.Text, stationNumber);
                    }
                    else if (rd_long.Checked)
                    {
                        result = client.ReadInt64(txt_address.Text, stationNumber);
                    }
                    else if (rd_ulong.Checked)
                    {
                        result = client.ReadUInt64(txt_address.Text, stationNumber);
                    }
                    else if (rd_float.Checked)
                    {
                        result = client.ReadFloat(txt_address.Text, stationNumber);
                    }
                    else if (rd_double.Checked)
                    {
                        result = client.ReadDouble(txt_address.Text, stationNumber);
                    }
                    else if (rd_discrete.Checked)
                    {
                        result = client.ReadDiscrete(txt_address.Text, stationNumber);
                    }

                    if (result.IsSucceed)
                    {
                        constant.AddData(result.Value);
                    }
                }
            }
            catch (Exception)
            { }
        }