Esempio n. 1
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();
        }
Esempio n. 2
0
        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();
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        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);
        }