Example #1
0
        public static void Test()
        {
            foreach (string SerialPortItem in SerialCom.GetSerialPorts())
            {
                Console.WriteLine(SerialPortItem);
            }

            Stepper CurrentStepper = new Stepper("COM4");

            MoveInfoCollection MySequence = new MoveInfoCollection();

            MySequence.AddItem(new MoveInfo(EDirection.Clockwise, 20, 1));
            //MySequence.AddItem(new MoveInfo(EDirection.Clockwise, 20, 0.8));
            //MySequence.AddItem(new MoveInfo(EDirection.Clockwise, 20, 0.6));
            //MySequence.AddItem(new MoveInfo(EDirection.Clockwise, 20, 1));
            //MySequence.AddItem(new MoveInfo(EDirection.Clockwise, 4500, 0.2));
            //MySequence.AddItem(new MoveInfo(EDirection.Clockwise, 100, 0.5));
            //MySequence.AddItem(new MoveInfo(EDirection.CounterClockwise, 4690, 0));

            for (int i = 1; i <= 10; i++)
            {
                TChrono NewChrono = new TChrono();
                NewChrono.Start();
                Task.Run(() => CurrentStepper.Execute(MySequence)).Wait();
                Console.WriteLine($"Execution time = {NewChrono.ElapsedTime.TotalMilliseconds}");
            }
            //Task.Run(() => CurrentStepper.Execute(new MoveInfo(EDirection.Clockwise, 5, 100))).Wait();
        }
Example #2
0
        static async Task MainAsync(string[] args)
        {
            TChrono chrono = new TChrono();

            chrono.Start();

            SplitArgs Args = new SplitArgs(args);

            string        SourceRepository = Args.GetValue <string>("source", "");
            string        RepositoryName   = Args.GetValue <string>("name", SourceRepository.AfterLast(Path.DirectorySeparatorChar));
            string        OutputFilename   = Args.GetValue <string>("output", "bdindex");
            string        OutputFormat     = Args.GetValue <string>("outputformat", "txt").ToLower();
            List <string> AllowedFormats   = new List <string>()
            {
                "txt", "json", "xml"
            };

            if (!AllowedFormats.Contains(OutputFormat))
            {
                OutputFormat = "txt";
            }

            Console.WriteLine(TextBox.BuildDynamic($"Index folder {SourceRepository}..."));
            Console.WriteLine($"  Name = {RepositoryName}");
            Console.WriteLine($"  Output to {OutputFilename}.{OutputFormat}");
            Console.WriteLine();

            if (!Directory.Exists(SourceRepository))
            {
                Usage("Missing source directory");
            }

            TRepository CurrentRepository = new TRepository(SourceRepository, RepositoryName);
            await CurrentRepository.BuildIndex();

            Console.WriteLine($"Total folders : {CurrentRepository.Books.EnumerateCollections().Count()}");
            Console.WriteLine($"Found (...) folders : {CurrentRepository.Books.EnumerateCollections().Count(x => x.HasArticle)}");

            Console.WriteLine("------------------ Display name -----------------");

            foreach (IEnumerable <TBookCollection> BookCollectionItems in CurrentRepository.Books.EnumerateCollections().OrderBy(x => x.DisplayName).GroupBy(x => x.DisplayName.First()))
            {
                Console.Write($"{BookCollectionItems.First().DisplayName.First()} : ");
                Console.WriteLine(new string('#', BookCollectionItems.Count()));
            }

            Console.WriteLine("------------------ Name -----------------");

            foreach (IEnumerable <TBookCollection> BookCollectionItems in CurrentRepository.Books.EnumerateCollections().OrderBy(x => x.Name).GroupBy(x => x.Name.First()))
            {
                Console.Write($"{BookCollectionItems.First().Name.First()} : ");
                Console.WriteLine(new string('#', BookCollectionItems.Count()));
            }

            OutputFilename += $".{OutputFormat}";
            if (File.Exists(OutputFilename))
            {
                File.Delete(OutputFilename);
            }

            switch (OutputFormat)
            {
            case "txt":
                foreach (TBookCollection BookCollectionItem in CurrentRepository.Books.EnumerateCollections())
                {
                    File.AppendAllText(OutputFilename, BookCollectionItem.ToString());
                    File.AppendAllText(OutputFilename, Environment.NewLine);
                }
                break;

            case "json":
                JsonValue.Save(OutputFilename, CurrentRepository.ToJson());
                break;

            case "xml":
                File.AppendAllText(OutputFilename, CurrentRepository.ToXml().ToString());
                break;
            }



            //TBookCollection MissingInBrilly = new TBookCollection(BdBrilly.Books.GetMissingFrom(BdLuc.Books));
            //TBookCollection MissingInLuc = new TBookCollection(BdLuc.Books.GetMissingFrom(BdBrilly.Books));

            //Console.WriteLine("=== Missing in Luc =================================================");
            //string OutputMissingLuc = @"i:\# BDS\MissingInLuc.txt";
            //File.Delete(OutputMissingLuc);
            //File.AppendAllText(OutputMissingLuc, $"{MissingInLuc.Count()} books{Environment.NewLine}");
            //foreach ( TBookCollection BookCollectionItem in MissingInLuc.EnumerateCollections() ) {
            //  File.AppendAllText(OutputMissingLuc, BookCollectionItem.ToString());
            //  File.AppendAllText(OutputMissingLuc, Environment.NewLine);
            //}
            //Console.WriteLine("=== Missing in Brilly ==============================================");
            //foreach ( TBookCollection BookCollectionItem in MissingInBrilly.EnumerateCollections() ) {
            //  Console.WriteLine(BookCollectionItem.ToString());
            //}

            Console.WriteLine($"Indexing process completed in {chrono.ElapsedTime.TotalSeconds} secs");
            //ConsoleExtension.Pause();

            //Environment.Exit(0);
        }