Beispiel #1
0
 static void Main(string[] args)
 {
     _log.Debug("Debug message");
     _log.Info("Info message");
     _log.Warn("Warn message");
     _log.Error("Error message");
     _log.Flush();
     Console.WriteLine("Done");
 }
Beispiel #2
0
        /// <summary>
        /// DBを保存するディレクトリを作る
        /// </summary>
        private void MakeDbRoot()
        {
            dbRoot = FilePath.FilePath.Expand(Path.Combine(Config.Config.Instance.WorkingRoot, "aries", "db"));
            if (Directory.Exists(dbRoot))
            {
                return;
            }
            log.Warn($"DbRoot: {dbRoot} not found");

            bool Ask()
            {
                Console.Write($"Dbファイルを {dbRoot} に保存しますか?(y/n)>> ");
                return(Console.ReadLine() switch { "y" => true, "yes" => true, _ => false });
            }
Beispiel #3
0
        private static void Main(string[] args)
        {
            var logger = new Logger.Logger();

            try {
                // parse cli options
                var request = Parser.Default.ParseArguments <DracoOption>(args)
                              .MapResult(
                    o => o.Build(), e => throw new DracoParseFailedException());


                using var cts = new CancellationTokenSource();
                var token = cts.Token;
                Console.CancelKeyPress += (sender, eventArgs) => {
                    eventArgs.Cancel = true;
                    cts.Cancel();
                };
                logger.Warn("Press Ctrl+C to cancel");


                // start process
                Spinner.Start("Ptolemy.Draco ", spin => {
                    using var draco = new Draco(token, request);
                    // print logs to stdout
                    var d = draco.Log.Subscribe(s => logger.Info(s));
                    try {
                        draco.Run();
                        spin.Info("Completed");
                    }
                    catch (Exception) {
                        spin.Fail("Failed");
                    }
                    finally {
                        d.Dispose();
                    }
                });
            }
            catch (DracoException e) {
                logger.Error($"{e}");
            }
            catch (DracoParseFailedException) {
            }
            catch (Exception e) {
                logger.Fatal($"{e}");
            }
        }
Beispiel #4
0
        private static void Main(string[] args)
        {
            var log = new Logger.Logger();

            try {
                Config.Config.Load();
                log.Info($"use config file: {Config.Config.ConfigFile}");
            }
            catch (Exception e) {
                log.Error($"Failed load config file: {Config.Config.ConfigFile}\n\t-->{e}");
                Environment.Exit(1);
            }


            Console.Clear();
            using var cts           = new CancellationTokenSource();
            Console.CancelKeyPress += (sender, eventArgs) => {
                eventArgs.Cancel = true;
                cts.Cancel();
            };

            log.Warn("Press Ctrl+C to cancel");
            var token = cts.Token;

            try {
                var itf = Parser.Default.ParseArguments <AriesMake, AriesRun, AriesLsDb>(args)
                          .MapResult(
                    (AriesMake a) => a,
                    (AriesRun a) => a,
                    (AriesLsDb a) => (IAriesVerb)a,
                    e => throw new ParseFailedException());

                itf.Run(token);
            }
            catch (ParseFailedException) {
            }
            catch (AriesException e) {
                log.Error(e);
            }
            catch (Exception e) {
                log.Error($"Unknown error has occured\n\t-->{e}");
            }

            Console.ResetColor();
        }
Beispiel #5
0
        public TResult Run <TException>() where TException : Exception
        {
            Console.CancelKeyPress += (sender, args) => {
                args.Cancel = true;
                cts.Cancel();
            };
            log.Warn("Press Ctrl+C to cancel");

            try {
                return(Process());
            }
            catch (OperationCanceledException) {
                throw new PtolemyCliException("Canceled by user");
            }
            catch (TException e) {
                throw new PtolemyCliException($"{e}");
            }
            catch (Exception e) {
                throw new PtolemyCliException($"Unknown error has occured\n\t-->{e}");
            }
        }
Beispiel #6
0
        private static void Main(string[] args)
        {
            Console.Clear();

            var log = new Logger.Logger();

            using var cts = new CancellationTokenSource();
            var token = cts.Token;

            Console.CancelKeyPress += (sender, eventArgs) => {
                eventArgs.Cancel = true;
                cts.Cancel();
            };
            log.Warn("Press Ctrl+C to cancel");

            try {
                Tuple <string, long>[] result = null;
                var sw = new Stopwatch();
                sw.Start();

                log.Info("Start Ptolemy.Libra");
                var request = Parser
                              .Default
                              .ParseArguments <LibraOption>(args)
                              .MapResult(o => o.BuildRequest(), e => throw new ParseFailedException());
                log.Info("Built request");
                log.Info($"{request.Expressions.Count} expression(s) detected");
                log.Info($"Sweep");
                if (request.IsSplitWithSeed)
                {
                    log.Info($"\tSeed: Start: {request.SeedStart}, End: {request.SeedEnd}");
                    log.Info($"\tSweep per query: {request.Sweeps.Size}");
                    log.Info($"\tTotal Sweeps: {(request.SeedEnd - request.SeedStart + 1) * request.Sweeps.Size}");
                }
                else
                {
                    log.Info($"\tSeed: {request.SeedStart}");
                    log.Info($"\tSweep: Start: {request.Sweeps.Start}, End: {request.Sweeps.Total+request.Sweeps.Start-1}");
                }

                var libra = new Libra(token, log);
                result = libra.Run(request);

                sw.Stop();
                log.Info($"Elapsed time: {sw.Elapsed}");
                log.Info("Result: ");
                Console.WriteLine();
                foreach (var(key, value) in result)
                {
                    Console.WriteLine($"Expression: {key}, Value: {value}");
                }
            }
            catch (ParseFailedException) {
            }
            catch (LibraException e) {
                log.Error(e);
            }
            catch (Exception e) {
                log.Error($"Unknown has occured\n\t-->{e}");
            }
        }
Beispiel #7
0
        private static void Main(string[] args)
        {
            var log = new Logger.Logger();

            log.Info("Welcome to Ptolemy.Argo");
            try {
                var req = Parser.Default.ParseArguments <ArgoOption>(args)
                          .MapResult(o => {
                    if (!o.Clean)
                    {
                        return(o.BuildRequest());
                    }

                    // --clean
                    var path = Path.Combine(Path.GetTempPath(), "Ptolemy.Argo");
                    Spinner.Start("Cleanup...", spin => {
                        if (Directory.Exists(path))
                        {
                            Directory.Delete(path, true);
                        }
                        spin.Info("Finished");
                    });


                    throw new ArgoClean();
                }, e => throw new ParseFailedException());

                Console.Clear();
                log.Info($"TargetNetList Netlist: {req.NetList}");
                log.Info("Parameters");
                log.Info("\tVtn:");
                log.Info($"\t\tThreshold: {req.Transistors.Vtn.Threshold}");
                log.Info($"\t\tSigma: {req.Transistors.Vtn.Sigma}");
                log.Info($"\t\tNumberOfSigma: {req.Transistors.Vtn.NumberOfSigma}");
                log.Info("\tVtp:");
                log.Info($"\t\tThreshold: {req.Transistors.Vtp.Threshold}");
                log.Info($"\t\tSigma: {req.Transistors.Vtp.Sigma}");
                log.Info($"\t\tNumberOfSigma: {req.Transistors.Vtp.NumberOfSigma}");
                log.Info($"\tSweeps: {req.SweepStart:E} to {req.Sweep + req.SweepStart - 1:E}");
                log.Info($"\tSeed: {req.Seed:E}");
                log.Info($"\tTemperature: {req.Temperature}");
                log.Info($"\tSimulationTime: {req.Time.Start:E} to {req.Time.Stop:E} (step={req.Time.Step:E})");
                log.Info($"ExtractTargets: {string.Join(",", req.Signals)}");
                log.Info($"Include {req.Includes.Count} files");
                foreach (var inc in req.Includes)
                {
                    log.Info($"\t--> {inc}");
                }

                log.Warn($"Press Ctrl+C to cancel");

                using var cts           = new CancellationTokenSource();
                Console.CancelKeyPress += (sender, eventArgs) => {
                    eventArgs.Cancel = true;
                    cts.Cancel();
                };

                var sw = new Stopwatch();
                sw.Start();
                var res = Argo.Run(cts.Token, req);
                sw.Stop();

                log.Info("Finished simulation");
                log.Info($"Elapsed: {sw.Elapsed}");
                log.Info($"{res.Count} result records");
                // 結果をSTDOUTに出す
                if (string.IsNullOrEmpty(req.ResultFile))
                {
                    log.Warn("result file not set. print to stdout");
                    Console.WriteLine("[");
                    foreach (var r in res)
                    {
                        Console.WriteLine($"{r},");
                    }
                    Console.WriteLine("]");
                }
                // 結果をファイルに書く
                else
                {
                    log.Info($"Write to {req.ResultFile}");
                    using var writer = new StreamWriter(req.ResultFile);
                    writer.WriteLine("[");
                    foreach (var r in res)
                    {
                        writer.WriteLine($"{r},");
                        writer.Flush();
                    }
                    writer.WriteLine("]");
                    writer.Flush();
                }
            }
            catch (ArgoClean) {
                log.Info("Ptolemy.Argo clean temp directory /tmp/Ptolemy.Argo");
            }
            catch (ParseFailedException) {
                log.Warn("Failed parse options");
            }
            catch (ArgoException e) {
                log.Error(e);
                Environment.ExitCode = 1;
            }
            catch (Exception e) {
                log.Error($"Unexpected exception was thrown\n-->{e}");
                Environment.ExitCode = 1;
            }
        }