Exemplo n.º 1
0
        /// <summary>
        /// initialize only the document path and logging functionality, so that Helios classes that log can be used, without starting Helios
        /// </summary>
        /// <param name="docPath"></param>
        /// <param name="logLevel"></param>
        /// <param name="application">optional Application specification that can customize features of Helios system</param>
        public static void InitializeLogging(string docPath, LogLevel logLevel, HeliosApplication application = null)
        {
            // Create documents directory if it does not exist
            ConfigManager.DocumentPath = docPath;

            if (application?.AllowLogging ?? true)
            {
                // start up logging
                InitializeNLog(logLevel);
            }
            else
            {
                DisableLogging();
            }

            // create this legacy interface for other DLLs that don't have access to NLog
            ConfigManager.LogManager = new LogManager(logLevel);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Start Helios global objects in ConfigManager
        /// </summary>
        /// <param name="docPath"></param>
        /// <param name="logFileNameIgnored">is ignored in this implementation, as log name is from the process name of the running process</param>
        /// <param name="logLevel"></param>
        /// <param name="application"></param>
        public static void Initialize(string docPath, string logFileNameIgnored, LogLevel logLevel, HeliosApplication application = null)
        {
            // check OS and build
            CheckPlatform();

            // initialize logging and documents folder
            InitializeLogging(docPath, logLevel, application);

            // previous versions of Helios got their log file name from here, now it is based on the process name of the running process
            _ = logFileNameIgnored;

            // initialize the rest of Helios
            Logger.Info("Helios Version " + RunningVersion.FromHeliosAssembly());

            ConfigManager.Application = application ?? new HeliosApplication();
            bool applicationSettingsAreWritable = ConfigManager.Application.SettingsAreWritable;

            InitializeSettings(applicationSettingsAreWritable);
            ConfigManager.VersionChecker = new VersionChecker(ConfigManager.SettingsManager, applicationSettingsAreWritable);
            ConfigManager.UndoManager    = new UndoManager();
            ConfigManager.ProfileManager = new ProfileManager();
            ConfigManager.FontManager    = new FontManager();
            ConfigManager.FontManager.LoadInstalledPrivateFonts();
            ConfigManager.ImageManager    = new ImageManager(ConfigManager.ImagePath);
            ConfigManager.DisplayManager  = new DisplayManager();
            ConfigManager.ModuleManager   = new ModuleManager(ConfigManager.ApplicationPath);
            ConfigManager.TemplateManager = new TemplateManager(ConfigManager.TemplatePath);

            Logger.Debug("Searching for Helios modules in libraries");

            Assembly execAssembly = Assembly.GetExecutingAssembly();

            LoadModule(execAssembly);

            if (ConfigManager.Application.AllowPlugins)
            {
                string pluginsFolder = Path.Combine(Path.GetDirectoryName(execAssembly.Location) ?? "", "Plugins");
                if (Directory.Exists(pluginsFolder))
                {
                    foreach (string pluginPath in Directory.EnumerateFiles(pluginsFolder, "*.dll", SearchOption.AllDirectories))
                    {
                        LoadModule(pluginPath);
                    }
                }

                // REVISIT: move this to plugins folder and get rid of special case if we can add the check for system libraries
                // to HeliosModuleAttribute.  This would be relevant if we create other plugins for DCSFlightPanels and the like
                String phidgetsDllPath = Path.Combine(Environment.SystemDirectory, "phidget21.dll");
                if (File.Exists("Phidgets.dll") && File.Exists(phidgetsDllPath))
                {
                    LoadModule("Phidgets.dll");
                }
            }

            if (RenderCapability.Tier == 0)
            {
                Logger.Warn("Hardware rendering is not available on this machine.  Helios will consume large amounts of CPU.");
            }
        }