Пример #1
0
        /// <summary>
        /// Calculates the best configuration between this and the other.
        /// </summary>
        /// <param name="otherConfiguration">Other to compare to</param>
        /// <param name="nextItem">Item to make</param>
        /// <returns>fastest config or null if neither can make</returns>
        public Configuration GetFastestConfig(Configuration otherConfiguration, ProductMasterItem nextItem)
        {
            if (otherConfiguration == null)
            {
                return(this);
            }

            var myOutput    = OutputItems.FirstOrDefault(o => o.MasterID == nextItem.MasterID);
            var otherOutput = otherConfiguration.OutputItems.FirstOrDefault(o => o.MasterID == nextItem.MasterID);

            // neither can make
            if (otherOutput == null && myOutput == null)
            {
                return(null);
            }

            // I can't make
            if (myOutput == null)
            {
                return(otherConfiguration);
            }

            // Other can't make
            if (otherOutput == null)
            {
                return(this);
            }

            double myRate    = PiecesOutPerMinute;
            double otherRate = otherConfiguration.PiecesOutPerMinute;

            return(myRate > otherRate ? this : otherConfiguration);
        }
Пример #2
0
        public bool Add(ProductMasterItem item, ref double count)
        {
            bool   added    = false;
            double numToAdd = count;

            if (!IsFull())
            {
                // get the number that can be added.
                double hoursAvailable = GetAvailableHours();
                double maxUnitsToMake = hoursAvailable * item.UnitsPerHour;

                // clamp
                numToAdd = numToAdd > maxUnitsToMake ? maxUnitsToMake : numToAdd;

                PressMasterItem pressItem = Produced.FirstOrDefault(p => p.MasterItem == item);

                if (pressItem == null)
                {
                    Produced.Add(new PressMasterItem(item, numToAdd));
                }
                else
                {
                    pressItem.UnitsMade += numToAdd;
                }
                RaisePropertyChangedEvent("Produced");
                count -= numToAdd;
                added  = true;
            }

            return(added);
        }
 public PressMasterItem([NotNull] ProductMasterItem item, double units)
 {
     MasterItem = item;
     UnitsMade  = units;
     Thickness  = item.Thickness;
     Name       = item.Description;
 }
Пример #4
0
        public static XlRgbColor GetExcelColor(ProductMasterItem item)
        {
            XlRgbColor color = XlRgbColor.rgbWhite;

            if (MasterBrushDictionary.ContainsKey(item))
            {
                Brush brush = MasterBrushDictionary[item];

                if (Equals(brush, Brushes.Aquamarine))
                {
                    color = XlRgbColor.rgbAquamarine;
                }
                else if (Equals(brush, Brushes.LightGreen))
                {
                    color = XlRgbColor.rgbLightGreen;
                }
                else if (Equals(brush, Brushes.DarkSalmon))
                {
                    color = XlRgbColor.rgbDarkSalmon;
                }
                else if (Equals(brush, Brushes.CadetBlue))
                {
                    color = XlRgbColor.rgbCadetBlue;
                }
                else if (Equals(brush, Brushes.BurlyWood))
                {
                    color = XlRgbColor.rgbBurlyWood;
                }
            }

            return(color);
        }
Пример #5
0
 public static void AddWatch(ProductMasterItem item)
 {
     if (!Instance.Watches.Contains(item))
     {
         Instance.Watches.Add(item);
     }
 }
Пример #6
0
 /// <summary>
 /// Adds the item to tracking
 /// </summary>
 /// <param name="item"></param>
 public double AddTracking(ProductMasterItem item, double current)
 {
     foreach (var trackingShift in Shifts)
     {
         current = trackingShift.AddSummary(item, current);
     }
     return(current);
 }
        public double GetConsumed(ProductMasterItem item)
        {
            double consumed = 0;

            consumed = _coatingLine.UnitsConsumed(item);

            return(consumed);
        }
Пример #8
0
 public ItemSummary(ProductMasterItem item, double current, double added, double removed)
 {
     Item            = item;
     CurrentUnits    = current;
     AddedUnits      = added;
     RemovedUnits    = removed;
     BackgroundColor = GetColor();
 }
 public static void AddMasterItem(ProductMasterItem item)
 {
     _productMasterList.Add(item);
     if (item.MadeIn == "Press")
     {
         _pressMasterList.Add(item);
     }
 }
Пример #10
0
 /// <summary>
 /// Get the weight value of scheduling the item
 /// </summary>
 /// <param name="item">Item to potentially schedule</param>
 /// <returns>weight that the item should be scheduled</returns>
 private static int EvaluateWidth(GenerationSettings settings, ProductMasterItem item, string line)
 {
     if (ScheduleGenerator.Instance.GenerationData.LastWidth.ContainsKey(line) && ScheduleGenerator.Instance.GenerationData.LastWidth[line] != 0)
     {
         // Linear progression of weight with the dif in current working width.
         return(settings.WidthWeight - (int)Math.Abs(ScheduleGenerator.Instance.GenerationData.LastWidth[line] - item.Width));
     }
     return(0);
 }
Пример #11
0
    /// <summary>
    /// Get the weight value of scheduling the item
    /// </summary>
    /// <param name="item">Item to potentially schedule</param>
    /// <returns>weight that the item should be scheduled</returns>
    private static int EvaluateProjection(GenerationSettings settings, ProductMasterItem item)
    {
        if (ScheduleGenerator.Instance.GenerationData.PredictionList == null)
        {
            return(0);
        }

        return(ScheduleGenerator.Instance.GenerationData.PredictionList.Any(p => p.MasterID == item.MasterID) ? settings.ProjectionWeight : 0);
    }
        private DateTime SchedulePress(ProductMasterItem currentItem, double unitsRequired)
        {
            var scheduledTime = PressManager.ScheduleItem(currentItem, unitsRequired, scheduleLine.Date);

            GenerationData.AddPressProduction(scheduledTime);

            GenerationData.CurrentWaste += currentItem.Waste * unitsRequired;

            return(scheduledTime);
        }
Пример #13
0
 private static int EvaluateThickness(GenerationSettings settings, ProductMasterItem item, string line)
 {
     if (ScheduleGenerator.Instance.GenerationData.LastWidth.ContainsKey(line) && ScheduleGenerator.Instance.GenerationData.LastWidth[line] != 0)
     {
         return(settings.ThicknessWeight -
                ((int)Math.Abs(ScheduleGenerator.Instance.GenerationData.LastThickness[line] - item.Thickness) * 8));
         // 2*.25 = 8*1
     }
     return(0);
 }
Пример #14
0
        public void AddPastSaleTestDontAddCurrentMonth()
        {
            ProductMasterItem master = new ProductMasterItem(1, "TestMaster01", "Testing master item", 48, 92, .5, "OM", 40, 50, "", true, "", "", 0, 0, 0, 0);

            StaticInventoryTracker.ProductMasterList.Add(master);

            StaticInventoryTracker.AddPastSale(1, DateTime.Today, 100);

            // item should not be added
            Assert.AreEqual(StaticInventoryTracker.ForecastItems.Count, 0);
        }
        public bool CanMake(int masterID)
        {
            ProductMasterItem item =
                StaticInventoryTracker.ProductMasterList.FirstOrDefault(prod => prod.MasterID == masterID);

            if (item != null)
            {
                return(CanMake(item));
            }
            return(false);
        }
Пример #16
0
        public void AddPastSaleTestAdd12MonthsAgo()
        {
            ProductMasterItem master = new ProductMasterItem(1, "TestMaster01", "Testing master item", 48, 92, .5, "OM", 40, 50, "", true, "", "", 0, 0, 0, 0);

            StaticInventoryTracker.ProductMasterList.Add(master);

            StaticInventoryTracker.AddPastSale(1, DateTime.Today.AddDays(-DateTime.Today.Day).AddMonths(-12), 100);

            // item should be added
            Assert.AreEqual(StaticInventoryTracker.ForecastItems.Count, 1);
        }
Пример #17
0
        /// <summary>
        /// Calculates the units that can be output for the duration.
        /// </summary>
        /// <param name="item">Item to make</param>
        /// <param name="hours">Time frame</param>
        /// <returns>-1 if the <see cref="Configuration"/> can't make the item.</returns>
        public double UnitsToMakeInHours(ProductMasterItem item, double hours)
        {
            var output = OutputItems.FirstOrDefault(o => o.MasterID == item.MasterID);

            if (output == null)
            {
                return(-1);
            }

            return((output.Pieces * PiecesOutPerMinute * hours * 60) / item.PiecesPerUnit);
        }
Пример #18
0
    /// <summary>
    /// Get the weight value of scheduling the item
    /// </summary>
    /// <param name="item">Item to potentially schedule</param>
    /// <returns>weight that the item should be scheduled</returns>
    private static int EvaluateWaste(GenerationSettings settings, ProductMasterItem item)
    {
        var wasteGeneratedEstimate = item.Waste * item.TargetSupply;
        var scheduledWaste         = ScheduleGenerator.Instance.GenerationData.CurrentWaste + wasteGeneratedEstimate;

        if (scheduledWaste < StaticFactoryValuesManager.WasteMin || scheduledWaste > StaticFactoryValuesManager.WasteMax)
        {
            return(-settings.WasteWeight);
        }
        return(0);
    }
Пример #19
0
        private void RemoveWatch(object obj)
        {
            ProductMasterItem newWatch = obj as ProductMasterItem;

            if (newWatch == null)
            {
                return;
            }

            WatchList.Remove(newWatch);
            ExtendedSchedule.Instance.Update();
        }
Пример #20
0
 /// <summary>
 /// Get the weight value of scheduling the item
 /// </summary>
 /// <param name="item">Item to potentially schedule</param>
 /// <returns>weight that the item should be scheduled</returns>
 private static int EvaluateGrouping(GenerationSettings settings, ProductMasterItem item, string line)
 {
     if (ScheduleGenerator.Instance.GenerationData.LastRunConfigurationGroups.ContainsKey(line))
     {
         var possibleGroups = MachineHandler.Instance.AllConfigGroups.Where(confGroup => confGroup.CanMake(item));
         if (possibleGroups.Contains(ScheduleGenerator.Instance.GenerationData.LastRunConfigurationGroups[line]))
         {
             return(settings.GroupWeight);
         }
     }
     return(0);
 }
Пример #21
0
        public double UnitsConsumed(ProductMasterItem item)
        {
            double consumed = 0;

            foreach (var coatingScheduleLogic in ChildrenLogic)
            {
                CoatingScheduleShift shift = coatingScheduleLogic as CoatingScheduleShift;
                consumed += shift.UnitsConsumed(item);
            }

            return(consumed);
        }
Пример #22
0
    /// <summary>
    /// Gathers the weight that the item should be scheduled. Based on any registered evaluators.
    /// </summary>
    /// <param name="item"></param>
    /// <param name="line"></param>
    /// <returns></returns>
    public static PriorityItem Evaluate(ProductMasterItem item, string line, GenerationSettings settings)
    {
        int weight = 0;

        weight += EvaluateSales(settings, item);
        weight += EvaluateWidth(settings, item, line);
        weight += EvaluateProjection(settings, item);
        weight += EvaluateGrouping(settings, item, line);
        weight += EvaluateThickness(settings, item, line);
        weight += EvaluateWaste(settings, item);

        return(new PriorityItem(item, weight));
    }
Пример #23
0
        public Configuration GetBestConfig(ProductMasterItem nextItem)
        {
            //TODO: fix tis
            //var configs = ConfigurationList.Where(conf => conf.ItemOutID == nextItem.MasterID);
            //Configuration config = configs.FirstOrDefault();

            //foreach (var configuration in configs)
            //{
            //    config = config.GetFastestConfig(configuration, nextItem);
            //}

            return(null);//config;
        }
    /// <summary>
    /// Adds a prediction listing for the item to be scheduled.
    /// </summary>
    /// <param name="master"></param>
    public void AddPredictionOrder(ProductMasterItem master)
    {
        var order = PredictionList.FirstOrDefault(p => p.MasterID == master.MasterID);

        if (order == null)
        {
            PredictionList.Add(new MakeOrder(master.MasterID, master.TargetSupply * master.PiecesPerUnit));
        }
        else
        {
            order.PiecesToMake += (int)(master.PiecesPerUnit * master.TargetSupply);
        }
    }
        public bool CanMake(ProductMasterItem item)
        {
            bool canMake = false;

            foreach (var configuration in Configurations)
            {
                if (configuration.CanMake(item))
                {
                    canMake = true;
                    break;
                }
            }
            return(canMake);
        }
Пример #26
0
        /// <summary>
        /// Adds the summary
        /// </summary>
        /// <param name="item">Item to track</param>
        /// <param name="running">Current unit amount going into shift</param>
        /// <returns>Units in inventory after shift</returns>
        public double AddSummary(ProductMasterItem item, double running)
        {
            double added   = GetProduced(item);
            double removed = GetConsumed(item);

            var newSum = new ItemSummary(item, running, added, removed);

            ItemSummaries.Add(newSum);
            Control.AddSummary(newSum);

            ExtendedSchedule.RunningTotalsDictionary[item.MasterID] = newSum.RunningUnits;

            return(newSum.RunningUnits);
        }
Пример #27
0
        private bool CanMakeOnLine(ProductMasterItem master, string line)
        {
            // check all machines that can run on that line
            List <Machine> machines = MachineHandler.Instance.MachineList.Where(m => m.LinesCanRunOn.Contains(line)).ToList();

            if (machines.Any())
            {
                return(machines.Any(m => m.ConfigurationList.Any(c => c.CanMake(master))));
            }
            else
            {
                return(false);
            }
        }
Пример #28
0
        public double UnitsConsumed(ProductMasterItem item)
        {
            double consumed = 0;

            foreach (var coatingScheduleLogic in ChildrenLogic.Where(l => l is CoatingScheduleProduct))
            {
                var product = ((CoatingScheduleProduct)coatingScheduleLogic);
                var config  = product.Config;

                consumed += config.GetUnitsConsumed(item, product.Units, product.MasterID);
            }

            return(consumed);
        }
Пример #29
0
        public double GetProduced(ProductMasterItem item)
        {
            double modification = 0;

            modification = _coatingLine.UnitsProduced(item);

            foreach (var pressShift in _pressShifts)
            {
                foreach (var prod in pressShift.Produced.Where(i => i.MasterItem.Equals(item)))
                {
                    modification += prod.UnitsMade;
                }
            }
            return(modification);
        }
Пример #30
0
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            ProductMasterItem master = value as ProductMasterItem;

            if (master != null)
            {
                if (!MasterBrushDictionary.ContainsKey(master))
                {
                    MasterBrushDictionary[master] = GetNextBrush();
                }

                return(MasterBrushDictionary[master]);
            }
            return(null);
        }