Ejemplo n.º 1
0
 public void Add(ScheduledItem i)
 {
     if (_list.Count == 0)
     {
         _list.Add(i);
         return;
     }
     for (int x = 0; x < _list.Count; x++)
     {
         if (i.Time < _list[x].Time)
         {
             _list.Insert(x, i);
             return;
         }
     }
     _list.Add(i);
 }
Ejemplo n.º 2
0
        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));
        }
Ejemplo n.º 3
0
 public static bool LoadFromFile(string fileName, out ScheduledItem obj)
 {
     System.Exception exception = null;
     return LoadFromFile(fileName, out obj, out exception);
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Deserializes xml markup from file into an ScheduledItem object
 /// </summary>
 /// <param name="fileName">string xml file to load and deserialize</param>
 /// <param name="obj">Output ScheduledItem object</param>
 /// <param name="exception">output Exception value if deserialize failed</param>
 /// <returns>true if this XmlSerializer can deserialize the object; otherwise, false</returns>
 public static bool LoadFromFile(string fileName, out ScheduledItem obj, out System.Exception exception)
 {
     exception = null;
     obj = default(ScheduledItem);
     try
     {
         obj = LoadFromFile(fileName);
         return true;
     }
     catch (System.Exception ex)
     {
         exception = ex;
         return false;
     }
 }
Ejemplo n.º 5
0
 public static bool Deserialize(string xml, out ScheduledItem obj)
 {
     System.Exception exception = null;
     return Deserialize(xml, out obj, out exception);
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Deserializes workflow markup into an ScheduledItem object
 /// </summary>
 /// <param name="xml">string workflow markup to deserialize</param>
 /// <param name="obj">Output ScheduledItem object</param>
 /// <param name="exception">output Exception value if deserialize failed</param>
 /// <returns>true if this XmlSerializer can deserialize the object; otherwise, false</returns>
 public static bool Deserialize(string xml, out ScheduledItem obj, out System.Exception exception)
 {
     exception = null;
     obj = default(ScheduledItem);
     try
     {
         obj = Deserialize(xml);
         return true;
     }
     catch (System.Exception ex)
     {
         exception = ex;
         return false;
     }
 }