using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace _87K_ao { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { cbbSlot.SelectedIndex = 0; cbbChannel.SelectedIndex = 0; int total_ch = int.Parse(cbbChannel.Items[cbbChannel.SelectedIndex].ToString()); addItems2cbbSingleCh(total_ch); cbbSingleCh.SelectedIndex = 0; } private void addItems2cbbSingleCh(int total_ch) { cbbSingleCh.Items.Clear(); for (int i = 0; i < total_ch; i++) { cbbSingleCh.Items.Add(i); } } private void button1_Click(object sender, EventArgs e) { int slot = cbbSlot.SelectedIndex + 1; int total_ch = int.Parse(cbbChannel.Items[cbbChannel.SelectedIndex].ToString()); int ch = int.Parse(cbbSingleCh.Items[cbbSingleCh.SelectedIndex].ToString()); float AO_fValue = float.Parse(textBox1.Text); IntPtr h = PACNET.UART.Open(""); PACNET.PAC_IO.WriteAO(h, slot, ch, total_ch, AO_fValue); PACNET.UART.Close(h); } private void button2_Click(object sender, EventArgs e) { int slot = cbbSlot.SelectedIndex + 1; int total_ch = int.Parse(cbbChannel.Items[cbbChannel.SelectedIndex].ToString()); int ch = int.Parse(cbbSingleCh.Items[cbbSingleCh.SelectedIndex].ToString()); float AO_fValue = 0; IntPtr h = PACNET.UART.Open(""); PACNET.PAC_IO.ReadAO(h, slot, ch, total_ch, ref AO_fValue); textBox2.Text = AO_fValue.ToString(); PACNET.UART.Close(h); } private void cbbChannel_SelectedIndexChanged(object sender, EventArgs e) { int slot = cbbSlot.SelectedIndex + 1; int total_ch = int.Parse(cbbChannel.Items[cbbChannel.SelectedIndex].ToString()); addItems2cbbSingleCh(total_ch); cbbSingleCh.SelectedIndex = 0; } } }