Ejemplo n.º 1
0
        public static void Main(string[] args)
        {
            string environment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");

            Console.WriteLine($"Środowisko: {environment}");
            Console.WriteLine($"Katalog roboczy: {Directory.GetCurrentDirectory()}");
            Console.WriteLine($"Wejście: {System.Reflection.Assembly.GetExecutingAssembly().Location}; PID:{Process.GetCurrentProcess().Id}");

            //
#if DEBUG
            BoardProvider.Provider.LoadBoard();
            PythonModelGenerator pmg = new PythonModelGenerator();
            pmg.ApplyBoard(BoardProvider.Board, "code_anfis.handlebars");
            while (true)
            {
                pmg.Run();
                string pc = pmg.PythonCode;
                Console.WriteLine(pc);
                return;
            }
#endif
            //
            //

            cts = new CancellationTokenSource();
            Thread th = new Thread(new ThreadStart(StoreThread));
            th.Start();
            CreateHostBuilder(args).Build().Run();
            cts.Cancel();
            th.Join();
            BoardProvider.Provider.StoreBoard();
        }
Ejemplo n.º 2
0
        private async Task OnGenerateCode(MouseEventArgs e, GeneratorType genType)
        {
            try
            {
                string code_template_file = genType switch
                {
                    GeneratorType.SkFuzzyClassic => "code_classic.handlebars",
                    GeneratorType.SkFuzzyANFIS => "code_anfis.handlebars",
                    _ => null
                };

                PythonModelGenerator generator = new PythonModelGenerator();
                generator.ApplyBoard(BoardProvider.Board, code_template_file);
                generator.Run();
                await this._editor.SetValue(generator.PythonCode);
            }
            catch (Exception ex)
            {
                StringBuilder sb = new StringBuilder();
                sb.AppendLine("\"\"\"");
                sb.AppendLine("### wystąpił wyjątek podczas generowania kodu źródłowego: ###");
                sb.AppendLine(ex.Message);
                sb.AppendLine(ex.StackTrace);
                sb.AppendLine();
                sb.AppendLine("\"\"\"");
                await this._editor.SetValue(sb.ToString());
            }
        }