コード例 #1
0
        /// <summary>
        /// Получить экспертную оценку в зависимости от месторасположения и количества оценок в массиве.
        /// </summary>
        /// <param name="estimates">Массив экспертных оценок для участка.</param>
        /// <param name="location">Расположение внутри участка.</param>
        /// <returns>Значение оценки.</returns>
        protected static double GetEstimate(ushort[] estimates, LocationInRegion location)
        {
            try
            {
                if (estimates == null || estimates.Length == 0)
                {
                    throw new ArgumentNullException(nameof(estimates), "Estimates array is null or empty!");
                }

                if (location == LocationInRegion.Inside)                // Для внутренней части участка - последняя оценка
                {
                    return(GetEstimateFromArray(estimates, ESTIMATES_ARRAY_LENGTH - 1));
                }

                if ((int)location < ESTIMATES_ARRAY_LENGTH - 1)         // Если требуется не угловая оценка, берём просто по индексу в массиве оценок
                {
                    return(GetEstimateFromArray(estimates, (int)location));
                }

                switch (location)       // Для угловых месторасположений считаем среднее по двум границам
                {
                case LocationInRegion.LeftTopCorder:
                    return((GetEstimateFromArray(estimates, (int)LocationInRegion.LeftBorder) +
                            GetEstimateFromArray(estimates, (int)LocationInRegion.TopBorder)) / 2);

                case LocationInRegion.RightTopCorner:
                    return((GetEstimateFromArray(estimates, (int)LocationInRegion.RightBorder) +
                            GetEstimateFromArray(estimates, (int)LocationInRegion.TopBorder)) / 2);

                case LocationInRegion.RightBottomCorner:
                    return((GetEstimateFromArray(estimates, (int)LocationInRegion.RightBorder) +
                            GetEstimateFromArray(estimates, (int)LocationInRegion.BottomBorder)) / 2);

                case LocationInRegion.LeftBottomCorner:
                    return((GetEstimateFromArray(estimates, (int)LocationInRegion.LeftBorder) +
                            GetEstimateFromArray(estimates, (int)LocationInRegion.BottomBorder)) / 2);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("GetEstimate failed! {0}", ex.Message);
            }

            return(0);
        }
コード例 #2
0
 /// <summary>
 /// Получить оценку трудности прокладывания кабелей.
 /// </summary>
 /// <param name="location">Расположение внутри участка.</param>
 /// <returns>Значение оценки.</returns>
 public double GetBadWiredTransmittanceEstimate(LocationInRegion location)
 {
     return(GetEstimate(BadWiredTransmittance, location));
 }
コード例 #3
0
 /// <summary>
 /// Получить оценку непригодности.
 /// </summary>
 /// <param name="location">Расположение внутри участка.</param>
 /// <returns>Значение оценки.</returns>
 public double GetUnavailabilityEstimate(LocationInRegion location)
 {
     return(GetEstimate(Unavailability, location));
 }
コード例 #4
0
 /// <summary>
 /// Получить оценку трудоемкости.
 /// </summary>
 /// <param name="location">Расположение внутри участка.</param>
 /// <returns>Значение оценки.</returns>
 public double GetLaboriousnessEstimate(LocationInRegion location)
 {
     return(GetEstimate(Laboriousness, location));
 }
コード例 #5
0
 /// <summary>
 /// Получить оценку агрессивности.
 /// </summary>
 /// <param name="location">Расположение внутри участка.</param>
 /// <returns>Значение оценки.</returns>
 public double GetAggressivenessEstimate(LocationInRegion location)
 {
     return(GetEstimate(Aggressiveness, location));
 }