Пример #1
0
        public async void LoadLog(DSLOGFileEntry file)
        {
            var fileName = $"{file.FilePath}\\{file.Name}.dsevents";

            EventsDict.Clear();
            Entries = null;
            //listViewEvents.Items.Clear();
            if (!File.Exists(fileName))
            {
                return;
            }
            DSEVENTSReader reader = new DSEVENTSReader(fileName);

            try
            {
                reader.Read();
            } catch (Exception ex)
            {
                MessageBox.Show("dsevent file corrupted!");
                return;
            }

            if (reader.Version != 4)
            {
                return;
            }
            Entries = reader.Entries;
        }
Пример #2
0
        public void TestReadEvents()
        {
            var reader = new DSEVENTSReader("TestFiles\\2022_02_25 21_25_39 Fri.dsevents");

            reader.Read();
            Assert.IsTrue(reader.Version == 4);
            Assert.IsTrue(reader.Entries[0].Data == "<TagVersion>1 <time> 04.803 <message> ********** Robot program starting ********** ");
        }
Пример #3
0
        private bool SetFMS()
        {
            string dseventsPath = FilePath + "\\" + Name + ".dsevents";

            if (File.Exists(dseventsPath))
            {
                DSEVENTSReader reader = new DSEVENTSReader(dseventsPath);
                reader.ReadForFMS();
                if (reader.Version == 4)
                {
                    StringBuilder sb = new StringBuilder();
                    foreach (DSEVENTSEntry en in reader.Entries)
                    {
                        sb.Append(en.Data + " ");
                    }
                    String txtF = sb.ToString();
                    if (!string.IsNullOrWhiteSpace(txtF))
                    {
                        IsFMSMatch = true;
                    }
                    else
                    {
                        IsFMSMatch = false;
                        return(true);
                    }


                    if (txtF.Contains("FMS Connected:   Qualification"))
                    {
                        MatchType   = FMSMatchType.Qualification;
                        FMSMatchNum = int.Parse(txtF.Substring(txtF.IndexOf("FMS Connected:   Qualification - ") + 33, 5).Split(':')[0]);
                    }
                    else if (txtF.Contains("FMS Connected:   Elimination"))
                    {
                        MatchType   = FMSMatchType.Elimination;
                        FMSMatchNum = int.Parse(txtF.Substring(txtF.IndexOf("FMS Connected:   Elimination - ") + 31, 5).Split(':')[0]);
                    }
                    else if (txtF.Contains("FMS Connected:   Practice"))
                    {
                        MatchType   = FMSMatchType.Practice;
                        FMSMatchNum = int.Parse(txtF.Substring(txtF.IndexOf("FMS Connected:   Practice - ") + 28, 5).Split(':')[0]);
                    }
                    else if (txtF.Contains("FMS Connected:   None"))
                    {
                        MatchType   = FMSMatchType.None;
                        FMSMatchNum = int.Parse(txtF.Substring(txtF.IndexOf("FMS Connected:   None - ") + 24, 5).Split(':')[0]);
                    }
                    Match eventMatch = Regex.Match(txtF, "Info FMS Event Name: [a-zA-Z0-9]+");
                    if (eventMatch.Success)
                    {
                        if (!string.IsNullOrWhiteSpace(eventMatch.Value))
                        {
                            EventName = eventMatch.Value.Replace("FMS Event Name: ", "").Replace("Info", "").Trim();
                        }
                    }
                }
                else
                {
                    return(false);
                }
            }
            return(true);
        }
Пример #4
0
        private bool SetFMS(string dir, string name, out Match match)
        {
            match = null;
            string dseventsPath = dir + "\\" + name + ".dsevents";

            if (File.Exists(dseventsPath))
            {
                DSEVENTSReader reader = new DSEVENTSReader(dseventsPath);
                reader.ReadForFMS();
                if (reader.Version == 3)
                {
                    match      = new Match();
                    match.Name = name;
                    StringBuilder sb = new StringBuilder();
                    foreach (DSEVENTSEntry en in reader.Entries)
                    {
                        sb.Append(en.Data + " ");
                    }
                    String txtF = sb.ToString();

                    if (!string.IsNullOrWhiteSpace(txtF))
                    {
                        match.IsFMS = true;
                    }
                    else
                    {
                        match.IsFMS = false;
                    }


                    if (txtF.Contains("FMS Connected:   Qualification"))
                    {
                        match.MatchType = FMSMatchType.Qualification;
                        match.MatchNum  = int.Parse(txtF.Substring(txtF.IndexOf("FMS Connected:   Qualification - ") + 33, 5).Split(':')[0]);
                    }
                    else if (txtF.Contains("FMS Connected:   Elimination"))
                    {
                        match.MatchType = FMSMatchType.Elimination;
                        match.MatchNum  = int.Parse(txtF.Substring(txtF.IndexOf("FMS Connected:   Elimination - ") + 31, 5).Split(':')[0]);
                    }
                    else if (txtF.Contains("FMS Connected:   Practice"))
                    {
                        match.MatchType = FMSMatchType.Practice;
                        match.MatchNum  = int.Parse(txtF.Substring(txtF.IndexOf("FMS Connected:   Practice - ") + 28, 5).Split(':')[0]);
                    }
                    else if (txtF.Contains("FMS Connected:   None"))
                    {
                        match.MatchType = FMSMatchType.None;
                        match.MatchNum  = int.Parse(txtF.Substring(txtF.IndexOf("FMS Connected:   None - ") + 24, 5).Split(':')[0]);
                    }

                    if (txtF.Contains("FMS Event Name: "))
                    {
                        string[] sArray = txtF.Split(new string[] { "Info" }, StringSplitOptions.None);
                        foreach (String ss in sArray)
                        {
                            if (ss.Contains("FMS Event Name: "))
                            {
                                match.EventName = ss.Replace("FMS Event Name: ", "").Trim();
                                break;
                            }
                        }
                    }
                    else
                    {
                        match.EventName = "???";
                    }
                }
                else
                {
                    return(false);
                }
            }
            return(true);
        }
Пример #5
0
        private void backgroundWorkerExport_DoWork(object sender, DoWorkEventArgs e)
        {
            var tempDict = new Dictionary <string, DSLOGFileEntry>();

            Files.ForEach(en => tempDict.Add(en.Name, en));
            TotalExported = 0;
            Parallel.ForEach(CheckedFiles, (file, state) =>
            {
                DSLOGFileEntry entry;
                if (tempDict.TryGetValue(file, out entry))
                {
                    DateTime matchTime = DateTime.Now;
                    if (checkBoxLogs.Checked)
                    {
                        string dsFile = $"{entry.FilePath}\\{entry.Name}.dslog";
                        if (File.Exists(dsFile))
                        {
                            DSLOGReader reader = new DSLOGReader(dsFile);
                            try
                            {
                                reader.Read();
                            }
                            catch (Exception ex)
                            {
                                return;
                            }



                            if (entry.IsFMSMatch)
                            {
                                string eventName = entry.EventName;
                                if (!UseFilledInEvents && entry.FMSFilledIn)
                                {
                                    eventName = "";
                                }
                                string data = Util.GetTableFromLogEntries(reader.Entries, Series, IdToPDPGroup, checkBoxMatchTime.Checked && reader.Entries.TryFindMatchStart(out matchTime), matchTime, ",");
                                var dir     = $"{FilePath}\\{eventName}{entry.StartTime.Year}";
                                if (!Directory.Exists(dir))
                                {
                                    Directory.CreateDirectory(dir);
                                }
                                File.WriteAllText($"{dir}\\{entry.Name} {entry.MatchType}_{entry.FMSMatchNum}.csv", data);
                            }
                            else
                            {
                                string data = Util.GetTableFromLogEntries(reader.Entries, Series, IdToPDPGroup, false, matchTime, ",");
                                var dir     = $"{FilePath}\\{entry.StartTime.Year}";
                                if (!Directory.Exists(dir))
                                {
                                    Directory.CreateDirectory(dir);
                                }
                                File.WriteAllText($"{dir}\\{entry.Name}.csv", data);
                            }
                        }
                    }
                    if (checkBoxEvents.Checked)
                    {
                        string dsFile = $"{entry.FilePath}\\{entry.Name}.dsevents";
                        if (File.Exists(dsFile))
                        {
                            DSEVENTSReader reader = new DSEVENTSReader(dsFile);
                            try
                            {
                                reader.Read();
                            }
                            catch (Exception ex)
                            {
                                return;
                            }

                            if (entry.IsFMSMatch)
                            {
                                string eventName = entry.EventName;
                                if (!UseFilledInEvents && entry.FMSFilledIn)
                                {
                                    eventName = "";
                                }
                                string data = Util.GetTableFromEvents(reader.Entries, checkBoxMatchTime.Checked && checkBoxLogs.Checked, matchTime, ",");
                                var dir     = $"{FilePath}\\{eventName}{entry.StartTime.Year}";
                                if (!Directory.Exists(dir))
                                {
                                    Directory.CreateDirectory(dir);
                                }
                                File.WriteAllText($"{dir}\\{entry.Name} {entry.MatchType}_{entry.FMSMatchNum}_Events.csv", data);
                            }
                            else
                            {
                                string data = Util.GetTableFromEvents(reader.Entries, false, matchTime, ",");
                                var dir     = $"{FilePath}\\{entry.StartTime.Year}";
                                if (!Directory.Exists(dir))
                                {
                                    Directory.CreateDirectory(dir);
                                }
                                File.WriteAllText($"{dir}\\{entry.Name}_Events.csv", data);
                            }
                        }
                    }
                }
                if (backgroundWorkerExport.CancellationPending)
                {
                    e.Cancel = true;
                    state.Break();
                }
                int precent = (int)((double)++TotalExported / CheckedFiles.Count * 100.0);
                backgroundWorkerExport.ReportProgress(precent);
            });
        }