Beispiel #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            byte[] Bytes = File.ReadAllBytes("201002-lebl-080001_smr_mlat_adsb.ast"); //vector bytes todos juntos, sin separar ni nada
            //byte[] Bytes = File.ReadAllBytes("201002-lebl-080001_adsb.ast"); //vector bytes todos juntos, sin separar ni nada
            CatLib[] Cat = Hertz_Hülsmeyer.CarregarCategories();
            PGB1.Maximum = Bytes.Count();
            int H = 0;                                               //Contador delements no inscrits a CAT10 i CAT21

            List <DataBlock> DataBlockList = new List <DataBlock>(); //lista con paquetes separados

            int i = 0;

            while (i < Bytes.Count())
            {
                //Obtenirm dades inicials del block
                string       CAT       = Bytes[i].ToString();
                int          Long      = Convert.ToInt32(Bytes[i + 2].ToString());
                Queue <byte> BytesSave = new Queue <byte>();

                //Introduim tots els bytes dins d'una queue per crear el DataBlock
                int j = 0;
                while (j < Long)
                {
                    BytesSave.Enqueue(Bytes[j + i]); //Afegim a la llista local
                    j++;
                }

                //Si es de la categoria desitjada l'enllistem a la llista general
                if ((CAT == "10") || (CAT == "21"))
                {
                    DataBlockList.Add(new DataBlock(BytesSave, Cat)); //Afegim a la llista general
                }
                else
                {
                    H++;
                }

                i         = i + j;
                PGB1.Step = j;
                PGB1.PerformStep();
            }

            i = 0;
        }
Beispiel #2
0
 public Form1()
 {
     InitializeComponent();
     Hertz_Hülsmeyer.test();
     PGB1.Minimum = 1;
 }
Beispiel #3
0
        private void LoadBTN_Click(object sender, EventArgs e)
        {
            TargetList  = new List <Target>();
            TargetTable = new DataTable();
            TargetTable.Columns.Add("Target ID");
            TargetTable.Columns.Add("Track Number");
            TargetTable.Columns.Add("Vehicle Fleet");
            TargetTable.Columns.Add("Source");
            TargetTable.Columns.Add("N. DataBlocks");

            DataInf.Text      = "Loading Data...";
            DataInf.ForeColor = Color.DarkGray;
            pictureBox5.BringToFront();
            OpenFileDialog openFileDialog = new OpenFileDialog
            {
                InitialDirectory = @"D:\",
                Title            = "Browse Files",

                CheckFileExists  = true,
                CheckPathExists  = true,
                Filter           = "ast files (*.ast)|*.ast",
                DefaultExt       = ".ast",
                FilterIndex      = 2,
                RestoreDirectory = true,

                ReadOnlyChecked = true,
                ShowReadOnly    = true
            };


            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                TextVisorBTN.BorderStyle     = BorderStyle.None;
                PanelControlSuperior.Visible = false;
                TextVisorPanel.Visible       = false;
                this.DataBlockList           = new List <DataBlock>();//lista con paquetes separados
                this.DataTable1000           = new List <DataTable>();
                this.Cursor  = Cursors.WaitCursor;
                PGB1.Visible = true;
                byte[]   Bytes = File.ReadAllBytes(openFileDialog.FileName); //vector bytes todos juntos, sin separar ni nada
                CatLib[] Cat   = Hertz_Hülsmeyer.CarregarCategories();
                PGB1.Maximum = Bytes.Count();
                int H = 0; //Contador delements no inscrits a CAT10 i CAT21
                PGB1.Value = 1;

                bool Cat10 = false; bool Cat21 = false; bool Psr = false; bool Multi = false;

                DataTable DT = new DataTable();
                DT.Columns.Add("Category");
                DT.Columns.Add("Source");
                DT.Columns.Add("Target ID");
                DT.Columns.Add("Track Number");
                DT.Columns.Add("Vehicle Fleet");
                DT.Columns.Add("DataBlock Id");

                int i = 0; int numDT = 0;
                while (i < Bytes.Count())
                {
                    //Obtenirm dades inicials del block
                    string CAT = Bytes[i].ToString();
                    if (CAT == "10")
                    {
                        Cat10 = true;
                    }
                    else
                    {
                        Cat21 = true;
                    }
                    int          Long      = Convert.ToInt32(Bytes[i + 2].ToString());
                    Queue <byte> BytesSave = new Queue <byte>();


                    //Introduim tots els bytes dins d'una queue per crear el DataBlock
                    int j = 0;
                    while (j < Long)
                    {
                        BytesSave.Enqueue(Bytes[j + i]); //Afegim a la llista local
                        j++;
                    }

                    //Si es de la categoria desitjada l'enllistem a la llista general
                    if ((CAT == "10") || (CAT == "21"))
                    {
                        DataBlockList.Add(new DataBlock(BytesSave, Cat, DataBlockList.Count())); //Afegim a la llista general

                        if (DataBlockList.Last().From == "Multi.")
                        {
                            Multi = true;
                        }
                        else if (DataBlockList.Last().From == "SMR")
                        {
                            Psr = true;
                        }
                        numDT++;
                        if (numDT == 999)
                        {
                            this.DataTable1000.Add(DT);
                            DT = new DataTable();
                            DT.Columns.Add("Category");
                            DT.Columns.Add("Source");
                            DT.Columns.Add("Target ID");
                            DT.Columns.Add("Track Number");
                            DT.Columns.Add("Vehicle Fleet");
                            DT.Columns.Add("DataBlock Id");
                            numDT = 0;
                        }

                        DT.Rows.Add(DataBlockList.Last().StringLin());
                    }
                    else
                    {
                        H++;
                    }

                    i         = i + j;
                    PGB1.Step = j;
                    PGB1.PerformStep();
                }

                //Agrupar Targets
                TargetGroup();

                this.DataTable1000.Add(DT);
                this.Cursor  = Cursors.Default;
                PGB1.Visible = false;
                PanelControlSuperior.Visible = true;
                DataInf.Text      = "Data loaded";
                DataInf.ForeColor = Color.Green;
                FileName.Text     = "(File: " + openFileDialog.FileName + ")";
                FileName.Visible  = true;
                Current.Text      = "1";
                Max.Text          = Convert.ToString(this.DataTable1000.Count());
                TextVisorPanel.BringToFront();

                if ((Cat10 == true) && (Cat21 == true))
                {
                    Cat010BTN.Visible = true;
                    AllCatBTN.Visible = true;
                    Cat021BTN.Visible = true;
                    AdsBTN.Visible    = true;
                    if ((Multi == true) && (Psr == true))
                    {
                        MultiBTN.Visible = true;
                        AllSBTN.Visible  = true;
                        PSRBTN.Visible   = true;
                    }
                    else if (Multi == true)
                    {
                        MultiBTN.Visible = true;
                        AllSBTN.Visible  = true;
                        PSRBTN.Visible   = false;
                    }
                    else
                    {
                        MultiBTN.Visible = false;
                        AllSBTN.Visible  = true;
                        PSRBTN.Visible   = true;
                    }
                }
                else if (Cat10 == true)
                {
                    Cat010BTN.Visible     = true;
                    AllCatBTN.Visible     = false;
                    Cat021BTN.Visible     = false;
                    AdsBTN.Visible        = false;
                    Cat010BTN.BorderStyle = BorderStyle.FixedSingle;
                    if ((Multi == true) && (Psr == true))
                    {
                        MultiBTN.Visible = true;
                        PSRBTN.Visible   = true;
                        AllSBTN.Visible  = true;
                    }
                    else if (Multi == true)
                    {
                        MultiBTN.Visible     = true;
                        PSRBTN.Visible       = false;
                        AllSBTN.Visible      = false;
                        MultiBTN.BorderStyle = BorderStyle.FixedSingle;
                    }
                    else
                    {
                        MultiBTN.Visible   = false;
                        PSRBTN.Visible     = true;
                        AllSBTN.Visible    = false;
                        PSRBTN.BorderStyle = BorderStyle.FixedSingle;
                    }
                }
                else
                {
                    Cat010BTN.Visible     = false;
                    MultiBTN.Visible      = false;
                    PSRBTN.Visible        = false;
                    AllCatBTN.Visible     = false;
                    Cat021BTN.Visible     = true;
                    AdsBTN.Visible        = true;
                    AllSBTN.Visible       = false;
                    Cat021BTN.BorderStyle = BorderStyle.FixedSingle;
                    AdsBTN.BorderStyle    = BorderStyle.FixedSingle;
                }
            }
            else
            {
                DataInf.Text      = "No data loaded";
                DataInf.ForeColor = Color.Red;
                TextVisorPanel.BringToFront();
                if (DataBlockList.Count != 0)
                {
                    DataInf.Text      = "Data loaded";
                    DataInf.ForeColor = Color.Green;
                }
            }
        }