Ejemplo n.º 1
0
            public override bool InventoryTags(Tag tag, bool loop, InventoryTagDelegate itd, object context)
            {
                STPv3Response response;
                STPv3Request  request = new STPv3Request();

                request.Tag = tag;
                //request.RID = reader.ReaderID;
                request.Command   = STPv3Commands.SELECT_TAG;
                request.Inventory = true;
                request.Loop      = loop;

issue:
                request.Issue(this.m_device);

                response = request.GetResponse();

                if (response == null)
                {
                    return(false);
                }

                if (response.ResponseCode == STPv3ResponseCode.SELECT_TAG_LOOP_OFF)
                {
                    goto issue;
                }

                while (true)
                {
                    response = request.GetResponse();

                    if (response == null)
                    {
                        continue;
                    }

                    if (!response.Success)
                    {
                        return(false);
                    }

                    if (response.ResponseCode == STPv3ResponseCode.SELECT_TAG_PASS)
                    {
                        Tag iTag = new Tag();
                        iTag.TID  = response.TID;
                        iTag.Type = response.TagType;

                        //BTM - If we are simply performing an inventory then we let it run to
                        //completion to prevent later synchronization issues
                        if (itd(iTag, context) && loop)
                        {
                            return(true);
                        }
                    }
                }
            }
Ejemplo n.º 2
0
            public Tag[] SelectTags(Tag tag)
            {
                ArrayList its = new ArrayList();

                InventoryTagDelegate itd = delegate(Tag it, object ctx)
                {
                    its.Add(it);
                    return(true);
                };

                this.InventoryTags(tag, false, itd, null);

                return((Tag[])its.ToArray(typeof(Tag)));
            }
Ejemplo n.º 3
0
            public override bool InventoryTags(Tag tag, bool loop, InventoryTagDelegate itd, object context)
            {
                STPv3Response response;
                STPv3Request request = new STPv3Request();

                request.Tag = tag;
                //request.RID = reader.ReaderID;
                request.Command = STPv3Commands.SELECT_TAG;
                request.Inventory = true;
                request.Loop = loop;

                if(m_device.Type==DeviceType.SERIAL)
                {
                issue:
                request.Issue(this.m_device);

                response = request.GetResponse();

                if (response == null)
                    return false;

                if (response.ResponseCode == STPv3ResponseCode.SELECT_TAG_LOOP_OFF)
                    goto issue;

                while (true)
                {
                    response = request.GetResponse();

                    if (response == null)
                        continue;

                    if (!response.Success)
                        return false;

                    if (response.ResponseCode == STPv3ResponseCode.SELECT_TAG_PASS)
                    {
                        Tag iTag = new Tag();
                        iTag.TID = response.TID;
                        iTag.Type = response.TagType;

                        //BTM - If we are simply performing an inventory then we let it run to
                        //completion to prevent later synchronization issues
                        if (itd(iTag, context) && loop)
                        {
                            return true;
                        }
                    }
                }

                }
                //Not Tested!!!   Lachezar Temelkov 02/19/2010
                //When the user return false in the delegate, the routine/reader goes out of loop
                //when user return rue it is keep on going
                //the delegate is called every xx amount of miliseconds, regardless if there is tag found or not
                //the time out is specified m_devise.setreadertimeout! use 20ms for instance

                else if ((m_device.Type == DeviceType.TCP)||(m_device.Type==DeviceType.USB))
                {
                    //TCP code
                    bool stoploop = false;
                    try
                    {
                    issue:
                        request.Issue(this.m_device);

                        while (true)
                        {
                            //response return with a time out,regardles if Tag is Found or Not
                            response = request.GetResponse();
                            if ((response.ResponseCode == STPv3ResponseCode.SELECT_TAG_LOOP_OFF) && (stoploop==false))
                                 goto issue;
                            switch (response.ResponseCode)
                            {
                                case STPv3ResponseCode.SELECT_FILE_PASS:
                                    {
                                        Tag iTag = new Tag();
                                        iTag.Type = response.TagType;
                                        iTag.TID = response.TID;

                                        stoploop=itd(iTag, context);
                                        if ((stoploop==true)&& loop)
                                        {
                                           request.Issue(this.m_device);
                                        }
                                        break;
                                    }

                                case STPv3ResponseCode.SELECT_TAG_FAIL:
                                    {
                                        Debug.Print("Selecet Tag fail--Inventory Done");
                                        return true;
                                    }
                                case STPv3ResponseCode.SELECT_TAG_LOOP_OFF:
                                    {
                                        Debug.Print("Selecet Tag fail--Inventory Done");
                                        return true;
                                    }
                                case STPv3ResponseCode.READER_TIME_OUT:
                                    {
                                        Tag iTag = null;
                                        stoploop = itd(iTag, context);
                                        if ((stoploop == true)&& loop)
                                           {
                                            request.Issue(this.m_device);
                                           }
                                        break;
                                    }
                                  }

                               }
                             }

                    catch (NullReferenceException ex)  //response is null exception
                    {
                        //if response is null
                        throw new Exception("Null Device Reference in TCP object");
                    }
                    catch (Exception e) //general exception just in case
                    {
                        throw new Exception("Error Inventory mode");
                    }

                }//end tcp
                else
                {
                   throw new Exception("Unknown Interface Type in Inventory Mode");
                 }
            }
Ejemplo n.º 4
0
 /// <summary>
 /// Inventory tags in the readers field. 
 /// </summary>
 /// <param name="tag">This parameter describes the tags to inventory (e.g. by type, by epc, by afi, etc...).</param>
 /// <param name="loop">True indicates the reader should inventory tags until explicitly told to stop</param>
 /// <param name="itd">Delegate to call when a tag is inventoried.  Any long running or computationally intensive work should
 /// be done outside of the this function call so as not to impede the inventory process.</param>
 /// <param name="context">Context object passed through to delegate call</param>
 /// <returns>True if the call to InventoryTags was terminated by a call to the InventoryTagDelegate, false if terminated because of another reason</returns>
 public abstract bool InventoryTags(Tag tag, bool loop, InventoryTagDelegate itd, object context);
Ejemplo n.º 5
0
            public override bool InventoryTags(Tag tag, bool loop, InventoryTagDelegate itd, object context)
            {
                STPv3Response response;
                STPv3Request request = new STPv3Request();

                request.Tag = tag;
                //request.RID = reader.ReaderID;
                request.Command = STPv3Commands.SELECT_TAG;
                request.Inventory = true;
                request.Loop = loop;

                issue:
                request.Issue(this.m_device);

                response = request.GetResponse();

                if (response == null)
                    return false;

                if (response.ResponseCode == STPv3ResponseCode.SELECT_TAG_LOOP_OFF)
                    goto issue;

                while (true)
                {
                    response = request.GetResponse();

                    if (response == null)
                        continue;

                    if (!response.Success)
                        return false;

                    if (response.ResponseCode == STPv3ResponseCode.SELECT_TAG_PASS)
                    {
                        Tag iTag = new Tag();
                        iTag.TID = response.TID;
                        iTag.Type = response.TagType;

                        //BTM - If we are simply performing an inventory then we let it run to
                        //completion to prevent later synchronization issues
                        if (itd(iTag, context) && loop)
                        {
                            return true;
                        }
                    }
                }
            }
Ejemplo n.º 6
0
 /// <summary>
 /// Inventory tags in the readers field.
 /// </summary>
 /// <param name="tag">This parameter describes the tags to inventory (e.g. by type, by epc, by afi, etc...).</param>
 /// <param name="loop">True indicates the reader should inventory tags until explicitly told to stop</param>
 /// <param name="itd">Delegate to call when a tag is inventoried.  Any long running or computationally intensive work should
 /// be done outside of the this function call so as not to impede the inventory process.</param>
 /// <param name="context">Context object passed through to delegate call</param>
 /// <returns>True if the call to InventoryTags was terminated by a call to the InventoryTagDelegate, false if terminated because of another reason</returns>
 public abstract bool InventoryTags(Tag tag, bool loop, InventoryTagDelegate itd, object context);