Exemple #1
0
        private void tChart1_MouseMove(object sender, MouseEventArgs e)
        {
            if (files_ops.Count == 0)
            {
                return;
            }
            double   YF, XF;
            DateTime dt;

            //XF = e.X;
            //YF = e.Y;
            XF = tChart1.Axes.Bottom.CalcPosPoint(e.X);
            dt = DateTime.FromOADate(XF);

            YF = tChart1.Axes.Left.CalcPosPoint(e.Y);
            //long seconds = (long)(dt.Hour * 3600 + dt.Minute * 60 + dt.Second) -
            //(long)(file_ops.time_begin.Hour * 3600 + file_ops.time_begin.Minute * 60 + file_ops.time_begin.Second);
            long     msec  = (long)(dt - files_ops.First().date_begin).TotalMilliseconds;
            DateTime t_UTC = astronom.UTCToStarTime(dt);

            //long msec = (long)((float)seconds * 1000 / file_ops.tresolution);
            msec = (long)((float)msec / file_ops.tresolution);
            _file_ops file_ops_utc = files_ops.First();

            file_ops_utc.delta_lucha = 0.89;
            string s = StarTime.StarTime(file_ops_utc, msec);

            //string s = t_UTC.AddSeconds(67.5).ToString("HH:mm:ss");
            label_position.Text = "X=" + msec.ToString() + "  " + dt.ToString("dd:MM:yyy HH:mm:ss:F00")
                                  + " Y=" + YF.ToString("#0.000")
                                  + "   StarTime =" + t_UTC.ToString("HH:mm:ss")
                                  + "  STBSA:" + s;
        }
Exemple #2
0
        public string StarTime(_file_ops data, long point) // dateTime UTC
        {
            DateTime time        = data.datetime_utc.AddMilliseconds(data.tresolution * point);
            double   delta_lucha = data.delta_lucha; /// ????
            DateTime dnow        = new DateTime(data.date_begin.Year, data.date_begin.Month, data.date_begin.Day, 0, 0, 0);
            double   t           = (ToJulianDate(dnow) - ToJulianDate(new DateTime(2000, 1, 1, 0, 0, 0)) - 1);

            t /= 36525;
            double s0      = 6 + 41 / 60.0 + 50.55 / 3600.0 + 8640184 / 3600.0 * t + 0.093104 / 3600.0 * t * t - 6.27 / 3600.0 * (1e-6) * t * t * t;
            double t_culm  = time.Hour + time.Minute / 60.0 + time.Second / 3600.0;
            double alambda = 2 + 30 / 60.0 + 34 / 3600.0;
            double cnst    = 2.7379093e-3;
            double s_culm  = s0 + (cnst + 1) * t_culm + alambda;
            Pair   res     = get_alf(s_culm, delta_lucha);

            if (point != -1)
            {
                return(res.First.ToString());
            }
            else
            {
                return(res.Second.ToString());
            }
        }
Exemple #3
0
        private void button_p1h_left_Click(object sender, EventArgs e)
        {
            if (files_names.Count == 0)
            {
                MessageBox.Show("Нет ни одного прочитанного файла!");
                return;
            }
            string extension = Path.GetExtension(files_names.Last());

            if (extension != ".pnt")
            {
                //MessageBox.Show(Path.GetFileName(files_names.Last()), "Этот режим только для коротких данных: "); return;
            }

            string name_first = GetFileNameByTl(files_ops.First().date_end.AddHours(-1.992), file_ops.recorder);

            name_first = Path.GetFileNameWithoutExtension(name_first) + extension;
            name_first = Path.GetDirectoryName(files_names.Last()) + "\\" + name_first;
            int buf_length = (file_ops.nbands + 1) * 8;                 // точка во вх.данных для 1-го модуля
            int nbeams_all = buf_length * file_ops.modulus.Count;       // для всех модулей

            List <Single>[] _pmbb      = new List <float> [nbeams_all]; // данные для 8 лучей
            _file_ops       file_ops_t = new _file_ops();

            file_ops_t.modulus = new List <int>();
            file_ops_t.wbands  = new List <float>();
            file_ops_t.fbands  = new List <float>();
            for (int i = 0; i < _pmbb.Count(); i++)
            {
                _pmbb[i] = new List <Single>();
            }

            if (!GetDataByFileName(name_first, ref file_ops_t, ref _pmbb))
            {
                MessageBox.Show(name_first, "Ошибка при чтении файла: "); return;
            }
            DateTime        t   = file_ops_t.date_begin;
            List <DateTime> xvt = new List <DateTime>();
            List <Double>   yv  = new List <double>();

            //for (int i = 0; i < files_ops.Count; i++) count_points += files_ops[i].npoints;
            for (long i = 0; i < _pmbb[0].Count(); i++)
            {
                xvt.Add(t.AddMilliseconds((double)i * file_ops_t.tresolution));
            }
            x_axes.InsertRange(0, xvt);
            //for (long i = 0; i < count_points; i++) xvt.Add(DateTime.FromOADate(tChart1.Series[0].XValues.Value[i]));
            for (int i = 0; i < p_beams_all.Length; i++)
            {
                p_beams_all[i].InsertRange(0, _pmbb[i]);
            }

/*
 *              for (int b = 0; b < 8; b++)
 *              {
 *                  yv.Clear();
 *                  for (int i = 0; i < file_ops_t.npoints; i++) yv.Add((double)_pmbb[b][i]);
 *                  for (long i = 0; i < count_points; i++) yv.Add(tChart1.Series[b].YValues.Value[i]);
 *                  tChart1.Series[b].Clear();
 *
 *                  tChart1.Series[b].Add(xvt.ToArray(), yv.ToArray());
 *              }
 */

            files_ops.Insert(0, file_ops_t);
            files_names.Insert(0, name_first);
            ChartRefresh();
        }
Exemple #4
0
        private bool GetDataByFileName(string name_last, ref _file_ops file_ops, ref List <Single>[] pmbb)
        {
            System.IO.FileStream   fstr;
            System.IO.StreamReader strf;
            System.IO.BinaryReader bf;
            //List<Single> pmbb;
            string s;

            char[]   delimiterChars = { ' ', '\t' };
            string[] words;
            int      numpar;
            ulong    size_header;

            try
            {
                fstr = new System.IO.FileStream(name_last, System.IO.FileMode.Open);
            }
            catch (Exception E)
            {
                tBmessages.AppendText(E.Message);
                return(false);
            }
            //-----
            strf        = new System.IO.StreamReader(fstr);
            size_header = 0;
            s           = strf.ReadLine();
            words       = s.Split(delimiterChars, 2, StringSplitOptions.RemoveEmptyEntries);
            if (words.Length <= 1)
            {
                //MessageBox.Show(openFileDialog1.FileName, "Неверный формат файла");
                strf.Close();
                fstr.Close();
                return(false);
            }
            if (words[0] != "numpar")
            {
                //MessageBox.Show(openFileDialog1.FileName, "Неверный формат файла");
                strf.Close();
                fstr.Close();
                return(false);
            }


            numpar          = Convert.ToInt32(words[1]);
            size_header    += (ulong)s.Length + 1; // "\r\n"
            tBmessages.Text = "";

            //------------------номер регистратора---------------------------
            char[]   _delimiterChars = { ' ', '\t', '_' };
            string[] _words          = Path.GetFileNameWithoutExtension(name_last).Split(_delimiterChars,
                                                                                         StringSplitOptions.RemoveEmptyEntries);
            string _s = _words[2]; _s = _s.Replace("N", "");

            file_ops.recorder = Convert.ToInt32(_s);
            //--------обработка заголовка-------------------------
            CultureInfo culture_en = new CultureInfo("en-US");
            CultureInfo culture_ru = new CultureInfo("ru-RU");

            try
            {
                for (int i = 0; i < numpar - 1; i++)
                {
                    s = strf.ReadLine();
                    tBmessages.AppendText(s + "\r\n");
                    size_header += (ulong)s.Length + 1;
                    words        = s.Split(delimiterChars, StringSplitOptions.RemoveEmptyEntries);
                    words[0]     = words[0].ToLower();
                    switch (words[0])
                    {
                    case "source":
                        file_ops.source = words[1];
                        break;

                    case "alpha":
                        file_ops.alpha = words[1];
                        break;

                    case "delta":
                        file_ops.delta = words[1];
                        break;

                    case "fcentral":
                        file_ops.fcentral = Convert.ToSingle(words[1], culture_en);
                        break;

                    case "npoints":
                        file_ops.npoints = Convert.ToUInt32(words[1]);
                        break;

                    case "wb_total":
                        file_ops.fcentral = Convert.ToSingle(words[1], culture_en);
                        break;

                    case "tresolution":
                        file_ops.tresolution = Convert.ToSingle(words[1], culture_en);
                        break;

                    case "date_begin":
                        file_ops.date_begin     = Convert.ToDateTime(words[1], culture_ru);
                        file_ops.date_begin_str = words[1];
                        break;

                    case "date_end":
                        file_ops.date_end     = Convert.ToDateTime(words[1], culture_ru);
                        file_ops.date_end_str = words[1];
                        break;

                    case "time_begin":
                        file_ops.time_begin     = Convert.ToDateTime(words[1], culture_en);
                        file_ops.time_begin_str = words[1];
                        break;

                    case "time_end":
                        file_ops.time_end     = Convert.ToDateTime(words[1], culture_en);
                        file_ops.time_end_str = words[1];
                        break;

                    case "modulus":
                        file_ops.modulus.Clear();
                        for (int k = 1; k < words.Length; k++)
                        {
                            file_ops.modulus.Add(Convert.ToInt32(words[k]));
                        }
                        break;

                    case "nbands":
                        file_ops.nbands = Convert.ToInt32(words[1]);
                        //UD_band.Maximum = file_ops.nbands+1;
                        break;

                    case "wbands":
                        file_ops.wbands.Clear();
                        for (int k = 1; k < words.Length; k++)
                        {
                            file_ops.wbands.Add(Convert.ToSingle(words[k], culture_en));
                        }
                        break;

                    case "fbands":
                        file_ops.fbands.Clear();
                        for (int k = 1; k < words.Length; k++)
                        {
                            file_ops.fbands.Add(Convert.ToSingle(words[k], culture_en));
                        }
                        break;
                    } // switch
                }     // for (int i = 0; i < numpar-1; i++)
            }
            catch (Exception)
            {
                //MessageBox.Show(s, "Ошибка при обработке строки");
                strf.Close();
                fstr.Close();
                return(false);
            }
            //----------------------------------------------------
            file_ops.date_begin = file_ops.date_begin.Add(new TimeSpan(file_ops.time_begin.Hour,
                                                                       file_ops.time_begin.Minute, file_ops.time_begin.Second));
            file_ops.date_end = file_ops.date_end.Add(new TimeSpan(file_ops.time_end.Hour,
                                                                   file_ops.time_end.Minute, file_ops.time_end.Second));
            //
            int nmodule = GetRadioIndex(groupBox1);

            long nmodule_;

            if (!file_ops.modulus.Contains(nmodule))
            {
                //MessageBox.Show("Выбран неактивный модуль", "Ошибка при выборе номера модуля");
                strf.Close();
                fstr.Close();
                return(false);
            }
            else
            {
                nmodule_ = nmodule - 1;
            }
            bf = new System.IO.BinaryReader(fstr);
            bf.BaseStream.Position = (long)size_header;
            int buf_length = (file_ops.nbands + 1) * 8;           // точка во вх.данных для 1-го модуля
            int nbeams_all = buf_length * file_ops.modulus.Count; // для всех модулей

            byte[] buf_1p = new byte[nbeams_all * sizeof(float)];

            float[] buf_float = new float[nbeams_all];
            int     size      = Marshal.SizeOf(buf_1p[0]) * buf_1p.Length;
            IntPtr  pnt       = Marshal.AllocHGlobal(size);

            pB_load.Visible = true;
            //pB_load.Maximum = (int)(file_ops.npoints/100)+1;
            pB_load.Maximum = 100;
            pB_load.Value   = 0;
//
            for (long i = 0; i < file_ops.npoints; i++)
            {
                buf_1p = bf.ReadBytes(buf_1p.Length);
                Marshal.Copy(buf_1p, 0, pnt, buf_1p.Length);
                Marshal.Copy(pnt, buf_float, 0, buf_float.Length);
                for (int im = 0; im < file_ops.modulus.Count; im++) // module
                {
                    for (int ib = 0; ib < 8; ib++)                  // beam into module
                    {
                        for (int ispectr = 0; ispectr <= file_ops.nbands; ispectr++)
                        {
                            pmbb[im * (file_ops.nbands + 1) * 8 + (file_ops.nbands + 1) * ib + ispectr].Add
                                (buf_float[im * (file_ops.nbands + 1) * 8 + (file_ops.nbands + 1) * ib + ispectr]);
                        }
                    }
                }
                if (((double)i / (double)file_ops.npoints) * 100 > (double)pB_load.Value)
                {
                    pB_load.Value++;
                    //this.Refresh();
                    //this.Invalidate();
                    Application.DoEvents();
                }
            }
            pB_load.Visible = false;

            Marshal.FreeHGlobal(pnt);

            ///

//
            bf.Close();
            strf.Close();
            fstr.Close();

            return(true);
        }