コード例 #1
0
        public void FixtureInit()
        {
            // we must create xwtProvider and register surrogate for monitor
            // before initializng plugin manager, as there might be
            // plugins in configuration that will start at this moment
            // (so the environment must be already prepared)
            xwtProvider = new XwtProvider();
            new System.Threading.Thread(Emulator.ExecuteAsMainThread)
            {
                IsBackground = true
            }.Start();

            // this must be set before creating monitor
            ConfigurationManager.Instance.SetNonPersistent("monitor", "consume-exceptions-from-command", false);

            monitor = new Monitor {
                Interaction = new DummyCommandInteraction(true)
            };

            context = ObjectCreator.Instance.OpenContext();
            context.RegisterSurrogate(typeof(Monitor), monitor);

            InitializePluginManager();

            TemporaryFilesManager.Instance.OnFileCreated += HandleTemporaryFileCreated;
            EmulationManager.Instance.EmulationChanged   += RemovedTemporaryFiles;
            loadedFiles = new List <string>();
        }
コード例 #2
0
        public static void Main(string[] args)
        {
            var options       = new Emul8.Robot.Options();
            var optionsParser = new OptionsParser();

            if (!optionsParser.Parse(options, args))
            {
                return;
            }

            var keywordManager = new KeywordManager();

            TypeManager.Instance.AutoLoadedType += keywordManager.Register;

            var processor = new XmlRpcServer(keywordManager);

            server = new HttpServer(processor);

            Task.Run(() =>
            {
                XwtProvider xwt = null;
                try
                {
                    if (!options.DisableX11)
                    {
                        var preferredUARTAnalyzer = typeof(UARTWindowBackendAnalyzer);
                        EmulationManager.Instance.CurrentEmulation.BackendManager.SetPreferredAnalyzer(typeof(UARTBackend), preferredUARTAnalyzer);
                        EmulationManager.Instance.EmulationChanged += () =>
                        {
                            EmulationManager.Instance.CurrentEmulation.BackendManager.SetPreferredAnalyzer(typeof(UARTBackend), preferredUARTAnalyzer);
                        };
                        xwt = new XwtProvider(new WindowedUserInterfaceProvider());
                    }

                    using (var context = ObjectCreator.Instance.OpenContext())
                    {
                        var monitor = new Emul8.UserInterface.Monitor()
                        {
                            Interaction = new CommandInteractionEater()
                        };
                        context.RegisterSurrogate(typeof(Emul8.UserInterface.Monitor), monitor);

                        // we must initialize plugins AFTER registering monitor surrogate
                        // as some plugins might need it for construction
                        TypeManager.Instance.PluginManager.Init("CLI");

                        server.Run(options.Port);
                        server.Dispose();
                    }
                }
                finally
                {
                    if (xwt != null)
                    {
                        xwt.Dispose();
                    }
                }
            });

            Emulator.ExecuteAsMainThread();
        }