private void bTcpCon_Click(object sender, EventArgs e) { int status; int port; byte v1 = 0; byte v2 = 0; string s = ""; try { port = int.Parse(tPort.Text); s = tIp.Text; } catch (Exception) { lInfo.Items.Add("Please input the ip address and port !"); return; } status = Api.TcpConnectReader(tIp.Text, port); if (status != 0) { lInfo.Items.Add("Connect Reader Failed!"); return; } status = Api.GetFirmwareVersion(ref v1, ref v2); if (status != 0) { lInfo.Items.Add("Can not connect with the reader!"); Api.TcpCloseConnect(); return; } lInfo.Items.Add("Connect the reader success!"); s = string.Format("The reader's firmware version is:V{0:d2}.{1:d2}", v1, v2); lInfo.Items.Add(s); bTcpCon.Enabled = false; bTcpDiscon.Enabled = true; bReset.Enabled = true; bRs232Con.Enabled = false; bRs232Discon.Enabled = false; bRfSet.Enabled = true; bRfQuery.Enabled = true; bIsoId.Enabled = true; bIsoRead.Enabled = true; bIsoWrite.Enabled = true; bIsoLock.Enabled = true; bIsoQueryLock.Enabled = true; bEpcId.Enabled = true; bEpcRead.Enabled = true; bEpcWrite.Enabled = true; bEpcInit.Enabled = true; bEpcKill.Enabled = false; bRfQuery_Click(null, null); }
private void bTcpCon_Click(object sender, EventArgs e) { int status; int port; byte v1 = 0; byte v2 = 0; string s = ""; try { port = int.Parse(tPort.Text); s = tIp.Text; } catch (Exception) { lInfo.Items.Add("Please input the ip address and port !"); return; } // Start to ping reader if (Reader1.StartPing(tIp.Text) <= 0) { while (Reader1.CheckPing() > 0) { lInfo.Items.Add("Check reader ping state ..."); Application.DoEvents(); System.Threading.Thread.Sleep(500); } lInfo.Items.Add("Reader ping success"); timerPing.Enabled = true; } status = Reader1.TcpConnectReader(tIp.Text, port); if (status != 0) { lInfo.Items.Add("Connect Reader Failed!"); Reader1.EndPing(); return; } status = Reader1.GetFirmwareVersion(ref v1, ref v2); if (status != 0) { lInfo.Items.Add("Can not connect with the reader!"); Reader1.TcpCloseConnect(); Reader1.EndPing(); return; } lInfo.Items.Add("Connect the reader success!"); s = string.Format("The reader's firmware version is:V{0:d2}.{1:d2}", v1, v2); lInfo.Items.Add(s); bAntQuery_Click(sender, e); bTcpCon.Enabled = false; bTcpDiscon.Enabled = true; bReset.Enabled = true; bRs232Con.Enabled = false; bRs232Discon.Enabled = false; bRfSet.Enabled = true; bRfQuery.Enabled = true; bIsoId.Enabled = true; bIsoRead.Enabled = true; bIsoWrite.Enabled = true; bIsoLock.Enabled = true; bIsoQueryLock.Enabled = true; bEpcId.Enabled = true; bEpcRead.Enabled = true; bEpcWrite.Enabled = true; bEpcInit.Enabled = true; bEpcKill.Enabled = false; bRfQuery_Click(null, null); }