예제 #1
0
 public void ClearContents()
 {
     ResetSlot();
     SlotContents.sprite = null;
     _slotStatus         = SlotStatus.AwaitingRequirements;
     DoClearContents();
 }
예제 #2
0
        /// <summary>
        /// Gets Status Color Object
        /// </summary>
        public static Color GetStatusColor(this SlotStatus status)
        {
            switch (status)
            {
            case SlotStatus.Running:
                return(Color.Green);

            case SlotStatus.RunningNoFrameTimes:
                return(Color.Yellow);

            case SlotStatus.Finishing:
                return(Color.Khaki);

            case SlotStatus.Ready:
                return(Color.DarkCyan);

            case SlotStatus.Stopping:
            case SlotStatus.Failed:
                return(Color.DarkRed);

            case SlotStatus.Paused:
                return(Color.Orange);

            case SlotStatus.Offline:
                return(Color.Gray);

            default:
                return(Color.Gray);
            }
        }
예제 #3
0
 public async Task AddPacketsToSpecificPlayers(Packet packet, SlotStatus status = SlotStatus.Playing)
 {
     foreach (var slot in Slots.Where(x => x.Status == status))
     {
         slot.User.WaitingPackets.Enqueue(packet);
     }
 }
예제 #4
0
 public void Clear()
 {
     Mods     = Mods.None;
     Presence = null;
     Status   = SlotStatus.Open;
     Team     = SlotTeams.Neutral;
 }
예제 #5
0
 public SlotAirStatus()
 {
     this.ichainmode = ChainMode.AUTO;
     this.istatus = SlotStatus.WAITING;
     this.ifillsong = false;
     this.cutsong = false;
 }
예제 #6
0
 public void CopyFrom(Slot source)
 {
     Mods     = source.Mods;
     Presence = source.Presence;
     Status   = source.Status;
     Team     = source.Team;
 }
예제 #7
0
 public SlotAirStatus(ChainMode chainmode)
 {
     this.ichainmode = chainmode;
     this.istatus = SlotStatus.WAITING;
     this.ifillsong = false;
     this.cutsong = false;
 }
예제 #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RedisAcquireMasterRoleResult"/> struct.
 /// </summary>
 public RedisAcquireMasterRoleResult(int masterId, string priorMasterMachineName, DateTime priorMasterLastHeartbeat, SlotStatus priorMachineStatus)
 {
     MasterId = masterId;
     PriorMasterMachineName   = priorMasterMachineName;
     PriorMasterLastHeartbeat = priorMasterLastHeartbeat;
     PriorMachineStatus       = priorMachineStatus;
 }
예제 #9
0
        /// <summary>Creates a "symmetric difference" set, that is a set whose elements
        /// are either in this or in the other set, but not in both.</summary>
        /// <remarks>Equivalent to <c>(A | B) - (A &amp; B)</c>, if <c>this == A</c> and
        /// <c>otherSet == B</c>.</remarks>
        /// <param name="otherSet">The other set to construct the "symmetric difference" set from.</param>
        public void SymmetricDiff(Set <T> otherSet)
        {
            int delta = 0;

            SlotStatus[] otherSlots = otherSet.slots;
            for (int otherIndx = 0; otherIndx < otherSlots.Length; otherIndx++)
            {
                if (otherSlots[otherIndx] == SlotStatus.Filled)
                {
                    T    otherItem = otherSet.items[otherIndx];
                    int  indx;
                    bool found = FindSlot(otherItem, out indx);
                    if (found)
                    {
                        items[indx] = default(T);
                        slots[indx] = SlotStatus.Deleted;
                        delta++;
                    }
                    else
                    {
                        SlotStatus slot = slots[indx];
                        items[indx] = otherItem;
                        slots[indx] = SlotStatus.Filled;
                        IncCount(slot == SlotStatus.Empty);
                    }
                }
            }
            DecCount(delta);
        }
        public ActionResult DeleteConfirmed(int id)
        {
            SlotStatus m = db.SlotStatus.Find(id);

            db.SlotStatus.Remove(m);
            db.SaveChanges();
            return(RedirectToAction("Index", "SlotStatus"));
        }
예제 #11
0
            public Slot(XmlNode slotNode)
            {
                if (slotNode == null)
                {
                    throw new ApplicationException("Invalid Environment xml file. No slot node found");
                }

                ID     = Convert.ToInt32(slotNode.Attributes["id"].Value);
                Status = (SlotStatus)Enum.Parse(typeof(SlotStatus), slotNode.Attributes["status"].Value);
            }
예제 #12
0
 public async Task Unready(SlotStatus status = SlotStatus.Ready)
 {
     foreach (var slot in Slots)
     {
         if ((slot.Status & status) != 0)
         {
             slot.Status = SlotStatus.NotReady;
         }
     }
 }
 public ActionResult Edit([Bind(Include = "SlotStatusID,Status")] SlotStatus m)
 {
     if (ModelState.IsValid)
     {
         db.Entry(m).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index", "SlotStatus"));
     }
     return(View(m));
 }
예제 #14
0
        /// <summary>Sets capacity of hash table as power of 2.</summary>
        /// <param name="value">Base 2 logarithm of new size of hash table.</param>
        protected void SetSizeLog(byte value)
        {
            int indx;

            T[]          newItems;
            SlotStatus[] newSlots;
            int          newSize;
            uint         mask;

            newSize = (int)1 << value;
            if ((value < 2) || (newSize < (count << 1)))
            {
                string msg = "Size too small: {0}."; // Resources.GetString(RsId.SizeTooSmall);
                throw new ArgumentException(String.Format(msg, value), "value");
            }

            mask     = unchecked ((uint)(newSize - 1));
            newItems = new T[newSize];
            newSlots = new SlotStatus[newSize];

            // re-hash: loop through existing items and insert them into new array
            for (indx = slots.Length - 1; indx >= 0; indx--)
            {
                if (slots[indx] == SlotStatus.Filled)
                {
                    T   item    = items[indx];
                    int keyHash = comparer == null?item.GetHashCode() : comparer.GetHashCode(item);

                    int newIndx = unchecked (keyHash & (int)mask);
                    // don't have to check for deleted items in new slots array
                    if (newSlots[newIndx] != SlotStatus.Empty)
                    {
                        unchecked {
                            // see comments to step in FindSlot()
                            int step = ((((keyHash & (int)~mask) >> (value - 1)) &
                                         (int)(mask >> 2)) | (int)1) & (int)0xFF;
                            do
                            {
                                newIndx = newIndx - step;
                                if (newIndx < 0)
                                {
                                    newIndx = newIndx + newSize;
                                }
                            } while (newSlots[newIndx] != SlotStatus.Empty);
                        }
                    }
                    newItems[newIndx] = item;
                    newSlots[newIndx] = SlotStatus.Filled;
                }
            }
            items     = newItems;
            slots     = newSlots;
            sizeLog   = value;
            usedCount = count;
        }
        public ActionResult Create([Bind(Include = "SlotStatusID,Status")] SlotStatus m)
        {
            if (ModelState.IsValid)
            {
                db.SlotStatus.Add(m);
                db.SaveChanges();
                return(RedirectToAction("Index", "SlotStatus"));
            }

            return(View(m));
        }
        private static ISlot CreateSlot(int id,
                                        SlotStatus statusOne,
                                        string date)
        {
            var one = Substitute.For <ISlot>();

            one.Id.Returns(id);
            one.Status        = statusOne;
            one.StartDateTime = DateTime.Parse(date);
            return(one);
        }
예제 #17
0
        internal List<VirtualSlot> ListStatus(SlotStatus cStatus)
        {
            List<VirtualSlot> sList = new List<VirtualSlot>();

            foreach(VirtualSlot vSlot in List())
            {
                if (vSlot.Status != cStatus) { continue; }
                sList.Add(vSlot);
            }

            return sList;
        }
예제 #18
0
파일: Slot.cs 프로젝트: yunsoa/nintegrate
        public bool Book(int ubrn)
        {
            if (_status == SlotStatus.Booked)
            {
                return(false);
            }

            _status = SlotStatus.Booked;
            _ubrn   = ubrn;
            this.Save();
            return(true);
        }
예제 #19
0
        public async Task UpdateUserStatus(Presence user, SlotStatus status)
        {
            var slot = user.Match.GetSlot(user.Id);

            if (slot is null)
            {
                return;
            }

            slot.Status = status;
            await Update();
        }
예제 #20
0
파일: Slot.cs 프로젝트: yunsoa/nintegrate
        public bool Cancel()
        {
            if (_status == SlotStatus.Available)
            {
                return(false);
            }

            _status = SlotStatus.Available;
            _ubrn   = null;
            this.Save();
            return(true);
        }
예제 #21
0
        public static bool IsRunning(this SlotStatus status)
        {
            switch (status)
            {
            case SlotStatus.Running:
            case SlotStatus.Finishing:
            case SlotStatus.RunningNoFrameTimes:
                return(true);

            default:
                return(false);
            }
        }
예제 #22
0
        internal static Color GetHtmlFontColor(SlotStatus status)
        {
            switch (status)
            {
            case SlotStatus.RunningNoFrameTimes:
            case SlotStatus.Paused:
            case SlotStatus.Finishing:
            case SlotStatus.Offline:
                return(Color.Black);

            default:
                return(Color.White);
            }
        }
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            SlotStatus m = db.SlotStatus.Find(id);

            if (m == null)
            {
                return(HttpNotFound());
            }
            return(View(m));
        }
예제 #24
0
        /// <summary>
        /// Gets Status Html Font Color String
        /// </summary>
        public static string GetHtmlFontColor(this SlotStatus status)
        {
            switch (status)
            {
            case SlotStatus.RunningNoFrameTimes:
            case SlotStatus.Paused:
            case SlotStatus.Finishing:
            case SlotStatus.Offline:
                return(ColorTranslator.ToHtml(Color.Black));

            default:
                return(ColorTranslator.ToHtml(Color.White));
            }
        }
예제 #25
0
        public async Task Toggle()
        {
            if (Status == SlotStatus.Locked)
            {
                Status = SlotStatus.Open;
                return;
            }

            if ((Status & SlotStatus.HasPlayer) != 0)
            {
                await User.Match.Leave(User);
            }

            Status = SlotStatus.Locked;
        }
예제 #26
0
        /// <summary>
        /// Handles the Client Status Returned by Log Parsing and then determines what values to feed the DetermineStatus routine.
        /// </summary>
        private void HandleReturnedStatus(SlotStatus returnedStatus, SlotModel slot)
        {
            var statusData = new LegacyClientStatusData
            {
                ClientName                = Settings.Name,
                SlotType                  = slot.UnitInfoModel.UnitInfoData.SlotType,
                UnitRetrievalTime         = slot.UnitInfoModel.UnitInfoData.UnitRetrievalTime,
                UtcOffsetIsZero           = Settings.UtcOffsetIsZero,
                UtcOffset                 = TimeZone.CurrentTimeZone.GetUtcOffset(DateTime.Now),
                ClientTimeOffset          = Settings.ClientTimeOffset,
                TimeOfLastUnitStart       = slot.TimeOfLastUnitStart,
                TimeOfLastFrameProgress   = slot.TimeOfLastFrameProgress,
                CurrentStatus             = slot.Status,
                ReturnedStatus            = returnedStatus,
                FrameTime                 = slot.UnitInfoModel.GetRawTime(Prefs.Get <PpdCalculationType>(Preference.PpdCalculation)),
                BenchmarkAverageFrameTime = GetBenchmarkAverageFrameTimeOrDefault(slot.UnitInfo),
                TimeOfLastFrame           = slot.UnitInfoModel.UnitInfoData.CurrentFrame == null
                                                  ? TimeSpan.Zero
                                                  : slot.UnitInfoModel.UnitInfoData.CurrentFrame.TimeOfFrame,
                UnitStartTimeStamp = slot.UnitInfoModel.UnitInfoData.UnitStartTimeStamp,
                AllowRunningAsync  = Prefs.Get <bool>(Preference.AllowRunningAsync)
            };

            SlotStatus computedStatus = LegacyClientStatus.GetSlotStatus(statusData, Logger);

            // If the returned status is EuePause and current status is not
            if (computedStatus.Equals(SlotStatus.EuePause) && statusData.CurrentStatus.Equals(SlotStatus.EuePause) == false)
            {
                if (Prefs.Get <bool>(Preference.EmailReportingEnabled) &&
                    Prefs.Get <bool>(Preference.ReportEuePause))
                {
                    SendEuePauseEmail(statusData.ClientName);
                }
            }

            // If the returned status is Hung and current status is not
            if (computedStatus.Equals(SlotStatus.Hung) && statusData.CurrentStatus.Equals(SlotStatus.Hung) == false)
            {
                if (Prefs.Get <bool>(Preference.EmailReportingEnabled) &&
                    Prefs.Get <bool>(Preference.ReportHung))
                {
                    SendHungEmail(statusData.ClientName);
                }
            }

            slot.Status = computedStatus;
        }
예제 #27
0
        public static bool IsOnline(this SlotStatus status)
        {
            switch (status)
            {
            case SlotStatus.Paused:
            case SlotStatus.Running:
            case SlotStatus.Finishing:
            case SlotStatus.Ready:
            case SlotStatus.Stopping:
            case SlotStatus.Failed:
            case SlotStatus.RunningNoFrameTimes:
                return(true);

            default:
                return(false);
            }
        }
        protected override int CompareInternal(SlotModel xVal, SlotModel yVal)
        {
            /* Get property values */
            object     xValue       = GetPropertyValue(xVal, Property);
            object     yValue       = GetPropertyValue(yVal, Property);
            SlotStatus xStatusValue = xVal.Status;
            SlotStatus yStatusValue = yVal.Status;
            object     xNameValue   = xVal.Name;
            object     yNameValue   = yVal.Name;

            // check for offline clients first
            if (OfflineClientsLast)
            {
                if (xStatusValue == SlotStatus.Offline &&
                    yStatusValue != SlotStatus.Offline)
                {
                    return(1);
                }
                if (yStatusValue == SlotStatus.Offline &&
                    xStatusValue != SlotStatus.Offline)
                {
                    return(-1);
                }
            }

            int returnValue;

            /* Determine sort order */
            if (Direction == ListSortDirection.Ascending)
            {
                returnValue = CompareAscending(xValue, yValue);
            }
            else
            {
                returnValue = CompareDescending(xValue, yValue);
            }

            // if values are equal, sort via the client name (asc)
            if (returnValue == 0)
            {
                returnValue = CompareAscending(xNameValue, yNameValue);
            }

            return(returnValue);
        }
예제 #29
0
        /// <summary>Inserts a T item.</summary>
        /// <returns><c>true</c> if inserted successfully, <c>false</c> if item is already present.</returns>
        /// <param name="value">Item to be stored.</param>
        public bool Insert(T value)
        {
            int  indx;
            bool found = FindSlot(value, out indx);

            if (found)
            {
                return(false);
            }
            else
            {
                SlotStatus slot = slots[indx];
                items[indx] = value;
                slots[indx] = SlotStatus.Filled;
                IncCount(slot == SlotStatus.Empty);
                return(true);
            }
        }
예제 #30
0
 public void TryUnveil()
 {
     if (Status == SlotStatus.CHARGED)
     {
         LeanTween.value(gameObject, updateValueExampleCallback, 0f, 1f, 0.75f).setEase(LeanTweenType.easeInExpo);
         CharacterRenderer.transform.localScale = Vector3.zero;
         Status = SlotStatus.OPENING;
         Burst.Emit(20);
         LeanTween.scale(CharacterRenderer.gameObject, Vector3.one, 0.75f).setEase(LeanTweenType.easeInExpo);
         CharacterRenderer.IsSelected = true;
     }
     if (Status == SlotStatus.OPEN)
     {
         Burst.Emit(20);
         Status      = SlotStatus.EMPTY;
         Pill.Slider = 0;
         CharacterRenderer.IsSelected = true;
     }
 }
예제 #31
0
        public void ShowProductionTrace(ILogger logger, string slotName, SlotStatus status, PPDCalculation ppdCalculation, BonusCalculation bonusCalculation)
        {
            // test the level
            if (!logger.IsDebugEnabled)
            {
                return;
            }

            if (ProteinIsUnknown(CurrentProtein))
            {
                logger.Debug(String.Format(Logger.NameFormat, slotName, "Protein is unknown... 0 PPD."));
                return;
            }

            switch (bonusCalculation)
            {
            case BonusCalculation.DownloadTime:
                logger.Debug(String.Format(Logger.NameFormat, slotName,
                                           status == SlotStatus.RunningNoFrameTimes
                            ? "Calculate Bonus PPD by Frame Time."
                            : "Calculate Bonus PPD by Download Time."));
                break;

            case BonusCalculation.FrameTime:
                logger.Debug(String.Format(Logger.NameFormat, slotName, "Calculate Bonus PPD by Frame Time."));
                break;

            default:
                logger.Debug(String.Format(Logger.NameFormat, slotName, "Calculate Standard PPD."));
                break;
            }

            TimeSpan frameTime = GetFrameTime(ppdCalculation);
            var      noBonus   = CurrentProtein.GetProteinProduction(frameTime, TimeSpan.Zero);
            TimeSpan unitTimeByDownloadTime = GetUnitTimeByDownloadTime(frameTime);
            var      bonusByDownload        = CurrentProtein.GetProteinProduction(frameTime, unitTimeByDownloadTime);
            TimeSpan unitTimeByFrameTime    = GetUnitTimeByFrameTime(frameTime);
            var      bonusByFrame           = CurrentProtein.GetProteinProduction(frameTime, unitTimeByFrameTime);

            logger.Debug(CreateProductionDebugOutput(WorkUnit.ToShortProjectString(), frameTime, CurrentProtein, noBonus,
                                                     unitTimeByDownloadTime, bonusByDownload,
                                                     unitTimeByFrameTime, bonusByFrame));
        }
예제 #32
0
        public void ShowProductionTrace(ILogger logger, string slotName, SlotStatus status, PpdCalculationType calculationType, BonusCalculationType bonusCalculationType)
        {
            // test the level
            if (!logger.IsDebugEnabled)
            {
                return;
            }

            if (CurrentProtein.IsUnknown())
            {
                logger.DebugFormat(Constants.ClientNameFormat, slotName, "Protein is unknown... 0 PPD.");
                return;
            }

            switch (bonusCalculationType)
            {
            case BonusCalculationType.DownloadTime:
                logger.DebugFormat(Constants.ClientNameFormat, slotName,
                                   status == SlotStatus.RunningNoFrameTimes
                            ? "Calculate Bonus PPD by Frame Time."
                            : "Calculate Bonus PPD by Download Time.");
                break;

            case BonusCalculationType.FrameTime:
                logger.DebugFormat(Constants.ClientNameFormat, slotName, "Calculate Bonus PPD by Frame Time.");
                break;

            default:
                logger.DebugFormat(Constants.ClientNameFormat, slotName, "Calculate Standard PPD.");
                break;
            }

            TimeSpan frameTime              = GetFrameTime(calculationType);
            var      noBonusValues          = CurrentProtein.GetProductionValues(frameTime, TimeSpan.Zero);
            TimeSpan unitTimeByDownloadTime = GetUnitTimeByDownloadTime(frameTime);
            var      bonusByDownloadValues  = CurrentProtein.GetProductionValues(frameTime, unitTimeByDownloadTime);
            TimeSpan unitTimeByFrameTime    = GetUnitTimeByFrameTime(frameTime);
            var      bonusByFrameValues     = CurrentProtein.GetProductionValues(frameTime, unitTimeByFrameTime);

            logger.Debug(CreateProductionDebugOutput(UnitInfoData.ToShortProjectString(), frameTime, CurrentProtein, noBonusValues,
                                                     unitTimeByDownloadTime, bonusByDownloadValues,
                                                     unitTimeByFrameTime, bonusByFrameValues));
        }
예제 #33
0
 public TimeSlot(string name, SlotStatus slotStatus, long milliseconds)
 {
     Name = name;
     SlotStatus = slotStatus;
     Start = milliseconds;
 }
예제 #34
0
        public void Close(string name, long milliseconds)
        {
            foreach (var timeSlot in _slots)
            {
                if (timeSlot.SlotStatus == SlotStatus.Open)
                {
                    timeSlot.Close(timeSlot.Name, milliseconds);
                }
            }
            End = milliseconds;
            SlotStatus = SlotStatus.Closed;

            if (Name != name)
            {
                if (Parent != null)
                {
                    Parent.Close(name, milliseconds);
                }
            }
        }
예제 #35
0
        public void ShowPPDTrace(ILogger logger, string slotName, SlotStatus status, PpdCalculationType calculationType, BonusCalculationType calculateBonus)
        {
            // test the level
             if (!logger.IsDebugEnabled) return;

             if (CurrentProtein.IsUnknown())
             {
            logger.DebugFormat(Constants.ClientNameFormat, slotName, "Protein is unknown... 0 PPD.");
            return;
             }

             // Issue 125
             if (calculateBonus.Equals(BonusCalculationType.DownloadTime))
             {
            // Issue 183
            if (status.Equals(SlotStatus.RunningAsync) ||
                status.Equals(SlotStatus.RunningNoFrameTimes))
            {
               logger.DebugFormat(Constants.ClientNameFormat, slotName, "Calculate Bonus PPD by Frame Time.");
            }
            else
            {
               logger.DebugFormat(Constants.ClientNameFormat, slotName, "Calculate Bonus PPD by Download Time.");
            }
             }
             else if (calculateBonus.Equals(BonusCalculationType.FrameTime))
             {
            logger.DebugFormat(Constants.ClientNameFormat, slotName, "Calculate Bonus PPD by Frame Time.");
             }
             else
             {
            logger.DebugFormat(Constants.ClientNameFormat, slotName, "Calculate Standard PPD.");
             }

             TimeSpan frameTime = GetFrameTime(calculationType);
             var values = CurrentProtein.GetProductionValues(frameTime, GetEftByDownloadTime(frameTime), GetEftByFrameTime(frameTime), calculateBonus.IsEnabled());
             logger.Debug(values.ToMultiLineString());
        }
예제 #36
0
      /// <summary>
      /// Return Multi-Line String (Array)
      /// </summary>
      private IEnumerable<string> ToMultiLineString(ProteinBenchmark benchmark, UnitInfoModel unitInfoModel, bool valuesOk, SlotStatus status, string ppdFormatString)
      {
         var output = new List<string>(12);

         Protein protein = _proteinService.Get(benchmark.ProjectID);
         if (protein != null)
         {
            var calculateBonus = _prefs.Get<BonusCalculationType>(Preference.BonusCalculation);

            output.Add(String.Empty);
            output.Add(String.Format(" Name: {0}", benchmark.OwningSlotName));
            output.Add(String.Format(" Path: {0}", benchmark.OwningClientPath));
            output.Add(String.Format(" Number of Frames Observed: {0}", benchmark.FrameTimes.Count));
            output.Add(String.Empty);
            output.Add(String.Format(" Min. Time / Frame : {0} - {1:" + ppdFormatString + "} PPD",
               benchmark.MinimumFrameTime, ProductionCalculator.GetPPD(benchmark.MinimumFrameTime, protein, calculateBonus.IsEnabled())));
            output.Add(String.Format(" Avg. Time / Frame : {0} - {1:" + ppdFormatString + "} PPD",
               benchmark.AverageFrameTime, ProductionCalculator.GetPPD(benchmark.AverageFrameTime, protein, calculateBonus.IsEnabled())));

            if (unitInfoModel != null && unitInfoModel.UnitInfoData.ProjectID.Equals(protein.ProjectNumber) && valuesOk)
            {
               output.Add(String.Format(" Cur. Time / Frame : {0} - {1:" + ppdFormatString + "} PPD",
                  unitInfoModel.GetFrameTime(PpdCalculationType.LastFrame), unitInfoModel.GetPPD(status, PpdCalculationType.LastFrame, calculateBonus)));
               output.Add(String.Format(" R3F. Time / Frame : {0} - {1:" + ppdFormatString + "} PPD",
                  unitInfoModel.GetFrameTime(PpdCalculationType.LastThreeFrames), unitInfoModel.GetPPD(status, PpdCalculationType.LastThreeFrames, calculateBonus)));
               output.Add(String.Format(" All  Time / Frame : {0} - {1:" + ppdFormatString + "} PPD",
                  unitInfoModel.GetFrameTime(PpdCalculationType.AllFrames), unitInfoModel.GetPPD(status, PpdCalculationType.AllFrames, calculateBonus)));
               output.Add(String.Format(" Eff. Time / Frame : {0} - {1:" + ppdFormatString + "} PPD",
                  unitInfoModel.GetFrameTime(PpdCalculationType.EffectiveRate), unitInfoModel.GetPPD(status, PpdCalculationType.EffectiveRate, calculateBonus)));
            }

            output.Add(String.Empty);
         }
         else
         {
            _logger.WarnFormat("Could not find Project {0}.", benchmark.ProjectID);
         }

         return output.ToArray();
      }
예제 #37
0
        /// <summary>
        /// Handles the Client Status Returned by Log Parsing and then determines what values to feed the DetermineStatus routine.
        /// </summary>
        private void HandleReturnedStatus(SlotStatus returnedStatus, SlotModel slot)
        {
            var statusData = new StatusData
                          {
                             ClientName = Settings.Name,
                             SlotType = slot.UnitInfoLogic.UnitInfoData.SlotType,
                             UnitRetrievalTime = slot.UnitInfoLogic.UnitInfoData.UnitRetrievalTime,
                             UtcOffsetIsZero = Settings.UtcOffsetIsZero,
                             UtcOffset = TimeZone.CurrentTimeZone.GetUtcOffset(DateTime.Now),
                             ClientTimeOffset = Settings.ClientTimeOffset,
                             TimeOfLastUnitStart = slot.TimeOfLastUnitStart,
                             TimeOfLastFrameProgress = slot.TimeOfLastFrameProgress,
                             CurrentStatus = slot.Status,
                             ReturnedStatus = returnedStatus,
                             FrameTime = slot.UnitInfoLogic.GetRawTime(Prefs.Get<PpdCalculationType>(Preference.PpdCalculation)),
                             BenchmarkAverageFrameTime = GetBenchmarkAverageFrameTimeOrDefault(slot.UnitInfo),
                             TimeOfLastFrame = slot.UnitInfoLogic.UnitInfoData.CurrentFrame == null
                                                  ? TimeSpan.Zero
                                                  : slot.UnitInfoLogic.UnitInfoData.CurrentFrame.TimeOfFrame,
                             UnitStartTimeStamp = slot.UnitInfoLogic.UnitInfoData.UnitStartTimeStamp,
                             AllowRunningAsync = Prefs.Get<bool>(Preference.AllowRunningAsync)
                          };

             SlotStatus computedStatus = StatusLogic.HandleStatusData(statusData);

             // If the returned status is EuePause and current status is not
             if (computedStatus.Equals(SlotStatus.EuePause) && statusData.CurrentStatus.Equals(SlotStatus.EuePause) == false)
             {
            if (Prefs.Get<bool>(Preference.EmailReportingEnabled) &&
                Prefs.Get<bool>(Preference.ReportEuePause))
            {
               SendEuePauseEmail(statusData.ClientName);
            }
             }

             // If the returned status is Hung and current status is not
             if (computedStatus.Equals(SlotStatus.Hung) && statusData.CurrentStatus.Equals(SlotStatus.Hung) == false)
             {
            if (Prefs.Get<bool>(Preference.EmailReportingEnabled) &&
                Prefs.Get<bool>(Preference.ReportHung))
            {
               SendHungEmail(statusData.ClientName);
            }
             }

             slot.Status = computedStatus;
        }
예제 #38
0
 /// <summary>
 /// Points per day (PPD) rating for this unit
 /// </summary>
 public double GetPPD(SlotStatus status, PpdCalculationType calculationType, BonusCalculationType calculateBonus)
 {
     TimeSpan frameTime = GetFrameTime(calculationType);
      return GetPPD(frameTime, GetEftByDownloadTime(frameTime), GetEftByFrameTime(frameTime), status, calculateBonus);
 }
 private IEnumerable<ISlot> CreateListWithSameStatus(SlotStatus status)
 {
     return CreateList(status,
                       status,
                       status);
 }
        public void List_ReturnsSlots_ForMultipleForStatus(SlotStatus status,
                                                           int expected)
        {
            // Arrange
            IEnumerable <ISlot> list = CreateListWithSameStatus(status);
            var repository = Substitute.For <IDoctorsSlotsRepository>();
            repository.FindSlotsForDoctorByDoctorId(Arg.Any <int>()).Returns(list);
            InformationFinder sut = CreateSut(repository);

            // Act
            IEnumerable <ISlot> actual = sut.List(DoesNotMatter,
                                                  null,
                                                  status.ToString());

            // Assert
            Assert.Equal(expected,
                         actual.Count());
        }
예제 #41
0
        private double GetPPD(TimeSpan frameTime, TimeSpan eftByDownloadTime, TimeSpan eftByFrameTime, SlotStatus status, BonusCalculationType calculateBonus)
        {
            if (CurrentProtein.IsUnknown())
             {
            return 0;
             }

             // Issue 125
             if (calculateBonus.Equals(BonusCalculationType.DownloadTime))
             {
            // Issue 183
            if (status.Equals(SlotStatus.RunningAsync) ||
                status.Equals(SlotStatus.RunningNoFrameTimes))
            {
               return CurrentProtein.GetPPD(frameTime, eftByFrameTime, true);
            }

            return CurrentProtein.GetPPD(frameTime, eftByDownloadTime, true);
             }
             if (calculateBonus.Equals(BonusCalculationType.FrameTime))
             {
            return CurrentProtein.GetPPD(frameTime, eftByFrameTime, true);
             }

             return CurrentProtein.GetPPD(frameTime);
        }
        private static IEnumerable<ISlot> CreateList(SlotStatus statusOne,
                                                      SlotStatus statusTwo,
                                                      SlotStatus statusThree)
        {
            ISlot one = CreateSlot(3,
                                   statusOne,
                                   "2001-03-01");
            ISlot two = CreateSlot(2,
                                   statusTwo,
                                   "2001-02-01");
            ISlot three = CreateSlot(1,
                                     statusThree,
                                     "2001-01-01");

            var list = new Collection <ISlot>
                       {
                           one,
                           two,
                           three
                       };

            return list;
        }
 private static ISlot CreateSlot(int id,
                                 SlotStatus statusOne,
                                 string date)
 {
     var one = Substitute.For <ISlot>();
     one.Id.Returns(id);
     one.Status = statusOne;
     one.StartDateTime = DateTime.Parse(date);
     return one;
 }