Пример #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;
        }
Пример #2
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;
                }
            }
        }
Пример #3
0
        private void TargetGroup()
        {
            //Creem targets i poblem datagrid targets
            PGB1.Value = 1;
            PGB1.Refresh();
            DataInf.Text = "Grouping Targets...";
            DataInf.Refresh();
            List <DataBlock> Copia = DataBlockList.ToList();

            PGB1.Maximum = Copia.Count();

            //Bucle ADS-B
            bool             adsb_fin = false; int i = 0;
            List <DataBlock> ADSB = Copia.Where(x => x.From == "ADS-B").ToList();

            while ((Copia.Count != 0) && (adsb_fin == false) && (ADSB.Count != 0))
            {
                DataBlock Evaluat = ADSB.First();

                List <DataBlock> Filtrados = new List <DataBlock>();

                if (Evaluat.T_ID != "-")
                {
                    Filtrados = Copia.Where(x => x.T_ID == Evaluat.T_ID).ToList();
                    Copia.RemoveAll(x => x.T_ID == Evaluat.T_ID);
                    ADSB.RemoveAll(x => x.T_ID == Evaluat.T_ID);
                }
                else
                {
                    Filtrados = Copia.Where(x => x.T_Number == Evaluat.T_Number).ToList();
                    Copia.RemoveAll(x => x.T_Number == Evaluat.T_Number);
                    ADSB.RemoveAll(x => x.T_Number == Evaluat.T_Number);
                }

                TargetList.Add(new Target(Filtrados));

                PGB1.Step = Filtrados.Count();
                PGB1.PerformStep();

                TargetTable.Rows.Add(TargetList.Last().StringLin());
                i++;
                if (ADSB.Count == 0)
                {
                    adsb_fin = true;
                }
            }

            //Bucle SMR
            List <DataBlock> SMR = Copia.Where(x => x.From == "SMR").ToList();
            bool             smr = false;

            while ((smr == false) && (SMR.Count() != 0))
            {
                DataBlock Evaluat = SMR.First();

                List <DataBlock> Filtrados = SMR.Where(x => x.T_Number == Evaluat.T_Number).ToList();
                TargetList.Add(new Target(Filtrados));

                SMR.RemoveAll(x => x.T_Number == Evaluat.T_Number);

                PGB1.Step = Filtrados.Count();
                PGB1.PerformStep();

                TargetTable.Rows.Add(TargetList.Last().StringLin());

                if (SMR.Count == 0)
                {
                    smr = true;
                }
            }

            //Bucle Multi
            bool             multi_fin = false;
            List <DataBlock> Multi     = Copia.Where(x => x.From == "Multi.").ToList();

            while ((multi_fin == false) && (Multi.Count() != 0))
            {
                DataBlock Evaluat = Multi.First();

                List <DataBlock> Filtrados = new List <DataBlock>();
                if (Evaluat.T_ID != "-")
                {
                    Filtrados = Multi.Where(x => x.T_ID == Evaluat.T_ID).ToList();
                    Multi.RemoveAll(x => x.T_ID == Evaluat.T_ID);
                }
                else
                {
                    Filtrados = Multi.Where(x => x.T_Number == Evaluat.T_Number).ToList();
                    Multi.RemoveAll(x => x.T_Number == Evaluat.T_Number);
                }

                TargetList.Add(new Target(Filtrados));

                PGB1.Step = Filtrados.Count();
                PGB1.PerformStep();

                TargetTable.Rows.Add(TargetList.Last().StringLin());

                if (Multi.Count == 0)
                {
                    multi_fin = true;
                }
            }
            TargetShow_Act();
        }