private void timer1_Tick(object sender, EventArgs e) { TagChipType nxpchiptype = TagChipType.TagChipType_None; try { this.labEASAlert.BackColor = Color.Gray; if (this.cbbnxpchiptype.SelectedIndex == 0) { nxpchiptype = TagChipType.TagChipType_NXP_G2X; } else if (this.cbbnxpchiptype.SelectedIndex == 1) { nxpchiptype = TagChipType.TagChipType_NXP_G2i; } NXP_EASAlarmPara EasAlarmPara = new NXP_EASAlarmPara(0x01, 0x02, 0x01, nxpchiptype); NXP_EASAlarmResult result = (NXP_EASAlarmResult)mrdr.CustomCmd(null, CustomCmdType.NXP_EASAlarm, EasAlarmPara); tbEASAlarmData.Text = ByteFormat.ToHex(result.EASAlarmData); System.Media.SystemSounds.Beep.Play(); this.labEASAlert.BackColor = Color.Red; } catch (Exception ex) { } }
private void btnEASAlarm_Click(object sender, EventArgs e) { TagChipType nxpchiptype = TagChipType.TagChipType_None; 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; } } 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; } } try { NXP_EASAlarmPara EasAlarmPara = new NXP_EASAlarmPara(0x01, 0x02, 0x01, nxpchiptype); NXP_EASAlarmResult result = (NXP_EASAlarmResult)mrdr.CustomCmd(null, CustomCmdType.NXP_EASAlarm, EasAlarmPara); tbEASAlarmData.Text = ByteFormat.ToHex(result.EASAlarmData); } catch (OpFaidedException notagexp) { if (notagexp.ErrCode == 0x400) { MessageBox.Show("没法发现标签"); } else { MessageBox.Show("操作失败:" + notagexp.ToString()); } return; } catch (Exception ex) { MessageBox.Show("EASAlarm失败:" + ex.ToString()); return; } }
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; } }