コード例 #1
0
ファイル: Program.cs プロジェクト: NordicSim/NordicSim
        // -- main

        public static async Task Main(string[] args)
        {
            var options = new CliOptionParser <CliOptions> {
                Prefix = "--"
            }.ReadArguments(args);

            LoggingProvider.Initialize(
                new LoggerFactory()
                .UseLevel(options.GetLogLevel())
                .AddSerilogConsole());
            _log = LoggingProvider.CreateLogger(typeof(Program));
            _log.Info($"Starting D3vS1m command line tool...");
            _log.Debug($"Start arguments: {string.Join(' ', args)}");

            try
            {
                var runtime = InitializeRuntime();

                if (!runtime.Validate())
                {
                    throw new RuntimeException("The runtime validation failed.");
                }

                await runtime.RunAsync(5);
            }
            catch (Exception ex)
            {
                _log.Critical(ex);
            }
            finally
            {
                WaitAndExit(options.Break);
                _log.Info("Goodby!");
            }
        }
コード例 #2
0
        // -- main

        public static async Task Main(string[] args)
        {
            var options = new CliOptionParser <CliOptions> {
                Prefix = "--"
            }.ReadArguments(args);

            LoggingProvider.Initialize(
                new LoggerFactory()
                .UseLevel(options.GetLogLevel())
                .AddSerilogConsole());
            _log = LoggingProvider.CreateLogger(typeof(Program));
            _log.Info($"Starting D3vS1m command line tool...");
            _log.Debug($"Start arguments: {string.Join(' ', args)}");

            try
            {
                ImportSimulationArguments(options);
                Factory.SetupRuntime(SimArgs.Values.ToArray(), Runtime);

                Runtime.SetupSimulators((repo) =>
                {
                    repo[SimulationTypes.Antenna].With(SimArgs[SimulationTypes.Network]);
                    repo[SimulationTypes.Energy].With(SimArgs[SimulationTypes.Network]);
                });

                Runtime.Stopped += (o, e) =>
                {
                    WaitAndExit(options.Break);
                };

                Runtime.IterationPassed += (o, e) =>
                {
                };

                // -- validate

                if (!Runtime.Validate())
                {
                    throw new RuntimeException("The runtime validation failed.");
                }

                // -- run

                await Runtime.RunAsync(5);
            }
            catch (Exception ex)
            {
                _log.Critical(ex);
                WaitAndExit(options.Break);
            }
        }