using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using pac8172WNet; namespace pac_i8172AO { public partial class Form1 : Form { private static int slotIndex = 0, port = 0, group = 0; private static Int16 bitMode = 12; public Form1() { InitializeComponent(); } private void Write_AO(object sender, EventArgs e) { TextBox[] AO = new TextBox[] { txtAO0, txtAO1, txtAO2, txtAO3 }; ComboBox[] cbo = { cboType0, cboType1, cboType2, cboType3 }; Int16 index = Int16.Parse(((Button)sender).Tag.ToString()); Int16 typeCode = (Int16)(cbo[index].SelectedIndex + 0x30); pac8172WNet.pac8172W.WriteAOFloat(slotIndex, port, group, bitMode, index, typeCode,Convert.ToSingle(AO[index].Text ),0); } private void Form1_Load(object sender, EventArgs e) { int i; ComboBox[] cbo = { cboType0, cboType1, cboType2, cboType3 }; cboPort.SelectedIndex = 0; cboGroup.SelectedIndex = 0; for (i = 0; i < 4; i++) { cbo[i].SelectedIndex = 3; // type code = 0x8 +-10 V } } private void cboSlot_SelectedIndexChanged(object sender, EventArgs e) { int ret = -1; ret = pac8172W.Init(cboSlot.SelectedIndex); if (ret == 0) { slotIndex = cboSlot.SelectedIndex; } else { MessageBox.Show("I-8172W is not at slot " + cboSlot.SelectedIndex.ToString()); } } private void cboPort_SelectedIndexChanged(object sender, EventArgs e) { port = cboPort.SelectedIndex; } private void cboGroup_SelectedIndexChanged(object sender, EventArgs e) { group = cboGroup.SelectedIndex; } private void btnExit_Click(object sender, EventArgs e) { Application.Exit(); } } }