コード例 #1
0
        private static List <FeedbackController> GetNonConfigurableControllers(int maxCcu)
        {
            var peerCountThresholds = maxCcu == 0
                ? new SortedDictionary <FeedbackLevel, FeedbackLevelData>()
                : new SortedDictionary <FeedbackLevel, FeedbackLevelData>
            {
                { FeedbackLevel.Level0, new FeedbackLevelData(maxCcu / 10, 0) },
                { FeedbackLevel.Level1, new FeedbackLevelData(maxCcu / 5, maxCcu / 10) },
                { FeedbackLevel.Level2, new FeedbackLevelData(maxCcu * 3 / 10, maxCcu / 5) },
                { FeedbackLevel.Level3, new FeedbackLevelData(maxCcu * 4 / 10, maxCcu * 3 / 10) },
                { FeedbackLevel.Level4, new FeedbackLevelData(maxCcu * 5 / 10, maxCcu * 4 / 10) },
                { FeedbackLevel.Level5, new FeedbackLevelData(maxCcu * 6 / 10, maxCcu * 5 / 10) },
                { FeedbackLevel.Level6, new FeedbackLevelData(maxCcu * 7 / 10, maxCcu * 6 / 10) },
                { FeedbackLevel.Level7, new FeedbackLevelData(maxCcu * 8 / 10, maxCcu * 7 / 10) },
                { FeedbackLevel.Level8, new FeedbackLevelData(maxCcu * 9 / 10, maxCcu * 8 / 10) },
                { FeedbackLevel.Highest, new FeedbackLevelData(maxCcu * 10, maxCcu * 9 / 10) },
            };
            var peerCountController = new FeedbackController(FeedbackName.PeerCount, peerCountThresholds, 0, FeedbackLevel.Lowest);

            return(new List <FeedbackController> {
                peerCountController
            });
        }
コード例 #2
0
        private void Initialize(string workLoadConfigFile)
        {
            // CCU, Out-of-Rotation
            var allControllers = GetNonConfigurableControllers(this.maxCcu);

            // try to load feedback controllers from file:

            string message;
            FeedbackControlSystemSection section;
            string filename = Path.Combine(this.applicationRootPath, workLoadConfigFile);

            if (!ConfigurationLoader.TryLoadFromFile(filename, out section, out message))
            {
                log.WarnFormat(
                    "Could not initialize Feedback Control System from configuration: Invalid configuration file {0}. Using default settings... ({1})",
                    filename,
                    message);
            }

            if (section != null)
            {
                // load controllers from config file.);
                foreach (FeedbackControllerElement controllerElement in section.FeedbackControllers)
                {
                    var dict = new Dictionary<FeedbackLevel, int>();
                    foreach (FeedbackLevelElement level in controllerElement.Levels)
                    {
                        dict.Add(level.Level, level.Value);
                    }

                    var controller = new FeedbackController(controllerElement.Name, dict, controllerElement.InitialInput, controllerElement.InitialLevel);

                    allControllers.Add(controller);
                }

                log.InfoFormat("Initialized FeedbackControlSystem with {0} controllers from config file.", section.FeedbackControllers.Count);
            }
            else
            {
                // default settings, in case no config file was found.
                allControllers.AddRange(DefaultConfiguration.GetDefaultControllers());
            }

            this.controllerCollection = new FeedbackControllerCollection(allControllers.ToArray());
        }
コード例 #3
0
        private static List<FeedbackController> GetNonConfigurableControllers(int maxCcu)
        {
            Dictionary<FeedbackLevel, int> peerCountThresholds = maxCcu == 0
                                                                     ? new Dictionary<FeedbackLevel, int>()
                                                                     : new Dictionary<FeedbackLevel, int> {
                                                                             { FeedbackLevel.Lowest, 1 },
                                                                             { FeedbackLevel.Low, 2 },
                                                                             { FeedbackLevel.Normal, maxCcu / 2 },
                                                                             { FeedbackLevel.High, maxCcu * 8 / 10 },
                                                                             { FeedbackLevel.Highest, maxCcu }
                                                                         };
            var peerCountController = new FeedbackController(FeedbackName.PeerCount, peerCountThresholds, 0, FeedbackLevel.Lowest);

            return new List<FeedbackController> { peerCountController };
        }