Beispiel #1
0
        public void DispacthOrder(WareHouse wh, Order o)
        {
            foreach (var p in o.Products) {
                int q = wh.UnloadProduct(p.Key, p.Value);
                o.Products[p.Key] -= q;

                int load = 0;
                while (q > 0) {
                    Drone d = FindOptimistDrone (wh);
                    d.MoveTo (wh.Position);
                    q -= d.LoadProduct (p.Key, q);
                    d.MoveTo (o.Destination);
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Create a monoProduct order and update the inventory
        /// </summary>
        /// <param name="warehouse">Warehouse.</param>
        /// <param name="cell">Cell.</param>
        /// <param name="type">Type.</param>
        /// <param name="qtt">Qtt.</param>
        void PlaceOrder(WareHouse warehouse, Cell cell, ProductType type, int qtt)
        {
            var detail = new Dictionary<ProductType, int>();
            detail.Add(type, qtt);

            Order order = new Order(detail, cell);

            Affect(order, warehouse);

            var inv = Inventories [warehouse];

            var value = inv [type];

            value -= qtt;

            if(value == 0)
            {
                inv.Remove(type);
            }
            else
            {
                inv [type] = value;
            }
        }
Beispiel #3
0
        void AppendOrder(Order order)
        {
            if (!Deliveries.ContainsKey(order.Destination))
            {
                Deliveries.Add(order.Destination, new Dictionary<ProductType, int>());
            }

            var destinationDeliveries = Deliveries [order.Destination];

            foreach (var orderItem in order.Products)
            {
                if(!destinationDeliveries.ContainsKey(orderItem.Key))
                {
                    destinationDeliveries.Add(orderItem.Key, orderItem.Value);
                }
                else
                {
                    var value = destinationDeliveries [orderItem.Key] + orderItem.Value;
                    destinationDeliveries [orderItem.Key] = value;
                }
            }
        }
Beispiel #4
0
        /// <summary>
        /// Affect the specified order to the given warehouse
        /// </summary>
        /// <param name="o">O.</param>
        /// <param name="h">The height.</param>
        void Affect(Order o, WareHouse h)
        {
            if(!DispatchResults.ContainsKey(h))
            {
                DispatchResults.Add(h, new List<Order>());
            }

            var orders = DispatchResults [h];

            orders.Add(o);
        }