Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            /*
             * string data_path = @"C:\Users\white\source\repos\msu_homework\msu_homework\data.txt";
             * V4DataCollection new_thing = new V4DataCollection(data_path);
             * Console.WriteLine(new_thing.ToLongString());
             */
            V4MainCollection new_thing = new V4MainCollection();

            new_thing.AddDefaults();

            string           data_path = @"C:\Users\white\source\repos\msu_homework\msu_homework\data.txt";
            V4DataCollection new_v4datacollect_thing = new V4DataCollection(data_path);
            Grid2D           just_object             = new Grid2D((float)2.1, 0, (float)2.1, 0);
            Grid2D           just_object_test        = new Grid2D((float)2.1, 2, (float)2.1, 2);
            V4DataOnGrid     new_v4dataongrid_thing  = new V4DataOnGrid("test", 12.5, just_object_test);

            new_v4dataongrid_thing.InitRandom(1, 2);
            new_thing.Add(new_v4datacollect_thing);
            new_thing.Add(new_v4dataongrid_thing);

            Console.WriteLine(new_thing);
            Console.WriteLine(new_thing.MaxLength);
            Console.WriteLine(new_thing.MaxMagn);
            Console.WriteLine(string.Join("\n", new_thing.Perechisl));
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            Thread.CurrentThread.CurrentCulture = new CultureInfo("ru-RU");

            /*
             * string data_path = System.IO.Directory.GetCurrentDirectory() + @"\data.txt";
             * V4DataCollection new_thing = new V4DataCollection(data_path);
             * Console.WriteLine(new_thing.ToLongString());
             */

            /*
             * V4MainCollection new_thing = new V4MainCollection();
             * new_thing.AddDefaults();
             *
             * string data_path = System.IO.Directory.GetCurrentDirectory() + @"\data.txt";
             * V4DataCollection new_v4datacollect_thing = new V4DataCollection(data_path);
             *
             *
             *
             * Grid2D just_object = new Grid2D((float)2.1, 0, (float)2.1, 0);
             * Grid2D just_object_test = new Grid2D((float)2.1, 2, (float)2.1, 2);
             * V4DataOnGrid new_v4dataongrid_thing = new V4DataOnGrid("test", 12.5, just_object_test);
             * new_v4dataongrid_thing.InitRandom(1, 2);
             * new_thing.Add(new_v4datacollect_thing);
             * new_thing.Add(new_v4dataongrid_thing);
             *
             * Console.WriteLine(new_thing);
             * Console.WriteLine("MaxLength");
             * Console.WriteLine(new_thing.MaxLength);
             * Console.WriteLine("MaxMagn");
             * Console.WriteLine(new_thing.MaxMagn.ToString());
             * Console.WriteLine("Perechisl");
             * Console.WriteLine(string.Join("\n", new_thing.Perechisl));
             */

            Grid2D       just_object_test = new Grid2D((float)2.1, 2, (float)2.1, 2);
            V4DataOnGrid test             = new V4DataOnGrid("test", 12.5, just_object_test);

            Console.WriteLine(test.ToLongString("{0}"));
            V4MainCollection test_new = new V4MainCollection();

            test_new.DataChanged += DataC;
            test_new.Add(test);
            V4DataCollection AddTest = new V4DataCollection("add2", 7.6);

            test_new.Add(AddTest);
            V4DataCollection replTest = new V4DataCollection("rep", 5.6);

            test_new[0]       = replTest;
            test_new[0].CInfo = "TestChangeValue";
            test_new.Remove("TestChangeValue", 5.6);
        }
Ejemplo n.º 3
0
        public V4DataCollection(string filename)  : base("", 0)
        {
            FileStream       fs      = null;
            V4DataCollection dataSet = null;

            string[] vectInfo;
            Dictionary <Vector2, Complex> dict_new = new Dictionary <Vector2, Complex>();

            try
            {
                fs = new FileStream(filename, FileMode.Open);
                StreamReader istream    = new StreamReader(fs);
                string       parsingArg = istream.ReadLine();
                if (parsingArg == null)
                {
                    throw new Exception("no measure\n");
                }
                string measures = parsingArg;
                parsingArg = istream.ReadLine();
                if (parsingArg == null)
                {
                    throw new Exception("no freq info\n");
                }
                double frequency = Convert.ToDouble(parsingArg);
                while ((parsingArg = istream.ReadLine()) != null)
                {
                    vectInfo = parsingArg.Split(' ');
                    if (vectInfo.Length != 4)
                    {
                        throw new Exception("length problem\n");
                    }
                    dict_new.Add(new Vector2(Convert.ToSingle(vectInfo[0]), Convert.ToSingle(vectInfo[1])), new Complex(Convert.ToDouble(vectInfo[2]), Convert.ToDouble(vectInfo[3])));
                }
                measures_info  = measures;
                frequency_info = frequency;
            }
            catch (Exception e)
            {
                dataSet = null;
                System.Console.WriteLine("Parse error");
                System.Console.WriteLine(e.Message);
            }
            finally
            {
                if (fs != null)
                {
                    fs.Close();
                }
            }
            dict = dict_new;
        }
Ejemplo n.º 4
0
        public void AddDefaults()
        {
            int n = 0;

            Grid2D           just_object       = new Grid2D((float)2.1, 4, (float)2.1, 4);
            V4DataOnGrid     onGrid_object     = new V4DataOnGrid("hello", 2.3, just_object);
            V4DataCollection collection_object = new V4DataCollection("hello", 2.3);
            int    number_of_new_objects       = 5;
            double minVal = 12.0;
            double maxVal = 24.0;
            Random rnd    = new Random();

            for (int i = 0; i < 1; i++)
            {
                onGrid_object.InitRandom(minVal, maxVal);
                collection_object.InitRandom(number_of_new_objects, (float)rnd.NextDouble(), (float)rnd.NextDouble(), minVal, maxVal);
                list.Add(onGrid_object);
                list.Add(collection_object);
            }
        }