Exemplo n.º 1
0
 /// <summary>
 /// Convenience method flushes this <see cref="LogFileListener"/>, flushes
 /// <see cref="TraceSources"/>, <see cref="Trace"/>, and <see cref="Debug"/>.
 /// This will be invoked when disposed.
 /// </summary>
 public void FlushAll()
 {
     TraceSources.FlushAll();
     LogFileListener?.Flush();
     Trace.Flush();
     Debug.Flush();
 }
Exemplo n.º 2
0
        public void UnitTest_LogFileListenerOneLineWithDate()
        {
            LogFileListener logListener = new LogFileListener(@"C:\Temp\TestLog.log");

            Trace.Listeners.Add(logListener);
            Trace.IndentLevel = 0;

            Trace.WriteLine("This is a test.");

            Trace.Listeners.Clear();
            logListener.Dispose();

            List <string> lines = File.ReadAllLines(@"C:\Temp\TestLog.log").ToList();

            Assert.IsTrue(lines.Count == 1);

            string firstLine = lines.FirstOrDefault();
            string datePart  = firstLine.Split('-').First().Trim();
            string msgPart   = firstLine.Split('-').Last().Trim();

            DateTime dateTime;
            bool     isDate = DateTime.TryParse(datePart, out dateTime);

            Assert.IsTrue(isDate);

            Assert.IsTrue(msgPart == "This is a test.");
        }
Exemplo n.º 3
0
        public override bool OnInit()
        {
            coreConfig = new CoreConfig(startup.Name);

            //Create the log.
            logListener = new LogFileListener();
            logListener.openLogFile(CoreConfig.LogFile);
            Log.Default.addLogListener(logListener);
            Log.ImportantInfo("Running from directory {0}", FolderFinder.ExecutableFolder);
            startup.ConfigureServices(services);
            BuildPluginManager();

            //Create containers
            var scope = this.pluginManager.GlobalScope;

            //Build engine
            var pluginManager = scope.ServiceProvider.GetRequiredService <PluginManager>();

            mainTimer = scope.ServiceProvider.GetRequiredService <UpdateTimer>();
            var frameClearManager = scope.ServiceProvider.GetRequiredService <FrameClearManager>();

            PerformanceMonitor.setupEnabledState(scope.ServiceProvider.GetRequiredService <SystemTimer>());

            MyGUIInterface.Instance.CommonResourceGroup.addResource(GetType().AssemblyQualifiedName, "EmbeddedScalableResource", true);
            MyGUIInterface.Instance.CommonResourceGroup.addResource(startup.GetType().AssemblyQualifiedName, "EmbeddedScalableResource", true);

            startup.Initialized(this, pluginManager);

            if (Initialized != null)
            {
                Initialized.Invoke(this);
            }

            return(true);
        }
Exemplo n.º 4
0
        public void Start()
        {
            Directory.CreateDirectory(System.IO.Path.GetDirectoryName(Path));
            var logFile = new LogFileListener(Path, true);

            Log.Level = TraceLevel.Verbose;
            Log.Open(logFile);
        }
Exemplo n.º 5
0
        public void UnitTest_LogFileListenerOneLineNoDate()
        {
            LogFileListener logListener = new LogFileListener(@"C:\Temp\TestLog.log", false);

            Trace.Listeners.Add(logListener);
            Trace.IndentLevel = 0;

            Trace.WriteLine("This is a test.");

            Trace.Listeners.Clear();
            logListener.Dispose();

            List <string> lines = File.ReadAllLines(@"C:\Temp\TestLog.log").ToList();

            Assert.IsTrue(lines.Count == 1);
            Assert.IsTrue(lines.Contains("This is a test."));
        }
Exemplo n.º 6
0
        public void UnitTest_LogFileListenerMultiWriteSingleLineNoDate()
        {
            LogFileListener logListener = new LogFileListener(@"C:\Temp\TestLog.log", false);

            Trace.Listeners.Add(logListener);
            Trace.IndentLevel = 0;

            Trace.Write("1 ");
            Trace.Write("2");

            Trace.Listeners.Clear();
            logListener.Dispose();

            List <string> lines = File.ReadAllLines(@"C:\Temp\TestLog.log").ToList();

            Assert.IsTrue(lines.Count == 1, $"line count: {lines.Count}");
            Assert.IsTrue(lines.Contains("1 2"), $"line: {lines.First().Replace(" ", "|")}");
        }
Exemplo n.º 7
0
        public void UnitTest_LogFileListenerOneLineNoDateDefaultLocation()
        {
            LogFileListener logListener = new LogFileListener(includeDateTime: false);
            string          logFilename = logListener.LogFilename;

            Trace.Listeners.Add(logListener);
            Trace.IndentLevel = 0;

            Trace.WriteLine("This is a test.");

            Trace.Listeners.Clear();
            logListener.Dispose();

            List <string> lines = File.ReadAllLines(logFilename).ToList();

            Assert.IsTrue(lines.Count == 1);
            Assert.IsTrue(lines.Contains("This is a test."));
        }
Exemplo n.º 8
0
        public void UnitTest_LogFileWhenLocked()
        {
            FileStream fileStream1 = new FileStream(@"C:\Temp\TestLog.log", FileMode.Create);

            fileStream1.Lock(0, 0);
            FileStream fileStream2 = new FileStream(@"C:\Temp\TestLog_2.log", FileMode.Create);

            fileStream2.Lock(0, 0);

            LogFileListener logListener = new LogFileListener(@"C:\Temp\TestLog.log", false);

            logListener.WriteLine("This is a test.");
            logListener.Dispose();

            fileStream1.Unlock(0, 0);
            fileStream2.Unlock(0, 0);

            List <string> lines = File.ReadAllLines(@"C:\Temp\TestLog_3.log").ToList();

            Assert.IsTrue(lines.Count == 1, $"line count: {lines.Count}");
            Assert.IsTrue(lines.Contains("This is a test."), $"line: {lines.First()}");
        }
Exemplo n.º 9
0
        /// <summary>
        /// Constructor.
        /// </summary>
        public AnomalyController(App app, Solution solution, IAnomalyImplementation implementation)
        {
            this.app            = app;
            this.solution       = solution;
            this.implementation = implementation;

            //Create the log.
            logListener = new LogFileListener();
            logListener.openLogFile(AnomalyConfig.DocRoot + "/log.log");
            Log.Default.addLogListener(logListener);

            mainWindow         = new NativeOSWindow(String.Format("{0} - Anomaly", solution.Name), new IntVector2(-1, -1), new IntSize2(AnomalyConfig.EngineConfig.HorizontalRes, AnomalyConfig.EngineConfig.VerticalRes));
            mainWindow.Closed += mainWindow_Closed;

            //Setup DPI
            float pixelScale = mainWindow.WindowScaling;

            ScaleHelper._setScaleFactor(pixelScale);

            var builder = new ServiceCollection();

            //Initialize the plugins
            pluginManager   = new PluginManager(AnomalyConfig.ConfigFile, builder);
            sceneController = new SceneController(pluginManager);
            //Hardcoded assemblies
            MyGUIInterface.EventLayerKey = EventLayers.Main;

            GuiFrameworkCamerasInterface.MoveCameraEventLayer   = EventLayers.Cameras;
            GuiFrameworkCamerasInterface.SelectWindowEventLayer = EventLayers.AfterMain;
            GuiFrameworkCamerasInterface.ShortcutEventLayer     = EventLayers.Main;

            GuiFrameworkEditorInterface.ToolsEventLayers = EventLayers.Tools;

            //Setup microcode cache load
            OgreInterface.MicrocodeCachePath      = Path.Combine(AnomalyConfig.DocRoot, "ShaderCache.mcc");
            OgreInterface.AllowMicrocodeCacheLoad = AnomalyConfig.LastShaderVersion == UnifiedMaterialBuilder.Version;
            AnomalyConfig.LastShaderVersion       = UnifiedMaterialBuilder.Version;

            implementation.AddPlugins(pluginManager);
            pluginManager.OnConfigureDefaultWindow = createWindow;

            //Create core classes
            systemTimer = new NativeSystemTimer();

            mainTimer = new NativeUpdateTimer(systemTimer);
            mainTimer.FramerateCap = AnomalyConfig.EngineConfig.MaxFPS;
            idleHandler            = new IdleHandler(mainTimer.OnIdle);
            inputHandler           = new NativeInputHandler(mainWindow, false);
            eventManager           = new EventManager(inputHandler, Enum.GetValues(typeof(EventLayers)));
            eventUpdate            = new EventUpdateListener(eventManager);

            builder.TryAddSingleton <EventManager>(eventManager); //This is externally owned

            pluginManager.initializePlugins();
            frameClearManager = new FrameClearManager(OgreInterface.Instance.OgrePrimaryWindow.OgreRenderTarget, new Color(0.2f, 0.2f, 0.2f));

            lightManager = pluginManager.RendererPlugin.createSceneViewLightManager();

            //Core resources
            MyGUIInterface.Instance.CommonResourceGroup.addResource(this.GetType().AssemblyQualifiedName, "EmbeddedResource", true);
            OgreResourceGroupManager.getInstance().initializeAllResourceGroups();

            //Intialize the platform
            mainTimer.addUpdateListener(eventUpdate);
            mainTimer.addUpdateListener(updateEventListener);
            pluginManager.setPlatformInfo(mainTimer, eventManager);

            GuiFrameworkInterface.Instance.handleCursors(mainWindow);

            //Layout Chain
            mdiLayout = new MDILayoutManager();

            //Scene views
            sceneViewController      = new SceneViewController(mdiLayout, eventManager, mainTimer, pluginManager.RendererPlugin.PrimaryWindow, MyGUIInterface.Instance.OgrePlatform.RenderManager, null);
            sceneStatsDisplayManager = new SceneStatsDisplayManager(sceneViewController, OgreInterface.Instance.OgrePrimaryWindow.OgreRenderTarget);
            sceneStatsDisplayManager.StatsVisible = true;
            sceneViewController.createWindow("Camera 1", AnomalyConfig.CameraConfig.MainCameraPosition, AnomalyConfig.CameraConfig.MainCameraLookAt, Vector3.Min, Vector3.Max, 0.0f, float.MaxValue, 100);

            virtualTextureLink = new VirtualTextureSceneViewLink(this);

            //Tools
            selectionMovementTools         = new SimObjectMover("SelectionMover", PluginManager.Instance.RendererPlugin, eventManager, sceneViewController);
            selectionMovementTools.Visible = true;
            selectionMovementTools.addMovableObject("Selection", new SelectionMovableObject(selectionController));

            mainForm = new AnomalyMain(this);

            LayoutChain layoutChain = new LayoutChain();

            layoutChain.addLink(new SingleChildChainLink(GUILocationNames.Taskbar, mainForm.LayoutContainer), true);
            layoutChain.addLink(new PopupAreaChainLink(GUILocationNames.FullscreenPopup), true);
            layoutChain.SuppressLayout = true;
            layoutChain.addLink(new MDIChainLink(GUILocationNames.MDI, mdiLayout), true);
            layoutChain.addLink(new PopupAreaChainLink(GUILocationNames.ContentAreaPopup), true);
            layoutChain.addLink(new FinalChainLink("SceneViews", mdiLayout.DocumentArea), true);
            layoutChain.SuppressLayout = false;

            guiManager = new GUIManager();
            guiManager.createGUI(mdiLayout, layoutChain, mainWindow);

            layoutChain.layout();

            splashScreen                = new SplashScreen(mainWindow, 100, "Anomaly.GUI.SplashScreen.SplashScreen.layout", "Anomaly.GUI.SplashScreen.SplashScreen.xml");
            splashScreen.Hidden        += splashScreen_Hidden;
            splashScreen.StatusUpdated += splashScreen_StatusUpdated;
            splashScreen.updateStatus(0, "Loading...");

            idleHandler.runTemporaryIdle(finishInitialization());
        }
        public OgreModelEditorController(App app, String defaultModel)
        {
            this.app = app;

            //Create the log.
            logListener = new LogFileListener();
            logListener.openLogFile(OgreModelEditorConfig.DocRoot + "/log.log");
            Log.Default.addLogListener(logListener);

            //Main window
            mainWindow         = new NativeOSWindow("Ogre Model Editor", new IntVector2(-1, -1), new IntSize2(OgreModelEditorConfig.EngineConfig.HorizontalRes, OgreModelEditorConfig.EngineConfig.VerticalRes));
            mainWindow.Closed += mainWindow_Closed;

            //Setup DPI
            ScaleHelper._setScaleFactor(mainWindow.WindowScaling);

            //Initailize plugins
            MyGUIInterface.EventLayerKey = EventLayers.Main;

            GuiFrameworkCamerasInterface.MoveCameraEventLayer   = EventLayers.Cameras;
            GuiFrameworkCamerasInterface.SelectWindowEventLayer = EventLayers.AfterMain;
            GuiFrameworkCamerasInterface.ShortcutEventLayer     = EventLayers.Main;

            GuiFrameworkEditorInterface.ToolsEventLayers = EventLayers.Tools;

            //Setup microcode cache load
            OgreInterface.MicrocodeCachePath        = Path.Combine(OgreModelEditorConfig.DocRoot, "ShaderCache.mcc");
            OgreInterface.AllowMicrocodeCacheLoad   = OgreModelEditorConfig.LastShaderVersion == UnifiedMaterialBuilder.Version;
            OgreModelEditorConfig.LastShaderVersion = UnifiedMaterialBuilder.Version;
            OgreInterface.TrackMemoryLeaks          = true;
            OgreInterface.CompressedTextureSupport  = OgreModelEditorConfig.CompressedTextureSupport;

            RuntimePlatformInfo.addPath(OgreModelEditorConfig.OpenGLESEmulatorPath);

            pluginManager = new PluginManager(OgreModelEditorConfig.ConfigFile, new ServiceCollection());
            pluginManager.OnConfigureDefaultWindow = createWindow;
            pluginManager.addPluginAssembly(typeof(OgreInterface).Assembly);
            pluginManager.addPluginAssembly(typeof(NativePlatformPlugin).Assembly);
            pluginManager.addPluginAssembly(typeof(MyGUIInterface).Assembly);
            pluginManager.addPluginAssembly(typeof(GuiFrameworkInterface).Assembly);
            pluginManager.addPluginAssembly(typeof(GuiFrameworkCamerasInterface).Assembly);
            pluginManager.addPluginAssembly(typeof(GuiFrameworkEditorInterface).Assembly);
            pluginManager.addPluginAssembly(typeof(GuiFrameworkDebuggingInterface).Assembly);
            pluginManager.initializePlugins();
            frameClearManager = new FrameClearManager(OgreInterface.Instance.OgrePrimaryWindow.OgreRenderTarget, new Color(0.2f, 0.2f, 0.2f));

            lightManager = pluginManager.RendererPlugin.createSceneViewLightManager();

            //Core resources
            MyGUIInterface.Instance.CommonResourceGroup.addResource(this.GetType().AssemblyQualifiedName, "EmbeddedResource", true);
            OgreResourceGroupManager.getInstance().addResourceLocation(GetType().AssemblyQualifiedName, "EmbeddedResource", "DebugShaders", true);
            OgreResourceGroupManager.getInstance().initializeAllResourceGroups();

            //Intialize the platform
            systemTimer = new NativeSystemTimer();

            mainTimer = new NativeUpdateTimer(systemTimer);
            mainTimer.FramerateCap = OgreModelEditorConfig.EngineConfig.MaxFPS;
            idleHandler            = new IdleHandler(mainTimer.OnIdle);

            inputHandler = new NativeInputHandler(mainWindow, false);
            eventManager = new EventManager(inputHandler, Enum.GetValues(typeof(EventLayers)));
            eventUpdate  = new EventUpdateListener(eventManager);
            mainTimer.addUpdateListener(eventUpdate);
            mainTimer.addUpdateListener(updateEventListener);
            pluginManager.setPlatformInfo(mainTimer, eventManager);
            GuiFrameworkInterface.Instance.handleCursors(mainWindow);

            //Layout Chain
            mdiLayout = new MDILayoutManager();

            //Scene views
            sceneViewController      = new SceneViewController(mdiLayout, eventManager, mainTimer, pluginManager.RendererPlugin.PrimaryWindow, MyGUIInterface.Instance.OgrePlatform.RenderManager, null);
            sceneStatsDisplayManager = new SceneStatsDisplayManager(sceneViewController, OgreInterface.Instance.OgrePrimaryWindow.OgreRenderTarget);
            sceneStatsDisplayManager.StatsVisible = true;
            sceneViewController.createWindow("Camera 1", OgreModelEditorConfig.CameraConfig.MainCameraPosition, OgreModelEditorConfig.CameraConfig.MainCameraLookAt, Vector3.Min, Vector3.Max, 0.0f, float.MaxValue, 100);

            virtualTextureLink = new VirtualTextureSceneViewLink(this);

            materialController = new MaterialController(this);

            //Tools
            objectMover = new SimObjectMover("ModelMover", PluginManager.Instance.RendererPlugin, eventManager, sceneViewController);

            mainForm = new OgreModelEditorMain(this);

            LayoutChain layoutChain = new LayoutChain();

            layoutChain.addLink(new SingleChildChainLink(GUILocationNames.Taskbar, mainForm.LayoutContainer), true);
            layoutChain.addLink(new PopupAreaChainLink(GUILocationNames.FullscreenPopup), true);
            layoutChain.SuppressLayout = true;
            layoutChain.addLink(new MDIChainLink(GUILocationNames.MDI, mdiLayout), true);
            layoutChain.addLink(new PopupAreaChainLink(GUILocationNames.ContentAreaPopup), true);
            layoutChain.addLink(new FinalChainLink("SceneViews", mdiLayout.DocumentArea), true);
            layoutChain.SuppressLayout = false;

            guiManager = new GUIManager(mdiLayout, mainWindow);
            guiManager.createGUILayout(layoutChain);

            layoutChain.layout();

            splashScreen                = new SplashScreen(mainWindow, 100, "OgreModelEditor.GUI.SplashScreen.SplashScreen.layout", "OgreModelEditor.GUI.SplashScreen.SplashScreen.xml");
            splashScreen.Hidden        += splashScreen_Hidden;
            splashScreen.StatusUpdated += splashScreen_StatusUpdated;
            splashScreen.updateStatus(0, "Loading...");

            idleHandler.runTemporaryIdle(finishInitialization(defaultModel));
        }
Exemplo n.º 11
0
        public MedicalController(NativeOSWindow mainWindow)
        {
            //Create the log.
            logListener = new LogFileListener();
            logListener.openLogFile(MedicalConfig.LogFile);
            Log.Default.addLogListener(logListener);
            Log.ImportantInfo("Running from directory {0}", FolderFinder.ExecutableFolder);

            //Create pluginmanager
            pluginManager = new PluginManager(MedicalConfig.ConfigFile, services);

            //Configure the filesystem
            VirtualFileSystem archive = VirtualFileSystem.Instance;

            //Setup microcode cache load
            OgreInterface.MicrocodeCachePath      = Path.Combine(FolderFinder.LocalPrivateDataFolder, "ShaderCache.mcc");
            OgreInterface.AllowMicrocodeCacheLoad = MedicalConfig.LastShaderVersion == UnifiedMaterialBuilder.Version;
            OgreInterface.TrackMemoryLeaks        = MedicalConfig.TrackMemoryLeaks;
            MedicalConfig.LastShaderVersion       = UnifiedMaterialBuilder.Version;

            MyGUIInterface.EventLayerKey     = EventLayers.Gui;
            MyGUIInterface.CreateGuiGestures = MedicalConfig.EnableMultitouch && PlatformConfig.TouchType == TouchType.Screen;
            MyGUIInterface.TrackMemoryLeaks  = MedicalConfig.TrackMemoryLeaks;

            RuntimePlatformInfo.addPath(MedicalConfig.OpenGLESEmulatorPath);

            //Configure plugins
            pluginManager.OnConfigureDefaultWindow = delegate(out WindowInfo defaultWindow)
            {
                //Setup main window
                defaultWindow              = new WindowInfo(mainWindow, "Primary");
                defaultWindow.Fullscreen   = MedicalConfig.EngineConfig.Fullscreen;
                defaultWindow.MonitorIndex = 0;

                if (MedicalConfig.EngineConfig.Fullscreen)
                {
                    mainWindow.setSize(MedicalConfig.EngineConfig.HorizontalRes, MedicalConfig.EngineConfig.VerticalRes);
                    mainWindow.ExclusiveFullscreen = true;
                    defaultWindow.Width            = MedicalConfig.EngineConfig.HorizontalRes;
                    defaultWindow.Height           = MedicalConfig.EngineConfig.VerticalRes;
                }
                else
                {
                    mainWindow.Maximized = true;
                }
                mainWindow.show();
            };

            GuiFrameworkCamerasInterface.CameraTransitionTime   = MedicalConfig.CameraTransitionTime;
            GuiFrameworkCamerasInterface.DefaultCameraButton    = MedicalConfig.CameraMouseButton;
            GuiFrameworkCamerasInterface.MoveCameraEventLayer   = EventLayers.Cameras;
            GuiFrameworkCamerasInterface.SelectWindowEventLayer = EventLayers.AfterGui;
            GuiFrameworkCamerasInterface.ShortcutEventLayer     = EventLayers.Gui;
            GuiFrameworkCamerasInterface.TouchType = PlatformConfig.TouchType;
            GuiFrameworkCamerasInterface.PanKey    = PlatformConfig.PanKey;

            GuiFrameworkEditorInterface.ToolsEventLayers = EventLayers.Tools;

            pluginManager.addPluginAssembly(typeof(OgreInterface).Assembly);
            pluginManager.addPluginAssembly(typeof(BulletInterface).Assembly);
            pluginManager.addPluginAssembly(typeof(NativePlatformPlugin).Assembly);
            pluginManager.addPluginAssembly(typeof(MyGUIInterface).Assembly);
            pluginManager.addPluginAssembly(typeof(RocketInterface).Assembly);
            pluginManager.addPluginAssembly(typeof(SoundPluginInterface).Assembly);
            pluginManager.addPluginAssembly(typeof(BEPUikInterface).Assembly);
            pluginManager.addPluginAssembly(typeof(SimulationPlugin).Assembly);
            pluginManager.addPluginAssembly(typeof(GuiFrameworkInterface).Assembly);
            pluginManager.addPluginAssembly(typeof(RocketWidgetInterface).Assembly);
            pluginManager.addPluginAssembly(typeof(GuiFrameworkCamerasInterface).Assembly);
            pluginManager.addPluginAssembly(typeof(GuiFrameworkEditorInterface).Assembly);
            pluginManager.addPluginAssembly(typeof(GuiFrameworkDebuggingInterface).Assembly);
            pluginManager.initializePlugins();

            performanceMetricTimer = new NativeSystemTimer();
            PerformanceMonitor.setupEnabledState(performanceMetricTimer);

            //Intialize the platform
            BulletInterface.Instance.ShapeMargin = 0.005f;
            systemTimer = new NativeSystemTimer();

            mainTimer = new NativeUpdateTimer(systemTimer);

            if (OgreConfig.VSync && MedicalConfig.EngineConfig.FPSCap < 300)
            {
                //Use a really high framerate cap if vsync is on since it will cap our
                //framerate for us. If the user has requested a higher rate use it anyway.
                mainTimer.FramerateCap = 300;
            }
            else
            {
                mainTimer.FramerateCap = MedicalConfig.EngineConfig.FPSCap;
            }

            inputHandler = new NativeInputHandler(mainWindow, MedicalConfig.EnableMultitouch);
            eventManager = new EventManager(inputHandler, Enum.GetValues(typeof(EventLayers)));
            eventUpdate  = new EventUpdateListener(eventManager);
            mainTimer.addUpdateListener(eventUpdate);
            pluginManager.setPlatformInfo(mainTimer, eventManager);
            medicalUpdate = new MedicalUpdate(this);
            mainTimer.addUpdateListener(medicalUpdate);

            //Initialize controllers
            medicalScene      = new MedicalSceneController(pluginManager);
            frameClearManager = new FrameClearManager(OgreInterface.Instance.OgrePrimaryWindow.OgreRenderTarget);

            SoundConfig.initialize(MedicalConfig.ConfigFile);

            GuiFrameworkInterface.Instance.handleCursors(mainWindow);
            SoundPluginInterface.Instance.setResourceWindow(mainWindow);

            TouchMouseGuiForwarder = new TouchMouseGuiForwarder(eventManager, inputHandler, systemTimer, mainWindow, EventLayers.Last);
            TouchMouseGuiForwarder.ForwardTouchesAsMouse = PlatformConfig.ForwardTouchAsMouse;
            var myGuiKeyboard  = new MyGUIOnscreenKeyboardManager(TouchMouseGuiForwarder);
            var rocketKeyboard = new RocketWidgetOnscreenKeyboardManager(TouchMouseGuiForwarder);
        }
Exemplo n.º 12
0
        private static void RunApplication(object data)
        {
            try
            {
                bool   verboseOff  = (bool)((object[])data)[0];
                string oprFilename = (string)((object[])data)[1];

                // check whether opr file exists
                if (oprFilename == null)
                {
                    Console.WriteLine("Error: -r switch was not specified.");
                    _exitCode = 3;
                    return;
                }

                FileInfo fileInfo = new FileInfo(oprFilename);
                if (!fileInfo.Exists)
                {
                    Console.WriteLine("Error: cannot find input file " + oprFilename);
                    _exitCode = 4;
                    return;
                }


                // open OPR
                CompositionManager composition = new CompositionManager();

                if (!verboseOff)
                {
                    Console.WriteLine("Loading project file " + fileInfo.FullName + "...");
                }
                composition.LoadFromFile(fileInfo.FullName);


                // prepare listeners
                if (!verboseOff)
                {
                    Console.WriteLine("Preparing listener(s)...");
                }
                ArrayList listOfListeners = new ArrayList();

                // logfile listener
                if (composition.LogToFile != null && composition.LogToFile != "")
                {
                    // get composition file's directory to logfile is saved in same directory
                    string          logFileName     = Utils.GetFileInfo(fileInfo.DirectoryName, composition.LogToFile).FullName;
                    LogFileListener logFileListener = new LogFileListener(composition.ListenedEventTypes, logFileName);
                    listOfListeners.Add(logFileListener);
                }

                // console listener
                if (!verboseOff)
                {
                    ConsoleListener consoleListener = new ConsoleListener(composition.ListenedEventTypes);
                    listOfListeners.Add(consoleListener);
                }

                // create proxy listener
                ProxyListener proxyListener = new ProxyListener();
                proxyListener.Initialize(listOfListeners);

                // run simulation
                if (!verboseOff)
                {
                    Console.WriteLine("Starting composition run...");
                }
                composition.Run(proxyListener, true);

                if (!verboseOff)
                {
                    Console.WriteLine("Closing composition...");
                }
                composition.Release();

                _exitCode = 0;
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception occured: " + e.ToString());
                _exitCode = -2;
                return;
            }
        }
Exemplo n.º 13
0
 public LogFileProvider()
 {
     _logFileListener             = new LogFileListener();
     _logFileListener.NewEntries += On_LogFileListener_NewEntries;
 }