コード例 #1
0
        public void AddItem(ISimulatedItem item, int position)
        {
            if (position >= Length || position < 0)
            {
                throw new ArgumentOutOfRangeException("position", "index position " + position + " does not exist in " + Name);
            }

            if (_itemPositions.Any(i => i.Value == position))
            {
                _alarmOccurredSubject.OnNext(new Alarm
                {
                    Source  = this,
                    Type    = AlarmType.Warning,
                    Message = "Possible collision: Can't add item " + item.ItemId + " to index " + position +
                              " because it's aleady occupied by item " + _itemPositions.First(i => i.Value == position).Key.ItemId
                });
            }

            _itemPositions.Add(item, position);

            // process single equipment at position if existing
            var equipment = _simulatedEquipments.FirstOrDefault(e => e.Position == position);

            if (equipment != null)
            {
                equipment.ItemPassed(item);
            }
        }
コード例 #2
0
        /// <summary>
        /// The equipment will remove the single item and put it into a fifo list which is assigned to the slot.
        /// </summary>
        /// <param name="item"></param>
        public void ItemPassed(ISimulatedItem item)
        {
            lock (_lock)
            {
                if (!IsActive || item == _queue)
                {
                    return;
                }

                ItemPassedCount++;

                _module.RemoveItem(item);

                // create and add new queue if not done
                if (_module.GetItemByPosition(Position) == null)
                {
                    _module.AddItem(_queue, Position);
                }

                _queue.Items.Insert(0, item);

                // itemId of the overall queue is the last added item
                _queue.ItemId = item.ItemId;

                CheckCapacity();
            }
        }
コード例 #3
0
        public void ItemPassed(ISimulatedItem item)
        {
            if (IsActive)
            {
                ItemPassedCount++;

                long itemId = (long)item.ItemId;

                if (_mosaicControlledJunction.Routings.ContainsKey(itemId))
                {
                    int lane = _mosaicControlledJunction.Routings[itemId];

                    if (lane >= _targetModules.Length)
                    {
                        throw new IndexOutOfRangeException("mosaic routes to port " + lane +
                                                           " which does not exist in the simulation. origin module was " +
                                                           _originModule.Name);
                    }

                    _originModule.RemoveItem(item);
                    _targetModules[lane].AddItem(item);
                }

                _mosaicControlledJunction.SimulateRouting(item);
            }
        }
コード例 #4
0
        public void SimulateRouting(ISimulatedItem item)
        {
            long itemId = (long)item.ItemId;

            if (Routings.ContainsKey(itemId))
            {
                Routings.Remove(itemId);

                if (ItemRoutedEvent != null)
                {
                    ItemRoutedEvent(this, itemId);
                }
            }
            else
            {
                string moduleName = string.Empty;
                if (AssociatedModule != null)
                {
                    moduleName = AssociatedModule.Name;
                }

                _logger.WarnFormat("junction in module " + moduleName + " could not find routing for item-id={0}, default route port 0 will be used", itemId);

                if (ItemRoutedEvent != null)
                {
                    ItemRoutedEvent.Invoke(this, itemId);
                }
            }
        }
コード例 #5
0
 public void ItemPassed(ISimulatedItem item)
 {
     if (IsActive)
     {
         _action(item);
         ItemPassedCount++;
     }
 }
コード例 #6
0
ファイル: SimulatedItem.cs プロジェクト: fengxing1121/Mosaic
        public bool Equals(ISimulatedItem other)
        {
            if (other == null)
            {
                return(false);
            }

            return(ItemId == other.ItemId);
        }
コード例 #7
0
 public void ItemPassed(ISimulatedItem item)
 {
     if (IsActive)
     {
         ItemPassedCount++;
         _dataChannelTag.Value      = _getDataChannelValue(item);
         _dataChannelStateTag.Value = (short)DataStateEnum.DataWritten;
     }
 }
コード例 #8
0
        public void ItemPassed(ISimulatedItem item)
        {
            if (IsActive)
            {
                ItemPassedCount++;

                object barcode;
                item.Metadata.TryGetValue("barcode", out barcode);

                _mosaicBarcodeReader.SimulateBarcodeRead(barcode != null ? barcode.ToString() : string.Empty);
            }
        }
コード例 #9
0
        public void ItemPassed(ISimulatedItem item)
        {
            if (!IsActive)
            {
                return;
            }

            ItemPassedCount++;

            DetectedItems.Add(item);

            item.AddLog("collision detected", "CollisionWatcherEquipment");

            _alarmOccurredSubject.OnNext(new Alarm
            {
                Source  = this,
                Message = "Collision detected of item " + item.ItemId,
                Type    = AlarmType.Warning
            });
        }
コード例 #10
0
        public void ItemPassed(ISimulatedItem item)
        {
            if (IsActive)
            {
                ItemPassedCount++;

                switch (Mode)
                {
                case JunctionDistributionMode.SortOutNothing:
                    return;

                case JunctionDistributionMode.SortOutEverything:
                    _originModule.RemoveItem(item);
                    _targetModule.AddItem(item);
                    break;

                case JunctionDistributionMode.SortOutEverySecond:
                    if (ItemPassedCount % 2 == 0)
                    {
                        _originModule.RemoveItem(item);
                        _targetModule.AddItem(item);
                    }
                    break;

                case JunctionDistributionMode.SortOutRandomly:
                    if (_random.Next(0, 1) == 1)
                    {
                        _originModule.RemoveItem(item);
                        _targetModule.AddItem(item);
                    }
                    break;

                default:
                    throw new NotImplementedException("JunctionDistributionMode");
                }
            }
        }
コード例 #11
0
        public bool Equals(ISimulatedItem other)
        {
            var otherItemList = other as SimulatedItemList;

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

            if (otherItemList.Items.Count != Items.Count)
            {
                return(false);
            }

            for (int i = 0; i < Items.Count; i++)
            {
                if (!otherItemList.Items[i].Equals(Items[i]))
                {
                    return(false);
                }
            }

            return(true);
        }
コード例 #12
0
 public void RemoveItem(ISimulatedItem item)
 {
     _itemPositions.Remove(item);
 }
コード例 #13
0
 public void AddItem(ISimulatedItem item)
 {
     AddItem(item, 0);
 }
コード例 #14
0
 public void ItemPassed(ISimulatedItem item)
 {
 }
コード例 #15
0
 public ItemCreatorEventArgs(ISimulatedItem simulatedItem)
 {
     CreatedItem = simulatedItem;
 }