Exemplo n.º 1
0
 public DemoBitmapMenuItem()
 {
     Name = "Internalize Bitmap";
     TagFilter.Add(HaloTags.bitm);
     ApplyTagFilter = true;
     Click         += DemoBitmapMenuItem_Click;
 }
Exemplo n.º 2
0
        private ReadOnlyCollection <MediaInstance> GetFilteredMedia(SearchMediaData searchMedia)
        {
            var tagFilter     = new TagFilter(searchMedia.IncludedTags, searchMedia.ExcludedTags, _tagGraph.Object);
            var filteredMedia = tagFilter.Filter(_mediaInstances.ToList().AsReadOnly());

            return(filteredMedia);
        }
Exemplo n.º 3
0
        private static void AssertResults
        (
            string folderPath,
            string filter,
            params string[] expectedResults)
        {
            // Reset the testing directory before comparing, in case a previous test
            // changed it
            Utils.ResetTestFolder();

            // Get the actual results
            string    fullPath  = Utils.GetTestFolder(folderPath);
            TagFilter tagFilter = new TagFilter(filter);

            var actualResults = TagUtils.GetMatchingFiles(fullPath, tagFilter);

            // Convert them to their file names so we can compare them as strings
            var actualResultsPaths = actualResults.Select(f => f.Name);

            // Sort them before comparing them, because we don't care about order.
            actualResultsPaths = actualResultsPaths.OrderBy(s => s).ToArray();
            expectedResults    = expectedResults.OrderBy(s => s).ToArray();

            // Compare them to the expected results
            bool matches = actualResultsPaths.SequenceEqual(expectedResults);

            Assert.IsTrue(matches);
        }
Exemplo n.º 4
0
        private void search_button_Click(object sender, EventArgs e)
        {// Begins identification on button click.
            //Creates new image tagger object and inputs user path through the GetTags method
            ImageTagger animalImageTagger = new ImageTagger();
            List <Tag>  tags = animalImageTagger.GetTagsForImage(textBoxText);

            //creates new tag filter and then runs the tag list through it
            TagFilter  filter       = new TagFilter();
            List <Tag> filteredTags = filter.Filter(tags);

            foreach (Tag tag in tags)
            {
                if (tag.name == "cat")
                {
                    checkBox2.Checked = true;
                }
                if (tag.name == "dog")
                {
                    checkBox1.Checked = true;
                }
                if (tag.name == "bird")
                {
                    checkBox3.Checked = true;
                }
            }
        }
Exemplo n.º 5
0
        public ValidationResults FindAll(TagFilter tagFilter, params string[] tags)
        {
            if (tags == null)
            {
                string[] array = new string[1];
                tags = array;
            }
            ValidationResults validationResults = new ValidationResults();

            foreach (ValidationResult current in ((IEnumerable <ValidationResult>) this))
            {
                bool     flag   = false;
                string[] array2 = tags;
                for (int i = 0; i < array2.Length; i++)
                {
                    string text = array2[i];
                    if ((text == null && current.Tag == null) || (text != null && text.Equals(current.Tag)))
                    {
                        flag = true;
                        break;
                    }
                }
                if (flag ^ tagFilter == TagFilter.Ignore)
                {
                    validationResults.AddResult(current);
                }
            }
            return(validationResults);
        }
        public void Execute(CommandLineArguments arguments)
        {
            var assemblyPath = arguments.AssemblyPath;
            var featurePattern = arguments.FeaturePattern;

            featureRunner.AddListener(new ConsoleWritingEventListener
                                          {
                                              ShowCurrentTimes = arguments.ShowCurrentTime,
                                          });

            var filter = new TagFilter(arguments.TagsToInclude, arguments.TagsToExclude);

            var featuresToRun = featureFileFinder.Find(featurePattern)
                .SelectMany(fileName => gherkinParser.Parse(fileName, fileReader.Read(fileName, Encoding.UTF8)).Features)
                .Where(f => filter.IsSatisfiedBy(f.Tags));

            Console.WriteLine("Found {0} features containing {1} executable scenarios", featuresToRun.Count(),
                              featuresToRun.Sum(f => f.Scenarios.Count));

            var actionStepsTypes = actionStepsFinder.FindTypesWithActionSteps(assemblyPath);

            var options = new RunnerOptions
                              {
                                  Filter = filter,
                                  DruRun = arguments.DruRun,
                                  SuccessRequired = arguments.SuccessRequired,
                              };

            foreach(var feature in featuresToRun)
            {
                var featureResult = featureRunner.Run(feature, actionStepsTypes, options);

                if (options.SuccessRequired && !featureResult.Success) break;
            }
        }
Exemplo n.º 7
0
        public async Task <ListResponse <TagResponse> > RunAsync(TagFilter filter, ListOptions options)
        {
            var tags = _uow.Tags.Query(t => t.Tasks);

            foreach (var tag in tags)
            {
                tag.Tasks = _uow.TagsInTasks.Query(t => t.Task).Where(t => t.TagId == tag.Id).ToList();
            }

            await _factory.CreateAsyncQueryable(tags).LoadAsync();

            var query = tags.ProjectTo <TagResponse>();

            query = ApplyFilter(query, filter);
            int totalCount = await _factory.CreateAsyncQueryable(query).CountAsync();

            if (options.Sort == null)
            {
                options.Sort = "Name";
            }

            query = options.ApplySort(query);

            query = options.ApplyPaging(query);

            return(new ListResponse <TagResponse>
            {
                Items = await _factory.CreateAsyncQueryable(query).ToListAsync(),
                Page = options.Page,
                PageSize = options.PageSize ?? totalCount,
                Sort = options.Sort,
                TotalItemsCount = totalCount
            });
        }
Exemplo n.º 8
0
        public void CanonDependentsFilter()
        {
            var canon = new FilterCanonicalizer();

            var tagFilter1 = new TagFilter(Tag("A"));
            var tagFilter2 = new TagFilter(Tag("A"));
            var tagFilter3 = new TagFilter(Tag("B"));

            var dependentsFilter1 = new DependentsFilter(tagFilter1);
            var dependentsFilter2 = new DependentsFilter(tagFilter2);
            var dependentsFilter3 = new DependentsFilter(tagFilter3);

            var canonDependentsFilter1 = dependentsFilter1.Canonicalize(canon);
            var canonDependentsFilter2 = dependentsFilter2.Canonicalize(canon);
            var canonDependentsFilter3 = dependentsFilter3.Canonicalize(canon);

            Assert.Same(canonDependentsFilter1, canonDependentsFilter2);
            Assert.NotSame(canonDependentsFilter1, canonDependentsFilter3);

            var canonTagFilter = tagFilter1.Canonicalize(canon);
            var canonFilter1   = canonDependentsFilter1 as DependentsFilter;
            var canonFilter2   = canonDependentsFilter2 as DependentsFilter;

            Assert.NotNull(canonFilter1);
            Assert.NotNull(canonFilter2);
            Assert.Same(canonFilter1.Inner, canonTagFilter);
            Assert.Same(canonFilter2.Inner, canonTagFilter);
        }
Exemplo n.º 9
0
        public void CanonBinaryFilter()
        {
            var canon = new FilterCanonicalizer();

            var tagFilter1      = new TagFilter(Tag("A"));
            var tagFilter2      = new TagFilter(Tag("A"));
            var negatingFilter1 = new NegatingFilter(new TagFilter(Tag("B")));
            var negatingFilter2 = new NegatingFilter(new TagFilter(Tag("B")));

            var binaryFilter1 = new BinaryFilter(tagFilter1, FilterOperator.And, negatingFilter1);
            var binaryFilter2 = new BinaryFilter(tagFilter2, FilterOperator.And, negatingFilter2);
            var binaryFilter3 = new BinaryFilter(negatingFilter1, FilterOperator.And, tagFilter2);
            var binaryFilter4 = new BinaryFilter(tagFilter1, FilterOperator.Or, negatingFilter1);

            var canonBinaryFilter1 = binaryFilter1.Canonicalize(canon);
            var canonBinaryFilter2 = binaryFilter2.Canonicalize(canon);
            var canonBinaryFilter3 = binaryFilter3.Canonicalize(canon);
            var canonBinaryFilter4 = binaryFilter4.Canonicalize(canon);

            Assert.Same(canonBinaryFilter1, canonBinaryFilter2);
            Assert.Same(canonBinaryFilter1, canonBinaryFilter3);
            Assert.NotSame(canonBinaryFilter1, canonBinaryFilter4);

            var canonFilter1 = canonBinaryFilter1 as BinaryFilter;
            var canonFilter2 = canonBinaryFilter2 as BinaryFilter;
            var canonFilter3 = canonBinaryFilter3 as BinaryFilter;

            Assert.NotNull(canonFilter1);
            Assert.NotNull(canonFilter2);
            Assert.NotNull(canonFilter3);
            Assert.Same(canonFilter1.Left, canonFilter2.Left);
            Assert.Same(canonFilter1.Right, canonFilter2.Right);
            Assert.Same(canonFilter1.Left, canonFilter3.Left);
            Assert.Same(canonFilter1.Right, canonFilter3.Right);
        }
Exemplo n.º 10
0
        public void CanonNegatingFilter()
        {
            var canon = new FilterCanonicalizer();

            var tagFilter1 = new TagFilter(Tag("A"));
            var tagFilter2 = new TagFilter(Tag("A"));
            var tagFilter3 = new TagFilter(Tag("B"));

            var negatingFilter1 = new NegatingFilter(tagFilter1);
            var negatingFilter2 = new NegatingFilter(tagFilter2);
            var negatingFilter3 = new NegatingFilter(tagFilter3);

            var canonNegatingFilter1 = negatingFilter1.Canonicalize(canon);
            var canonNegatingFilter2 = negatingFilter2.Canonicalize(canon);
            var canonNegatingFilter3 = negatingFilter3.Canonicalize(canon);

            Assert.Same(canonNegatingFilter1, canonNegatingFilter2);
            Assert.NotSame(canonNegatingFilter1, canonNegatingFilter3);

            var canonTagFilter = tagFilter1.Canonicalize(canon);
            var canonFilter1   = canonNegatingFilter1 as NegatingFilter;
            var canonFilter2   = canonNegatingFilter2 as NegatingFilter;

            Assert.NotNull(canonFilter1);
            Assert.NotNull(canonFilter2);
            Assert.Same(canonFilter1.Inner, canonTagFilter);
            Assert.Same(canonFilter2.Inner, canonTagFilter);
        }
Exemplo n.º 11
0
        internal static Filters GenerateFromGroupFilter(NancyContext ctx, SVR_GroupFilter gf, int uid, bool nocast, bool notag, bool all,
            int level, bool allpic, int pic, byte tagfilter)
        {
            Filters f = new Filters
            {
                id = gf.GroupFilterID,
                name = gf.GroupFilterName
            };
            List<SVR_GroupFilter> allGfs = RepoFactory.GroupFilter.GetByParentID(f.id)
                .Where(a => a.InvisibleInClients == 0 &&
                            ((a.GroupsIds.ContainsKey(uid) && a.GroupsIds[uid].Count > 0) ||
                             (a.FilterType & (int) GroupFilterType.Directory) == (int) GroupFilterType.Directory))
                .ToList();
            List<Filter> filters = allGfs
                .Where(cgf =>
                    (cgf.FilterType & (int) GroupFilterType.Tag) != (int) GroupFilterType.Tag ||
                    TagFilter.ProcessTags(tagfilter, new List<string> {cgf.GroupFilterName}).Count != 0)
                .Select(cgf =>
                    Filter.GenerateFromGroupFilter(ctx, cgf, uid, nocast, notag, level - 1, all, allpic, pic,
                        tagfilter)).ToList();

            if (gf.FilterType == ((int)GroupFilterType.Season | (int)GroupFilterType.Directory))
                f.filters = filters.OrderBy(a => a.name, new SeasonComparator()).ToList();
            else
                f.filters = filters.OrderByNatural(a => a.name).ToList();

            f.size = f.filters.Count();
            f.url = APIHelper.ConstructFilterIdUrl(ctx, f.id);

            return f;
        }
Exemplo n.º 12
0
        public static void embeddedRead(TagProtocol protocol, TagFilter filter, TagOp tagop)
        {
            TagReadData[]  tagReads = null;
            SimpleReadPlan plan     = new SimpleReadPlan(antennaList, protocol, filter, tagop, 1000);

            r.ParamSet("/reader/read/plan", plan);
            tagReads = r.Read(1000);
            // Print tag reads
            foreach (TagReadData tr in tagReads)
            {
                Console.WriteLine(tr.ToString());
                if (tr.isErrorData)
                {
                    // In case of error, show the error to user. Extract error code.
                    int errorCode = ByteConv.ToU16(tr.Data, 0);
                    Console.WriteLine("Embedded Tag operation failed. Error: " + ReaderCodeException.faultCodeToMessage(errorCode));
                }
                else
                {
                    if (tagop is Gen2.EMMicro.EM4325.GetSensorData)
                    {
                        if (tr.Data.Length > 0)
                        {
                            GetSensorDataResponse rData = new GetSensorDataResponse(tr.Data);
                            Console.WriteLine("Data:" + rData.ToString());
                        }
                    }
                    else
                    {
                        Console.WriteLine("  Data:" + ByteFormat.ToHex(tr.Data, "", " "));
                    }
                }
            }
        }
Exemplo n.º 13
0
        public async Task <ListResponse <TagResponse> > RunAsync(TagFilter filter, ListOptions options)
        {
            var tag = _context.Tags
                      .Include(t => t.Tasks).ThenInclude(tt => tt.Task);

            IQueryable <TagResponse> query = tag
                                             .Select(t => Mapper.Map <TagResponse>(t));



            query = ApplyFilter(query, filter);
            int totalCount = await query.CountAsync();

            if (options.Sort == null)
            {
                options.Sort = "Name";
            }

            query = options.ApplySort(query);
            query = options.ApplyPaging(query);

            return(new ListResponse <TagResponse>
            {
                Items = await query.ToListAsync(),
                Page = options.Page,
                PageSize = options.PageSize ?? totalCount,
                Sort = options.Sort,
                TotalItemsCount = totalCount
            });
        }
Exemplo n.º 14
0
        /// <summary>
        /// Just like AssertResults, but it also tests a given sort method as well.
        /// </summary>
        /// <param name="folderPath"></param>
        /// <param name="sortMethod"></param>
        /// <param name="filter"></param>
        /// <param name="expectedResults"></param>
        private static void AssertSorted
        (
            string folderPath,
            string filter,
            SortMethod sortMethod,
            bool descending,
            params string[] expectedResults)
        {
            // Reset the testing directory before comparing, in case a previous test
            // changed it
            Utils.ResetTestFolder();

            // Get the actual results
            string    fullPath  = Utils.GetTestFolder(folderPath);
            TagFilter tagFilter = new TagFilter(filter);

            var actualResults =
                TagUtils.GetMatchingFiles(fullPath, tagFilter, sortMethod, descending)
                .Select(f => f.Name);

            // Compare them to the expected results
            bool matches = actualResults.SequenceEqual(expectedResults);

            Assert.IsTrue(matches);
        }
Exemplo n.º 15
0
        public static List <Tag> GetTags(HttpContext ctx, SVR_AniDB_Anime anime, TagFilter.Filter filter, bool excludeDescriptions = false)
        {
            var tags = new List <Tag>();

            var allTags      = anime.GetAniDBTags().DistinctBy(a => a.TagName).ToList();
            var filteredTags = TagFilter.ProcessTags(filter, allTags, tag => tag.TagName);

            foreach (AniDB_Tag tag in filteredTags)
            {
                var toAPI = new Tag
                {
                    Name = tag.TagName
                };
                var animeXRef = RepoFactory.AniDB_Anime_Tag.GetByTagID(tag.TagID).FirstOrDefault();
                if (animeXRef != null)
                {
                    toAPI.Weight = animeXRef.Weight;
                }
                if (!excludeDescriptions)
                {
                    toAPI.Description = tag.TagDescription;
                }

                tags.Add(toAPI);
            }

            return(tags);
        }
Exemplo n.º 16
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                rd = Reader.Create("192.168.1.101", ModuleTech.Region.NA, 4);
            }
            catch (Exception ex)
            {
                MessageBox.Show("连接失败,请检查读写器地址是否正确" + ex.ToString());

                return;
            }

            lst1.Items.Add("连接成功!");
            int[] connectedants = (int[])rd.ParamGet("ConnectedAntennas");
            for (int c = 0; c < connectedants.Length; ++c)
            {
                lst1.Items.Add(c + "->" + connectedants[c]);
            }
            TagFilter tf = (TagFilter)rd.ParamGet("Singulation");

            // rd.read

            int[]         ants   = new int[] { 1, 4 };
            Gen2TagFilter filter = new Gen2TagFilter(ByteFormat.FromHex("FFFFFFFF"), MemBank.EPC, 32, false);

            rd.ParamSet("Singulation", filter);
            SimpleReadPlan searchPlan = new SimpleReadPlan(ants);

            rd.ParamSet("ReadPlan", searchPlan);
        }
Exemplo n.º 17
0
        bool DoTagsMatch(TagsCollectionBase osmGeoTags, TagFilter tagFilter)
        {
            // No tags to match
            if (tagFilter == null)
            {
                return(true);
            }

            // Doesn't match if it doesn't contain all of tags
            foreach (var tag in tagFilter.AllOfTags)
            {
                if (!osmGeoTags.Contains(tag.Key, tag.Value))
                {
                    return(false);
                }
            }

            // Doesn't match if it contains at least none of tags
            foreach (var tag in tagFilter.NoneOfTags)
            {
                if (osmGeoTags.Contains(tag.Key, tag.Value))
                {
                    return(false);
                }
            }

            return(true);
        }
        private static bool MatchesFilter(string content, string tagList)
        {
            var page       = new StubStoryTestPage(content);
            var testparser = new TagFilter(tagList);

            return(testparser.Matches(page));
        }
Exemplo n.º 19
0
        public ValidationResults FindAll(TagFilter tagFilter, params string[] tags)
        {
            if (tags == null)
            {
                string[] array = new string[1];
                tags = array;
            }
            ValidationResults validationResults = new ValidationResults();

            foreach (ValidationResult item in (IEnumerable <ValidationResult>) this)
            {
                bool     flag   = false;
                string[] array2 = tags;
                foreach (string text in array2)
                {
                    if (text == null && item.Tag == null)
                    {
                        goto IL_0053;
                    }
                    if (text != null && text.Equals(item.Tag))
                    {
                        goto IL_0053;
                    }
                    continue;
IL_0053:
                    flag = true;
                    break;
                }
                if (flag ^ tagFilter == TagFilter.Ignore)
                {
                    validationResults.AddResult(item);
                }
            }
            return(validationResults);
        }
Exemplo n.º 20
0
        private void PerformReadAllMemOperation(TagFilter filter, TagOp op)
        {
            TagReadData[]  tagReads = null;
            SimpleReadPlan plan     = new SimpleReadPlan(null, TagProtocol.GEN2, filter, op, 1000);

            reader.ParamSet("/reader/read/plan", plan);
            Console.WriteLine("Embedded tag operation - ");
            // Read tags
            tagReads = reader.Read(500);
            foreach (TagReadData tr in tagReads)
            {
                Console.WriteLine(tr.ToString());
                if (0 < tr.Data.Length)
                {
                    Console.WriteLine(" Embedded read data: " + ByteFormat.ToHex(tr.Data, "", " "));
                    Console.WriteLine(" User memory: " + ByteFormat.ToHex(tr.USERMemData, "", " "));
                    Console.WriteLine(" Reserved memory: " + ByteFormat.ToHex(tr.RESERVEDMemData, "", " "));
                    Console.WriteLine(" Tid memory: " + ByteFormat.ToHex(tr.TIDMemData, "", " "));
                    Console.WriteLine(" EPC memory: " + ByteFormat.ToHex(tr.EPCMemData, "", " "));
                }
                Console.WriteLine(" Embedded read data length:" + tr.Data.Length);
            }
            Console.WriteLine();
            Console.WriteLine("Standalone tag operation - ");
            ushort[] data = (ushort[])reader.ExecuteTagOp(op, filter);
            //// Print tag reads
            if (0 < data.Length)
            {
                Console.WriteLine(" Standalone read data:" + ByteFormat.ToHex(ByteConv.ConvertFromUshortArray(data), "", " "));
                Console.WriteLine(" Standalone read data length:" + ByteConv.ConvertFromUshortArray(data).Length);
            }
            data = null;
            Console.WriteLine();
        }
Exemplo n.º 21
0
        bool DoTagsMatch(TagsCollectionBase osmGeoTags, TagFilter tagFilter)
        {
            var allOfTags  = tagFilter.AllOfTags;
            var noneOfTags = tagFilter.NoneOfTags;

            // Doesn't match if it doesn't contain all of tags
            for (int i = 0; i < allOfTags.Length; i++)
            {
                if (!osmGeoTags.Contains(allOfTags[i].Key, allOfTags[i].Value))
                {
                    return(false);
                }
            }

            // Doesn't match if it contains at least none of tags
            for (int i = 0; i < noneOfTags.Length; i++)
            {
                if (osmGeoTags.Contains(noneOfTags[i].Key, noneOfTags[i].Value))
                {
                    return(false);
                }
            }

            return(true);
        }
Exemplo n.º 22
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="session"></param>
 /// <param name="target"></param>
 /// <param name="filter"></param>
 /// <param name="antID"></param>
 public CustomAntConfigPerAntenna(Gen2.Session session, Gen2.Target target, TagFilter filter, int antID)
 {
     this.session = session;
     this.target  = target;
     this.filter  = filter;
     this.antID   = antID;
 }
Exemplo n.º 23
0
        public ValidationResults FindAll(TagFilter tagFilter, params string[] tags)
        {
            // workaround for params behavior - a single null parameter will be interpreted
            // as null array, not as an array with null as element
            if (tags == null)
            {
                tags = new string[] { null };
            }

            var filteredValidationResults = new ValidationResults();

            foreach (ValidationResult validationResult in this)
            {
                bool matches = tags.Any(tag => (tag == null && validationResult.Tag == null) || (tag != null && tag.Equals(validationResult.Tag)));

                // if ignore, look for !match
                // if include, look for match
                if (matches ^ (tagFilter == TagFilter.Ignore))
                {
                    filteredValidationResults.AddResult(validationResult);
                }
            }

            return(filteredValidationResults);
        }
Exemplo n.º 24
0
        /// <summary>
        /// Read tag memory for readers or modules other the M5e variants
        /// </summary>
        /// <param name="bank">Gen2 memory bank</param>
        /// <param name="filter">filter</param>
        /// <param name="MemData">Data read from tag memory</param>
        private void ReadMemoryM6eVariants(Gen2.Bank bank, TagFilter filter, ref ushort[] MemData)
        {
            try
            {
                // Read tag memory with zero as start address and lenght of words to read as zero
                TagOp op = new Gen2.ReadData(bank, 0, 0);
                MemData = (ushort[])objectReader.ExecuteTagOp(op, filter);

                if (MemData.Length < 64)
                {
                    // If data read is less then 64 words, then perform read word by word to make sure
                    // all the data is read from the tag memory
                    ReadTagMemoryWordByWord(bank, filter, ref MemData);
                }
                else
                {
                    // If data read is more then 64 words then perform read with start address as 64 words
                    // and length as zero
                    ReadLargeTagMemory(bank, filter, ref MemData);
                }
            }
            catch (Exception ex)
            {
                if ((ex is FAULT_PROTOCOL_BIT_DECODING_FAILED_Exception) || ((ex is FAULT_NO_TAGS_FOUND_Exception)))
                {
                    // Perform read when the tag has mem more then 128 bytes and doesn't support
                    // Zero start address and number of words to read as zero
                    ReadLargeTagMemoryWithoutZeroLengthSupport(bank, filter, ref MemData);
                }
                else
                {
                    throw;
                }
            }
        }
Exemplo n.º 25
0
        public ValidationResults FindAll(TagFilter tagFilter, params string[] tags)
        {
            if (tags == null)
            {
                tags = new string[1];
            }
            ValidationResults results = new ValidationResults();

            foreach (ValidationResult result in (IEnumerable <ValidationResult>) this)
            {
                bool flag = false;
                foreach (string str in tags)
                {
                    if (((str == null) && (result.Tag == null)) || ((str != null) && str.Equals(result.Tag)))
                    {
                        flag = true;
                        break;
                    }
                }
                if (flag ^ (tagFilter == TagFilter.Ignore))
                {
                    results.AddResult(result);
                }
            }
            return(results);
        }
Exemplo n.º 26
0
        private void SetReadPlan()
        {
            TagFilter filter = null;


            if (selectMemBank == Gen2.Bank.EPC)
            {
                if (txtEpc.Text != "")
                {
                    filter = new TagData(txtEpc.Text);
                }
            }
            else
            {
                byte[] data = ByteFormat.FromHex(txtData.Text);

                if (null == data)
                {
                    dataLength = 0;
                }
                else
                {
                    dataLength = data.Length;
                }

                filter = new Gen2.Select(false, selectMemBank, Convert.ToUInt16(startAddress * 16), Convert.ToUInt16(dataLength * 8), data);
            }

            SimpleReadPlan srp = new SimpleReadPlan(new int[] { antenna }, TagProtocol.GEN2, filter, 1000);

            objReader.ParamSet("/reader/read/plan", srp);
        }
        public static async Task <IEnumerable <string> > GetCommitMessagesFromTagAsync(
            this IRepository repository,
            TagFilter filter)
        {
            var tag = repository.Tags.From(filter);

            if (tag is null)
            {
                throw new NullReferenceException("No tag was found with provided name.");
            }

            var commit = repository.Commits.FirstOrDefault(x => x.Sha.Equals(tag.PeeledTarget.Sha));

            if (commit is null)
            {
                throw new NullReferenceException("No commits were found from provided tag.");
            }

            var exclusionList = new List <Commit>(commit.Parents)
            {
                commit
            };
            var commitFilter = new CommitFilter()
            {
                ExcludeReachableFrom = exclusionList
            };

            return(await repository.GetCommitMessagesByFilterAsync(commitFilter));
        }
Exemplo n.º 28
0
        public static List <Tag> GetTags(HttpContext ctx, SVR_AniDB_Anime anime, TagFilter.Filter filter, bool excludeDescriptions = false)
        {
            // TODO This is probably slow. Make it faster.
            var tags = new List <Tag>();

            var allTags      = anime.GetAniDBTags().DistinctBy(a => a.TagName).ToDictionary(a => a.TagName, a => a);
            var filteredTags = TagFilter.ProcessTags(filter, allTags.Keys.ToList());

            foreach (string filteredTag in filteredTags)
            {
                AniDB_Tag tag = allTags.ContainsKey(filteredTag)
                    ? allTags[filteredTag]
                    : RepoFactory.AniDB_Tag.GetByName(filteredTag).FirstOrDefault();
                if (tag == null)
                {
                    tags.Add(new Tag {
                        Name = filteredTag
                    });
                    continue;
                }
                var toAPI = new Tag
                {
                    Name = tag.TagName
                };
                if (!excludeDescriptions)
                {
                    toAPI.Description = tag.TagDescription;
                }
                tags.Add(toAPI);
            }

            return(tags);
        }
Exemplo n.º 29
0
 RunnerOptions NullFilter()
 {
     return(new RunnerOptions
     {
         Filter = TagFilter.Empty(),
         DruRun = false,
     });
 }
Exemplo n.º 30
0
 /// <summary>
 ///  Create a SimpleReadPlan
 /// </summary>
 /// <param name="antennaList">List of antenna numbers.  May be null.</param>
 /// <param name="protocol">Protocol identifier</param>
 /// <param name="filter">Tag filter.  May be null.</param>
 /// <param name="op">Operation mode</param>
 /// <param name="weight">Relative scheduling weight</param>
 public SimpleReadPlan(ICollection <int> antennaList, TagProtocol protocol, TagFilter filter, TagOp op, int weight)
     : base(weight)
 {
     Antennas = (antennaList != null) ? CollUtil.ToArray(antennaList) : null;
     Protocol = protocol;
     Filter   = filter;
     Op       = op;
 }
Exemplo n.º 31
0
        public void CanCompareFilters()
        {
            AssertEqual(TagFilter.Empty(),
                        new TagFilter(new string[0], new string[0]));

            AssertEqual(new TagFilter(new[] { "tag1", "tag2" }, new[] { "tag3", "tag4" }),
                        new TagFilter(new[] { "tag2", "tag1" }, new[] { "tag4", "tag3" }));
        }
Exemplo n.º 32
0
 // Use this for initialization
 void Start()
 {
     gps = GameObject.Find ("GamePanelHolder").GetComponent<GamePanelScript> ();
     gf = gameObject.GetComponent<GameFactory> ();
     xreader = new XMLReader ();
     taad = gameObject.GetComponent<TestAddAndDestroy> ();
     gamesActive = new List<string> {"Auditiv","Kinæstetisk","Visuel","Taktil"};
     tagFilter = new TagFilter ();
     LoadAllXML ();
 }
Exemplo n.º 33
0
        /// <summary>
        /// Creates a new additive filter
        /// </summary>
        /// <param name="a"></param>
        /// <param name="b"></param>
        public TagFilterAdditive(TagFilter a, TagFilter b)
        {
            if (a == null)
            {
                throw new ArgumentNullException("a");
            }

            if (b == null)
            {
                throw new ArgumentNullException("b");
            }

            _a = a;
            _b = b;
        }
Exemplo n.º 34
0
        /// <summary>
        /// Write a new ID to a tag.
        /// </summary>
        /// <param name="target">the tag target to operate on</param>
        /// <param name="epc">the tag ID to write</param>

        public override void WriteTag(TagFilter target, TagData epc)
        {
            // Validate parameters
            TagProtocol protocol = (TagProtocol)ParamGet("/reader/tagop/protocol");
            switch (protocol)
            {
                case TagProtocol.ISO180006B:
                case TagProtocol.ISO180006B_UCODE:
                    if (null == target)
                    {
                        throw new ReaderException("ISO18000-6B does not yet support writing ID to unspecified tags.  Please provide a TagFilter.");
                    }
                    break;
            }

            PrepForTagop();
            SetField("tag_id.id", new WriteTagArgs(target, epc));
        }
Exemplo n.º 35
0
        /// <summary>
        /// Write the data to user memoru
        /// </summary>
        /// <param name="filter"> data to be written on the specified tag which is used as filter</param>
        private void WriteUserMem(TagFilter filter)
        {
            string userMem = string.Empty;
            try
            {
                objReader.ParamSet("/reader/tagop/protocol", TagProtocol.GEN2);
                if ((bool)rbHexRep.IsChecked)
                {
                    for(int count = 0; count < txtbxHexRepList.Length; count++)
                    {
                        if (txtbxHexRepList[count].Text != string.Empty)
                        {
                            userMem += txtbxHexRepList[count].Text;
                        }
                        else
                        {
                            userMem += "00";
                        }
                    }
                        ExecuteUsermemoryTagOp(ByteConv.ToU16s(ByteFormat.FromHex(userMem)), filter);

                        UpdateHexUserMemoryRepresentation(ByteFormat.FromHex(userMem));
                        txtASCIIData.IsEnabled = true;
                        originalAsciiNewString = Utilities.HexStringToAsciiString(userMem);
                        btnWrite.IsEnabled = false;
                        btnWriteAscii.IsEnabled = false;
                }                
                else if ((bool)rbASCII.IsChecked)
                {
                    if (txtASCIIData.Text.Length > 0)
                    {
                        string editedAsciiData = EditAsciiString(editedAsciiNewString);
                        UpdateHexEditor(editedAsciiData);
                        ExecuteUsermemoryTagOp(ByteConv.ToU16s(ByteFormat.FromHex(Utilities.AsciiStringToHexString(editedAsciiData))), filter);                        
                        
                        txtASCIIData.Foreground = Brushes.Black;
                        originalAsciiNewString = editedAsciiData;
                        btnWrite.IsEnabled = false;
                        btnWriteAscii.IsEnabled = false;
                    }
                    else
                    {
                        return;
                    }
                }                
                MessageBox.Show("Write user memory is successfull", "Info", MessageBoxButton.OK, MessageBoxImage.Information);                                
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString(), "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Exemplo n.º 36
0
        /// <summary>
        /// Perform a lock or unlock operation on a tag. The first tag seen
        /// is operated on - the singulation parameter may be used to control
        /// this. Note that a tag without an access password set may not
        /// accept a lock operation or remain locked.
        /// </summary>
        /// <param name="target">the tag target to operate on</param>
        /// <param name="action">the tag lock action</param>
        public override void LockTag(TagFilter target, TagLockAction action)
        {
            PrepForTagop();
            TagProtocol protocol = (TagProtocol) ParamGet("/reader/tagop/protocol");

            if (action is Gen2.LockAction)
            {
                if (TagProtocol.GEN2 != protocol)
                {
                    throw new ArgumentException(String.Format(
                        "Gen2.LockAction not compatible with protocol {0}",
                        protocol.ToString()));
                }

                Gen2.LockAction la = (Gen2.LockAction) action;

                // TODO: M4API makes a distinction between locking tag ID and data.
                // Locking tag_id allows access to only the EPC, TID and password banks.
                // Locking tag_data allows access to only the User bank.
                // Ideally, M4API would stop making the distinction, since Gen2 has a unified locking model.
                // In the meantime, just lock tag_id, since it covers more and tags with user memory are still uncommon.

                if ((la.Mask & 0x3FC) != 0)
                    SetField("tag_id.locked", new Gen2LockArgs(target, (Gen2.LockAction) action));

                else if ((la.Mask & 0x3) != 0)
                    SetField("tag_data.locked", new Gen2LockArgs(target, (Gen2.LockAction) action));
            }
            else
                throw new ArgumentException("LockTag does not support this type of TagLockAction: " + action.ToString());
        }
Exemplo n.º 37
0
        /// <summary>
        /// Read tag memory for readers or modules other the M5e variants
        /// </summary>
        /// <param name="bank">Gen2 memory bank</param>
        /// <param name="filter">filter</param>
        /// <param name="MemData">Data read from tag memory</param>
        private void ReadMemoryM6eVariants(Gen2.Bank bank, TagFilter filter, ref ushort[] MemData)
        {
            try
            {
                // Read tag memory with zero as start address and lenght of words to read as zero
                TagOp op = new Gen2.ReadData(bank, 0, 0);
                MemData = (ushort[])objectReader.ExecuteTagOp(op, filter);

                if (MemData.Length < 64)
                {
                    // If data read is less then 64 words, then perform read word by word to make sure 
                    // all the data is read from the tag memory
                    ReadTagMemoryWordByWord(bank, filter, ref MemData);
                }
                else
                {
                    // If data read is more then 64 words then perform read with start address as 64 words
                    // and length as zero
                    ReadLargeTagMemory(bank, filter, ref MemData);
                }
            }
            catch (Exception ex)
            {
                if ((ex is FAULT_PROTOCOL_BIT_DECODING_FAILED_Exception) || ((ex is FAULT_NO_TAGS_FOUND_Exception)))
                {
                    // Perform read when the tag has mem more then 128 bytes and doesn't support 
                    // Zero start address and number of words to read as zero
                    ReadLargeTagMemoryWithoutZeroLengthSupport(bank, filter, ref MemData);
                }
                else
                {
                    throw;
                }
            }
        }
Exemplo n.º 38
0
 /// <summary>
 ///  Create a SimpleReadPlan
 /// </summary>
 /// <param name="antennaList">List of antenna numbers.  May be null.</param>
 /// <param name="protocol">Protocol identifier</param>
 /// <param name="filter">Tag filter.  May be null.</param>
 /// <param name="op">Operation mode</param>
 /// <param name="weight">Relative scheduling weight</param>
 /// <param name="useFastSearch">Enable fast search</param>
 public SimpleReadPlan(ICollection<int> antennaList, TagProtocol protocol, TagFilter filter, TagOp op, bool useFastSearch, int weight)
     : base(weight)
 {
     Antennas = (antennaList != null) ? CollUtil.ToArray(antennaList) : null;
     Protocol = protocol;
     Filter = filter;
     Op = op;
     UseFastSearch = useFastSearch;
 }
Exemplo n.º 39
0
        public void Iso180006bLockTag(TagFilter filter,byte address)
        {
            PrepForTagop();
            TagProtocol protocol = (TagProtocol) ParamGet("/reader/tagop/protocol");

            if (null != filter )
            {
                Iso180006bLockArgs lockArgs = new Iso180006bLockArgs(filter, address, 1);
                SetField("tag_data.locked", lockArgs);
            }
            else
                throw new ArgumentException("ISO180006B only supports locking a single tag specified by 64-bit EPC");
        }
Exemplo n.º 40
0
 public Iso180006bLockArgs(TagFilter target, byte address,int locked)
 {
     Target = target;
     Address = address;
     Locked = locked;
 }
Exemplo n.º 41
0
        /// <summary>
        /// Read data from the memory bank of a tag.
        /// </summary>
        /// <param name="target">the tag target to operate on</param>
        /// <param name="bank">the tag memory bank</param>
        /// <param name="address">the reading starting byte address</param>
        /// <param name="byteCount">the bytes to read</param>
        /// <returns>the bytes read</returns>
        public override byte[] ReadTagMemBytes(TagFilter target, int bank, int address, int byteCount)
        {
            PrepForTagop();
            int wordAddress = 0, wordCount = 0;

          
            List<string> wheres = new List<string>();
            if (TagProtocol.GEN2 == (TagProtocol)ParamGet("/reader/tagop/protocol"))
            {
                wheres.Add(String.Format("mem_bank={0:D}", bank));
                wordAddress = address / 2;
                wordCount = ByteConv.WordsPerBytes(byteCount);
            }
            else
            {
                wordAddress = address;
                wordCount = byteCount;
            }
            wheres.Add(String.Format("block_count={0:D}", wordCount));
            wheres.Add(String.Format("block_number={0:D}", wordAddress));
            
            Gen2.Password password = (Gen2.Password)(ParamGet("/reader/gen2/accessPassword"));
            if ((TagProtocol.GEN2 == (TagProtocol)ParamGet("/reader/tagop/protocol")) && (password.Value != 0))
            {
                wheres.Add(String.Format("password=0x{0:X}", password));
            }
            wheres.AddRange(MakeTagopWheres(target));
            string response = Select(new string[] { "data" }, "tag_data", wheres, -1)[0];
            if (TagProtocol.GEN2 == (TagProtocol)ParamGet("/reader/tagop/protocol"))
            {
                // Skip "0x" prefix
                int charOffset = 2;
                // Correct for word start boundary
                int byteOffset = address - (wordAddress * 2);
                charOffset += byteOffset * 2;
                int charLength = byteCount * 2;
                string byteStr = response.Substring(charOffset, charLength);

                return ByteFormat.FromHex(byteStr);
            }
            else
            {
                return ByteFormat.FromHex(response);
            }
        }
Exemplo n.º 42
0
 void AssertEqual(TagFilter filter1, TagFilter filter2)
 {
     Assert.IsTrue(filter1 == filter2);
     Assert.IsFalse(filter1 != filter2);
 }
Exemplo n.º 43
0
 public WriteTagArgs(TagFilter target, TagData epc)
 {
     Target = target;
     Epc = epc;
 }
Exemplo n.º 44
0
        /// <summary>
        /// Create WHERE clauses representing a tag filter
        /// </summary>
        /// <param name="tagFilter">Tag filter</param>
        /// <returns>List of strings to be incorporated into "WHERE ... AND ..." phrase.
        /// List may be empty.</returns>
        private List<string> TagFilterToWhereClause(TagFilter tagFilter)
        {
            List<string> wheres = new List<string>();

            if (null == tagFilter)
            {
                // Do nothing
            }
            else if (tagFilter is Iso180006b.TagData)
            {
                Iso180006b.TagData td = (Iso180006b.TagData)tagFilter;
                wheres.Add(String.Format("id={0}", ByteFormat.ToHex(td.EpcBytes)));
            }
            else if (tagFilter is TagData)
            {
                TagData td = (TagData) tagFilter;
                wheres.Add(String.Format("id={0}", ByteFormat.ToHex(td.EpcBytes)));
            }
            else if (tagFilter is Gen2.Select)
            {
                Gen2.Select sel = (Gen2.Select)tagFilter;
                wheres.Add("filter_subtype=0");
                wheres.Add(String.Format("filter_mod_flags=0x{0:X}", (sel.Invert) ? "00000001" : "00000000"));
                wheres.Add(String.Format("filter_bank=0x{0:X}" , sel.Bank));
                wheres.Add("filter_bit_address=" + sel.BitPointer);
                wheres.Add("filter_bit_length="+sel.BitLength);
                wheres.Add("filter_data=0x" + BitConverter.ToString(sel.Mask).Replace("-", string.Empty));
            }
            else if (tagFilter is Iso180006b.Select)
            {
                Iso180006b.Select sel = (Iso180006b.Select)tagFilter;
                wheres.Add("filter_subtype=0");
                string operation = string.Empty;
                switch (sel.Op)
                {
                    case Iso180006b.SelectOp.EQUALS: operation = "00"; break;
                    case Iso180006b.SelectOp.NOTEQUALS: operation = "01"; break;
                    case Iso180006b.SelectOp.GREATERTHAN: operation = "02"; break;
                    case Iso180006b.SelectOp.LESSTHAN: operation = "03"; break;
                    default: break;
                };
                wheres.Add(String.Format("filter_command=0x{0:X}",operation));
                wheres.Add(String.Format("filter_mod_flags=0x{0:X}", (sel.Invert) ? "00000001" : "00000000"));                
                wheres.Add("filter_bit_address=" + sel.Address);
                wheres.Add("filter_bit_length=64");
                wheres.Add("filter_data=0x" + BitConverter.ToString(sel.Data).Replace("-", string.Empty));
            }
            else
                throw new ArgumentException("RQL only supports singulation by EPC. " + tagFilter.ToString() + " is not supported.");

            return wheres;
        }
Exemplo n.º 45
0
 /// <summary>
 /// Read tag memory when tag has more then 64 words or 128 bytes. And module doesn't supports zero address and zero length.
 /// Reads the tag memory with 0 address and length of words as 64. If memory overrun received. Initiates reading of tag 
 /// word by word with start address as length of alread read data and length of words to read as 0. Returns the data read from 
 /// tag memory.
 /// </summary>
 /// <param name="bank">Gen2 mem bank</param>
 /// <param name="filter">filter</param>
 /// <param name="data">Data read from tag memory</param>
 private void ReadLargeTagMemoryWithoutZeroLengthSupport(Gen2.Bank bank, TagFilter filter, ref ushort[] data)
 {
     lock (new Object())
     {
         data = null;
         // Data from tag memory
         List<ushort> dataTemp = new List<ushort>();
         // Number of words to read
         int words = 64;
         // Start address
         uint startaddress = 0;
         TagOp op;
         bool isAllDatareceived = true;
         // Read till all the data from the tag memory is read
         while (isAllDatareceived)
         {
             try
             {
                 op = new Gen2.ReadData(bank, startaddress, Convert.ToByte(words));
                 dataTemp.AddRange(((ushort[])objectReader.ExecuteTagOp(op, filter)));
                 // Increment the start address to 64 and keep length of wrods to read as 64 for
                 // all the iterations
                 startaddress += 64;
             }
             catch (Exception ex)
             {
                 try
                 {
                     if (ex is FAULT_GEN2_PROTOCOL_MEMORY_OVERRUN_BAD_PC_Exception || (-1 != ex.Message.IndexOf("Non-specific reader error")) || (-1 != ex.Message.IndexOf("General Tag Error")) || (-1 != ex.Message.IndexOf("Tag data access failed")))
                     {
                         // If the memory to read requested is more then the available memory in the tag, then initiate 
                         // reading the tag memory word by word with start address as length of already read data if exists 
                         // and lenght of words to read is 1
                         ushort[] wordData = null;
                         if (dataTemp.Count > 0)
                         {
                             // If some data is already read then include this data also so that 
                             // reading of memory doesn't continue from zero and the list sholud 
                             // not contain same data twice
                             wordData = dataTemp.ToArray();
                         }
                         ReadTagMemoryWordByWord(bank, filter, ref wordData);
                         dataTemp.AddRange(wordData);
                         // Come out of main while loop. And read the already read data
                         isAllDatareceived = false;
                     }
                     else
                     {
                         throw;
                     }
                 }
                 catch (Exception exception)
                 {
                     // If more then once the below exceptions are recieved then come out of the loop.
                     if (exception is FAULT_GEN2_PROTOCOL_MEMORY_OVERRUN_BAD_PC_Exception || (-1 != exception.Message.IndexOf("Non-specific reader error")) || (-1 != exception.Message.IndexOf("General Tag Error")) || (-1 != exception.Message.IndexOf("Tag data access failed")))
                     {
                         if (dataTemp.Count > 0)
                         {
                             // Just skip the exception and move on. So as not to lose the already read data.
                             isAllDatareceived = false;
                         }
                         else
                         {
                             // throw the exception if the data received is null for the first iteration itself
                             throw;
                         }
                     }
                     else
                     {
                         throw;
                     }
                 }
             }
         }
         data = dataTemp.ToArray();
     }
 }
Exemplo n.º 46
0
        /// <summary>
        /// Read specified tag memory bank 
        /// </summary>
        /// <param name="bank">Gen2 bank</param>
        /// <param name="filter">filter</param>
        /// <param name="MemData">Data read from the tag memory</param>
        public void ReadTagMemoryData(Gen2.Bank bank, TagFilter filter, ref ushort[] MemData)
        {

            if (modelReader.Equals("M5e") || modelReader.Equals("M5e EU") || modelReader.Equals("M5e Compact") || modelReader.Equals("Astra"))
            {
                // Read tag memory word by word for M5e variants
                ReadTagMemoryWordByWord(bank, filter, ref MemData);
            }
            else
            {
                // Read tag memory for m6e variants
                ReadMemoryM6eVariants(bank, filter, ref MemData);
            }
        }
Exemplo n.º 47
0
 /// <summary>
 /// Write data to user memory
 /// </summary>
 /// <param name="userMemData"></param>
 /// <param name="filter"></param>
 private void ExecuteUsermemoryTagOp(ushort [] userMemData, TagFilter filter)
 {
     uint userMemStartAddress = (uint)startAddress;
     uint[] wrdAddressList = null;
     wrdAddressList = GetWordAddressList();
     int editedDataCellLocLength = 0;
     while (editedDataCellLocLength < wrdAddressList.Length)
     {
         userMemStartAddress = wrdAddressList[editedDataCellLocLength];
         ushort[] dataToBeWritten = new ushort[1];
         Array.Copy(userMemData, userMemStartAddress, dataToBeWritten, 0, 1);
         objReader.ExecuteTagOp(new Gen2.WriteData(Gen2.Bank.USER, userMemStartAddress, dataToBeWritten), filter);
         editedDataCellLocLength++;
     }
 }
Exemplo n.º 48
0
        /// <summary>
        /// Write data to the memory bank of a tag.
        /// </summary>
        /// <param name="target">the tag target to operate on</param>
        /// <param name="bank">the tag memory bank</param>
        /// <param name="address">the memory address to write</param>
        /// <param name="data">the data to write</param>
        public override void WriteTagMemWords(TagFilter target, int bank, int address, ICollection<ushort> data)
        {
            ushort[] dataArray = CollUtil.ToArray(data);
            byte[] dataBytes = new byte[dataArray.Length * 2];

            for (int i = 0; i < dataArray.Length; i++)
            {
                dataBytes[2 * i] = (byte)((dataArray[i] >> 8) & 0xFF);
                dataBytes[2 * i + 1] = (byte)((dataArray[i]) & 0xFF);
            }           
            
            WriteTagMemBytes(target, bank, address*2, dataBytes);
        }
Exemplo n.º 49
0
        /// <summary>
        /// Read data from the memory bank of a tag.
        /// </summary>
        /// <param name="target">the tag target to operate on</param>
        /// <param name="bank">the tag memory bank</param>
        /// <param name="wordAddress">the read starting word address</param>
        /// <param name="wordCount">the number of words to read</param>
        /// <returns>the read words</returns>

        public override ushort[] ReadTagMemWords(TagFilter target, int bank, int wordAddress, int wordCount)
        {
            return ReadTagMemWordsGivenReadTagMemBytes(target, bank, wordAddress, wordCount);
        }
        /// <summary>
        /// Parse epc memory data and populate the epc mem textboxes
        /// </summary>
        /// <param name="epcData">accepts read epc memory data</param>
        private void ParseEPCMemData(ushort[] epcData, TagFilter filter)
        {
            unUsedEpcData = string.Empty;
            byte[] epcBankData = null;
            if (null != epcData)
            {
                epcBankData = ByteConv.ConvertFromUshortArray(epcData);
                int readOffset = 0;
                byte[] epc, crc, pc, unusedEpc = null, additionalMemData = null;
                int lengthCounter = 2;
                crc = SubArray(epcBankData, ref readOffset, lengthCounter);
                pc = SubArray(epcBankData, ref readOffset, lengthCounter);
                lengthCounter += 2;

                // Extract the epc length from pc word
                int epclength = Convert.ToInt32(((pc[0] & 0xf8) >> 3)) * 2;

                epc = SubArray(epcBankData, ref readOffset, epclength);

                List<byte> xpc = new List<byte>();

                /* Add support for XPC bits
                    * XPC_W1 is present, when the 6th most significant bit of PC word is set
                    */
                if ((pc[0] & 0x02) == 0x02)
                {
                    /* When this bit is set, the XPC_W1 word will follow the PC word
                        * Our TMR_Gen2_TagData::pc has enough space, so copying to the same.
                        */
                    try
                    {
                        ushort[] xpcW1 = (ushort[])objReader.ExecuteTagOp(new Gen2.ReadData(Gen2.Bank.EPC, 0x21, 1), filter);
                        spXPC.Visibility = System.Windows.Visibility.Visible;
                        lblXPC1MemAddress.Content = "33";
                        xpc.AddRange(ByteConv.ConvertFromUshortArray(xpcW1));
                        lengthCounter += 2;
                        txtXPC1.Text = ByteFormat.ToHex(ByteConv.ConvertFromUshortArray(xpcW1), "", " ");
                        lblXPC1.Content = "XPC";
                    }
                    catch (Exception ex)
                    {
                        spXPC.Visibility = System.Windows.Visibility.Visible;
                        txtXPC1.Text = ex.Message;
                        lblXPC1.Content = "XPC";
                    }
                        /* If the most siginificant bit of XPC_W1 is set, then there exists
                        * XPC_W2. A total of 6  (PC + XPC_W1 + XPC_W2 bytes)
                        */
                    if ((xpc[0] & 0x80) == 0x80)
                    {
                        try
                        {
                            ushort[] xpcW2 = (ushort[])objReader.ExecuteTagOp(new Gen2.ReadData(Gen2.Bank.EPC, 0x22, 1), filter);
                            spXPC2.Visibility = System.Windows.Visibility.Visible;
                            lblXPC2MemAddress.Content = "34";
                            lengthCounter += 2;
                            txtXPC2.Text = ByteFormat.ToHex(ByteConv.ConvertFromUshortArray(xpcW2), "", " ");
                            // Change the name of XPC to XPC1
                            lblXPC1.Content = "XPC1";
                        }
                        catch (Exception ex)
                        {
                            spXPC2.Visibility = System.Windows.Visibility.Visible;
                            txtXPC2.Text = ex.Message;
                            // Change the name of XPC to XPC1
                            lblXPC1.Content = "XPC1";
                        }
                    }
                }
                // Read extended epc memory
                if (epcBankData.Length > (lengthCounter + epclength))
                {
                    lblExtdEPCMemAddress.Content = Convert.ToString(readOffset/2);
                    bool isExtendedEPCMemover = true;
                    uint startExtdEPCMemAddress = (uint)readOffset/2;
                    List<ushort> data = new List<ushort>();
                    try
                    {
                        while (isExtendedEPCMemover)
                        {
                            // Make sure reading of memory word by word doesn't override XPC1 data
                            if (startExtdEPCMemAddress < 33)
                            {
                                data.AddRange((ushort[])objReader.ExecuteTagOp(new Gen2.ReadData(Gen2.Bank.EPC, startExtdEPCMemAddress, 1), filter));
                                startExtdEPCMemAddress += 1;
                            }
                            else
                            {
                                // Read of memory should not exceed XPC bytes
                                isExtendedEPCMemover = false;
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        // If more then once the below exceptions are recieved then come out of the loop.
                        if (ex is FAULT_GEN2_PROTOCOL_MEMORY_OVERRUN_BAD_PC_Exception || (-1 != ex.Message.IndexOf("Non-specific reader error")) || (-1 != ex.Message.IndexOf("General Tag Error")) || (-1 != ex.Message.IndexOf("Tag data access failed")))
                        {
                            if (data.Count > 0)
                            {
                                // Just skip the exception and move on. So as not to lose the already read data.
                                isExtendedEPCMemover = false;
                            }
                        }
                    }

                    if (data.Count > 0)
                    {
                        unusedEpc = ByteConv.ConvertFromUshortArray(data.ToArray());
                    }
                }

                // Read additional memory
                if (epcBankData.Length > (lengthCounter + epclength))
                {
                    lblAddMemAddress.Content = "35";
                    bool isAdditionalMemover = true;
                    uint startAdditionalMemAddress = 0x23;
                    List<ushort> dataAdditionalMem = new List<ushort>();
                    try
                    {
                        while (isAdditionalMemover)
                        {
                            dataAdditionalMem.AddRange((ushort[])objReader.ExecuteTagOp(new Gen2.ReadData(Gen2.Bank.EPC, startAdditionalMemAddress, 1), filter));
                            startAdditionalMemAddress += 1;
                        }
                    }
                    catch (Exception ex)
                    {
                        // If more then once the below exceptions are recieved then come out of the loop.
                        if (ex is FAULT_GEN2_PROTOCOL_MEMORY_OVERRUN_BAD_PC_Exception || (-1 != ex.Message.IndexOf("Non-specific reader error")) || (-1 != ex.Message.IndexOf("General Tag Error")) || (-1 != ex.Message.IndexOf("Tag data access failed")))
                        {
                            if (dataAdditionalMem.Count > 0)
                            {
                                // Just skip the exception and move on. So as not to lose the already read data.
                                isAdditionalMemover = false;
                            }
                        }
                    }
                    if (dataAdditionalMem.Count > 0)
                    {
                        additionalMemData = ByteConv.ConvertFromUshortArray(dataAdditionalMem.ToArray());
                    }                    
                }

                if (txtXPC1.Text != "")
                {
                    spXPC.Visibility = System.Windows.Visibility.Visible;
                }
                if (txtXPC2.Text != "")
                {
                    spXPC2.Visibility = System.Windows.Visibility.Visible;
                }

                txtCRC.Text = ByteFormat.ToHex(crc, "", " ");
                txtPC.Text = ByteFormat.ToHex(pc, "", " ");
                if (epc.Length == epclength)
                {
                    txtEPCData.Text = ByteFormat.ToHex(epc, "", " ");
                }
                else
                {
                    txtEPCData.Text = currentEPC;
                }
                if (null != unusedEpc)
                {
                    txtEPCUnused.Text = ByteFormat.ToHex(unusedEpc, "", " ");
                    unUsedEpcData = ByteFormat.ToHex(unusedEpc, "", "");
                    // Visible additional memory
                    spUnused.Visibility = System.Windows.Visibility.Visible;
                }

                if (null != additionalMemData)
                {
                    txtAdditionalMem.Text = ByteFormat.ToHex(additionalMemData, "", " ");
                    unadditionalMemData = ByteFormat.ToHex(additionalMemData, "", "");
                    // Visible additional memory
                    spAddMemory.Visibility = System.Windows.Visibility.Visible;
                }

                if ((bool)rbEPCAscii.IsChecked)
                {
                    txtEPCValue.Text = Utilities.HexStringToAsciiString(currentEPC);
                    txtEPCUnusedValue.Text = Utilities.HexStringToAsciiString(unUsedEpcData);
                    txtadditionalMemValue.Text = Utilities.HexStringToAsciiString(unadditionalMemData);
                }
                else if ((bool)rbEPCBase36.IsChecked)
                {
                    txtEPCValue.Text = Utilities.ConvertHexToBase36(currentEPC);
                    txtEPCUnusedValue.Text = Utilities.ConvertHexToBase36(unUsedEpcData);
                    txtadditionalMemValue.Text = Utilities.ConvertHexToBase36(unadditionalMemData);
                }

                #region 0 length read

                //if (model.Equals("M5e") || model.Equals("M5e EU") || model.Equals("M5e Compact"))
                //{
                //    ReadData(Gen2.Bank.EPC, searchSelect, out epcData);
                //}
                //else
                //{
                //    op = new Gen2.ReadData(Gen2.Bank.EPC, 0, 0);
                //    epcData = (ushort[])objReader.ExecuteTagOp(op, searchSelect);
                //}

                //if(null!= epcData)
                //    epcBankData = ByteFormat.ToHex(ByteConv.ConvertFromUshortArray(epcData), "", " ");

                //if (epcBankData.Length > 0)
                //{
                //    int epcLen = txtEpc.Text.Length;
                //    txtCRC.Text = epcBankData.Substring(0, 5).TrimStart(' ');
                //    txtPC.Text = epcBankData.Substring(6, 5).TrimStart(' ');
                //    int epcstringLength = epcLen+((epcLen/2)-1);
                //    txtEPCData.Text = epcBankData.Substring(11, epcstringLength).TrimStart(' ');

                //    //string epcDataString = ByteFormat.ToHex(ByteConv.ConvertFromUshortArray(epcData), "", "");
                //    txtEPCUnused.Text = epcBankData.Substring(11 + epcstringLength).TrimStart(' '); //String.Join(" ", (epcDataString.Substring(8 + epcLen)).ToArray());
                #endregion

            }
        }
Exemplo n.º 51
0
 /// <summary>
 ///  Create a SimpleReadPlan
 /// </summary>
 /// <param name="antennaList">List of antenna numbers.  May be null.</param>
 /// <param name="protocol">Protocol identifier</param>
 /// <param name="filter">Tag filter.  May be null.</param>
 /// <param name="weight">Relative scheduling weight</param>
 public SimpleReadPlan(ICollection<int> antennaList, TagProtocol protocol, TagFilter filter, int weight)
     : this(antennaList, protocol, filter, _defaultTagOp, weight)
 {
 }
        private void ReadReservedMemData(Gen2.Bank bank, TagFilter filter)
        {            
            ushort [] reservedData;
            TagOp op;
            try
            {
                try
                {
                    // Read kill password
                    op = new Gen2.ReadData(Gen2.Bank.RESERVED, 0, 2);
                   reservedData = (ushort[])objReader.ExecuteTagOp(op, filter);
                   if (null != reservedData)
                   {
                       txtKillPassword.Text = ByteFormat.ToHex(ByteConv.ConvertFromUshortArray(reservedData), "", " ");
                   }
                   else
                   {
                       txtKillPassword.Text = "";
                   }
                }
                catch (Exception ex)
                {
                    if (ex is FAULT_GEN2_PROTOCOL_MEMORY_OVERRUN_BAD_PC_Exception)
                    {
                        txtKillPassword.Text = "Read Error";                        
                    }
                    else
                    {
                        txtKillPassword.Text = ex.Message;
                    }
                }

                try
                {
                    // Read access password
                    reservedData = null;
                    op = new Gen2.ReadData(Gen2.Bank.RESERVED, 2, 2);
                    reservedData = (ushort[])objReader.ExecuteTagOp(op, filter);
                    if (null != reservedData)
                    {
                        txtAcessPassword.Text = ByteFormat.ToHex(ByteConv.ConvertFromUshortArray(reservedData), "", " ");
                    }
                    else
                    {
                        txtAcessPassword.Text = "";
                    }
                }
                catch (Exception ex)
                {
                    if (ex is FAULT_GEN2_PROTOCOL_MEMORY_OVERRUN_BAD_PC_Exception)
                    {
                        txtAcessPassword.Text = "Read Error";
                    }
                    else
                    {                     
                        txtAcessPassword.Text = ex.Message;
                    }
                }

                // Read additional memory password
                try
                {
                    reservedData = null;
                    if (model.Equals("M5e") || model.Equals("M5e EU") || model.Equals("M5e Compact") || model.Equals("Astra"))
                    {                        
                        ReadAdditionalReservedMemDataM5eVariants(Gen2.Bank.RESERVED, 4, filter, out reservedData);
                    }
                    else
                    {
                        op = new Gen2.ReadData(Gen2.Bank.RESERVED, 4, 0);
                        reservedData = (ushort[])objReader.ExecuteTagOp(op, filter);
                    }

                    if (null != reservedData)
                    {
                        txtReservedMemUnusedValue.Text = ByteFormat.ToHex(ByteConv.ConvertFromUshortArray(reservedData), "", " ");
                        // Visible additional memory textboxes
                        lblAdditionalReservedMem.Visibility = System.Windows.Visibility.Visible;
                        txtReservedMemUnusedValue.Visibility = System.Windows.Visibility.Visible;
                        lblAdditionalReservedMemAdd.Visibility = System.Windows.Visibility.Visible;
                    }
                    else
                    {
                        txtReservedMemUnusedValue.Text = "";
                    }
                }
                catch
                { 
                    // catch the exception and move on. Only some tags has aditional memory 
                    txtReservedMemUnusedValue.Text = "";
                    // Hide additional memory textboxes
                    lblAdditionalReservedMem.Visibility = System.Windows.Visibility.Collapsed;
                    txtReservedMemUnusedValue.Visibility = System.Windows.Visibility.Collapsed;
                    lblAdditionalReservedMemAdd.Visibility = System.Windows.Visibility.Collapsed;
                }
            }
            catch (Exception)
            {
                throw;
            }            
        }
 private void PerformReadAllMemOperation(TagFilter filter, TagOp op)
 {
     TagReadData[] tagReads = null;
     SimpleReadPlan plan = new SimpleReadPlan(null, TagProtocol.GEN2, filter, op, 1000);
     reader.ParamSet("/reader/read/plan", plan);
     Console.WriteLine("Embedded tag operation - ");
     // Read tags
     tagReads = reader.Read(500);
     foreach (TagReadData tr in tagReads)
     {
         Console.WriteLine(tr.ToString());
         if (0 < tr.Data.Length)
         {
             Console.WriteLine(" Embedded read data: " + ByteFormat.ToHex(tr.Data, "", " "));
             Console.WriteLine(" User memory: " + ByteFormat.ToHex(tr.USERMemData, "", " "));
             Console.WriteLine(" Reserved memory: " + ByteFormat.ToHex(tr.RESERVEDMemData, "", " "));
             Console.WriteLine(" Tid memory: " + ByteFormat.ToHex(tr.TIDMemData, "", " "));
             Console.WriteLine(" EPC memory: " + ByteFormat.ToHex(tr.EPCMemData, "", " "));
         }
         Console.WriteLine(" Embedded read data length:" + tr.Data.Length);
     }
     Console.WriteLine();
     Console.WriteLine("Standalone tag operation - ");
     ushort[] data = (ushort[])reader.ExecuteTagOp(op, filter);
     //// Print tag reads
     if (0 < data.Length)
     {
         Console.WriteLine(" Standalone read data:" + ByteFormat.ToHex(ByteConv.ConvertFromUshortArray(data), "", " "));
         Console.WriteLine(" Standalone read data length:" + ByteConv.ConvertFromUshortArray(data).Length);
     }
     data = null;
     Console.WriteLine();
 }
 /// <summary>
 /// Read additional reserved memory for m5e variants
 /// </summary>
 /// <param name="bank"></param>
 /// <param name="startAddress"></param>
 /// <param name="filter"></param>
 /// <param name="data"></param>
 private void ReadAdditionalReservedMemDataM5eVariants(Gen2.Bank bank, uint startAddress, TagFilter filter, out ushort[] data)
 {
     data = null;
     int words = 1;
     TagOp op;
     while (true)
     {
         try
         {
             op = new Gen2.ReadData(bank, startAddress, Convert.ToByte(words));
             data = (ushort[])objReader.ExecuteTagOp(op, filter);
             words++;
         }
         catch (Exception)
         {
             throw;
         }
     }
 }
Exemplo n.º 55
0
 public Gen2LockArgs(TagFilter target, Gen2.LockAction action)
 {
     Target = target;
     Action = action;
 }
Exemplo n.º 56
0
        /// <summary>
        /// Write data to the memory bank of a tag.
        /// </summary>
        /// <param name="target">the tag target to operate on</param>
        /// <param name="bank">the tag memory bank</param>
        /// <param name="byteAddress">the starting memory address to write</param>
        /// <param name="data">the data to write</param>
        public override void WriteTagMemBytes(TagFilter target, int bank, int byteAddress, ICollection<byte> data)
        {
            PrepForTagop();
            int address = 0, byteCount = 0;
            TagProtocol proto = (TagProtocol)ParamGet("/reader/tagop/protocol");
            if (TagProtocol.GEN2 == proto)
            {
                address = byteAddress / 2;

                if (address * 2 != byteAddress)
                    throw new ArgumentException("Byte write address must be even");

                byteCount = data.Count;
                int count = ByteConv.WordsPerBytes(byteCount);

                if (count * 2 != byteCount)
                    throw new ArgumentException("Byte write length must be even");
            }
            else if (TagProtocol.ISO180006B == proto)
            {
                address = byteAddress;
            }
            else
            {
                throw new ReaderException("Writing tag data not supported for protocol  " + proto.ToString());
            }

            List<string> wheres = new List<string>();
            wheres.Add(String.Format("mem_bank={0:D}", bank));
            wheres.Add(String.Format("block_number={0:D}", address));
            wheres.AddRange(MakeTagopWheres(target));
            wheres.AddRange(MakeAccessPasswordWheres());

            SetField("tag_data.data", CollUtil.ToArray(data), wheres);   
        }
Exemplo n.º 57
0
 /// <summary>
 /// Read tag memory which has more then 64 words or 128 bytes. Returns the data read from tag memory. 
 /// Stops reading the tag memory if FAULT_PROTOCOL_BIT_DECODING_FAILED_Exception exception is received
 /// more then once. If the data read from tag memory is less then 64 words then initiates reading tag
 /// memory word by word
 /// </summary>
 /// <param name="bank"> Gen2 mem bank</param>
 /// <param name="filter">filter</param>
 /// <param name="data">Mem data obtained from the tag</param>
 private void ReadLargeTagMemory(Gen2.Bank bank, TagFilter filter, ref ushort[] data)
 {
     lock (new Object())
     {
         List<ushort> dataTemp = new List<ushort>();
         if (data != null)
         {
             dataTemp.AddRange(data);
         }
         int words = 0;
         uint startaddress = 64;
         TagOp op;
         bool isAllDatareceived = true;
         while (isAllDatareceived)
         {
             try
             {
                 op = new Gen2.ReadData(bank, startaddress, Convert.ToByte(words));
                 ushort[] tempDataReceived = (ushort[])objectReader.ExecuteTagOp(op, filter);
                 dataTemp.AddRange(tempDataReceived);
                 startaddress += 64;
                 if (tempDataReceived.Length < 64)
                 {
                     isAllDatareceived = false;
                     // If data received is less then 64 words, perform word by word with start address as length
                     // of the data and numer of words to read is 1 
                     ReadTagMemoryWordByWord(bank, filter, ref data);
                 }
             }
             catch (Exception ex)
             {
                 if (ex is FAULT_PROTOCOL_BIT_DECODING_FAILED_Exception)
                 {
                     try
                     {
                         // If read is success then continue the while loop with incremented start address and length as 0 
                         words = 64;
                         op = new Gen2.ReadData(bank, startaddress, Convert.ToByte(words));
                         dataTemp.AddRange(((ushort[])objectReader.ExecuteTagOp(op, filter)));
                         startaddress += 64;
                         words = 0;
                     }
                     catch (Exception et)
                     {
                         // If consecutively we get FAULT_PROTOCOL_BIT_DECODING_FAILED_Exception exception blindly come out of the loop to avoid
                         // dead lock
                         if (et is FAULT_PROTOCOL_BIT_DECODING_FAILED_Exception)
                         {
                             isAllDatareceived = false;
                         }
                         else
                         {
                             throw;
                         }
                     }
                 }
                 else
                 {
                     throw;
                 }
             }
         }
         data = dataTemp.ToArray();
     }
 }
Exemplo n.º 58
0
 public void SetupContext()
 {
     Filter = new TagFilter(new [] {"foo", "bar"});
 }
Exemplo n.º 59
0
 /// <summary>
 /// Create list of WHERE clauses representing tagop reader configuration (e.g., /reader/tagop/antenna, /reader/tagop/protocol)
 /// </summary>
 /// <param name="filt">Tags to target for tagop</param>
 /// <returns>List of strings to be incorporated into "WHERE ... AND ..." phrase.
 /// List may be empty.</returns>
 private List<string> MakeTagopWheres(TagFilter filt)
 {
     List<string> wheres = (List<string>) MakeTagopWheres();
     wheres.AddRange(TagFilterToWhereClause(filt));
     return wheres;
 }
Exemplo n.º 60
0
 /// <summary>
 /// Read tag memory word by word. If FAULT_GEN2_PROTOCOL_MEMORY_OVERRUN_BAD_PC_Exception 
 /// or Non-specific reader error or General Tag Error or Tag data access failed exception
 /// is recieved. Memory reading is stopped and the already read data is returned
 /// </summary>
 /// <param name="bank">Gen2 memory bank</param>
 /// <param name="filter">Select filter</param>
 /// <param name="data">Read tag memory data is returned</param>
 private void ReadTagMemoryWordByWord(Gen2.Bank bank, TagFilter filter, ref ushort[] data)
 {
     lock (new Object())
     {
         List<ushort> dataTemp = new List<ushort>();
         uint startaddress = 0;
         if (data != null)
         {
             // if the data varibale already contains the data, then add that data 
             // to data temp and chnage the start address to total data length
             dataTemp.AddRange(data);
             startaddress = (uint)data.Length;
         }
         int words = 1;
         TagOp op;
         bool isAllDatareceived = true;
         while (isAllDatareceived)
         {
             try
             {
                 // Read tag memory word by word
                 op = new Gen2.ReadData(bank, startaddress, Convert.ToByte(words));
                 dataTemp.AddRange(((ushort[])objectReader.ExecuteTagOp(op, filter)));
                 startaddress += 1;
             }
             catch (Exception exception)
             {
                 if (exception is FAULT_GEN2_PROTOCOL_MEMORY_OVERRUN_BAD_PC_Exception || (-1 != exception.Message.IndexOf("Non-specific reader error")) || (-1 != exception.Message.IndexOf("General Tag Error")) || (-1 != exception.Message.IndexOf("Tag data access failed")))
                 {
                     if (dataTemp.Count > 0)
                     {
                         // Just skip the exception and move on. So as not to lose the already read data.
                         isAllDatareceived = false;
                     }
                     else
                     {
                         // throw the exception if the data received is null for the first iteration itself
                         throw;
                     }
                 }
                 else
                 {
                     throw;
                 }
             }
         }
         data = dataTemp.ToArray();
     }
 }