Пример #1
0
        private void Inventory()
        {
            byte Qvalue  = Convert.ToByte(0);
            byte Session = Convert.ToByte(0);
            // Convert.ToByte((int)_readerProfile.InventorySearchMode);

            byte AdrTID  = 0;
            byte LenTID  = 0;
            byte TIDFlag = 0;

            byte[] EPC = new byte[5000];
            int    CardIndex;
            int    CardNum = 0;
            int    Totallen = 0;
            int    EPClen, m;
            string s, sEPC;
            string temps;

            int fCmdRet = StaticClassReaderB.Inventory_G2(ref fComAdr, AdrTID, LenTID, TIDFlag, EPC, ref Totallen, ref CardNum, comPortIndex);

            if ((fCmdRet == 1) | (fCmdRet == 2) | (fCmdRet == 3) | (fCmdRet == 4) | (fCmdRet == 0xFB)) //end of read
            {
                byte[] daw = new byte[Totallen];
                Array.Copy(EPC, daw, Totallen);
                temps = ByteArrayToHexString(daw);
                //   fInventory_EPC_List = temps;            //存贮记录
                m = 0;
                if (CardNum == 0)
                {
                    // fIsInventoryScan = false;
                    return;
                }


                string lastEPC = "";
                for (CardIndex = 0; CardIndex < CardNum; CardIndex++)
                {
                    EPClen = daw[m];
                    sEPC   = temps.Substring(m * 2 + 2, EPClen * 2);
                    m      = m + EPClen + 1;
                    if (sEPC.Length != EPClen * 2)
                    {
                        return;
                    }
                    var readTime = DateTime.Now;

                    var tag = new Split
                    {
                        DateTimeOfDay = readTime,
                        TimeOfDay     = readTime.ToString("hh.mm.ss.ff"),
                        Epc           = sEPC,
                        // Rssi = Convert.ToInt32(RSSI, 16).ToString(),
                        SplitName           = _readerProfile.Name,
                        SplitDeviceId       = _readerProfile.Id,
                        InventorySearchMode = _readerProfile.InventorySearchMode
                    };

                    if (_readerProfile.ReadingMode == ReadingMode.Desktop)
                    {
                        onAssignTag(tag);
                    }
                    else
                    {
                        onRecordTag(tag);
                    }
                }
            }
        }
Пример #2
0
        private bool SetWorkingMode()
        {
            int Reader_bit0;
            int Reader_bit1;
            int Reader_bit2;
            int Reader_bit3;

            byte[] Parameter = new byte[6];
            Parameter[0] = Convert.ToByte(1); // "0=Answer Mode", "1=Active mode"
            if (true)                         //"EPCC1-G2
            {
                Reader_bit0 = 0;              // "EPCC1-G2
            }
            else
            {
                Reader_bit0 = 1;
            }
            if (true)
            {
                Reader_bit1 = 0; //Wiegand Output
            }
            else
            {
                Reader_bit1 = 1;
            }
            if (true)            // buzzer
            {
                Reader_bit2 = 0; // Activate buzzer
            }
            else
            {
                Reader_bit2 = 1;
            }
            if (true)
            {
                Reader_bit3 = 0;  //Word Addr
            }
            else
            {
                Reader_bit3 = 1;
            }

            Parameter[1] = Convert.ToByte(Reader_bit0 * 1 + Reader_bit1 * 2 + Reader_bit2 * 4 + Reader_bit3 * 8);
            //storage area or inquiry condcuted Tags
            if (false)
            {
                Parameter[2] = 0; //Password
            }
            if (true)
            {
                Parameter[2] = 1; //EPC
            }
            if (false)
            {
                Parameter[2] = 2; //TID
            }
            if (false)
            {
                Parameter[2] = 3; //user
            }
            if (false)
            {
                Parameter[2] = 4; //Multi-Tag
            }
            if (false)
            {
                Parameter[2] = 5; //Single-Tag
            }
            //if (textBox3.Text == "")
            //{
            //    MessageBox.Show("Address is NULL!", "Information");
            //    return;
            //}
            Parameter[3] = Convert.ToByte("02", 16); //was textBox3.Text
            Parameter[4] = Convert.ToByte(1 + 1);    //real word number
            Parameter[5] = Convert.ToByte(0);;       //single tag filtering itme


            int resullt = StaticClassReaderB.SetWorkMode(ref fComAdr, Parameter, comPortIndex);

            if (resullt == 0)
            {
                return(true);
            }

            return(false);
        }