public PlainTextStream(string fp, Encoding enc, PriorityItem p, bool caseSensitive) { path = fp; encoding = enc; priority = p; CaseSensitive = caseSensitive; }
public PlainTextStream(string fp, Encoding enc, Dictionary <string, ByteStringAuto> h, PriorityItem p) { path = fp; encoding = enc; hashes = h; priority = p; }
private void cmbBoxPriority_SelectionChanged(object sender, SelectionChangedEventArgs e) { var selectedBox = (ComboBox)sender; priorityItem = (PriorityItem)selectedBox.SelectedItem; agendaItem.Priority = priorityItem.Id; }
public PlainTextStream(Stream s, Dictionary <string, ByteStringAuto> h, PriorityItem p, bool caseSensitive) { stream = s; hashes = h; priority = p; CaseSensitive = caseSensitive; }
//public PriorityQueue(int length) //{ // MaxLength = length; // Length = 0; // Array = new PriorityItem[Length]; //} public void Insert(Object value, int priority) { PriorityItem itemToInsert = new PriorityItem(value, priority); //MaxLength++; PriorityItem[] newArray = new PriorityItem[Length + 1]; for (int i = Length - 1; i > -1; i--) { newArray[i] = Array[i]; } Array = newArray; for (int i = Length; i > -1; i--) { if (i - 1 == -1 || Array[i - 1] == null || Array[i - 1].Priority <= itemToInsert.Priority) { Array[i] = itemToInsert; break; } else { Array[i] = Array[i - 1]; } //newArray[i] = Array[i]; } Length++; }
public PlainTextStream(Stream s, Encoding enc, Dictionary <string, ByteStringAuto> h, PriorityItem p) { stream = s; encoding = enc; hashes = h; priority = p; }
public PlainTextStream(Stream s, Encoding enc, PriorityItem p, bool caseSensitive) { stream = s; encoding = enc; priority = p; CaseSensitive = caseSensitive; }
public PlainTextStream(string fp, Encoding enc, Dictionary <string, ByteStringAuto> h, PriorityItem p, bool caseSensitive) { path = fp; encoding = enc; hashes = h; priority = p; CaseSensitive = caseSensitive; }
public int CompareTo(PriorityItem <DataType, ComparerType> other) { if (other == null) { return(1); } return(Priority.CompareTo(other.Priority)); }
public static int Comparer(PriorityItem x, PriorityItem y) { if (x == null || y == null) { return(0); } return(y.Priority - x.Priority); }
public void MultipleWorkItemsMultiplePriorities() { // Get all the available priorities WorkItemPriority [] priorities = Enum.GetValues(typeof(WorkItemPriority)) as WorkItemPriority []; // Create an array of priority items PriorityItem [] priorityItems = new PriorityItem[priorities.Length]; // Create a priority item for each priority int i = priorities.Length; foreach (WorkItemPriority workItemPriority in priorities) { --i; priorityItems[i] = new PriorityItem(workItemPriority); } // Create a PermutationGenerator for the priority items PermutationGenerator permutations = new PermutationGenerator(priorityItems); int count = 0; // Iterate over the permutations foreach (object [] permutation in permutations) { ++count; Console.Write("Permutation #" + count + " : "); for (int j = 0; j < permutation.Length; ++j) { PriorityItem pi = permutation[j] as PriorityItem; Console.Write(pi.WorkItemPriority + ", "); } Console.WriteLine(); // Create a priority queue PriorityQueue pq = new PriorityQueue(); // Enqueue each priority item according to the permutation for (i = 0; i < permutation.Length; ++i) { PriorityItem priorityItem = permutation[i] as PriorityItem; pq.Enqueue(priorityItem); } // Make sure all the priority items are in the queue Assert.AreEqual(priorityItems.Length, pq.Count); // Compare the order of the priority items for (i = 0; i < priorityItems.Length; ++i) { PriorityItem priorityItem = pq.Dequeue() as PriorityItem; Assert.AreSame(priorityItems[i], priorityItem); } } }
public void MultipleWorkItemsMultiplePriorities() { // Get all the available priorities WorkItemPriority [] priorities = Enum.GetValues(typeof(WorkItemPriority)) as WorkItemPriority []; // Create an array of priority items PriorityItem [] priorityItems = new PriorityItem[priorities.Length]; // Create a priority item for each priority int i = priorities.Length; foreach(WorkItemPriority workItemPriority in priorities) { --i; priorityItems[i] = new PriorityItem(workItemPriority); } // Create a PermutationGenerator for the priority items PermutationGenerator permutations = new PermutationGenerator(priorityItems); int count = 0; // Iterate over the permutations foreach(object [] permutation in permutations) { ++count; Console.Write("Permutation #" + count + " : "); for(int j = 0; j < permutation.Length; ++j) { PriorityItem pi = permutation[j] as PriorityItem; Console.Write(pi.WorkItemPriority + ", "); } Console.WriteLine(); // Create a priority queue PriorityQueue pq = new PriorityQueue(); // Enqueue each priority item according to the permutation for(i = 0; i < permutation.Length; ++i) { PriorityItem priorityItem = permutation[i] as PriorityItem; pq.Enqueue(priorityItem); } // Make sure all the priority items are in the queue Assert.AreEqual(priorityItems.Length, pq.Count); // Compare the order of the priority items for(i = 0; i < priorityItems.Length; ++i) { PriorityItem priorityItem = pq.Dequeue() as PriorityItem; Assert.AreSame(priorityItems[i], priorityItem); } } }
public void DecreaseKey(T item, double f) { int ci = data.IndexOf(new PriorityItem<T>(item, -1)); data[ci].f = f; while (ci > 0) { int pi = (ci - 1) / 2; // parent index if (data[ci].f >= data[pi].f) break; // child item is larger than (or equal) parent so we're done PriorityItem<T> tmp = data[ci]; data[ci] = data[pi]; data[pi] = tmp; ci = pi; } }
public void Enqueue(T item, double f) { data.Add(new PriorityItem<T>(item, f)); int ci = data.Count - 1; // child index; start at end while (ci > 0) { int pi = (ci - 1) / 2; // parent index if (data[ci].f >= data[pi].f) break; // child item is larger than (or equal) parent so we're done PriorityItem<T> tmp = data[ci]; data[ci] = data[pi]; data[pi] = tmp; ci = pi; } }
public override bool Equals(object obj) { if (obj == null) { return false; } // If parameter cannot be cast to Point return false. PriorityItem<N> otherT = obj as PriorityItem<N>; N other = otherT.Value; if (other == null) { return false; } // Return true if the fields match: return value.Equals(other); }
public void OneWorkItem() { WorkItemPriority [] priorities = Enum.GetValues(typeof(WorkItemPriority)) as WorkItemPriority []; foreach(WorkItemPriority wip in priorities) { PriorityQueue pq = new PriorityQueue(); PriorityItem pi = new PriorityItem(wip); pq.Enqueue(pi); Assert.AreEqual(1, pq.Count, "Failed for priority {0}", wip); PriorityItem pi2 = pq.Dequeue() as PriorityItem; Assert.IsNotNull(pi2, "Failed for priority {0}", wip); Assert.AreSame(pi, pi2, "Failed for priority {0}", wip); Assert.AreEqual(0, pq.Count, "Failed for priority {0}", wip); } }
public void OneWorkItem() { WorkItemPriority [] priorities = Enum.GetValues(typeof(WorkItemPriority)) as WorkItemPriority []; foreach (WorkItemPriority wip in priorities) { PriorityQueue pq = new PriorityQueue(); PriorityItem pi = new PriorityItem(wip); pq.Enqueue(pi); Assert.AreEqual(1, pq.Count, "Failed for priority {0}", wip); PriorityItem pi2 = pq.Dequeue() as PriorityItem; Assert.IsNotNull(pi2, "Failed for priority {0}", wip); Assert.AreSame(pi, pi2, "Failed for priority {0}", wip); Assert.AreEqual(0, pq.Count, "Failed for priority {0}", wip); } }
public T Dequeue() { // assumes pq is not empty; up to calling code int li = data.Count - 1; // last index (before removal) PriorityItem<T> frontItem = data[0]; // fetch the front data[0] = data[li]; data.RemoveAt(li); --li; // last index (after removal) int pi = 0; // parent index. start at front of pq while (true) { int ci = pi * 2 + 1; // left child index of parent if (ci > li) break; // no children so done int rc = ci + 1; // right child if (rc <= li && data[rc].f < data[ci].f) // if there is a rc (ci + 1), and it is smaller than left child, use the rc instead ci = rc; if (data[pi].f <= data[ci].f) break; // parent is smaller than (or equal to) smallest child so done PriorityItem<T> tmp = data[pi]; data[pi] = data[ci]; data[ci] = tmp; // swap parent and child pi = ci; } return frontItem.Value; }
public void MultipleWorkItemsOnePriority() { WorkItemPriority [] priorities = Enum.GetValues(typeof(WorkItemPriority)) as WorkItemPriority []; foreach(WorkItemPriority wip in priorities) { PriorityQueue pq = new PriorityQueue(); PriorityItem [] priorityItems = new PriorityItem[10]; for(int i = 0; i < priorityItems.Length; ++i) { priorityItems[i] = new PriorityItem(wip); pq.Enqueue(priorityItems[i]); Assert.AreEqual(i+1, pq.Count, "Failed for priority {0} item count {1}", wip, i+1); } for(int i = 0; i < priorityItems.Length; ++i) { PriorityItem pi = pq.Dequeue() as PriorityItem; Assert.AreEqual(priorityItems.Length-(i+1), pq.Count, "Failed for priority {0} item count {1}", wip, i+1); Assert.IsNotNull(pi, "Failed for priority {0} item count {1}", wip, i+1); Assert.AreSame(pi, priorityItems[i], "Failed for priority {0} item count {1}", wip, i+1); } Assert.AreEqual(0, pq.Count, "Failed for priority {0}", wip); Assert.IsNull(pq.Dequeue()); Assert.AreEqual(0, pq.Count); } }
public void MultipleWorkItemsOnePriority() { WorkItemPriority [] priorities = Enum.GetValues(typeof(WorkItemPriority)) as WorkItemPriority []; foreach (WorkItemPriority wip in priorities) { PriorityQueue pq = new PriorityQueue(); PriorityItem [] priorityItems = new PriorityItem[10]; for (int i = 0; i < priorityItems.Length; ++i) { priorityItems[i] = new PriorityItem(wip); pq.Enqueue(priorityItems[i]); Assert.AreEqual(i + 1, pq.Count, "Failed for priority {0} item count {1}", wip, i + 1); } for (int i = 0; i < priorityItems.Length; ++i) { PriorityItem pi = pq.Dequeue() as PriorityItem; Assert.AreEqual(priorityItems.Length - (i + 1), pq.Count, "Failed for priority {0} item count {1}", wip, i + 1); Assert.IsNotNull(pi, "Failed for priority {0} item count {1}", wip, i + 1); Assert.AreSame(pi, priorityItems[i], "Failed for priority {0} item count {1}", wip, i + 1); } Assert.AreEqual(0, pq.Count, "Failed for priority {0}", wip); Assert.IsNull(pq.Dequeue()); Assert.AreEqual(0, pq.Count); } }
public PlainTextStream(Stream s, PriorityItem p, bool caseSensitive) { stream = s; priority = p; CaseSensitive = caseSensitive; }
private void SetCommandFromFactory(ICommandFactory commandFactory) { this.updatePriority = PriorityItem.CommandFactory; if (commandFactory == null || CommandProvider == null) { return; } if (CommandProvider.CommandFactories.Any((f) => AreCommandFactoriesEqual(f, commandFactory))) { this.updatePriority = PriorityItem.None; this.allowPropertyBehaviours = false; try { var command = commandFactory.CreateCommand(); commandFactory.PopulateCommand(command, CommandProvider); Command = command; } finally { this.allowPropertyBehaviours = true; } } }
public void GenerateSchedule(GenerationSettings settings) { GenerationSettings = settings; if (GenerationData == null) { GenerationData = new GenerationData(); } if (!MachineHandler.Instance.IsLoaded) { MachineHandler.Instance.Load(); } if (!MachineHandler.Instance.IsLoaded) { MessageBox.Show("Could not load machine config data. Please open the machine config file."); if (!MachineHandler.Instance.LoadDialog()) { MessageBox.Show("Failed to load or canceled. Cannot generate schedule without machine config data. Stopping generation."); return; } } if (StaticInventoryTracker.ProductMasterList.Count == 0) { MessageBox.Show("No master loaded. Please load master before generating schedule."); return; } if (MachineHandler.Instance.MachineList.Count == 0) { MessageBox.Show("No machines configured/loaded. Please load or configure the plant machines before generating schedule."); return; } if (!StaticFactoryValuesManager.Loaded) { StaticFactoryValuesManager.LoadValues(); if (!StaticFactoryValuesManager.Loaded) { MessageBox.Show("No machines configured/loaded. Please load or configure the plant machines before generating schedule."); return; } } try { CoatingSchedule.CurrentSchedule?.ChildrenLogic.Clear(); CoatingScheduleWindow scheduleWindow = new CoatingScheduleWindow(schedule); scheduleWindow.Show(); PressScheduleWindow pressScheduleWindow = new PressScheduleWindow(); pressScheduleWindow.Show(); PressManager.PlateConfigurations.Clear(); pressScheduleWindow.UpdateControls(); // add the first shift to the schedule schedule.AddLogic(); scheduleDay = (CoatingScheduleDay)schedule.ChildrenLogic[0]; scheduleDay.Date = GenerationSettings.StartGen; scheduleDay.AddLogic(); scheduleLine = (CoatingScheduleLine)scheduleDay.ChildrenLogic[0]; GenerationData.InitializeData(RequirementsHandler.GetMakeOrders(GenerationSettings.SalesOutlook), GenerationSettings); // get list of items that can be made in the coating plant List <ProductMasterItem> masterItemsAvailableToMake = StaticInventoryTracker.ProductMasterList.Where( m => m.MadeIn.ToUpper().Equals("COATING")).ToList(); List <ProductMasterItem> unmakeableItems = masterItemsAvailableToMake.Where( item => MachineHandler.Instance.AllConfigurations.All(c => !c.CanMake(item))).ToList(); if (unmakeableItems.Any()) { StringBuilder badItems = new StringBuilder(); badItems.AppendLine("No configuration found for " + unmakeableItems.Count + " items:"); foreach (var productMasterItem in unmakeableItems) { masterItemsAvailableToMake.Remove(productMasterItem); badItems.AppendLine(productMasterItem.ToString()); } badItems.AppendLine( "Please note that these items cannot be scheduled in coating until they have configurations that output their masterID."); MessageBox.Show(badItems.ToString()); } // While we have not reached the end of the schedule while (GenerationData.CurrentDay <= GenerationSettings.EndGen) { int itemIndex = 0; bool wasScheduled = false; bool skipShift = false; // attempt to schedule the highest priority item until the line is full. Also as long as we have not tried every item on this shift while (GenerationData.ScheduledItem.Any(s => !s.Value) && !LineIsFull() && !skipShift && GenerationData.CurrentDay <= GenerationSettings.EndGen) { wasScheduled = false; // try each coating line for (var index = 0; GenerationData.CurrentDay <= GenerationSettings.EndGen && index < StaticFactoryValuesManager.CoatingLines.Count; index++) { var coatingLine = StaticFactoryValuesManager.CoatingLines[index]; // Get item with highest priority GenerationData.CreatePriorityList(masterItemsAvailableToMake, coatingLine); if (itemIndex >= GenerationData.PriorityList.Count) { skipShift = true; break; } // Use the next item in the prereq. list as the most favorable. PriorityItem currentItem = GenerationData.GetPriorityItem(itemIndex); if (currentItem.Item.MadeIn.ToUpper().Equals("COATING")) { wasScheduled = ScheduleCoating(currentItem.Item, coatingLine); } else if (currentItem.Item.MadeIn.ToUpper().Equals("PRESS")) { // make the target supply, unless 0, then use 1 and fill. var unitsToMake = currentItem.Item.TargetSupply > 0 ? currentItem.Item.TargetSupply : 1; // should have a sale if scheduling here. var sale = GenerationData.SalesList.FirstOrDefault(s => s.MasterID == currentItem.Item.MasterID); if (sale != null) { unitsToMake = sale.PiecesToMake * currentItem.Item.PiecesPerUnit; } SchedulePress(currentItem.Item, unitsToMake); wasScheduled = true; // don't move on due to a press scheduling. } else { // error MessageBox.Show( "ERROR: Attempted to schedule item that cannot be made in coating or press. Could not make item " + currentItem.Item); } // move to next item // Check if all the lines have been scheduled or if we have tried all the items and none can be scheduled, move on if (GenerationData.ScheduledItem.All(s => s.Value) || itemIndex >= GenerationData.PriorityList.Count) { AddControl(); } } if (!wasScheduled) { // move to the next item, as the highest priority item can't be made currently. itemIndex++; } } // if all items have been run, reset the counter. If there have been no schedulings, then also add a shift if (skipShift || LineIsFull()) { AddControl(); } } pressScheduleWindow.UpdateControls(); while (_errors.Count > 0) { MessageBox.Show(_errors.Dequeue()); } MessageBox.Show("Schedule done generating"); } catch (Exception e) { Console.WriteLine(e); throw; } }
public PlainTextStream(string fp, PriorityItem p) { path = fp; priority = p; }
public PlainTextStream(string fp, Encoding enc, PriorityItem p) { path = fp; encoding = enc; priority = p; }
public PlainTextStream(string fp, PriorityItem p, bool caseSensitive) { path = fp; priority = p; CaseSensitive = caseSensitive; }
private void SetCommandFactoryFromCommand(ICommand command) { this.updatePriority = PriorityItem.Command; if (CommandProvider == null) { return; } this.updatePriority = PriorityItem.None; if (command == null) { CommandFactory = null; return; } this.allowPropertyBehaviours = false; try { CommandFactory = CoerceCommandFactory(command.GetFactory()); } finally { this.allowPropertyBehaviours = true; } }
public PlainTextStream(Stream s, PriorityItem p) { stream = s; priority = p; }
public PlainTextStream(Stream s, Encoding enc, PriorityItem p) { stream = s; encoding = enc; priority = p; }