Ejemplo n.º 1
0
        private void OnTagAdded(object sender, TagChangedEventArgs args)
        {
            AddTag(args.Tag);

            // Ensure that this tag is no longer "uncategorized".
            RemoveTag("Uncategorized");
        }
Ejemplo n.º 2
0
            /// <summary>
            /// The subscription calls this method whenever a subscribed tag's
            /// current value changes.
            /// </summary>
            private void NotifyTagChanged(object sender, TagChangedEventArgs args)
            {
                switch (args.Tag.DataType)
                {
                case DataType.Double:
                    Console.WriteLine("[subscription] {0} value changed to {1}",
                                      args.Tag.Path, args.DoubleValue.Read());
                    break;

                case DataType.Int32:
                    Console.WriteLine("[subscription] {0} value changed to {1}",
                                      args.Tag.Path, args.Int32Value.Read());
                    break;

                default:
                    Console.WriteLine("[subscription] Unexpected {0} of type {1}",
                                      args.Tag.Path, args.Tag.DataType);
                    break;
                }

                lock (_lock)
                {
                    ++_receivedEvents;
                    Monitor.PulseAll(_lock);
                }
            }
Ejemplo n.º 3
0
 private void CurrentApp_TagChanged(object sender, TagChangedEventArgs e)
 {
     // 如果有读者卡,要延时提醒不要忘了拿走读者卡
     if (/*PageBorrow.isPatronChanged(e) &&*/ TagList.Patrons?.Count > 0)
     {
         PageBorrow.BeginNotifyTask();
     }
 }
Ejemplo n.º 4
0
        // 跟随事件动态更新列表
        // Add: 检查列表中是否存在这个 PII,如果存在,则修改状态为 在架,并设置 UID 成员
        //      如果不存在,则为列表添加一个新元素,修改状态为在架,并设置 UID 和 PII 成员
        // Remove: 检查列表中是否存在这个 PII,如果存在,则修改状态为 不在架
        //      如果不存在这个 PII,则不做任何动作
        // Update: 检查列表中是否存在这个 PII,如果存在,则修改状态为 在架,并设置 UID 成员
        //      如果不存在,则为列表添加一个新元素,修改状态为在架,并设置 UID 和 PII 成员
        async Task ChangeEntities(BaseChannel <IRfid> channel,
                                  TagChangedEventArgs e)
        {
            // 读者。不再精细的进行增删改跟踪操作,而是笼统地看 TagList.Patrons 集合即可
            var task = RefreshPatrons();

            bool          changed         = false;
            List <Entity> update_entities = new List <Entity>();

            Application.Current.Dispatcher.Invoke(new Action(() =>
            {
                if (e.AddBooks != null)
                {
                    foreach (var tag in e.AddBooks)
                    {
                        var entity = _entities.OnShelf(tag);
                        if (entity != null)
                        {
                            update_entities.Add(entity);
                        }
                    }
                }
                if (e.RemoveBooks != null)
                {
                    foreach (var tag in e.RemoveBooks)
                    {
                        var entity = _entities.OffShelf(tag);
                        if (entity != null)
                        {
                            update_entities.Add(entity);
                        }
                        // changed = true;
                    }
                }
                if (e.UpdateBooks != null)
                {
                    foreach (var tag in e.UpdateBooks)
                    {
                        var entity = _entities.OnShelf(tag);
                        if (entity != null)
                        {
                            update_entities.Add(entity);
                        }
                    }
                }
            }));

            if (update_entities.Count > 0)
            {
                // await FillBookFields(channel, update_entities);

                await Update(channel, update_entities, new CancellationToken());

                // Trigger(update_entities);
            }

            /*
             * else if (changed)
             * {
             *  // 修改 borrowable
             *  booksControl.SetBorrowable();
             * }*/

            if (update_entities.Count > 0)
            {
                changed = true;
            }

            /*
             * {
             *  if (_entities.Count == 0
             * && changed == true  // 限定为,当数量减少到 0 这一次,才进行清除
             * && _patron.IsFingerprintSource)
             *      PatronClear();
             *
             *  // 2019/7/1
             *  // 当读卡器上的图书全部拿走时候,自动关闭残留的模式对话框
             *  if (_entities.Count == 0
             * && changed == true  // 限定为,当数量减少到 0 这一次,才进行清除
             * )
             *      CloseDialogs();
             *
             *  // 当列表为空的时候,主动清空一次 tag 缓存。这样读者可以用拿走全部标签一次的方法来迫使清除缓存(比如中途利用内务修改过 RFID 标签的 EAS)
             *  // TODO: 不过此举对反复拿放图书的响应速度有一定影响。后面也可以考虑继续改进(比如设立一个专门的清除缓存按钮,这里就不要清除缓存了)
             *  if (_entities.Count == 0 && TagList.TagTableCount > 0)
             *      TagList.ClearTagTable(null);
             * }
             */
        }
Ejemplo n.º 5
0
 private async void CurrentApp_TagChanged(object sender, TagChangedEventArgs e)
 {
     await ChangeEntities((BaseChannel <IRfid>) sender, e);
 }
 private void OnTagRemoved(object sender, TagChangedEventArgs args)
 {
     RemoveTag(args.Tag);
     m_componentsLibrary.RemoveTagIfEmpty(args.Tag);
 }
        private void OnTagAdded(object sender, TagChangedEventArgs args)
        {
            AddTag(args.Tag);

            // Ensure that this tag is no longer "uncategorized".
            RemoveTag("Uncategorized");
        }
Ejemplo n.º 8
0
 private static void MyDevices_TagStatusChanged(object sender, TagChangedEventArgs e)
 {
     Console.WriteLine($"{e.Name} -> {e.Value} {e.Quality}");
 }
Ejemplo n.º 9
0
#pragma warning disable VSTHRD100 // 避免使用 Async Void 方法
        private async void CurrentApp_TagChanged(object sender, TagChangedEventArgs e)
#pragma warning restore VSTHRD100 // 避免使用 Async Void 方法
        {
            await ChangeEntitiesAsync((BaseChannel <IRfid>) sender, e);
        }
Ejemplo n.º 10
0
 private void OnTagRemoved(object sender, TagChangedEventArgs args)
 {
     RemoveTag(args.Tag);
     m_componentsLibrary.RemoveTagIfEmpty(args.Tag);
 }