Beispiel #1
0
        private void btnChangeEAS_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;
                }
            }

            if ((!this.rbEASset.Checked) && (!this.rbEASreset.Checked))
            {
                MessageBox.Show("please select EAS state");
                return;
            }

            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("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;
            }
            NXP_ChangeEASPara ChEasPara = new NXP_ChangeEASPara(pwd, isSet);

            try
            {
                mrdr.CustomCmd(filter, CustomCmdType.NXP_ChangeEAS, ChEasPara);
            }
            catch (OpFaidedException notagexp)
            {
                if (notagexp.ErrCode == 0x400)
                {
                    MessageBox.Show("no tag");
                }
                else
                {
                    MessageBox.Show("operation failed:" + notagexp.ToString());
                }

                return;
            }
            catch (Exception ex)
            {
                MessageBox.Show("ChangeEAS failed:" + ex.ToString());
                return;
            }
        }
Beispiel #2
0
        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;
            }
        }