예제 #1
0
        private void WriteButton_Click(object sender, EventArgs e)
        {
            if (!m_Connected)
            {
                return;
            }

            String DeviceName = DeviceAddr.Text;

            String[]      values = DeviceData.Text.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            StringBuilder data   = new StringBuilder();

            try
            {
                foreach (String v in values)
                {
                    byte c = byte.Parse(v);
                    data.Append((Char)(c));
                }

                String dataStr = data.ToString();
                CommUtil.SetStringToDevice(dataStr, DeviceName, dataStr.Length, m_PLCCom);

                MessageBox.Show("写入成功", "信息");
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message, "错误");
            }
        }