private void UpdateCPE(String dmId, double ffCpe, double ttCpe, int time) { if (!_dmCPEs.ContainsKey(dmId)) { _dmCPEs.Add(dmId, new CPEPair(dmId, ffCpe, ttCpe, time)); } else { _dmCPEs[dmId].FF_CPE = ffCpe; _dmCPEs[dmId].TT_CPE = ttCpe; _dmCPEs[dmId].LastTimeUpdated = time; } _lastCPEUpdateTime = time; AppendToInfoBox(tbInfoBox, String.Format("{0} CPEs updated to: FindFix={1}, TrackTarget={2}\r\n", dmId, ffCpe, ttCpe)); //if they have a queued item waiting, send it now! if (_timelineEvents.Count() > 0 && !_hasFinishedPreTest) { _readyToSendItems = true; //next time tick, will check for next scheduled item return; //only adaptively choose if there are no more scheduled items remaining. } _hasFinishedPreTest = true; //Do stuff! List <int> usedItemIds = new List <int>(); CellRange nextItemRange = _itemSelector.GetNextItem(ffCpe, ttCpe); T_Item nextItem = SelectNextItemByRange(nextItemRange, dmId); int failedAttempts = 0; while (nextItem == null && _items.Count > usedItemIds.Count)//0) { failedAttempts++; usedItemIds.Add(nextItemRange.CellNumber); //get a similar cell range and try again nextItemRange = _itemSelector.GetNextItem(ffCpe, ttCpe, usedItemIds, failedAttempts); nextItem = SelectNextItemByRange(nextItemRange, dmId); } if (nextItem == null) { Console.WriteLine("Serious issues where we can't find a good fit"); nextItem = _items[Math.Min(_items.Count, 5).ToString()]; } //Thread.Sleep(1000); //TEMP ScheduledItem si = new ScheduledItem(); si.DM_ID = dmId; si.ID = nextItem.ID; si.Time = time; _timelineEvents.Add(si); _readyToSendItems = true; //SendItem(nextItem, dmId, time); AppendToInfoBox(tbInfoBox, String.Format("{3}: Next Item ({4}) selected for {0}: FindFixDifficulty={1}, TrackTargetDifficulty={2}\r\n", dmId, nextItem.Parameters.FF_Difficulty, nextItem.Parameters.TT_Difficulty, time, nextItem.ID)); }
private void buttonProcess_Click(object sender, RoutedEventArgs e) { double cpe1 = 0; double cpe2 = 0; if (Double.TryParse(tbCpe1.Text, out cpe1) == false || Double.TryParse(tbCpe2.Text, out cpe2) == false) { MessageBox.Show("Invalid input"); return; } String method = ((ComboBoxItem)comboBox1.SelectedItem).Content.ToString(); switch (method) { case "Maintain": _selector.SetGoal(new MaintainMethod()); break; case "Challenge": _selector.SetGoal(new ChallengeMethod()); break; case "Consolidate": _selector.SetGoal(new ConsolidateMethod()); break; } CellRange cur = _selector.GetCurrentCpeItem(cpe1, cpe2); CellRange next = _selector.GetNextItem(cpe1, cpe2); matrixControl.SetCurrentAndNextColors(cur.CellNumber, next.CellNumber); }