Пример #1
0
 /// <summary>
 /// Removes a pod from the list of inbound pods.
 /// </summary>
 /// <param name="pod">The pod that is not inbound anymore.</param>
 internal void UnregisterInboundPod(Pod pod)
 {
     _inboundPods.Remove(pod);
 }
Пример #2
0
 /// <summary>
 /// Marks a pod as inbound for a station.
 /// </summary>
 /// <param name="pod">The pod that being brought to the station.</param>
 internal void RegisterInboundPod(Pod pod)
 {
     _inboundPods.Add(pod);
 }
Пример #3
0
        /// <summary>
        /// Picks up the specified pod.
        /// </summary>
        /// <param name="pod">The pod to pick up.</param>
        /// <param name="currentTime">The current simulation time.</param>
        /// <returns><code>true</code> if the pickup-operation was successful, <code>false</code> otherwise.</returns>
        public bool PickupPod(Pod pod, double currentTime)
        {
            // Cannot pick up no pod
            if (pod == null)
            {
                return(false);
            }

            // Cannot pick up a pod if already carrying one
            if (this.Pod != null)
            {
                return(false);
            }

            // Can't ask pick up while moving
            if (this.GetSpeed() > 0.0)
            {
                return(false);
            }

            // Cannot pick up a pod that is on another tier
            if (Instance.Compound.BotCurrentTier[this] != Instance.Compound.PodCurrentTier[pod])
            {
                return(false);
            }

            // If outside of tolerance range, can't pick it up
            if ((pod.X - this.X) * (pod.X - this.X) + (pod.Y - this.Y) * (pod.Y - this.Y) > Instance.SettingConfig.Tolerance * Instance.SettingConfig.Tolerance)
            {
                return(false);
            }

            // See if pod bot can adjust position to pick it up
            if (!Instance.Compound.BotCurrentTier[this].MoveBot(this, pod.X, pod.Y))
            {
                return(false);
            }

            //#RealWorldIntegration.start
            if (Instance.SettingConfig.RealWorldIntegrationCommandOutput)
            {
                // Log the pickup command
                var sb = new StringBuilder();
                sb.Append("#RealWorldIntegration => Bot ").Append(ID).Append(" PickUp Pod");
                Instance.SettingConfig.LogAction(sb.ToString());
                // Issue the pickup command
                Instance.RemoteController.RobotSubmitPickupCommand(ID);
            }
            //#RealWorldIntegration.end

            // Pick it up!
            pod.InUse    = true;
            this.Pod     = pod;
            BlockedUntil = currentTime + this.PodTransferTime;
            this.StatNumberOfPickups++;

            // Notify the instance about the pickup operation
            Instance.NotifyPodPickup(pod, this);

            // Return success
            return(true);
        }
Пример #4
0
        /// <summary>
        /// Picks the next enqueued item.
        /// </summary>
        /// <param name="currentTime">The current simulation time.</param>
        /// <returns><code>true</code> if there was an item to pick and the operation was successful, <code>false</code> otherwise.</returns>
        protected bool TakeItemFromPod(double currentTime)
        {
            // Keep going through queue until have something to take or done with queue
            while (_requestsExtract.Count > 0)
            {
                // Fetch necessary stuff
                Bot             bot     = _requestsBot.Dequeue();
                Pod             pod     = bot.Pod;
                ExtractRequest  request = _requestsExtract.Dequeue();
                ItemDescription item    = request.Item;

                if (pod.IsContained(item) && GetDistance(pod) < GetInfoRadius())
                {
                    // If order is null, then just choose the first one that fits
                    if (request.Order == null)
                    {
                        foreach (var order in _assignedOrders)
                        {
                            if (order.Serve(item))
                            {
                                // Physically remove the item
                                pod.Remove(item, request);
                                // Block the station for the transfer
                                BlockedUntil = currentTime + ItemTransferTime;
                                // Make the bot wait until completion
                                bot.WaitUntil(currentTime + ItemPickTime);
                                // Count the number of picked items
                                StatNumItemsPicked++;
                                // Keep track of injected item picks
                                if (request.StatInjected)
                                {
                                    StatNumInjectedItemsPicked++;
                                }
                                // Keep track of current number of items to pick
                                StatCurrentlyOpenItems--;
                                // Count pods served if this is a beginning transaction
                                if (_newPodTransaction)
                                {
                                    _newPodTransaction = false;
                                }
                                // Notify instance about the pick
                                Instance.NotifyItemHandled(pod, bot, this, request.Item);
                                Instance.NotifyPodHandled(pod, null, this);
                                // Notify the instance, if the line was completed by the pick
                                if (order.PositionServedCount(item) >= order.PositionOverallCount(item))
                                {
                                    Instance.NotifyLineHandled(this, item, order.PositionOverallCount(item));
                                }
                                // Keep track of the time at which the transaction will be finished
                                _statLastTimeTransactionFinished = currentTime + ItemTransferTime;
                                // Return success
                                return(true);
                            }
                        }
                        // Mark request aborted
                        request.Abort();
                    }
                    else
                    {
                        // Order is specified
                        // If it's at this station and the item can be added, then add it
                        if (_assignedOrders.Contains(request.Order) && request.Order.Serve(item))
                        {
                            // Physically remove the item
                            pod.Remove(item, request);
                            // Block the station for the transfer
                            BlockedUntil = currentTime + ItemTransferTime;
                            // Make the bot wait until completion
                            bot.WaitUntil(currentTime + ItemPickTime);
                            // Count the number of picked items
                            StatNumItemsPicked++;
                            // Keep track of injected item picks
                            if (request.StatInjected)
                            {
                                StatNumInjectedItemsPicked++;
                            }
                            // Keep track of current number of items to pick
                            StatCurrentlyOpenItems--;
                            // Count pods served if this is a beginning transaction
                            if (_newPodTransaction)
                            {
                                _newPodTransaction = false;
                            }
                            // Notify instance about the pick
                            Instance.NotifyItemHandled(pod, bot, this, request.Item);
                            Instance.NotifyPodHandled(pod, null, this);
                            // Notify the instance, if the line was completed by the pick
                            if (request.Order.PositionServedCount(item) >= request.Order.PositionOverallCount(item))
                            {
                                Instance.NotifyLineHandled(this, item, request.Order.PositionOverallCount(item));
                            }
                            // Keep track of the time at which the transaction will be finished
                            _statLastTimeTransactionFinished = currentTime + ItemTransferTime;
                            // Return success
                            return(true);
                        }
                        else
                        {
                            // Mark the request aborted
                            request.Abort();
                        }
                    }
                }
            }
            // Nothing to pick - return unsuccessfully
            return(false);
        }
Пример #5
0
        /// <summary>
        /// Puts the next possible bundle in the queue on the pod.
        /// </summary>
        /// <param name="currentTime">The current time.</param>
        public void GiveBundleToPod(double currentTime)
        {
            while (_requestsInsert.Count > 0)
            {
                Bot           bot     = _requestsBot.Dequeue();
                Pod           pod     = bot.Pod;
                InsertRequest request = _requestsInsert.Dequeue();
                ItemBundle    bundle  = request.Bundle;

                // Can't service the request if the pod is full or not close enough
                if (!pod.Fits(bundle) || GetDistance(pod) > GetInfoRadius())
                {
                    continue;
                }

                // Find matching bundle to transfer
                if (_itemBundles.Contains(bundle))
                {
                    // Transfer bundle, wait until transfer is complete, remove request
                    pod.Add(bundle, request);
                    if (Instance.SettingConfig.VisualizationAttached)
                    {
                        lock (_syncRoot)
                        {
                            _itemBundles.Remove(bundle);
                        }
                    }
                    else
                    {
                        _itemBundles.Remove(bundle);
                    }
                    // Keep track of capacity
                    CapacityInUse = _itemBundles.Sum(b => b.BundleWeight);
                    // Check if the station has no further bundles and may rest now
                    if (!_itemBundles.Any())
                    {
                        _statDepletionTime = currentTime;
                    }
                    // Notify the item manager about this
                    Instance.ItemManager.CompleteBundle(bundle);
                    // Notify instance about this
                    Instance.NotifyBundleStored(this, bot, pod, bundle);
                    Instance.NotifyPodHandled(pod, this, null);
                    // Track the number of transferred bundles
                    StatNumBundlesStored++;
                    // Track the number of transferred injected bundles
                    if (request.StatInjected)
                    {
                        StatNumInjectedBundlesStored++;
                    }
                    // Count pods served if this is a beginning transaction
                    if (_newPodTransaction)
                    {
                        _newPodTransaction = false;
                    }
                    // Keep track of the time at which the transaction will be finished
                    _statLastTimeTransactionFinished = currentTime + ItemBundleTransferTime;
                    // Block the bot
                    BlockedUntil = currentTime + ItemBundleTransferTime;
                    bot.WaitUntil(BlockedUntil);
                    return;
                }
            }
        }