Пример #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 DSLOGFileEntry AddEntry(string filename, string dir)
        {
            var entry = new DSLOGFileEntry(filename, dir);

            Cache.TryAdd(entry.Name, entry);
            NewEntries.Add(entry);
            return(entry);
        }
Пример #3
0
        private void buttonOpenFile_Click(object sender, EventArgs e)
        {
            OpenFileDialog fileDialog = new OpenFileDialog();

            fileDialog.Filter      = "DSLOG Files (.dslog)|*.dslog";
            fileDialog.Multiselect = false;
            var result = fileDialog.ShowDialog();

            if (result == DialogResult.OK)
            {
                DSLOGFileEntry entry = new DSLOGFileEntry(System.IO.Path.GetFileName(fileDialog.FileName).Replace(".dslog", ""), System.IO.Path.GetDirectoryName(fileDialog.FileName));
                DSLOGFiles.Add(entry.Name + " Opened", entry);
                FilterLogs(true);
                GraphLog(entry);
            }
        }
Пример #4
0
 private async void GraphLog(DSLOGFileEntry file)
 {
     if (MainChart != null && file != null && file.Valid)
     {
         while (LoadingLog)
         {
             Application.DoEvents();
         }
         SeriesViewObserving.Enabled = false;
         LoadingLog = true;
         var   tc = Task.Run(() => { MainChart.LoadLog(file); });
         var   te = Task.Run(() => { EventView.LoadLog(file); });
         await tc;
         await te;
         SeriesViewObserving.Enabled = true;
         EventView.AddEvents();
         LoadingLog = false;
     }
 }
Пример #5
0
 public DSLOGFileEntryCache(string file)
 {
     Cache = new ConcurrentDictionary <string, DSLOGFileEntry>();
     if (File.Exists(file))
     {
         string[] lines = File.ReadAllLines(file);
         foreach (var line in lines)
         {
             var entry = DSLOGFileEntry.FromCache(line.Replace("\n", ""), Path.GetDirectoryName(file));
             Cache.TryAdd(entry.Name, entry);
             //Cache.Add(entry.Name, entry);
         }
         New = false;
     }
     else
     {
         New = true;
     }
     FilePath   = file;
     NewEntries = new ConcurrentBag <DSLOGFileEntry>();
 }
Пример #6
0
        public static DSLOGFileEntry FromCache(string entry, string dir)
        {
            var logFile = new DSLOGFileEntry();

            string[] data = entry.Split(',');
            logFile.Name       = data[0];
            logFile.FilePath   = dir;
            logFile.IsFMSMatch = bool.Parse(data[1]);
            logFile.Seconds    = long.Parse(data[2]);
            logFile.StartTime  = DateTime.Parse(data[3]);
            logFile.Useless    = bool.Parse(data[4]);
            if (logFile.IsFMSMatch)
            {
                logFile.FMSFilledIn = bool.Parse(data[5]);
                logFile.MatchType   = (FMSMatchType)Enum.Parse(typeof(FMSMatchType), data[6]);
                logFile.FMSMatchNum = int.Parse(data[7]);
                logFile.EventName   = data[8];
            }
            logFile.Valid = true;
            return(logFile);
        }
Пример #7
0
 public bool TryGetEntry(string name, out DSLOGFileEntry entry)
 {
     return(Cache.TryGetValue(name, out entry));
 }
Пример #8
0
        private void timerFileUpdate_Tick(object sender, EventArgs e)
        {
            var  AddBack     = new List <string>();
            var  AddToFiles  = new List <DSLOGFileEntry>();
            bool listChanged = false;

            while (LogUpdateQueue.Count != 0)
            {
                string file = "";
                if (LogUpdateQueue.TryDequeue(out file))
                {
                    FileInfo fileInfo = new FileInfo($"{Path}\\{file}.dslog");
                    if (!fileInfo.Exists)
                    {
                        continue;
                    }
                    if (fileInfo.Length < 100)
                    {
                        AddBack.Add(file);
                    }
                    else
                    {
                        var entry = new DSLOGFileEntry(file, Path);
                        if (entry.Valid)
                        {
                            DSLOGFiles.Add(entry.Name, entry);
                            listChanged = true;
                        }
                    }
                }
                else
                {
                    break;
                }
            }

            foreach (string file in AddBack)
            {
                LogUpdateQueue.Enqueue(file);
            }

            foreach (var entry in DSLOGFiles.Values.Where(en => en.Live))
            {
                try
                {
                    File.OpenRead($"{Path}\\{entry.Name}.dslog").Close();
                    entry.PopulateInfo();
                    listChanged = true;
                }
                catch (IOException ex)
                {
                    if (listView.Items[listView.Items.Count - 1].Text == entry.Name)
                    {
                        entry.SetSeconds(DSLOG_Reader_Library.PDPType.Unknown);
                        listView.Items[listView.Items.Count - 1].SubItems[2].Text = entry.Seconds.ToString();
                    }
                }
            }

            if (listChanged)
            {
                FilterLogs(true);
            }
        }
Пример #9
0
        public void LoadLog(DSLOGFileEntry logInfo)
        {
            if (logInfo == null)
            {
                return;
            }
            WaitForLoadingPlotting();

            LoadingLog = true;
            LogInfo    = logInfo;
            string dslogFile = $"{logInfo.FilePath}\\{logInfo.Name}.dslog";

            chart.Invoke((Action)(() =>
            {
                StopStreaming();
                LogStreamer = null;
                InitChart();
                LogEntries = null;
                ClearInfoLabel();
                ProbeView.SetProbe(null);
            }));

            if (File.Exists(dslogFile))
            {
                DSLOGReader reader = null;
                LastEntry = 0;
                if (logInfo.Live)
                {
                    LogStreamer = new DSLOGStreamer(dslogFile);
                    reader      = LogStreamer;
                    LogStreamer.Stream();
                }
                else
                {
                    reader = new DSLOGReader(dslogFile);
                    try
                    {
                        reader.Read();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Log Corrupted!");
                        LoadingLog = false;
                        return;
                    }
                }



                if (reader.Version != 4)
                {
                    LoadingLog = false;
                    return;
                }
                chart.Invoke((Action)(() =>
                {
                    ChartArea area = chart.ChartAreas[0];
                    StartTime = reader.StartTime;
                    EndTime = reader.Entries.Last().Time;
                    LogEntries = reader.Entries;
                    area.AxisX.Minimum = StartTime.ToOADate();
                    area.AxisX.Maximum = EndTime.ToOADate();
                    area.CursorX.IntervalOffset = reader.StartTime.Millisecond % 20;


                    labelFileInfo.Text = $"{logInfo.Name}.dslog";


                    if (logInfo.IsFMSMatch)
                    {
                        labelFileInfo.Text = labelFileInfo.Text + $" ({logInfo.EventName} {logInfo.MatchType.ToString()} {logInfo.FMSMatchNum})";
                        labelFileInfo.BackColor = logInfo.GetMatchTypeColor();
                        //buttonAnalysis.Enabled = true;
                        SetUpMatchTime();
                    }
                    else
                    {
                        CanUseMatchTime = false;
                        ChangeUseMatchTime(false);
                    }
                }));


                PlotLog();
                PointCount = LogEntries.Count;

                chart.Invoke((Action)(() =>
                {
                    SetEnergy();

                    chart.ChartAreas[0].AxisX.ScaleView.ZoomReset();
                    chart.ChartAreas[0].AxisY2.ScaleView.ZoomReset();
                    this.chart.ChartAreas[0].CursorY.IsUserSelectionEnabled = false;
                }));
                LoadingLog = false;
                labelFileInfo.Invoke((Action)(() => {
                    if (logInfo.Live)
                    {
                        labelFileInfo.BackColor = Color.Lime;
                        BackColor = Color.Lime;
                        timerStream.Start();
                    }
                }));
                SetAutoScrollColor();
            }
            else
            {
                LoadingLog = false;
                MessageBox.Show("Log Corrupted!");
            }
        }