using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace _8k_87k_do { public partial class Form1 : Form { public Form1() { InitializeComponent(); } Int32 intSlot = 0; byte byteSlot; private void btnClear_Click(object sender, EventArgs e) { //87k module must build com port to send data IntPtr hPort = PACNET.UART.Open(""); intSlot = Convert.ToInt16(cmbSlot.Text); //Give DO '0' value to clear bool iRet = PACNET.PAC_IO.WriteDO(hPort, intSlot, Convert.ToInt32(txtChannel.Text), 0); if (!iRet) { uint ec = PACNET.ErrHandling.GetLastError(); MessageBox.Show(((PACNET.ErrCode)ec).ToString() + "\nError Code: 0x" + ec.ToString("X")); } PACNET.UART.Close(hPort); intSlot = Convert.ToInt16(cmbSlot2.Text); //8k module have not using com port to write or read data and Give DO '0' value to clear iRet = PACNET.PAC_IO.WriteDO((IntPtr)null, intSlot, Convert.ToInt32(txtChannel2.Text), 0); if (!iRet) { uint ec = PACNET.ErrHandling.GetLastError(); MessageBox.Show(((PACNET.ErrCode)ec).ToString() + "\nError Code: 0x" + ec.ToString("X")); } txtDOValue.Text = "0"; txtDOValue2.Text = "0"; } private void btnWriteDO_Click(object sender, EventArgs e) { //87k module must build com port to send data IntPtr hPort = PACNET.UART.Open(""); //get user insert 87k module slot intSlot = Convert.ToInt16(cmbSlot.Text); //Get byte state slot data byteSlot = Convert.ToByte(cmbSlot.Text); //write DO value bool iRet = PACNET.PAC_IO.WriteDO(hPort, intSlot, Convert.ToInt32(txtChannel.Text), Convert.ToUInt32(txtDOValue.Text, 16)); if (!iRet) { uint ec = PACNET.ErrHandling.GetLastError(); MessageBox.Show(((PACNET.ErrCode)ec).ToString() + "\nError Code: 0x" + ec.ToString("X")); } PACNET.UART.Close(hPort); //get user insert 8k module slot intSlot = Convert.ToInt16(cmbSlot2.Text); //Get byte state slot data byteSlot = Convert.ToByte(cmbSlot2.Text); //8k module have not using com port to write or read data and use pac_WriteDO to write do data iRet = PACNET.PAC_IO.WriteDO((IntPtr)null, intSlot, Convert.ToInt32(txtChannel2.Text), Convert.ToUInt32(txtDOValue2.Text, 16)); if (!iRet) { uint ec = PACNET.ErrHandling.GetLastError(); MessageBox.Show(((PACNET.ErrCode)ec).ToString() + "\nError Code: 0x" + ec.ToString("X")); } } private void btnWriteDO_MF_Click(object sender, EventArgs e) { //87k module must build com port to send data IntPtr hPort = PACNET.UART.Open(""); //get user insert 87k module slot intSlot = Convert.ToInt16(cmbSlot.Text); //Get byte state slot data byteSlot = Convert.ToByte(cmbSlot.Text); //write DO value bool iRet = PACNET.PAC_IO.WriteDO_MF(hPort, intSlot, Convert.ToInt32(txtChannel.Text), Convert.ToUInt32(txtDOValue.Text, 16)); if (!iRet) { uint ec = PACNET.ErrHandling.GetLastError(); MessageBox.Show(((PACNET.ErrCode)ec).ToString() + "\nError Code: 0x" + ec.ToString("X")); } PACNET.UART.Close(hPort); //get user insert 8k module slot intSlot = Convert.ToInt16(cmbSlot2.Text); //Get byte state slot data byteSlot = Convert.ToByte(cmbSlot2.Text); //8k module have not using com port to write or read data and use pac_WriteDO to write do data iRet = PACNET.PAC_IO.WriteDO((IntPtr)null, intSlot, Convert.ToInt32(txtChannel2.Text), Convert.ToUInt32(txtDOValue2.Text, 16)); if (!iRet) { uint ec = PACNET.ErrHandling.GetLastError(); MessageBox.Show(((PACNET.ErrCode)ec).ToString() + "\nError Code: 0x" + ec.ToString("X")); } } private void btnClear_MF_Click(object sender, EventArgs e) { //87k module must build com port to send data IntPtr hPort = PACNET.UART.Open(""); intSlot = Convert.ToInt16(cmbSlot.Text); //Give DO '0' value to clear bool iRet = PACNET.PAC_IO.WriteDO_MF(hPort, intSlot, Convert.ToInt32(txtChannel.Text), 0); if (!iRet) { uint ec = PACNET.ErrHandling.GetLastError(); MessageBox.Show(((PACNET.ErrCode)ec).ToString() + "\nError Code: 0x" + ec.ToString("X")); } PACNET.UART.Close(hPort); intSlot = Convert.ToInt16(cmbSlot2.Text); //8k module have not using com port to write or read data and Give DO '0' value to clear iRet = PACNET.PAC_IO.WriteDO((IntPtr)null, intSlot, Convert.ToInt32(txtChannel2.Text), 0); if (!iRet) { uint ec = PACNET.ErrHandling.GetLastError(); MessageBox.Show(((PACNET.ErrCode)ec).ToString() + "\nError Code: 0x" + ec.ToString("X")); } txtDOValue.Text = "0"; txtDOValue2.Text = "0"; } } }