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_cnt { public partial class Form1 : Form { public Form1() { InitializeComponent(); cmbSlot.SelectedIndex = 1; } private void btnReadDI_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 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 btnClearDICounter_Click(object sender, EventArgs e) { int intSlot; 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.ClearDICNT(hPort, intSlot, Convert.ToInt16(txtDICNTChannel.Text), Convert.ToInt16(txtChannel.Text)); if (!iRet) { uint ec = PACNET.ErrHandling.GetLastError(); MessageBox.Show(((PACNET.ErrCode)ec).ToString() + "\nError Code: 0x" + ec.ToString("X")); } else { textBox1.Text = ""; } PACNET.UART.Close(hPort); } private void btnReadDICounter_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 iRet = PACNET.PAC_IO.ReadDICNT(hPort, intSlot, Convert.ToInt16(txtDICNTChannel.Text), 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 { textBox1.Text = Convert.ToString(IDValue); } PACNET.UART.Close(hPort); } private void btnReadDI_MF_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); } private void btnClearDICounter_MF_Click(object sender, EventArgs e) { int intSlot; 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_ClearDICNT_MF iRet = PACNET.PAC_IO.ClearDICNT_MF(hPort, intSlot, Convert.ToInt16(txtDICNTChannel.Text), Convert.ToInt16(txtChannel.Text)); if (!iRet) { uint ec = PACNET.ErrHandling.GetLastError(); MessageBox.Show(((PACNET.ErrCode)ec).ToString() + "\nError Code: 0x" + ec.ToString("X")); } else { textBox1.Text = ""; } PACNET.UART.Close(hPort); } private void btnReadDICounter_MF_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_ReadDICNT_MF iRet = PACNET.PAC_IO.ReadDICNT_MF(hPort, intSlot, Convert.ToInt16(txtDICNTChannel.Text), 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 { textBox1.Text = Convert.ToString(IDValue); } PACNET.UART.Close(hPort); } } }