private void button1_Click(object sender, EventArgs e) { try { rd = Reader.Create("192.168.1.101", ModuleTech.Region.NA, 4); } catch (Exception ex) { MessageBox.Show("连接失败,请检查读写器地址是否正确" + ex.ToString()); return; } lst1.Items.Add("连接成功!"); int[] connectedants = (int[])rd.ParamGet("ConnectedAntennas"); for (int c = 0; c < connectedants.Length; ++c) { lst1.Items.Add(c + "->" + connectedants[c]); } TagFilter tf = (TagFilter)rd.ParamGet("Singulation"); // rd.read int[] ants = new int[] { 1, 4 }; Gen2TagFilter filter = new Gen2TagFilter(ByteFormat.FromHex("FFFFFFFF"), MemBank.EPC, 32, false); rd.ParamSet("Singulation", filter); SimpleReadPlan searchPlan = new SimpleReadPlan(ants); rd.ParamSet("ReadPlan", searchPlan); }
void ReConnect(Mach mc) { int i, j, k; String Ret = ""; if (mc.ReConnectedCount > 5) { /*本设备重连超过五次不成功,可能连接存在问题 */ MyManager.AddInfoToDB("错误", mc.MachName + "重连5次不成功,不再尝试连接。"); return; } try { mc.ReConnectedCount++; MyManager.AddInfoToDB("信息", mc.MachName + "开始重连."); mc.rd = Reader.Create(mc.MachIP, ModuleTech.Region.NA, 4); int[] connectedants = (int[])mc.rd.ParamGet("ConnectedAntennas"); if (connectedants.Length < 1) { Ret = ""; int[] xx = { 0, 0, 0, 0 }; for (j = 0; j < connectedants.Length; j++) { xx[connectedants[j] - 1] = 1; } for (k = 0; k < 4; k++) { if (xx[k] == 0) { Ret += (k + 1).ToString() + " "; } } Ret = mc.MachName + "," + Ret + "号天线未连接!!"; MyManager.AddInfoToDB("错误", Ret); } mc.ConnectedAnts = (int[])connectedants.Clone(); Gen2TagFilter filter = new Gen2TagFilter(ByteFormat.FromHex("FFFFFFFF"), MemBank.EPC, 32, false); mc.rd.ParamSet("Singulation", filter); SimpleReadPlan searchPlan = new SimpleReadPlan(mc.ConnectedAnts); mc.rd.ParamSet("ReadPlan", searchPlan); mc.Mthread = new Thread(new ParameterizedThreadStart(TagMonitorThread)); mc.Mthread.Start(mc); MyManager.AddInfoToDB("信息", mc.MachName + "重连并启动监视线程成功!"); mc.ReConnectedCount--; } catch (Exception ex) { Ret = mc.MachName + ",重连-->" + ex.ToString(); MyManager.AddInfoToDB("错误", Ret); ReConnect(mc); } mc.ReConnectedCount = 0; }
/************************************************************************/ /*写入标签方法 */ /************************************************************************/ public int WritertEPC(string _EpcStr, Window win) { Gen2TagFilter filter = null; byte[] filterbytes = new byte[(_EpcStr.Length - 1) / 8 + 1]; for (int c = 0; c < filterbytes.Length; ++c) { filterbytes[c] = 0; } int bitcnt = 0; foreach (Char ch in _EpcStr.Trim()) { if (ch == '1') { filterbytes[bitcnt / 8] |= (byte)(0x01 << (7 - bitcnt % 8)); } bitcnt++; } //modulerdr.ParamSet("AccessPassword", (uint)0); if (IsValidHexstr(_EpcStr.Trim(), 600) != 0) { JXMessageBox.Show(win, "将要写入的数据是16进制的字符,且长度为4字符的整数倍", MsgImage.Error); return(BaseRequest.ERROR); } try { modulerdr.WriteTag(filter, new TagData(_EpcStr.Trim())); JXMessageBox.Show(win, "写入标签成功!", MsgImage.Success); } catch (Exception ex) { JXMessageBox.Show(win, "写入标签失败,请检查设备是否正常状态!", MsgImage.Error); return(BaseRequest.ERROR); } if (modulerdr != null) { modulerdr.Disconnect(); } return(BaseRequest.SUCCESS); }
/************************************************************************/ /* 读取标签方法 */ /************************************************************************/ public string ReaderEPC() { Gen2TagFilter filter = null; modulerdr.ParamSet("AccessPassword", (uint)0); ushort[] readdata = null; try { int index = 1; int st = Environment.TickCount; readdata = modulerdr.ReadTagMemWords(filter, (MemBank)index, 2, 6); Debug.WriteLine("read dur :" + (Environment.TickCount - st).ToString()); if (rParms.setGPO1) { modulerdr.GPOSet(1, true); System.Threading.Thread.Sleep(20); modulerdr.GPOSet(1, false); } } catch (OpFaidedException notagexp) { if (notagexp.ErrCode == 0x400) { MessageBox.Show("没法发现标签"); } else { MessageBox.Show("操作失败:" + notagexp.ToString()); } } catch (Exception ex) { MessageBox.Show("操作失败:" + ex.ToString()); } string readdatastr = ""; for (int i = 0; i < readdata.Length; ++i) { readdatastr += readdata[i].ToString("X4"); } return(readdatastr); }
void CreateMonitorThreads() { int i, unFinished = 0; if (MachLst.Count == 0) { return; } for (i = 0, unFinished = 0; i < MachLst.Count; i++) { if (MachLst[i].rd == null) { unFinished = 1; MyManager.AddInfoToDB("错误", MachLst[i].MachName + "未建立连接!"); lst1.Items.Add(MachLst[i].MachName + "未建立连接!"); break; } //只显示EPC以FFFF FFFF开头的标签 Gen2TagFilter filter = new Gen2TagFilter(ByteFormat.FromHex("FFFFFFFF"), MemBank.EPC, 32, false); MachLst[i].rd.ParamSet("Singulation", filter); SimpleReadPlan searchPlan = new SimpleReadPlan(MachLst[i].ConnectedAnts); MachLst[i].rd.ParamSet("ReadPlan", searchPlan); MachLst[i].Mthread = new Thread(new ParameterizedThreadStart(TagMonitorThread)); } if (unFinished == 1) { return; } for (i = 0; i < MachLst.Count; i++) { MachLst[i].Mthread.Start(MachLst[i]); lst1.Items.Add("启动" + MachLst[i].Mthread); } lst1.Items.Add("创建线程完毕!"); }
int checkfilter(ref Gen2TagFilter flt) { if (this.cbisfilter.Checked) { int ret = Form1.IsValidBinaryStr(this.tbfldata.Text.Trim()); switch (ret) { case -3: MessageBox.Show("please input data for match"); return(-1); case -1: MessageBox.Show("match data must be binary string"); return(-1); } if (ret != 0) { return(-1); } if (this.cbbfilterbank.SelectedIndex == -1) { MessageBox.Show("please select filter bank"); return(-1); } if (this.cbbfilterrule.SelectedIndex == -1) { MessageBox.Show("please select filter rule"); return(-1); } int bitaddr = 0; if (this.tbfilteraddr.Text.Trim() == "") { MessageBox.Show("please input starting address in bit"); return(-1); } else { try { bitaddr = int.Parse(this.tbfilteraddr.Text.Trim()); } catch (Exception exc) { MessageBox.Show("starting address must be number"); return(-1); } if (bitaddr < 0) { MessageBox.Show("starting address must be more than zero"); return(-1); } } byte[] filterbytes = new byte[(this.tbfldata.Text.Trim().Length - 1) / 8 + 1]; for (int c = 0; c < filterbytes.Length; ++c) { filterbytes[c] = 0; } int bitcnt = 0; foreach (Char ch in this.tbfldata.Text.Trim()) { if (ch == '1') { filterbytes[bitcnt / 8] |= (byte)(0x01 << (7 - bitcnt % 8)); } bitcnt++; } flt = new Gen2TagFilter(this.tbfldata.Text.Trim().Length, filterbytes, (MemBank)this.cbbfilterbank.SelectedIndex + 1, bitaddr, this.cbbfilterrule.SelectedIndex == 0 ? false : true); return(0); } flt = null; return(0); }
void writetagfunc() { mordr.ParamSet("OpTimeout", (ushort)1000); mordr.ParamSet("TagopProtocol", TagProtocol.GEN2); EmbededCmdData emd = null; mordr.ParamSet("ReadPlan", new SimpleReadPlan(TagProtocol.GEN2, Invants.ToArray(), 30)); if (writefilter.isfilter) { emd = new EmbededCmdData(writefilter.bank, (uint)writefilter.addr, (byte)(writefilter.flen * 2)); } mordr.ParamSet("EmbededCmdOfInventory", emd); int readdur = 0; int genblf = (int)mordr.ParamGet("gen2BLF"); if (genblf < 640) { readdur = 60 * Invants.Count; } else { readdur = 30 * Invants.Count; } TagReadData[] tags = null; int successcnt = 0; int writecnt = 0; while (IsThreadRun) { try { tags = mordr.Read(readdur); } catch (ModuleLibrary.ModuleException ex) { IsThreadRun = false; this.BeginInvoke(new UpdateUi(UpdateTipLab), "异常码" + ex.ErrCode.ToString() + ",退出操作", true); return; } if (tags.Length > 0) { Gen2TagFilter tagfilter = null; if (writefilter.isfilter && (tags[0].EbdData != null)) { tagfilter = new Gen2TagFilter(writefilter.flen * 16, tags[0].EbdData, writefilter.bank, writefilter.addr * 16, false); } mordr.ParamSet("TagopAntenna", tags[0].Antenna); writecnt = 0; foreach (Gen2WriteDataItem item in WriteDataItems) { try { mordr.WriteTagMemWords(tagfilter, item.bank, item.addr, item.wdata); writecnt++; } catch { break; } } if (writecnt == WriteDataItems.Count) { if (!isrepeatwrite) { IsThreadRun = false; this.BeginInvoke(new UpdateUi(UpdateTipLab), "成功写入,退出操作", true); return; } else { successcnt++; this.BeginInvoke(new UpdateUi(UpdateTipLab), ("成功写入" + successcnt.ToString()), false); } } } } }
private void autoAcqData_Elapsed(object sender, ElapsedEventArgs e) { if (rdr != null) { try { tagMutex.WaitOne(); byte[] binaryStr = ByteFormat.FromHex(curEPC); Gen2TagFilter filter = new Gen2TagFilter(ByteFormat.FromHex(curEPC), ModuleTech.Gen2.MemBank.EPC, 32, false); rdr.ParamSet("Singulation", filter); for (int i = 0; i < readCount; i++) { TagReadData[] tempData = rdr.Read(200); if (tempData.Length != 0) { tagMutex.ReleaseMutex(); return; } } if (meb != null) { initialAllInfo(); } rdr.ParamSet("Singulation", null); EmbededCmdData ecd = new EmbededCmdData(MemBank.TID, TIDStart, TIDEnd); rdr.ParamSet("EmbededCmdOfInventory", ecd); for (int i = 0; i < readCount; i++) { TagReadData[] tagDatas = rdr.Read(200); if (tagDatas.Length != 0) { foreach (TagReadData tag in tagDatas) { bool isRead = false; foreach (tagInfo temp in tagList) { if (temp.epcid == tag.EPCString) { isRead = true; } } if (!isRead) { updateTagData(tag); } } } } if (meb != null) { refreshDataView(); if (!sendDataToUser()) { MessageBox.Show("发送失败"); } else { MessageBox.Show("发送成功,用户可以通过!"); } } tagMutex.ReleaseMutex(); //autoAcq.Enabled = false; } catch (OpFaidedException exxx) { //MessageBox.Show("read wrong"); } } }
int checkfilter(ref Gen2TagFilter flt) { if (this.cbisfilter.Checked) { int ret = Form1.IsValidBinaryStr(this.tbfldata.Text.Trim()); switch (ret) { case -3: MessageBox.Show("匹配数据不能为空"); return(-1); case -1: MessageBox.Show("匹配数据只能是二进制字符串"); return(-1); } if (ret != 0) { return(-1); } if (this.cbbfilterbank.SelectedIndex == -1) { MessageBox.Show("请选择过滤bank"); return(-1); } if (this.cbbfilterrule.SelectedIndex == -1) { MessageBox.Show("请输入过滤规则"); return(-1); } int bitaddr = 0; if (this.tbfilteraddr.Text.Trim() == "") { MessageBox.Show("请输入过滤bank的起始地址,以字为最小单位"); return(-1); } else { try { bitaddr = int.Parse(this.tbfilteraddr.Text.Trim()); } catch (Exception exc) { MessageBox.Show("起始地址请输入数字"); return(-1); } if (bitaddr < 0) { MessageBox.Show("地址必须大于零"); return(-1); } } byte[] filterbytes = new byte[(this.tbfldata.Text.Trim().Length - 1) / 8 + 1]; for (int c = 0; c < filterbytes.Length; ++c) { filterbytes[c] = 0; } int bitcnt = 0; foreach (Char ch in this.tbfldata.Text.Trim()) { if (ch == '1') { filterbytes[bitcnt / 8] |= (byte)(0x01 << (7 - bitcnt % 8)); } bitcnt++; } flt = new Gen2TagFilter(this.tbfldata.Text.Trim().Length, filterbytes, (MemBank)this.cbbfilterbank.SelectedIndex + 1, bitaddr, this.cbbfilterrule.SelectedIndex == 0 ? false : true); return(0); } flt = null; return(0); }
private void button1_Click(object sender, EventArgs e) { int rdur = 0; int sdur = 0; frm1.rParms.isUniByEmd = this.cbisunibynullemd.Checked; frm1.rParms.isChangeColor = this.cbischgcolor.Checked; frm1.rParms.isUniByAnt = this.cbisunibyant.Checked; try { rdur = int.Parse(this.tbreaddur.Text.Trim()); sdur = int.Parse(this.tbsleepdur.Text.Trim()); } catch (Exception ex) { MessageBox.Show("Inventory duration and interval must be numbers in millisecond"); return; } frm1.rParms.readdur = rdur; frm1.rParms.sleepdur = sdur; frm1.rParms.isRevertAnts = this.cbisrevertants.Checked; if (this.cbisOneReadOneTime.Checked) { frm1.rParms.isOneReadOneTime = true; } else { frm1.rParms.isOneReadOneTime = false; } if (this.cbisReadFixCount.Checked) { if (this.tbReadCount.Text.Trim() == string.Empty) { MessageBox.Show("please input inventory count"); return; } try { frm1.rParms.FixReadCount = int.Parse(this.tbReadCount.Text.Trim()); } catch (System.Exception ere) { MessageBox.Show(ere.ToString()); return; } if (frm1.rParms.FixReadCount <= 0) { MessageBox.Show("inventory count must be more than zero"); return; } frm1.rParms.isReadFixCount = true; } else { frm1.rParms.isReadFixCount = false; frm1.rParms.FixReadCount = 0; } if (this.cbisfilter.Checked) { int ret = Form1.IsValidBinaryStr(this.tbfilterdata.Text.Trim()); switch (ret) { case -3: MessageBox.Show("please input data for match"); break; case -1: MessageBox.Show("match data must be binary string"); break; } if (ret != 0) { return; } if (this.cbbfilterbank.SelectedIndex == -1) { MessageBox.Show("please select filter bank"); return; } if (this.cbbfilterrule.SelectedIndex == -1) { MessageBox.Show("please select filter rule"); return; } int bitaddr = 0; if (this.tbfilteraddr.Text.Trim() == "") { MessageBox.Show("please input starting address in bit"); return; } else { try { bitaddr = int.Parse(this.tbfilteraddr.Text.Trim()); } catch (Exception exc) { MessageBox.Show("starting address must be number"); return; } if (bitaddr < 0) { MessageBox.Show("starting address must be more than zero"); return; } } byte[] filterbytes = new byte[(this.tbfilterdata.Text.Trim().Length - 1) / 8 + 1]; for (int c = 0; c < filterbytes.Length; ++c) { filterbytes[c] = 0; } int bitcnt = 0; foreach (Char ch in this.tbfilterdata.Text.Trim()) { if (ch == '1') { filterbytes[bitcnt / 8] |= (byte)(0x01 << (7 - bitcnt % 8)); } bitcnt++; } Gen2TagFilter filter = new Gen2TagFilter(this.tbfilterdata.Text.Trim().Length, filterbytes, (MemBank)this.cbbfilterbank.SelectedIndex + 1, bitaddr, this.cbbfilterrule.SelectedIndex == 0 ? false : true); frm1.modulerdr.ParamSet("Singulation", filter); } else { frm1.modulerdr.ParamSet("Singulation", null); } if (!(frm1.rParms.readertype == ReaderType.PR_ONEANT || frm1.modulerdr.HwDetails.module == Reader.Module_Type.MODOULE_R902_MT100)) { if (this.cbisaddiondata.Checked) { int wordaddr = 0; int ebbytescnt; if (this.tbebstartaddr.Text.Trim() == "") { MessageBox.Show("please input starting address of embedded data bank in word"); return; } else { try { wordaddr = int.Parse(this.tbebstartaddr.Text.Trim()); } catch (Exception exc) { MessageBox.Show("starting address must be number"); return; } if (wordaddr < 0) { MessageBox.Show("starting address must be more than zero"); return; } } if (this.tbebbytescnt.Text.Trim() == "") { MessageBox.Show("please input starting address of embedded data bank in word"); return; } else { try { ebbytescnt = int.Parse(this.tbebbytescnt.Text.Trim()); } catch (Exception exc) { MessageBox.Show("the byte count to read of embedded data must be number"); return; } if (ebbytescnt < 0 || ebbytescnt > 32) { MessageBox.Show("the byte count to read of embedded data must be in the range of 0-33"); return; } } if (this.cbbebbank.SelectedIndex == -1) { MessageBox.Show("please select bank of embedded data"); return; } EmbededCmdData ecd = new EmbededCmdData((MemBank)this.cbbebbank.SelectedIndex, (UInt32)wordaddr, (byte)ebbytescnt); frm1.modulerdr.ParamSet("EmbededCmdOfInventory", ecd); } else { frm1.modulerdr.ParamSet("EmbededCmdOfInventory", null); } if (this.cbispwd.Checked) { int ret = Form1.IsValidPasswd(this.tbacspwd.Text.Trim()); { switch (ret) { case -3: MessageBox.Show("please input access password"); break; case -2: case -4: MessageBox.Show("access password must be 8 of hexadecimal numbers"); break; case -1: MessageBox.Show("access password must be 8 of hexadecimal numbers"); break; } } if (ret != 0) { return; } else { uint passwd = uint.Parse(this.tbacspwd.Text.Trim(), System.Globalization.NumberStyles.AllowHexSpecifier); frm1.modulerdr.ParamSet("AccessPassword", passwd); } } else { frm1.modulerdr.ParamSet("AccessPassword", (uint)0); } } this.Close(); }
private void btnsetimpinjqt_Click(object sender, EventArgs e) { int ret; ret = IsAntSet(); if (ret == -1) { MessageBox.Show("请选择操作天线"); return; } else if (ret == 1) { DialogResult stat = DialogResult.OK; stat = MessageBox.Show("在未检测到天线的端口执行操作,真的要执行吗?", "警告", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); if (stat != DialogResult.OK) { return; } } byte[] pwd = null; ret = Form1.IsValidPasswd(this.tbaccesspasswd.Text.Trim()); { switch (ret) { case -3: MessageBox.Show("访问密码不能为空"); break; case -2: case -4: MessageBox.Show("访问密码必须是8个16进制数"); break; case -1: MessageBox.Show("访问密码只能是16进制数字"); break; } } if (ret != 0) { return; } else { pwd = ByteFormat.FromHex(this.tbaccesspasswd.Text.Trim()); } Gen2TagFilter filter = null; if (checkfilter(ref filter) != 0) { return; } if ((!this.rbimpinjqtread.Checked) && (!this.rbimpinjwrite.Checked)) { MessageBox.Show("请选择命令类型"); return; } try { if (this.rbimpinjqtread.Checked) { IMPINJ_M4_QtPara para = new IMPINJ_M4_QtPara(pwd); IMPINJ_M4_QtResult qtret = (IMPINJ_M4_QtResult)mrdr.CustomCmd(filter, CustomCmdType.IMPINJ_M4_Qt, para); if (qtret.MemType == IMPINJ_M4_QtPara.IMPINJ_Qt_Mem_Type.IMPINJ_Qt_Mem_Private) { this.rbimpinjqtmemprivate.Checked = true; } else { this.rbimpinjqtmempublic.Checked = true; } if (qtret.RangeType == IMPINJ_M4_QtPara.IMPINJ_Qt_Range_Type.IMPINJ_Qt_Range_FarField) { this.rbimpinjqtfarfield.Checked = true; } else { this.rbimpinjqtnearfiled.Checked = true; } } else { if ((!rbimpinjqtnearfiled.Checked) && (!rbimpinjqtfarfield.Checked)) { MessageBox.Show("请选择识别距离"); return; } if ((!rbimpinjqtmemprivate.Checked) && (!rbimpinjqtmempublic.Checked)) { MessageBox.Show("请选择内存视图"); return; } if ((!rbimpinjqtperm.Checked) && (!rbimpinjqttemp.Checked)) { MessageBox.Show("请选择状态类型"); return; } IMPINJ_M4_QtPara.IMPINJ_Qt_Range_Type trange = IMPINJ_M4_QtPara.IMPINJ_Qt_Range_Type.IMPINJ_Qt_Range_Invalid; IMPINJ_M4_QtPara.IMPINJ_Qt_Persist_Type tpersist = IMPINJ_M4_QtPara.IMPINJ_Qt_Persist_Type.IMPINJ_Qt_Persist_Invalid; IMPINJ_M4_QtPara.IMPINJ_Qt_Mem_Type tmem = IMPINJ_M4_QtPara.IMPINJ_Qt_Mem_Type.IMPINJ_Qt_Mem_Invalid; if (rbimpinjqtnearfiled.Checked) { trange = IMPINJ_M4_QtPara.IMPINJ_Qt_Range_Type.IMPINJ_Qt_Range_NearField; } else { trange = IMPINJ_M4_QtPara.IMPINJ_Qt_Range_Type.IMPINJ_Qt_Range_FarField; } if (rbimpinjqtmemprivate.Checked) { tmem = IMPINJ_M4_QtPara.IMPINJ_Qt_Mem_Type.IMPINJ_Qt_Mem_Private; } else { tmem = IMPINJ_M4_QtPara.IMPINJ_Qt_Mem_Type.IMPINJ_Qt_Mem_Public; } if (rbimpinjqtperm.Checked) { tpersist = IMPINJ_M4_QtPara.IMPINJ_Qt_Persist_Type.IMPINJ_Qt_Persist_Perm; } else { tpersist = IMPINJ_M4_QtPara.IMPINJ_Qt_Persist_Type.IMPINJ_Qt_Persist_Temp; } IMPINJ_M4_QtPara para = new IMPINJ_M4_QtPara(pwd, tpersist, trange, tmem); mrdr.CustomCmd(filter, CustomCmdType.IMPINJ_M4_Qt, para); } } catch (OpFaidedException notagexp) { if (notagexp.ErrCode == 0x400) { MessageBox.Show("没法发现标签"); } else { MessageBox.Show("操作失败:" + notagexp.ToString()); } return; } catch (Exception ex) { MessageBox.Show("操作失败:" + ex.ToString()); return; } }
private void btnResetReadProtect_Click(object sender, EventArgs e) { int ret; ret = IsAntSet(); if (ret == -1) { MessageBox.Show("请选择操作天线"); return; } else if (ret == 1) { DialogResult stat = DialogResult.OK; stat = MessageBox.Show("在未检测到天线的端口执行操作,真的要执行吗?", "警告", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); if (stat != DialogResult.OK) { return; } } byte[] pwd = null; ret = Form1.IsValidPasswd(this.tbaccesspasswd.Text.Trim()); { switch (ret) { case -3: MessageBox.Show("访问密码不能为空"); break; case -2: case -4: MessageBox.Show("访问密码必须是8个16进制数"); break; case -1: MessageBox.Show("访问密码只能是16进制数字"); break; } } if (ret != 0) { return; } else { pwd = ByteFormat.FromHex(this.tbaccesspasswd.Text.Trim()); } Gen2TagFilter filter = null; if (checkfilter(ref filter) != 0) { return; } try { NXP_ResetReadProtectPara para = new NXP_ResetReadProtectPara(pwd); mrdr.CustomCmd(filter, CustomCmdType.NXP_ResetReadProtect, para); } catch (OpFaidedException notagexp) { if (notagexp.ErrCode == 0x400) { MessageBox.Show("没法发现标签"); } else { MessageBox.Show("操作失败:" + notagexp.ToString()); } return; } catch (Exception ex) { MessageBox.Show("操作失败:" + ex.ToString()); return; } }
private void btnbrl_Click(object sender, EventArgs e) { int ret; ret = IsAntSet(); if (ret == -1) { MessageBox.Show("请选择操作天线"); return; } else if (ret == 1) { DialogResult stat = DialogResult.OK; stat = MessageBox.Show("在未检测到天线的端口执行操作,真的要执行吗?", "警告", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); if (stat != DialogResult.OK) { return; } } byte[] pwd = null; ret = Form1.IsValidPasswd(this.tbaccesspasswd.Text.Trim()); { switch (ret) { case -3: MessageBox.Show("访问密码不能为空"); break; case -2: case -4: MessageBox.Show("访问密码必须是8个16进制数"); break; case -1: MessageBox.Show("访问密码只能是16进制数字"); break; } } if (ret != 0) { return; } else { pwd = ByteFormat.FromHex(this.tbaccesspasswd.Text.Trim()); } byte bitmap = 0; if (cb1.Checked) { bitmap |= 1 << 7; } if (cb2.Checked) { bitmap |= 1 << 6; } if (cb3.Checked) { bitmap |= 1 << 5; } if (cb4.Checked) { bitmap |= 1 << 4; } if (cb5.Checked) { bitmap |= 1 << 3; } if (cb6.Checked) { bitmap |= 1 << 2; } if (cb7.Checked) { bitmap |= 1 << 1; } if (cb8.Checked) { bitmap |= 1 << 0; } Gen2TagFilter filter = null; if (checkfilter(ref filter) != 0) { return; } try { ALIEN_Higgs3_BlockReadLockPara para = new ALIEN_Higgs3_BlockReadLockPara(bitmap, pwd); mrdr.CustomCmd(filter, CustomCmdType.ALIEN_Higgs3_BlockReadLock, para); } catch (OpFaidedException notagexp) { if (notagexp.ErrCode == 0x400) { MessageBox.Show("没法发现标签"); } else { MessageBox.Show("操作失败:" + notagexp.ToString()); } return; } catch (Exception ex) { MessageBox.Show("操作失败" + ex.ToString()); return; } }
private void btnResetReadProtect_Click(object sender, EventArgs e) { int ret; ret = IsAntSet(); if (ret == -1) { MessageBox.Show("please select antenna"); return; } else if (ret == 1) { DialogResult stat = DialogResult.OK; stat = MessageBox.Show("execute operation on the port without finding antenna ?", "tip-off", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); if (stat != DialogResult.OK) { return; } } byte[] pwd = null; ret = Form1.IsValidPasswd(this.tbaccesspasswd.Text.Trim()); { switch (ret) { case -3: MessageBox.Show("please input access password"); break; case -2: case -4: MessageBox.Show("access password must be 8 of hexadecimal numbers"); break; case -1: MessageBox.Show("access password must be 8 of hexadecimal numbers"); break; } } if (ret != 0) { return; } else { pwd = ByteFormat.FromHex(this.tbaccesspasswd.Text.Trim()); } Gen2TagFilter filter = null; if (checkfilter(ref filter) != 0) { return; } try { NXP_ResetReadProtectPara para = new NXP_ResetReadProtectPara(pwd); mrdr.CustomCmd(filter, CustomCmdType.NXP_ResetReadProtect, para); } catch (OpFaidedException notagexp) { if (notagexp.ErrCode == 0x400) { MessageBox.Show("no tag"); } else { MessageBox.Show("operation failed:" + notagexp.ToString()); } return; } catch (Exception ex) { MessageBox.Show("operation failed:" + ex.ToString()); return; } }
private void button1_Click(object sender, EventArgs e) { int rdur = 0; int sdur = 0; //added on 3-26 if (this.cbisidtant.Checked) { if ((!this.rbidtantbydur.Checked) && (!this.rbidtantafter.Checked)) { MessageBox.Show("请选择判决模式"); return; } if (this.rbidtantbydur.Checked) { if (this.tbidtdur.Text.Trim() == string.Empty) { MessageBox.Show("请输入判决时间"); return; } try { int pjsj = int.Parse(this.tbidtdur.Text.Trim()); if (pjsj <= 0) { MessageBox.Show("判决时间必须大于0"); return; } } catch { MessageBox.Show("判决时间必须大于0"); return; } } if (this.rbidtantafter.Checked) { if (this.tbafttime.Text.Trim() == string.Empty) { MessageBox.Show("请输入等待时间"); return; } try { int ddsj = int.Parse(this.tbafttime.Text.Trim()); if (ddsj <= 0) { MessageBox.Show("等待时间必须大于0"); return; } } catch { MessageBox.Show("等待时间必须大于0"); return; } } } frm1.rParms.isUniByEmd = this.cbisunibynullemd.Checked; frm1.rParms.isChangeColor = this.cbischgcolor.Checked; frm1.rParms.isUniByAnt = this.cbisunibyant.Checked; try { rdur = int.Parse(this.tbreaddur.Text.Trim()); sdur = int.Parse(this.tbsleepdur.Text.Trim()); } catch (Exception ex) { MessageBox.Show("读时长和读间隔只能输入整数,单位为毫秒"); return; } frm1.rParms.readdur = rdur; frm1.rParms.sleepdur = sdur; frm1.rParms.isRevertAnts = this.cbisrevertants.Checked; if (this.cbisOneReadOneTime.Checked) { frm1.rParms.isOneReadOneTime = true; } else { frm1.rParms.isOneReadOneTime = false; } if (this.cbisReadFixCount.Checked) { if (this.tbReadCount.Text.Trim() == string.Empty) { MessageBox.Show("请输入固定读次数"); return; } try { frm1.rParms.FixReadCount = int.Parse(this.tbReadCount.Text.Trim()); } catch (System.Exception ere) { MessageBox.Show(ere.ToString()); return; } if (frm1.rParms.FixReadCount <= 0) { MessageBox.Show("读次数必须大于0"); return; } frm1.rParms.isReadFixCount = true; } else { frm1.rParms.isReadFixCount = false; frm1.rParms.FixReadCount = 0; } if (this.cbisfilter.Checked) { int ret = Form1.IsValidBinaryStr(this.tbfilterdata.Text.Trim()); switch (ret) { case -3: MessageBox.Show("匹配数据不能为空"); break; case -1: MessageBox.Show("匹配数据只能是二进制字符串"); break; } if (ret != 0) { return; } if (this.cbbfilterbank.SelectedIndex == -1) { MessageBox.Show("请选择过滤bank"); return; } if (this.cbbfilterrule.SelectedIndex == -1) { MessageBox.Show("请输入过滤规则"); return; } int bitaddr = 0; if (this.tbfilteraddr.Text.Trim() == "") { MessageBox.Show("请输入过滤bank的起始地址,以字为最小单位"); return; } else { try { bitaddr = int.Parse(this.tbfilteraddr.Text.Trim()); } catch (Exception exc) { MessageBox.Show("起始地址请输入数字"); return; } if (bitaddr < 0) { MessageBox.Show("地址必须大于零"); return; } } byte[] filterbytes = new byte[(this.tbfilterdata.Text.Trim().Length - 1) / 8 + 1]; for (int c = 0; c < filterbytes.Length; ++c) { filterbytes[c] = 0; } int bitcnt = 0; foreach (Char ch in this.tbfilterdata.Text.Trim()) { if (ch == '1') { filterbytes[bitcnt / 8] |= (byte)(0x01 << (7 - bitcnt % 8)); } bitcnt++; } Gen2TagFilter filter = new Gen2TagFilter(this.tbfilterdata.Text.Trim().Length, filterbytes, (MemBank)this.cbbfilterbank.SelectedIndex + 1, bitaddr, this.cbbfilterrule.SelectedIndex == 0 ? false : true); frm1.modulerdr.ParamSet("Singulation", filter); } else { frm1.modulerdr.ParamSet("Singulation", null); } //|| frm1.modulerdr.HwDetails.module == Reader.Module_Type.MODOULE_R902_MT100 if (!(frm1.rParms.readertype == ReaderType.PR_ONEANT)) { if (this.cbisaddiondata.Checked) { int wordaddr = 0; int ebbytescnt; if (this.tbebstartaddr.Text.Trim() == "") { MessageBox.Show("请输入附加数据bank的起始地址,以字为最小单位"); return; } else { try { wordaddr = int.Parse(this.tbebstartaddr.Text.Trim()); } catch (Exception exc) { MessageBox.Show("起始地址请输入数字"); return; } if (wordaddr < 0) { MessageBox.Show("地址必须大于零"); return; } } if (this.tbebbytescnt.Text.Trim() == "") { MessageBox.Show("请输入附加数据bank的起始地址,以字为最小单位"); return; } else { try { ebbytescnt = int.Parse(this.tbebbytescnt.Text.Trim()); } catch (Exception exc) { MessageBox.Show("附加数据字节数请输入数字"); return; } if (ebbytescnt < 0 || ebbytescnt > 128) { MessageBox.Show("附加数据字节数必须大于零且小于等于128"); return; } } if (this.cbbebbank.SelectedIndex == -1) { MessageBox.Show("请选择附加数据的bank"); return; } EmbededCmdData ecd = new EmbededCmdData((MemBank)this.cbbebbank.SelectedIndex, (UInt32)wordaddr, (byte)ebbytescnt); frm1.modulerdr.ParamSet("EmbededCmdOfInventory", ecd); } else { frm1.modulerdr.ParamSet("EmbededCmdOfInventory", null); } if (this.cbispwd.Checked) { int ret = Form1.IsValidPasswd(this.tbacspwd.Text.Trim()); { switch (ret) { case -3: MessageBox.Show("访问密码不能为空"); break; case -2: case -4: MessageBox.Show("访问密码必须是8个16进制数"); break; case -1: MessageBox.Show("访问密码只能是16进制数字"); break; } } if (ret != 0) { return; } else { uint passwd = uint.Parse(this.tbacspwd.Text.Trim(), System.Globalization.NumberStyles.AllowHexSpecifier); frm1.modulerdr.ParamSet("AccessPassword", passwd); } } else { frm1.modulerdr.ParamSet("AccessPassword", (uint)0); } // if (frm1.modulerdr.HwDetails.board != Reader.MaindBoard_Type.MAINBOARD_ARM9) // { if (this.gbpotlweight.Enabled) { if (this.tbwtgen2.Text.Trim() == string.Empty || this.tbwt180006b.Text.Trim() == string.Empty || this.tbwtipx256.Text.Trim() == string.Empty || this.tbwtipx64.Text.Trim() == string.Empty) { MessageBox.Show("请输入协议权重值"); return; } else { frm1.rParms.weight180006b = int.Parse(this.tbwt180006b.Text.Trim()); frm1.rParms.weightgen2 = int.Parse(this.tbwtgen2.Text.Trim()); frm1.rParms.weightipx256 = int.Parse(this.tbwtipx256.Text.Trim()); frm1.rParms.weightipx64 = int.Parse(this.tbwtipx64.Text.Trim()); } } if (this.gbsecureread.Enabled) { if (this.cbissecureread.Checked) { uint srpwd = 0; int srindexsbit = 96; int srindexbitsnum = 8; EmdSecureReadData.ESRD_TagType tagtype = EmdSecureReadData.ESRD_TagType.ESRD_TagType_None; if (this.tbsraddress.Text.Trim() == string.Empty) { MessageBox.Show("请输入安全附加数据起始地址"); return; } if (this.tbsrblks.Text.Trim() == string.Empty) { MessageBox.Show("请输入安全附加数据读块数"); return; } if (this.cbbsrbank.SelectedIndex == -1) { MessageBox.Show("请选择安全附加数据bank"); return; } if (this.cbbsrpwdtype.SelectedIndex == -1) { MessageBox.Show("请选择密码类型"); return; } if (this.cbbsrpwdtype.SelectedIndex == 0) { if (this.tbsracspwd.Text.Trim() == string.Empty) { MessageBox.Show("请输入固定的访问密码"); return; } srpwd = uint.Parse(this.tbsracspwd.Text.Trim(), System.Globalization.NumberStyles.AllowHexSpecifier); } if (this.cbbsrpwdtype.SelectedIndex == 1) { if (this.tbsrindexstartbit.Text.Trim() == string.Empty) { MessageBox.Show("请输入索引起始 bit"); return; } srindexsbit = int.Parse(this.tbsrindexstartbit.Text.Trim()); if (this.tbindexbitsnum.Text.Trim() == string.Empty) { MessageBox.Show("请输入索引bit数"); return; } srindexbitsnum = int.Parse(this.tbindexbitsnum.Text.Trim()); } if (this.cbbsrtagtype.SelectedIndex == -1) { MessageBox.Show("请选择标签类型"); return; } else if (this.cbbsrtagtype.SelectedIndex == 0) { tagtype = EmdSecureReadData.ESRD_TagType.ESRD_Alien_Higgs3; } else { tagtype = EmdSecureReadData.ESRD_TagType.ESRD_Impinj_M4; } EmdSecureReadData esrd = null; if (this.cbbsrpwdtype.SelectedIndex == 0) { esrd = new EmdSecureReadData(tagtype, (MemBank)this.cbbsrbank.SelectedIndex, int.Parse(this.tbsraddress.Text.Trim()), int.Parse(this.tbsrblks.Text.Trim()), srpwd); } else { esrd = new EmdSecureReadData(tagtype, srindexsbit, srindexbitsnum, (MemBank)this.cbbsrbank.SelectedIndex, int.Parse(this.tbsraddress.Text.Trim()), int.Parse(this.tbsrblks.Text.Trim())); } frm1.modulerdr.ParamSet("EmdSecureDataOfInventory", esrd); } else { frm1.modulerdr.ParamSet("EmdSecureDataOfInventory", null); } } // } } //added on 3-26 try { if (this.gbidentifyants.Enabled) { if (this.cbisidtant.Checked) { frm1.rParms.isIdtAnts = true; if (this.rbidtantbydur.Checked) { frm1.rParms.IdtAntsType = 1; frm1.rParms.DurIdtval = int.Parse(this.tbidtdur.Text.Trim()); } else if (this.rbidtantafter.Checked) { frm1.rParms.IdtAntsType = 2; frm1.rParms.AfterIdtWaitval = int.Parse(this.tbafttime.Text.Trim()); } frm1.modulerdr.ParamSet("IsTagdataRecordHighestRssi", true); frm1.rParms.isUniByAnt = true; } else { frm1.modulerdr.ParamSet("IsTagdataRecordHighestRssi", false); frm1.rParms.IdtAntsType = 0; frm1.rParms.isUniByAnt = this.cbisunibyant.Checked; frm1.rParms.isIdtAnts = false; } } } catch (System.Exception ex) { } this.Close(); }
private void btnsetimpinjqt_Click(object sender, EventArgs e) { int ret; ret = IsAntSet(); if (ret == -1) { MessageBox.Show("please select antenna"); return; } else if (ret == 1) { DialogResult stat = DialogResult.OK; stat = MessageBox.Show("execute operation on the port without finding antenna ?", "tip-off", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); if (stat != DialogResult.OK) { return; } } byte[] pwd = null; ret = Form1.IsValidPasswd(this.tbaccesspasswd.Text.Trim()); { switch (ret) { case -3: MessageBox.Show("please input access password"); break; case -2: case -4: MessageBox.Show("access password must be 8 of hexadecimal numbers"); break; case -1: MessageBox.Show("access password must be 8 of hexadecimal numbers"); break; } } if (ret != 0) { return; } else { pwd = ByteFormat.FromHex(this.tbaccesspasswd.Text.Trim()); } Gen2TagFilter filter = null; if (checkfilter(ref filter) != 0) { return; } if ((!this.rbimpinjqtread.Checked) && (!this.rbimpinjwrite.Checked)) { MessageBox.Show("please select command type"); return; } try { if (this.rbimpinjqtread.Checked) { IMPINJ_M4_QtPara para = new IMPINJ_M4_QtPara(pwd); IMPINJ_M4_QtResult qtret = (IMPINJ_M4_QtResult)mrdr.CustomCmd(filter, CustomCmdType.IMPINJ_M4_Qt, para); if (qtret.MemType == IMPINJ_M4_QtPara.IMPINJ_Qt_Mem_Type.IMPINJ_Qt_Mem_Private) { this.rbimpinjqtmemprivate.Checked = true; } else { this.rbimpinjqtmempublic.Checked = true; } if (qtret.RangeType == IMPINJ_M4_QtPara.IMPINJ_Qt_Range_Type.IMPINJ_Qt_Range_FarField) { this.rbimpinjqtfarfield.Checked = true; } else { this.rbimpinjqtnearfiled.Checked = true; } } else { if ((!rbimpinjqtnearfiled.Checked) && (!rbimpinjqtfarfield.Checked)) { MessageBox.Show("please select reading distance"); return; } if ((!rbimpinjqtmemprivate.Checked) && (!rbimpinjqtmempublic.Checked)) { MessageBox.Show("please select memory profile"); return; } if ((!rbimpinjqtperm.Checked) && (!rbimpinjqttemp.Checked)) { MessageBox.Show("please select persistence type"); return; } IMPINJ_M4_QtPara.IMPINJ_Qt_Range_Type trange = IMPINJ_M4_QtPara.IMPINJ_Qt_Range_Type.IMPINJ_Qt_Range_Invalid; IMPINJ_M4_QtPara.IMPINJ_Qt_Persist_Type tpersist = IMPINJ_M4_QtPara.IMPINJ_Qt_Persist_Type.IMPINJ_Qt_Persist_Invalid; IMPINJ_M4_QtPara.IMPINJ_Qt_Mem_Type tmem = IMPINJ_M4_QtPara.IMPINJ_Qt_Mem_Type.IMPINJ_Qt_Mem_Invalid; if (rbimpinjqtnearfiled.Checked) { trange = IMPINJ_M4_QtPara.IMPINJ_Qt_Range_Type.IMPINJ_Qt_Range_NearField; } else { trange = IMPINJ_M4_QtPara.IMPINJ_Qt_Range_Type.IMPINJ_Qt_Range_FarField; } if (rbimpinjqtmemprivate.Checked) { tmem = IMPINJ_M4_QtPara.IMPINJ_Qt_Mem_Type.IMPINJ_Qt_Mem_Private; } else { tmem = IMPINJ_M4_QtPara.IMPINJ_Qt_Mem_Type.IMPINJ_Qt_Mem_Public; } if (rbimpinjqtperm.Checked) { tpersist = IMPINJ_M4_QtPara.IMPINJ_Qt_Persist_Type.IMPINJ_Qt_Persist_Perm; } else { tpersist = IMPINJ_M4_QtPara.IMPINJ_Qt_Persist_Type.IMPINJ_Qt_Persist_Temp; } IMPINJ_M4_QtPara para = new IMPINJ_M4_QtPara(pwd, tpersist, trange, tmem); mrdr.CustomCmd(filter, CustomCmdType.IMPINJ_M4_Qt, para); } } catch (OpFaidedException notagexp) { if (notagexp.ErrCode == 0x400) { MessageBox.Show("no tag"); } else { MessageBox.Show("operation failed:" + notagexp.ToString()); } return; } catch (Exception ex) { MessageBox.Show("operation failed:" + ex.ToString()); return; } }
private void InventoryParasform_Load(object sender, EventArgs e) { this.cbischgcolor.Checked = frm1.rParms.isChangeColor; this.cbisunibynullemd.Checked = frm1.rParms.isUniByEmd; this.cbisunibyant.Checked = frm1.rParms.isUniByAnt; object obj = null; if (!(frm1.modulerdr.HwDetails.module == Reader.Module_Type.MODOULE_M6E || frm1.modulerdr.HwDetails.module == Reader.Module_Type.MODOULE_M6E_PRC)) { this.gbpotlweight.Enabled = false; } if (!(frm1.rParms.readertype == ReaderType.PR_ONEANT || frm1.rParms.readertype == ReaderType.MT_A7_16ANTS)) { this.tbwtgen2.Text = frm1.rParms.weightgen2.ToString(); this.tbwt180006b.Text = frm1.rParms.weight180006b.ToString(); this.tbwtipx256.Text = frm1.rParms.weightipx256.ToString(); this.tbwtipx64.Text = frm1.rParms.weightipx64.ToString(); if (frm1.modulerdr.HwDetails.module != Reader.Module_Type.MODOULE_R902_MT100) { EmdSecureReadData esrd = (EmdSecureReadData)frm1.modulerdr.ParamGet("EmdSecureDataOfInventory"); if (esrd != null) { this.cbissecureread.Checked = true; this.tbsraddress.Text = esrd.Address.ToString(); this.tbsrblks.Text = esrd.BlkCnt.ToString(); this.cbbsrbank.SelectedIndex = (int)esrd.Bank; if (esrd.PwdType == EmdSecureReadData.ESRD_AccessPasswordType.ESRD_Fix_AccessPassword) { this.cbbsrpwdtype.SelectedIndex = 0; } else { this.cbbsrpwdtype.SelectedIndex = 1; } if (esrd.TagType == EmdSecureReadData.ESRD_TagType.ESRD_Alien_Higgs3) { this.cbbsrtagtype.SelectedIndex = 0; } else { this.cbbsrtagtype.SelectedIndex = 1; } this.tbsracspwd.Text = esrd.AccessPassword.ToString("X8"); this.tbindexbitsnum.Text = esrd.ApIndexBitsNumInEpc.ToString(); this.tbsrindexstartbit.Text = esrd.ApIndexStartBitsInEpc.ToString(); } else { this.cbissecureread.Checked = false; } } else { this.gbsecureread.Enabled = false; } // } obj = frm1.modulerdr.ParamGet("EmbededCmdOfInventory"); if (obj != null) { EmbededCmdData ecd = (EmbededCmdData)obj; this.tbebstartaddr.Text = ecd.StartAddr.ToString(); this.tbebbytescnt.Text = ecd.ByteCnt.ToString(); this.cbbebbank.SelectedIndex = (int)ecd.Bank; this.cbisaddiondata.Checked = true; } uint pwd = (uint)frm1.modulerdr.ParamGet("AccessPassword"); if (pwd != 0) { this.cbispwd.Checked = true; this.tbacspwd.Text = pwd.ToString("X8"); } } else { this.gbemddata.Enabled = false; this.gbsecureread.Enabled = false; } obj = frm1.modulerdr.ParamGet("Singulation"); if (obj != null) { Gen2TagFilter filter = (Gen2TagFilter)obj; this.cbbfilterbank.SelectedIndex = (int)filter.FilterBank - 1; this.tbfilteraddr.Text = filter.FilterAddress.ToString(); string binarystr = ""; foreach (byte bt in filter.FilterData) { string tmp = Convert.ToString(bt, 2); if (tmp.Length != 8) { for (int c = 0; c < 8 - tmp.Length; ++c) { binarystr += "0"; } } binarystr += tmp; } this.tbfilterdata.Text = binarystr.Substring(0, filter.FilterLength); if (filter.IsInvert) { this.cbbfilterrule.SelectedIndex = 1; } else { this.cbbfilterrule.SelectedIndex = 0; } this.cbisfilter.Checked = true; } this.tbreaddur.Text = frm1.rParms.readdur.ToString(); this.tbsleepdur.Text = frm1.rParms.sleepdur.ToString(); if (frm1.rParms.isReadFixCount) { this.cbisReadFixCount.Checked = true; this.tbReadCount.Text = frm1.rParms.FixReadCount.ToString(); } else { this.cbisReadFixCount.Checked = false; this.tbReadCount.Enabled = false; } if (frm1.rParms.isOneReadOneTime) { this.cbisOneReadOneTime.Checked = true; } else { this.cbisOneReadOneTime.Checked = false; } // added on 3-26 this.cbisrevertants.Checked = frm1.rParms.isRevertAnts; if (frm1.modulerdr.HwDetails.module == Reader.Module_Type.MODOULE_M5E || frm1.modulerdr.HwDetails.module == Reader.Module_Type.MODOULE_M5E_C || frm1.modulerdr.HwDetails.module == Reader.Module_Type.MODOULE_M5E_PRC || frm1.modulerdr.HwDetails.module == Reader.Module_Type.MODOULE_M6E || frm1.modulerdr.HwDetails.module == Reader.Module_Type.MODOULE_M6E_PRC) { this.gbidentifyants.Enabled = true; this.cbisidtant.Checked = frm1.rParms.isIdtAnts; if (this.cbisidtant.Checked) { if (frm1.rParms.IdtAntsType == 1) { this.rbidtantbydur.Checked = true; } else if (frm1.rParms.IdtAntsType == 2) { this.rbidtantafter.Checked = true; } this.tbidtdur.Text = frm1.rParms.DurIdtval.ToString(); this.tbafttime.Text = frm1.rParms.AfterIdtWaitval.ToString(); } else { this.tbidtdur.Text = ""; this.tbafttime.Text = ""; } } else { this.gbidentifyants.Enabled = false; } // this.cbbantcnt.SelectedIndex = frm1.rParms.usecase_antcnt; if (frm1.rParms.usecase_ishighspeedblf) { this.cbishighspeed.Checked = true; } else { this.cbishighspeed.Checked = false; } this.cbbreadresult.SelectedIndex = frm1.rParms.usecase_readperform; this.cbbtagcnt.SelectedIndex = frm1.rParms.usecase_tagcnt; }
private void InventoryParasform_Load(object sender, EventArgs e) { this.cbischgcolor.Checked = frm1.rParms.isChangeColor; this.cbisunibynullemd.Checked = frm1.rParms.isUniByEmd; this.cbisunibyant.Checked = frm1.rParms.isUniByAnt; object obj = null; if (!(frm1.rParms.readertype == ReaderType.PR_ONEANT || frm1.rParms.readertype == ReaderType.MT_A7_16ANTS)) { obj = frm1.modulerdr.ParamGet("EmbededCmdOfInventory"); if (obj != null) { EmbededCmdData ecd = (EmbededCmdData)obj; this.tbebstartaddr.Text = ecd.StartAddr.ToString(); this.tbebbytescnt.Text = ecd.ByteCnt.ToString(); this.cbbebbank.SelectedIndex = (int)ecd.Bank; this.cbisaddiondata.Checked = true; } uint pwd = (uint)frm1.modulerdr.ParamGet("AccessPassword"); if (pwd != 0) { this.cbispwd.Checked = true; this.tbacspwd.Text = pwd.ToString("X8"); } } else { this.gbemddata.Enabled = false; } obj = frm1.modulerdr.ParamGet("Singulation"); if (obj != null) { Gen2TagFilter filter = (Gen2TagFilter)obj; this.cbbfilterbank.SelectedIndex = (int)filter.FilterBank - 1; this.tbfilteraddr.Text = filter.FilterAddress.ToString(); string binarystr = ""; foreach (byte bt in filter.FilterData) { string tmp = Convert.ToString(bt, 2); if (tmp.Length != 8) { for (int c = 0; c < 8 - tmp.Length; ++c) { binarystr += "0"; } } binarystr += tmp; } this.tbfilterdata.Text = binarystr.Substring(0, filter.FilterLength); if (filter.IsInvert) { this.cbbfilterrule.SelectedIndex = 1; } else { this.cbbfilterrule.SelectedIndex = 0; } this.cbisfilter.Checked = true; } this.tbreaddur.Text = frm1.rParms.readdur.ToString(); this.tbsleepdur.Text = frm1.rParms.sleepdur.ToString(); if (frm1.rParms.isReadFixCount) { this.cbisReadFixCount.Checked = true; this.tbReadCount.Text = frm1.rParms.FixReadCount.ToString(); } else { this.cbisReadFixCount.Checked = false; this.tbReadCount.Enabled = false; } if (frm1.rParms.isOneReadOneTime) { this.cbisOneReadOneTime.Checked = true; } else { this.cbisOneReadOneTime.Checked = false; } }
private void btnChangeEAS_Click(object sender, EventArgs e) { int ret; TagChipType nxpchiptype = TagChipType.TagChipType_None; ret = IsAntSet(); if (ret == -1) { MessageBox.Show("请选择操作天线"); return; } else if (ret == 1) { DialogResult stat = DialogResult.OK; stat = MessageBox.Show("在未检测到天线的端口执行操作,真的要执行吗?", "警告", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); if (stat != DialogResult.OK) { return; } } if ((!this.rbEASset.Checked) && (!this.rbEASreset.Checked)) { MessageBox.Show("请选择EAS状态"); return; } if (this.cbbnxpchiptype.SelectedIndex == -1) { MessageBox.Show("请选择芯片类型"); return; } else { if (this.cbbnxpchiptype.SelectedIndex == 0) { nxpchiptype = TagChipType.TagChipType_NXP_G2X; } else if (this.cbbnxpchiptype.SelectedIndex == 1) { nxpchiptype = TagChipType.TagChipType_NXP_G2i; } } bool isSet = false; if (this.rbEASset.Checked) { isSet = true; } else { isSet = false; } byte [] pwd = null; ret = Form1.IsValidPasswd(this.tbaccesspasswd.Text.Trim()); { switch (ret) { case -3: MessageBox.Show("访问密码不能为空"); break; case -2: case -4: MessageBox.Show("访问密码必须是8个16进制数"); break; case -1: MessageBox.Show("访问密码只能是16进制数字"); break; } } if (ret != 0) { return; } else { pwd = ByteFormat.FromHex(this.tbaccesspasswd.Text.Trim()); } Gen2TagFilter filter = null; if (checkfilter(ref filter) != 0) { return; } NXP_ChangeEASPara ChEasPara = new NXP_ChangeEASPara(pwd, isSet, nxpchiptype); try { mrdr.CustomCmd(filter, CustomCmdType.NXP_ChangeEAS, ChEasPara); } catch (OpFaidedException notagexp) { if (notagexp.ErrCode == 0x400) { MessageBox.Show("没法发现标签"); } else { MessageBox.Show("操作失败:" + notagexp.ToString()); } return; } catch (Exception ex) { MessageBox.Show("ChangeEAS失败:" + ex.ToString()); return; } }