using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace _87K_di { public partial class Form1 : Form { public Form1() { InitializeComponent(); cmbSlot.SelectedIndex = 1; } private void button1_Click_1(object sender, EventArgs e) { int intSlot; uint IDValue = 0; bool iRet; IntPtr hPort; //Open default com port , default com port is com 1 hPort = PACNET.UART.Open(""); //Get slot data intSlot = Convert.ToInt16(cmbSlot.Text); //Read data iRet = PACNET.PAC_IO.ReadDI(hPort, intSlot, Convert.ToInt16(txtChannel.Text), ref IDValue); if (!iRet) { uint ec = PACNET.ErrHandling.GetLastError(); MessageBox.Show(((PACNET.ErrCode)ec).ToString() + "\nError Code: 0x" + ec.ToString("X")); } else { txtDiValue.Text = Convert.ToString(IDValue,16); } PACNET.UART.Close(hPort); } private void button2_Click(object sender, EventArgs e) { int intSlot; uint IDValue = 0; bool iRet; IntPtr hPort; //Open default com port , default com port is com 1 hPort = PACNET.UART.Open(""); //Get slot data intSlot = Convert.ToInt16(cmbSlot.Text); //Read data pac_ReadDI_MF iRet = PACNET.PAC_IO.ReadDI_MF(hPort, intSlot, Convert.ToInt16(txtChannel.Text), ref IDValue); if (!iRet) { uint ec = PACNET.ErrHandling.GetLastError(); MessageBox.Show(((PACNET.ErrCode)ec).ToString() + "\nError Code: 0x" + ec.ToString("X")); } else { txtDiValue.Text = Convert.ToString(IDValue, 16); } PACNET.UART.Close(hPort); } } }