Ejemplo n.º 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);
            }
        }
Ejemplo n.º 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();
            }
        }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 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);
                }
            }
        }
Ejemplo n.º 5
0
 public void ItemPassed(ISimulatedItem item)
 {
     if (IsActive)
     {
         _action(item);
         ItemPassedCount++;
     }
 }
Ejemplo n.º 6
0
        public bool Equals(ISimulatedItem other)
        {
            if (other == null)
            {
                return(false);
            }

            return(ItemId == other.ItemId);
        }
 public void ItemPassed(ISimulatedItem item)
 {
     if (IsActive)
     {
         ItemPassedCount++;
         _dataChannelTag.Value      = _getDataChannelValue(item);
         _dataChannelStateTag.Value = (short)DataStateEnum.DataWritten;
     }
 }
Ejemplo n.º 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);
            }
        }
        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
            });
        }
        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");
                }
            }
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 12
0
 public void RemoveItem(ISimulatedItem item)
 {
     _itemPositions.Remove(item);
 }
Ejemplo n.º 13
0
 public void AddItem(ISimulatedItem item)
 {
     AddItem(item, 0);
 }
 public void ItemPassed(ISimulatedItem item)
 {
 }
 public ItemCreatorEventArgs(ISimulatedItem simulatedItem)
 {
     CreatedItem = simulatedItem;
 }