Exemplo n.º 1
0
        private ITagPageContents GetPage(int pageIndex)
        {
            int pageStartOffset = pageIndex * Config.PageDataSize;

            TagPageContents page = new TagPageContents()
            {
                PageIndex = pageIndex, ByteArray = ContentByteArray.SafeSubArray(pageStartOffset, Config.PageDataSize)
            };

            return(page);
        }
Exemplo n.º 2
0
        protected string PerformReadPagesAction(IProviderActionBase <NullObj, ITagPageContents[]> action, int startPageIdx, int numPages)
        {
            List <ITagPageContents> pageContentsList = new List <ITagPageContents>();

            // initialize the result to the empty array.
            action.ResultValue = pageContentsList.ToArray();

            if (!BaseState.IsOnline)
            {
                return("Reader is not online");
            }

            if (!privateState.TagIsPresent)
            {
                return("Tag (or Antenna) is not marked as present");
            }

            foreach (int pageIdx in Enumerable.Range(startPageIdx, numPages))
            {
                if (pageIdx < 0 || pageIdx >= CurrentConfig.NumPages)
                {
                    action.ResultValue = pageContentsList.ToArray();

                    return(Fcns.CheckedFormat("Reached invalid page at index:{0} [limit:{1}]", pageIdx, privateState.Config.NumPages));
                }

                int pageStartOffset           = pageIdx * privateState.Config.PageDataSize;
                ITagPageContents pageContents = new TagPageContents()
                {
                    PageIndex = pageIdx, ByteArray = privateState.ContentByteArray.SafeSubArray(pageStartOffset, privateState.Config.PageDataSize)
                };

                pageContentsList.Add(pageContents);

                if (privateState.Config.PageReadDelayTimeSpan != TimeSpan.Zero)
                {
                    System.Threading.Thread.Sleep(privateState.Config.PageReadDelayTimeSpan);
                }
            }

            action.ResultValue = pageContentsList.ToArray();

            return(String.Empty);
        }