예제 #1
0
        static Debug()
        {
            // Get the assembly version and print it to console and the log
            var version = Assembly.GetExecutingAssembly().GetName().Version;

            PepperDashCoreVersion = string.Format("{0}.{1}.{2}.{3}", version.Major, version.Minor, version.Build, version.Revision);

            var msg = string.Format("[App {0}] Using PepperDash_Core v{1}", InitialParametersClass.ApplicationNumber, PepperDashCoreVersion);

            CrestronConsole.PrintLine(msg);

            LogError(ErrorLogLevel.Notice, msg);

            IncludedExcludedKeys = new Dictionary <string, object>();

            //CrestronDataStoreStatic.InitCrestronDataStore();
            if (CrestronEnvironment.RuntimeEnvironment == eRuntimeEnvironment.SimplSharpPro)
            {
                // Add command to console
                CrestronConsole.AddNewConsoleCommand(SetDoNotLoadOnNextBootFromConsole, "donotloadonnextboot",
                                                     "donotloadonnextboot:P [true/false]: Should the application load on next boot", ConsoleAccessLevelEnum.AccessOperator);

                CrestronConsole.AddNewConsoleCommand(SetDebugFromConsole, "appdebug",
                                                     "appdebug:P [0-2]: Sets the application's console debug message level",
                                                     ConsoleAccessLevelEnum.AccessOperator);
                CrestronConsole.AddNewConsoleCommand(ShowDebugLog, "appdebuglog",
                                                     "appdebuglog:P [all] Use \"all\" for full log.",
                                                     ConsoleAccessLevelEnum.AccessOperator);
                CrestronConsole.AddNewConsoleCommand(s => CrestronLogger.Clear(false), "appdebugclear",
                                                     "appdebugclear:P Clears the current custom log",
                                                     ConsoleAccessLevelEnum.AccessOperator);
                CrestronConsole.AddNewConsoleCommand(SetDebugFilterFromConsole, "appdebugfilter",
                                                     "appdebugfilter [params]", ConsoleAccessLevelEnum.AccessOperator);
            }

            CrestronEnvironment.ProgramStatusEventHandler += CrestronEnvironment_ProgramStatusEventHandler;

            LoadMemory();

            var context = Contexts.GetOrCreateItem("DEFAULT");

            Level = context.Level;
            DoNotLoadOnNextBoot = context.DoNotLoadOnNextBoot;

            if (DoNotLoadOnNextBoot)
            {
                CrestronConsole.PrintLine(string.Format("Program {0} will not load config after next boot.  Use console command go:{0} to load the config manually", InitialParametersClass.ApplicationNumber));
            }

            try
            {
                if (InitialParametersClass.NumberOfRemovableDrives > 0)
                {
                    CrestronConsole.PrintLine("{0} RM Drive(s) Present.", InitialParametersClass.NumberOfRemovableDrives);
                    CrestronLogger.Initialize(2, LoggerModeEnum.DEFAULT); // Use RM instead of DEFAULT as not to double-up console messages.
                }
                else
                {
                    CrestronConsole.PrintLine("No RM Drive(s) Present.");
                }
            }
            catch (Exception e)
            {
                CrestronConsole.PrintLine("Initializing of CrestronLogger failed: {0}", e);
            }
        }