コード例 #1
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 SortedDictionary <FeedbackLevel, FeedbackLevelData>();
                    foreach (FeedbackLevelElement level in controllerElement.Levels)
                    {
                        var values = new FeedbackLevelData
                        {
                            UpperBound = level.Value,
                            LowerBound = level.ValueDown == -1 ? level.Value : level.ValueDown,
                        };
                        dict.Add(level.Level, values);
                    }

                    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());
        }
コード例 #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());
        }