static GradColor GradHSVType(GradColor color, double x, double y) { double min = Math.Min(x, y); double max = Math.Max(x, y); double midlen = max - min; double rndlen = min + (1.0 - max); GradColor shorter; if (rndlen < midlen) { shorter = (max == y ? GradColor.HSVcw : GradColor.HSVccw); } else { shorter = (max == y ? GradColor.HSVccw : GradColor.HSVcw); } if (color == GradColor.HSVlong) { return(shorter == GradColor.HSVcw ? GradColor.HSVccw : GradColor.HSVcw); } else if (color == GradColor.HSVshort) { return(shorter); } else { return(color); } }
/// <summary> /// Cоздается рандомный новый пакет /// </summary> /// <returns></returns> public Package New() { int DSCP = GetDSCP(); GradColor color = Huawei.GetColor(DSCP); int length = GetLength(color); //Создается пакет return(New(DSCP, length)); }
/// <summary> /// Установить размер пакета по цвету /// </summary> /// <param name="color">Зеленый, желтый, красный</param> /// <returns></returns> public int GetLength(GradColor color) { switch (color) { case GradColor.red: return(random.Next(1001, 1500)); case GradColor.yellow: return(random.Next(501, 1000)); case GradColor.green: return(random.Next(100, 500)); default: throw new Exception(); } }
/// <summary> /// Маркировка пакетов на выходе /// </summary> /// <param name="secviceClass"></param> /// <param name="color"></param> /// <returns></returns> public static int getDSCP(PHB secviceClass, GradColor color) { switch (secviceClass) { case PHB.DF: return(0); case PHB.AF1: switch (color) { case GradColor.red: return(14); case GradColor.yellow: return(12); case GradColor.green: return(10); default: throw new Exception(); } case PHB.AF2: switch (color) { case GradColor.red: return(22); case GradColor.yellow: return(20); case GradColor.green: return(18); default: throw new Exception(); } case PHB.AF3: switch (color) { case GradColor.red: return(30); case GradColor.yellow: return(28); case GradColor.green: return(26); default: throw new Exception(); } case PHB.AF4: switch (color) { case GradColor.red: return(38); case GradColor.yellow: return(36); case GradColor.green: return(34); default: throw new Exception(); } case PHB.EF: return(46); case PHB.CS6: return(48); case PHB.CS7: return(56); default: throw new Exception(); } }