private void btnOK_Click(object sender, EventArgs e) { IRP1.ReadTag.ReadMemoryBank rmb = (IRP1.ReadTag.ReadMemoryBank)Enum.Parse(typeof(IRP1.ReadTag.ReadMemoryBank), cbReadMB.Items[cbReadMB.SelectedIndex].ToString()); msg = new IRP1.ReadTag(rmb); byte a = 0x80;//天线 if (a1.Checked) { a += 0x01; } if (a2.Checked) { a += 0x02; } if (a3.Checked) { a += 0x04; } if (a4.Checked) { a += 0x08; } msg.Antenna = a; msg.IsLoop = (rbLoop.Checked) ? true : false; msg.Q = (byte)numQ.Value; this.Close(); }
public FormGPIO(IRP1.Reader reader, IRP1.ReadTag scanMsg) { InitializeComponent(); this.reader = reader; this.scanMsg = scanMsg; if (cmbox1.Items.Count > 0) { cmbox1.SelectedIndex = 0; } }
// 扫描配置 private void MI_ScanConfig_Click(object sender, EventArgs e) { if (frmScanConfig == null) { frmScanConfig = new FormScanConfig(reader); } if (frmScanConfig.ShowDialog() == System.Windows.Forms.DialogResult.OK) { scanMsg = frmScanConfig.msg; } }
private void btn_Connect_Click(object sender, EventArgs e) { reader = new IRP1.Reader("Reader1", "TCPIP_Client", tbIPconnect.Text + ":7086"); //TCP msg = new IRP1.ReadTag(IRP1.ReadTag.ReadMemoryBank.EPC_6C); // { // Added MQTT COde string BrokerAddress = "localhost"; Topic = txtTopic.Text; if (Topic == "") { Topic = "rfidX"; } client = new MqttClient(BrokerAddress); clientId = Guid.NewGuid().ToString(); client.Connect(clientId); // subscribe to the topic with QoS 2 //client.Subscribe(new string[] { Topic }, new byte[] { 2 }); // we need arrays as parameters because we can subscribe to different topics with one call //return; // For Debugging if (reader.Connect()) { reader.OnMessageNotificationReceived += new Invengo.NetAPI.Core.MessageNotificationReceivedHandle(reader_OnMessageNotificationReceived); lbl_msg.Text = "Conn successful"; btn_Disconnect.Enabled = true; btn_Connect.Enabled = false; btn_ReadEPC.Enabled = true; changeCtrlEnable("conn"); //btnQuery.PerformClick(); //btnModelSN.PerformClick(); //btn_Query.PerformClick(); //btnAntQuery.PerformClick(); //btnQueryRF.PerformClick(); } else { lbl_msg.Text = "Conn failed"; MessageBox.Show("Conn failed"); } } }
public static void InitRFID() { MCP.Config.Configuration conf = new MCP.Config.Configuration(); conf.Load("Config.xml"); string RFIDConnetIP = conf.Attributes["RFIDConnetIP"]; string Antenna = conf.Attributes["Antenna"]; string Q = conf.Attributes["Q"]; string IsLoop = conf.Attributes["IsLoop"]; isTryReconnNet = conf.Attributes["isTryReconnNet"] == "1" ? true : false; tryReconnNetTimeSpan = int.Parse(conf.Attributes["tryReconnNetTimeSpan"]); reader = new IRP1.Reader("Reader1", "TCPIP_Client", RFIDConnetIP); IRP1.Reader.OnApiException += new Core.ApiExceptionHandle(Reader_OnApiException); scanMsg = new IRP1.ReadTag(IRP1.ReadTag.ReadMemoryBank.EPC_TID_UserData_6C); scanMsg.Q = byte.Parse(Q); scanMsg.IsLoop = ((IsLoop == "1") ? true : false); scanMsg.Antenna = byte.Parse(Antenna); }
private void btnOK_Click(object sender, EventArgs e) { IRP1.ReadTag.ReadMemoryBank rmb = (IRP1.ReadTag.ReadMemoryBank)Enum.Parse(typeof(IRP1.ReadTag.ReadMemoryBank), "EPC_TID_UserData_6C"); msg = new IRP1.ReadTag(rmb); byte a = 0x80;//天线 if (a1.Checked) { a += 0x01; } if (a2.Checked) { a += 0x02; } if (a3.Checked) { a += 0x04; } if (a4.Checked) { a += 0x08; } msg.Antenna = a; msg.IsLoop = (rbLoop.Checked) ? true : false; msg.Q = (byte)numQ.Value; //保存到Config.xml System.Collections.Generic.Dictionary <string, string> attributes = null; ConfigUtil configUtil = new ConfigUtil(); attributes = configUtil.GetAttribute(); attributes["Antenna"] = a.ToString(); attributes["Q"] = numQ.Value.ToString(); attributes["IsLoop"] = (rbLoop.Checked) ? "1" : "0"; configUtil.Save(attributes); RFIDRead.scanMsg = msg; this.Close(); }
public MyReader(String readerName)//TCPIP_Client { _reader = new IRP1.Reader(readerName); if (_reader.ProtocolVersion == "IRP1") { XmlNode node = Common.sysit_xml.DocumentElement.SelectSingleNode("Reader[@Name='" + _reader.ReaderName + "']"); XmlNode sn = node.SelectSingleNode("ScanMessage"); #region ScanMessage IRP1.ReadTag.ReadMemoryBank rmb = (IRP1.ReadTag.ReadMemoryBank) Enum.Parse(typeof(IRP1.ReadTag.ReadMemoryBank), sn.Attributes["ReadMemoryBank"].Value); scanMsgParam.readMemoryBank = rmb; int readtime = int.Parse(sn.SelectSingleNode("ReadTime").InnerText); int stoptime = int.Parse(sn.SelectSingleNode("StopTime").InnerText); scanMsgParam.readtime = readtime; scanMsgParam.stoptime = stoptime; string readertype = "800"; if (_reader.ModelNumber.IndexOf("502E") != -1 || _reader.ModelNumber == "XC-RF811") { readertype = "500"; } if (readtime > 0 || stoptime > 0) { ScanMessage = new IRP1.ReadTag(rmb, readtime, stoptime); } else { ScanMessage = new IRP1.ReadTag(rmb); } IRP1.ReadTag rt = (IRP1.ReadTag)ScanMessage; switch (rmb) { case IRP1.ReadTag.ReadMemoryBank.EPC_6C: case IRP1.ReadTag.ReadMemoryBank.EPC_6C_ID_6B: case IRP1.ReadTag.ReadMemoryBank.EPC_PC_6C: case IRP1.ReadTag.ReadMemoryBank.EPC_TID_UserData_6C: case IRP1.ReadTag.ReadMemoryBank.EPC_TID_UserData_6C_ID_UserData_6B: case IRP1.ReadTag.ReadMemoryBank.TID_6C: case IRP1.ReadTag.ReadMemoryBank.TID_6C_ID_6B: { string[] ps = sn.SelectSingleNode("Param").InnerText.Split(','); scanMsgParam.antennaIndex = byte.Parse(ps[0]); rt.Antenna = getAntenna(ps[0], readertype); scanMsgParam.q = rt.Q = byte.Parse(ps[1]); scanMsgParam.isLoop = rt.IsLoop = ((ps[2] == "1") ? true : false); } break; case IRP1.ReadTag.ReadMemoryBank.EPC_TID_UserData_6C_2: { string[] ps = sn.SelectSingleNode("Param").InnerText.Split(','); scanMsgParam.antennaIndex = byte.Parse(ps[0]); rt.Antenna = getAntenna(ps[0], readertype); scanMsgParam.q = rt.Q = byte.Parse(ps[1]); scanMsgParam.isLoop = rt.IsLoop = ((ps[2] == "1") ? true : false); scanMsgParam.tidLen = rt.TidLen = byte.Parse(ps[3]); scanMsgParam.userdataPtr_6C = rt.UserDataPtr_6C = uint.Parse(ps[4]); scanMsgParam.userdataLen_6C = rt.UserDataLen_6C = byte.Parse(ps[5]); } break; case IRP1.ReadTag.ReadMemoryBank.EPC_TID_UserData_Reserved_6C_ID_UserData_6B: { string[] ps = sn.SelectSingleNode("Param").InnerText.Split(','); scanMsgParam.antennaIndex = byte.Parse(ps[0]); rt.Antenna = getAntenna(ps[0], readertype); scanMsgParam.q = rt.Q = byte.Parse(ps[1]); scanMsgParam.isLoop = rt.IsLoop = ((ps[2] == "1") ? true : false); scanMsgParam.tidLen = rt.TidLen = byte.Parse(ps[3]); scanMsgParam.userdataPtr_6C = rt.UserDataPtr_6C = uint.Parse(ps[4]); scanMsgParam.userdataLen_6C = rt.UserDataLen_6C = byte.Parse(ps[5]); scanMsgParam.userdataPtr_6B = rt.UserDataPtr_6B = byte.Parse(ps[6]); scanMsgParam.userdataLen_6B = rt.UserDataLen_6B = byte.Parse(ps[7]); scanMsgParam.reservedLen = rt.ReservedLen = byte.Parse(ps[8]); scanMsgParam.pwd = rt.AccessPwd = Util.ConvertHexStringToByteArray(ps[9]); scanMsgParam.readTimes_6C = rt.ReadTimes_6C = byte.Parse(ps[10]); scanMsgParam.readTimes_6B = rt.ReadTimes_6B = byte.Parse(ps[11]); } break; case IRP1.ReadTag.ReadMemoryBank.ID_6B: case IRP1.ReadTag.ReadMemoryBank.ID_UserData_6B: { string[] ps = sn.SelectSingleNode("Param").InnerText.Split(','); scanMsgParam.antennaIndex = byte.Parse(ps[0]); rt.Antenna = getAntenna(ps[0], readertype); scanMsgParam.isLoop = rt.IsLoop = ((ps[1] == "1") ? true : false); } break; } #endregion #region StopMessage StopMessage = new IRP1.PowerOff(); #endregion } }
private void btnApplyTxPwr_Click(object sender, EventArgs e) { #region Configure Antenna 1; if (nudAnt1.Text != string.Empty) { lbl_msg.Text = ""; String strSuc1 = ""; String strFai1 = ""; Byte[] aData = new Byte[2]; aData[0] = 0x00;//Antenna #1 aData[1] = (Byte)Convert.ToInt16(nudAnt1.Text); IRP1.SysConfig_800 order = new IRP1.SysConfig_800(0x65, aData); if (reader.Send(order)) { strSuc1 += "1,"; } else { strFai1 += "1,"; } if (strSuc1 == "1,") { lbl_msg.Text = lbl_msg.Text + "Ant1 Success, "; } else { lbl_msg.Text = lbl_msg.Text + "Ant1 Fail, "; } } #endregion #region Configure Antenna 2; if (nudAnt2.Text != string.Empty) { String strSuc = ""; String strFai = ""; Byte[] aData = new Byte[2]; aData[0] = 0x01;//Antenna #2 aData[1] = (Byte)Convert.ToInt16(nudAnt2.Text); IRP1.SysConfig_800 order = new IRP1.SysConfig_800(0x65, aData); if (reader.Send(order)) { strSuc += "1,"; } else { strFai += "1,"; } if (strSuc == "1,") { lbl_msg.Text = lbl_msg.Text + "Ant2 Success, "; } else { lbl_msg.Text = lbl_msg.Text + "Ant2 Fail, "; } #endregion } #region Configure Antenna 3; if (nudAnt3.Text != string.Empty) { String strSuc = ""; String strFai = ""; Byte[] aData = new Byte[2]; aData[0] = 0x02;//Antenna #3 aData[1] = (Byte)Convert.ToInt16(nudAnt3.Text); IRP1.SysConfig_800 order = new IRP1.SysConfig_800(0x65, aData); if (reader.Send(order)) { strSuc += "1,"; } else { strFai += "1,"; } if (strSuc == "1,") { lbl_msg.Text = lbl_msg.Text + "Ant3 Success, "; } else { lbl_msg.Text = lbl_msg.Text + "Ant3 Fail, "; } #endregion } #region Configure Antenna 4; if (nudAnt4.Text != string.Empty) { String strSuc = ""; String strFai = ""; Byte[] aData = new Byte[2]; aData[0] = 0x03;//Antenna #4 aData[1] = (Byte)Convert.ToInt16(nudAnt4.Text); IRP1.SysConfig_800 order = new IRP1.SysConfig_800(0x65, aData); if (reader.Send(order)) { strSuc += "1,"; } else { strFai += "1,"; } if (strSuc == "1,") { lbl_msg.Text = lbl_msg.Text + "Ant4 Success, "; } else { lbl_msg.Text = lbl_msg.Text + "Ant4 Fail, "; } #endregion } #region Configure Memory Bank, Antenna, Read Method and Q value IRP1.ReadTag.ReadMemoryBank rmb = (IRP1.ReadTag.ReadMemoryBank)Enum.Parse(typeof(IRP1.ReadTag.ReadMemoryBank), cbReadMB.Items[cbReadMB.SelectedIndex].ToString()); msg = new IRP1.ReadTag(rmb); // MessageBox.Show("Q = " + msg.Q.ToString() + " Is loop = " + msg.IsLoop.ToString()); byte a = 0x80;// if (cbAnt1.Checked) { a += 0x01; } if (cbAnt2.Checked) { a += 0x02; } if (cbAnt3.Checked) { a += 0x04; } if (cbAnt4.Checked) { a += 0x08; } msg.Antenna = a; msg.IsLoop = (rbContinuous.Checked) ? true : false; msg.Q = (byte)numQ.Value; //set Q byte[] bs = new byte[1]; bs[0] = (Byte)numQ.Value; IRP1.TagOperationConfig_6C msg1 = new IRP1.TagOperationConfig_6C(0x10, bs); if (reader.Send(msg1)) { lbl_msg.Text = lbl_msg.Text + "Q = " + numQ.Value.ToString(); } else { lbl_msg.Text = lbl_msg.Text + "Error Setting Q"; } #endregion }