public override void AddLogic(ICoatingScheduleLogic newController = null) //update with a picker window. include a default. { try { if (newController != null) { newController.CoatingLine = CoatingLine; } else { newController = new CoatingScheduleProduct(0, "", "", "", "") { CoatingLine = CoatingLine }; } ChildrenLogic.Add(newController); newController.Connect(this); if (Control != null) { Control.AddControlToBottom(newController); } } catch (Exception exception) { Console.WriteLine(exception.Message); } }
public CoatingScheduleProduct(CoatingScheduleProduct other) { InitializeMembers(other.Thickness, other.Description, other.ProductCode, other.Grades, other.Units, other.HasBarcode, other.Notes, other.Placement, other.UnitsPerHour); Machine = other.Machine; Config = other.Config; }
public void SpreadUnits() { // check if shift is full if (!IsFull()) { return; } // if full, give next shift remaining units Shift shift = ((CoatingScheduleLine)ParentLogic).Shift; double hours = shift.Duration.TotalHours; foreach (var logic in ChildrenLogic) { var product = logic as CoatingScheduleProduct; if (product != null) { var units = Double.Parse(product.Units); if (hours - units / product.UnitsPerHour >= 0) // not full. continue. { hours -= units / product.UnitsPerHour; } else // shift is full, split into two products and add to next shift { // Save as much production as possible and pass problem onto next shift double max = hours * product.UnitsPerHour; if (max <= 0) { product.SwapDown(); // move to next, cascade spread } else { CoatingScheduleProduct next = new CoatingScheduleProduct(product) { Config = product.Config, Machine = product.Machine, CoatingLine = CoatingLine }; product.SetUnits(max.ToString("N")); product.Control.UpdateControlData(); next.SetUnits((Double.Parse(next.Units) - max).ToString("N")); // add to bottom AddControlToBottom(next); // move to next control next.SwapDown(); } break; } } } }
public static CoatingScheduleProductBase Load(BinaryReader reader) { string baseType = reader.ReadString(); if (baseType == "Product") { return(CoatingScheduleProduct.Load(reader)); } else if (baseType == "Note") { return(CoatingScheduleNote.Load(reader)); } return(null); }
public void Add_Button(object sender, RoutedEventArgs e) { AddProductWindow addProductWindow = new AddProductWindow(); addProductWindow.ShowDialog(); if (!addProductWindow.Accepted) { return; } CoatingScheduleProduct newProduct = new CoatingScheduleProduct(addProductWindow.MasterItem); Shift.AddLogic(newProduct); var productControl = newProduct.Control as ProductControl; if (productControl != null) { productControl.Machine = addProductWindow.ItemMachine; productControl.Config = addProductWindow.Config; } }
/// <summary> /// Fills the shift with the item by using the config passed. /// </summary> /// <param name="machine"></param> /// <param name="config"></param> /// <param name="item"></param> /// <returns></returns> public double ScheduleItem(Machine machine, Configuration config, ProductMasterItem item) { double made = 0; CoatingScheduleProduct product = new CoatingScheduleProduct(item); AddLogic(product); Shift shift = ((CoatingScheduleLine)ParentLogic).Shift; double hours = shift.Duration.TotalHours; var productController = ChildrenLogic.Last() as CoatingScheduleProduct; // find the maximum units that can be scheduled. made = config.UnitsToMakeInHours(item, hours); made = Math.Ceiling(made); productController.Machine = machine; productController.Config = config; productController.SetUnits(made.ToString()); return(made); }
public void AddProduct(CoatingScheduleProduct next, CoatingScheduleShift coatingScheduleShift) { }