コード例 #1
0
ファイル: Program.cs プロジェクト: brettneuman/app-launcher
        private static async Task Main(string[] args)
        {
            Logger logger = LogManager.GetLogger("Launch");

            var parser = new CommandLineBuilder(LaunchCommand.GetCommand())
                         .UseHost((args) => CreateHostBuilder(args))
                         .UseDefaults()
                         .UseMiddleware(async(context, next) =>
            {
                await next(context);
            })
                         .UseExceptionHandler((ex, context) =>
            {
                var stackTrace = Configuration.GetValue <bool>("ShowStackTraceOnError")
                        ? ex.StackTrace
                        : "Error details hidden. Enable 'ShowStackTraceOnError' to see more...";

                logger.Error(ex, $"The global exception handler caught an exception: {ex.Message}{Environment.NewLine}{stackTrace}");
                logger.Info($"Press any key to close...");
                Console.ReadKey();
            })
                         .Build();

            // display some startup info

            Console.WriteAscii("Launch", Color.FromArgb(204, 102, 0));
            Console.Write($"Version: ");
            parser.Parse("--version").Invoke();

            // parse the arguments
            await parser.InvokeAsync(args);
        }
コード例 #2
0
        public SimulatorVM()
        {
            //   wcfObject = new WCFGetterFunctions();
            SearchCommand = new SearchCommand(this);
            imageList     = new List <String>();
            InitializeImageList(imageList);
            rocketsYetToLaunch = new ObservableCollection <Rocket>();
            logs = new ObservableCollection <Log>();
            rocketNameToObjectMap     = new Dictionary <string, Rocket>();
            rocketLaunchThreadMap     = new Dictionary <string, Thread>();
            rocketTelemetryThreadMap  = new Dictionary <string, Thread>();
            payloadTelemetryThreadMap = new Dictionary <string, Thread>();
            payloadDataThreadMap      = new Dictionary <string, Thread>();
            currentRockets            = new ObservableCollection <Rocket>();
            currentPayloads           = new ObservableCollection <Payload>();
            // Read Rocket data from config file
            string path      = Directory.GetCurrentDirectory();
            string upper     = "..\\..\\Config Files\\Rockets.json";
            string finalPath = Path.Combine(path, upper);

            PayLoadToRocketMap = new Dictionary <string, string>();
            DecomRocketsSet    = new HashSet <string>();
            dynamic rockets = JsonConvert.DeserializeObject(File.ReadAllText(finalPath));
            // optimize below initialization
            bool firstItem = false;

            rockets = rockets["rockets"];
            foreach (var rocket in rockets)
            {
                Rocket r = new Rocket();
                r.RocketName    = rocket["name"];
                r.OrbitRadius   = rocket["orbit"];
                r.PayloadId     = rocket["payload"];
                r.PayloadStatus = "Not Deployed";
                //r.TimeToOrbit = 3;
                r.TimeToOrbit             = Math.Round((double)r.OrbitRadius / 3600 + 10, 2);
                r.TimeToReachInitialOrbit = r.TimeToOrbit;
                //r.TimeToReachInitialOrbit = 3;
                r.rocketId = rocket["rocketId"];
                rocketNameToObjectMap.Add(r.RocketName, r);
                rocketsYetToLaunch.Add(r);
                if (!firstItem)
                {
                    rocketYetToLaunch = r;
                    firstItem         = true;
                }
            }
            LaunchCommand                = new LaunchCommand(this);
            RocketDeorbitCommand         = new RocketDeorbitCommand(this);
            StartTelemetryCommand        = new StartTelemetryCommand(this);
            StopTelemetryCommand         = new StopTelemetryCommand(this);
            DeployPayloadCommand         = new DeployPayloadCommand(this);
            StartPayloadTelemetryCommand = new StartPayloadTelemetryCommand(this);
            StopPayloadTelemetryCommand  = new StopPayloadTelemetryCommand(this);
            StartPayloadDataCommand      = new StartPayloadDataCommand(this);
            StopPayloadDataCommand       = new StopPayloadDataCommand(this);
            DecommissionCommand          = new DecommissionCommand(this);
        }
コード例 #3
0
 public override void RaiseCanExecuteChanges()
 {
     base.RaiseCanExecuteChanges();
     if (CheckFreestyleDatabaseCommand == null)
     {
         return;
     }
     CheckFreestyleDatabaseCommand.RaiseCanExecuteChanged();
     LaunchCommand.RaiseCanExecuteChanged();
     ShowFtpLogCommand.RaiseCanExecuteChanged();
     ShutdownCommand.RaiseCanExecuteChanged();
 }
コード例 #4
0
        /// <summary>
        ///   Called when a property on the model is changed.
        ///   Used to pass through property changed events and
        ///   update the parent view model instance.
        /// </summary>
        protected override void OnBasePropertyChanged(string propertyName)
        {
            if (propertyName == Property <Launcher> .Name(p => p.Parent))
            {
                Parent = new LaunchGroupViewModel(Model.Parent);
            }
            else if (propertyName == Property <Launcher> .Name(p => p.IsValid))
            {
                LaunchCommand.RaiseCanExecuteChanged();
            }

            base.OnBasePropertyChanged(propertyName);
        }
コード例 #5
0
 public Button()
 {
     InitializeComponent();
     PauseButton.Command = new UiCommand(o => Dispatch("Pause"));
     PlayButton.Command  = new UiCommand(o =>
     {
         if (Status == MediaState.Paused)
         {
             Dispatch("Play");
         }
         else if (LaunchCommand != null && LaunchCommand.CanExecute(LaunchCommandParameter))
         {
             LaunchCommand.Execute(LaunchCommandParameter);
         }
     });
 }
コード例 #6
0
ファイル: SampleTests.cs プロジェクト: optikos/MIEngine
        public void LaunchNonExistentDebuggee(ITestSettings settings)
        {
            this.TestPurpose("This test checks to see the debugger handles trying to start when there is no debuggee.");
            this.WriteSettings(settings);

            using (IDebuggerRunner runner = CreateDebugAdapterRunner(settings))
            {
                LaunchCommand launch = new LaunchCommand(settings.DebuggerSettings, "foofoo");
                launch.ExpectsSuccess = false;
                runner.RunCommand(launch);

                Assert.Matches(".*does not exist.*", launch.Message);

                runner.DisconnectAndVerify();
            }
        }
コード例 #7
0
ファイル: EnvironmentTests.cs プロジェクト: optikos/MIEngine
        private void TestEnvironmentVariable(ITestSettings settings, string variableName, string variableValue, bool newTerminal)
        {
            this.WriteSettings(settings);

            IDebuggee debuggee = SinkHelper.Open(this, settings.CompilerSettings, DebuggeeMonikers.KitchenSink.Environment);

            using (IDebuggerRunner runner = CreateDebugAdapterRunner(settings))
            {
                this.Comment("Configure launch");
                LaunchCommand launch = new LaunchCommand(settings.DebuggerSettings, debuggee.OutputPath, false, "-fEnvironment")
                {
                    StopAtEntry = false
                };
                if (variableValue != null)
                {
                    launch.Args.environment = new EnvironmentEntry[] {
                        new EnvironmentEntry {
                            Name = variableName, Value = variableValue
                        }
                    };
                }

                launch.Args.externalConsole = newTerminal;
                runner.RunCommand(launch);

                this.Comment("Set breakpoint");
                runner.SetBreakpoints(debuggee.Breakpoints(SinkHelper.Environment, 14));

                runner.Expects.StoppedEvent(StoppedReason.Breakpoint).AfterConfigurationDone();

                using (IThreadInspector threadInspector = runner.GetThreadInspector())
                {
                    IFrameInspector currentFrame = threadInspector.Stack.First();
                    this.Comment("Verify locals variables on current frame.");
                    currentFrame.AssertEvaluateAsString("varValue1", EvaluateContext.Watch, variableValue);
                }

                this.Comment("Continue until end");
                runner.Expects.ExitedEvent()
                .TerminatedEvent()
                .AfterContinue();

                runner.DisconnectAndVerify();
            }
        }
コード例 #8
0
        public bool CreateLaunchCommand(NewLaunchCommandDTO newLaunch)
        {
            if (newLaunch.DontCreateDuplicated && this.DoesAnUnexecutedLaunchCommandAlreadyExist(newLaunch.TestGuid))
            {
                return(false);
            }

            LaunchCommand newCommand = new LaunchCommand()
            {
                DateCreated         = DateTime.Now,
                TestId              = this.GetTestId(newLaunch.TestGuid),
                CommandText         = "LAUNCH",
                DateScheduled       = newLaunch.ScheduledDate,
                LaunchedByUserGuuid = newLaunch.LaunchedByUserGuid,
                LaunchedByUserName  = newLaunch.LaunchedByUserName,
                Parameters          = newLaunch.Parameters,
            };

            dbContext.LaunchCommands.Add(newCommand);
            dbContext.SaveChanges();

            return(true);
        }
コード例 #9
0
        public void MapSpecificFile(ITestSettings settings)
        {
            this.TestPurpose("Validate Specific File Mapping.");

            this.WriteSettings(settings);

            IDebuggee debuggee = SourceMappingHelper.Open(this, settings.CompilerSettings, DebuggeeMonikers.SourceMapping.Default);

            // VsDbg is case insensitive on Windows so sometimes stackframe file names might all be lowercase
            StringComparison comparison = settings.DebuggerSettings.DebuggerType == SupportedDebugger.VsDbg ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal;

            using (IDebuggerRunner runner = CreateDebugAdapterRunner(settings))
            {
                this.Comment("Configure");
                LaunchCommand launch = new LaunchCommand(settings.DebuggerSettings, debuggee.OutputPath, false);

                launch.Args.externalConsole = false;

                this.Comment("Setting up Source File Mappings");

                Dictionary <string, string> sourceMappings = new Dictionary <string, string>();
                string pathRoot = Path.GetPathRoot(debuggee.SourceRoot);

                string sourceFileMapping  = Path.Combine(pathRoot, Path.GetRandomFileName(), SourceMappingHelper.Writer);
                string compileFileMapping = Path.Combine(debuggee.SourceRoot, SourceMappingHelper.WriterFolder, SourceMappingHelper.Writer);

                if (PlatformUtilities.IsWindows)
                {
                    // Move file to the location
                    Directory.CreateDirectory(Path.GetDirectoryName(sourceFileMapping));
                    File.Copy(compileFileMapping, sourceFileMapping, true);
                }

                // Drive letter should be lowercase
                sourceMappings.Add(compileFileMapping, sourceFileMapping);

                launch.Args.sourceFileMap = sourceMappings;
                try
                {
                    runner.RunCommand(launch);

                    this.Comment("Set Breakpoint");

                    SourceBreakpoints writerBreakpoints = debuggee.Breakpoints(SourceMappingHelper.Writer, 9);
                    runner.SetBreakpoints(writerBreakpoints);
                    runner.Expects.StoppedEvent(StoppedReason.Breakpoint).AfterConfigurationDone();

                    using (IThreadInspector threadInspector = runner.GetThreadInspector())
                    {
                        IEnumerator <IFrameInspector> frameEnumerator = threadInspector.Stack.GetEnumerator();

                        // Move to first stack item
                        Assert.True(frameEnumerator.MoveNext());
                        this.Comment("Verify path is changed for writer.cpp frame");
                        ValidateMappingToFrame(SourceMappingHelper.Writer, EnsureDriveLetterLowercase(sourceFileMapping), frameEnumerator.Current, comparison);

                        // Move to second stack item
                        Assert.True(frameEnumerator.MoveNext());
                        this.Comment("Verify path is not changed for main.cpp frame.");
                        ValidateMappingToFrame(SourceMappingHelper.Main, EnsureDriveLetterLowercase(Path.Combine(debuggee.SourceRoot, SourceMappingHelper.Main)), frameEnumerator.Current, comparison);

                        writerBreakpoints.Remove(9);
                        runner.SetBreakpoints(writerBreakpoints);
                        this.Comment("Continue to end");

                        runner.Expects.TerminatedEvent().AfterContinue();
                        runner.DisconnectAndVerify();
                    }
                }
                finally
                {
                    if (PlatformUtilities.IsWindows)
                    {
                        // Cleanup the directory
                        if (Directory.Exists(Path.GetDirectoryName(sourceFileMapping)))
                        {
                            Directory.Delete(Path.GetDirectoryName(sourceFileMapping), true);
                        }
                    }
                }
            }
        }
コード例 #10
0
        public void MapDirectory(ITestSettings settings)
        {
            this.TestPurpose("Validate Source Mapping.");

            this.WriteSettings(settings);

            IDebuggee debuggee = SourceMappingHelper.Open(this, settings.CompilerSettings, DebuggeeMonikers.SourceMapping.Default);

            // VsDbg is case insensitive on Windows so sometimes stackframe file names might all be lowercase
            StringComparison comparison = settings.DebuggerSettings.DebuggerType == SupportedDebugger.VsDbg ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal;

            using (IDebuggerRunner runner = CreateDebugAdapterRunner(settings))
            {
                this.Comment("Configure");
                LaunchCommand launch = new LaunchCommand(settings.DebuggerSettings, debuggee.OutputPath, false, "-fCalling");

                launch.Args.externalConsole = false;

                this.Comment("Setting up Source File Mappings");

                Dictionary <string, string> sourceMappings = new Dictionary <string, string>();
                string pathRoot = Path.GetPathRoot(debuggee.SourceRoot);

                string mgrDirectoryMapping    = Path.Combine(debuggee.SourceRoot, SourceMappingHelper.Manager, Path.GetRandomFileName());
                string writerDirectoryMapping = Path.Combine(pathRoot, Path.GetRandomFileName(), Path.GetRandomFileName());
                string rootDirectoryMapping   = Path.Combine(pathRoot, Path.GetRandomFileName());
                sourceMappings.Add(Path.Combine(debuggee.SourceRoot, SourceMappingHelper.WriterFolder), writerDirectoryMapping);
                sourceMappings.Add(Path.Combine(debuggee.SourceRoot, SourceMappingHelper.ManagerFolder), mgrDirectoryMapping);
                sourceMappings.Add(debuggee.SourceRoot, rootDirectoryMapping);

                launch.Args.sourceFileMap = sourceMappings;

                try
                {
                    if (PlatformUtilities.IsWindows)
                    {
                        // Create all the directories but only some of the files will exist on disk.
                        foreach (var dir in sourceMappings.Values)
                        {
                            Directory.CreateDirectory(dir);
                        }
                        File.Copy(Path.Combine(debuggee.SourceRoot, SourceMappingHelper.WriterFolder, SourceMappingHelper.Writer), Path.Combine(writerDirectoryMapping, SourceMappingHelper.Writer), true);
                        File.Copy(Path.Combine(debuggee.SourceRoot, SourceMappingHelper.Main), Path.Combine(rootDirectoryMapping, SourceMappingHelper.Main), true);
                    }

                    runner.RunCommand(launch);

                    this.Comment("Set Breakpoint");

                    SourceBreakpoints writerBreakpoints  = debuggee.Breakpoints(SourceMappingHelper.Writer, 9);
                    SourceBreakpoints managerBreakpoints = debuggee.Breakpoints(SourceMappingHelper.Manager, 8);
                    runner.SetBreakpoints(writerBreakpoints);
                    runner.SetBreakpoints(managerBreakpoints);
                    runner.Expects.StoppedEvent(StoppedReason.Breakpoint).AfterConfigurationDone();

                    using (IThreadInspector threadInspector = runner.GetThreadInspector())
                    {
                        IEnumerator <IFrameInspector> frameEnumerator = threadInspector.Stack.GetEnumerator();

                        // Move to first stack item
                        Assert.True(frameEnumerator.MoveNext());
                        this.Comment(string.Format(CultureInfo.InvariantCulture, "Verify source path for {0}.", SourceMappingHelper.Writer));
                        // Since file is there, lowercase the drive letter
                        ValidateMappingToFrame(SourceMappingHelper.Writer, EnsureDriveLetterLowercase(Path.Combine(writerDirectoryMapping, SourceMappingHelper.Writer)), frameEnumerator.Current, comparison);


                        // Move to second stack item
                        Assert.True(frameEnumerator.MoveNext());
                        this.Comment(string.Format(CultureInfo.InvariantCulture, "Verify source path for {0}.", SourceMappingHelper.Main));
                        // Since file is there, lowercase the drive letter
                        ValidateMappingToFrame(SourceMappingHelper.Main, EnsureDriveLetterLowercase(Path.Combine(rootDirectoryMapping, SourceMappingHelper.Main)), frameEnumerator.Current, comparison);
                    }
                    runner.Expects.StoppedEvent(StoppedReason.Breakpoint).AfterContinue();

                    using (IThreadInspector threadInspector = runner.GetThreadInspector())
                    {
                        IEnumerator <IFrameInspector> frameEnumerator = threadInspector.Stack.GetEnumerator();

                        // Move to first stack item
                        Assert.True(frameEnumerator.MoveNext());
                        this.Comment(string.Format(CultureInfo.InvariantCulture, "Verify source path for {0}.", SourceMappingHelper.Manager));
                        // Since file is not there, keep what was passed in
                        ValidateMappingToFrame(SourceMappingHelper.Manager, EnsureDriveLetterLowercase(Path.Combine(mgrDirectoryMapping, SourceMappingHelper.Manager)), frameEnumerator.Current, comparison);

                        // Move to second stack item
                        Assert.True(frameEnumerator.MoveNext());
                        this.Comment(string.Format(CultureInfo.InvariantCulture, "Verify source path for {0}.", SourceMappingHelper.Main));
                        // Since file is there, lowercase the drive letter
                        ValidateMappingToFrame(SourceMappingHelper.Main, EnsureDriveLetterLowercase(Path.Combine(rootDirectoryMapping, SourceMappingHelper.Main)), frameEnumerator.Current, comparison);
                    }

                    writerBreakpoints.Remove(9);
                    managerBreakpoints.Remove(8);
                    runner.SetBreakpoints(writerBreakpoints);
                    runner.SetBreakpoints(managerBreakpoints);

                    this.Comment("Continue to end");

                    runner.Expects.TerminatedEvent().AfterContinue();
                    runner.DisconnectAndVerify();
                }
                finally
                {
                    if (PlatformUtilities.IsWindows)
                    {
                        foreach (var dir in sourceMappings.Values)
                        {
                            if (Directory.Exists(dir))
                            {
                                Directory.Delete(dir, recursive: true);
                            }
                        }
                    }
                }
            }
        }