using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace _87K_count { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { int slot = cbbSlot.SelectedIndex + 1; int channel = int.Parse(cbbChannel.Items[cbbChannel.SelectedIndex].ToString()); uint Counter_Value = 0; int overflow = 0; IntPtr h = PACNET.UART.Open(""); PACNET.PAC_IO.ReadCNT(h, slot, channel, ref Counter_Value); textBox1.Text = Counter_Value.ToString(); //check overflow: PACNET.PAC_IO.ReadCNTOverflow(h, slot, channel, ref overflow); if (1 == overflow) { lbOverflow.ForeColor = Color.Red; lbOverflow.Text = "YES."; } else { lbOverflow.ForeColor = Color.Green; lbOverflow.Text = "NO."; } PACNET.UART.Close(h); } private void button2_Click(object sender, EventArgs e) { int slot = cbbSlot.SelectedIndex + 1; int channel = int.Parse(cbbChannel.Items[cbbChannel.SelectedIndex].ToString()); IntPtr h = PACNET.UART.Open(""); PACNET.PAC_IO.ClearCNT(h, slot, channel); PACNET.UART.Close(h); } private void Form1_Load(object sender, EventArgs e) { cbbSlot.SelectedIndex = 0; cbbChannel.SelectedIndex = 0; } } }