Esempio n. 1
0
        // 筛选出需要 GetTagInfo() 的那些标签
        void FilterTags(BaseChannel <IRfid> channel, List <TagAndData> tags)
        {
            List <Entity> entities1 = new List <Entity>();
            List <Entity> all       = new List <Entity>();

            foreach (var tag in tags)
            {
                var entity = InventoryData.AddEntity(tag, out bool isNewly);
                var info   = entity.Tag as ProcessInfo;
                if (info == null)
                {
                    info       = new ProcessInfo();
                    entity.Tag = info;
                }

                if (isNewly)
                {
                    App.Invoke(new Action(() =>
                    {
                        _entities.Add(entity);
                    }));
                }

                if (string.IsNullOrEmpty(entity.PII))
                {
                    entities1.Add(entity);
                }

                all.Add(entity);
            }

            // 准备音阶
            SoundMaker.InitialSequence(entities1.Count);

            bool speaked = false;

            // 集中 GetTagInfo()
            foreach (var entity in entities1)
            {
                SoundMaker.NextSound();

                FillEntity(channel, entity,
                           (e) =>
                {
                    // 说过一次便不再说
                    if (speaked == true)
                    {
                        return(false);
                    }
                    speaked = SpeakLocation(e);
                    return(speaked);
                });
            }

            // 停止音阶响声
            SoundMaker.StopCurrent();

            // 获取题名等
            foreach (var entity in all)
            {
                var info = entity.Tag as ProcessInfo;

                if (string.IsNullOrEmpty(entity.PII) == false &&
                    string.IsNullOrEmpty(info.State))
                {
                    info.State = "processing";  // 正在获取册信息
                    InventoryData.AppendList(entity);
                    InventoryData.ActivateInventory();
                }
            }
        }