internal static Parser FromSource(PacketDefinitions.DefinitionSource source) { switch (source) { case PacketDefinitions.DefinitionSource.SMTModelS: return(new ModelSPackets()); case PacketDefinitions.DefinitionSource.SMTModel3: return(new Model3Packets()); default: // Defaults to Model S (ScanMyTesla) return(new ModelSPackets()); } }
internal static Parser FromSource(MainWindow mainWindow, PacketDefinitions.DefinitionSource source, string DBCFileName = null) { if (DBCFileName != null) { return(new Parser(mainWindow, DBCFileName)); } switch (source) { case PacketDefinitions.DefinitionSource.SMTModelS: return(new ModelSPackets(mainWindow)); case PacketDefinitions.DefinitionSource.SMTModel3: return(new Model3Packets(mainWindow)); default: // Defaults to Model S (ScanMyTesla) return(new ModelSPackets(mainWindow)); } }
private void PacketMode_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (PacketMode.SelectedItem != null) { PacketDefinitions.DefinitionSource selectedDefs = (PacketDefinitions.DefinitionSource)PacketMode.SelectedValue; //try { // Mode change only allowed while not running if (!run) { // LATER: Support DBC file selection. Better yet, put a dialog in front of "Load" where you can // select your input file, packet mode, and DBC file (if applicable) if (selectedDefs == PacketDefinitions.DefinitionSource.DBCFile) { OpenFileDialog openFileDialog1 = new OpenFileDialog(); openFileDialog1.Filter = "DBC|*.dbc"; if ((bool)openFileDialog1.ShowDialog()) { if (openFileDialog1.FileName != null) { parser = Parser.FromSource(this, selectedDefs, openFileDialog1.FileName); } } } else { parser = Parser.FromSource(this, selectedDefs); } } else if (parser != null && parser.Definitions.Source != selectedDefs && PacketMode.Tag == null) { PacketMode.Tag = "undo"; PacketMode.SelectedValue = parser.Definitions.Source; PacketMode.Tag = null; } /*} catch (Exception ex) { * MessageBox.Show(ex.ToString()); * }*/ } }
private void PacketMode_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (PacketMode.SelectedItem != null) { PacketDefinitions.DefinitionSource selectedDefs = (PacketDefinitions.DefinitionSource)PacketMode.SelectedValue; // Mode change only allowed while not running if (!run) { // LATER: Support DBC file selection. Better yet, put a dialog in front of "Load" where you can // select your input file, packet mode, and DBC file (if applicable) parser = Parser.FromSource(selectedDefs); } else if (parser != null && parser.Definitions.Source != selectedDefs && PacketMode.Tag == null) { PacketMode.Tag = "undo"; PacketMode.SelectedValue = parser.Definitions.Source; PacketMode.Tag = null; } } }
private void PacketMode_SelectionChanged(object sender, SelectionChangedEventArgs e) { PacketDefinitions.DefinitionSource selectedDefs = (PacketDefinitions.DefinitionSource)PacketMode.SelectedValue; if (selectedDefs == PacketDefinitions.DefinitionSource.DBCFile) { OpenFileDialog openFileDialog1 = new OpenFileDialog(); openFileDialog1.Filter = "DBC|*.dbc"; openFileDialog1.Multiselect = true; string[] selectedDBCs = null; if ((bool)openFileDialog1.ShowDialog()) { if (thread != null && thread.IsAlive) { thread.Abort(); } selectedDBCs = openFileDialog1.FileNames; } if (selectedDBCs != null) { foreach (var element in selectedDBCs) { var newItem = new DBCwAssociatedBus(); if (dbcList.Where(x => x.Path == element).Count() == 0) { newItem.Path = element; newItem.Bus = "-1"; //newItem.isJ1939 = false; dbcList.Add(newItem); } } DBCFilesGrid.Items.Refresh(); Start_Parsing(); } } parser = Parser.FromSource(this, PacketDefinitions.DefinitionSource.DBCFile, dbcList); }
internal static Parser FromSource(MainWindow mainWindow, PacketDefinitions.DefinitionSource source, ObservableCollection <DBCwAssociatedBus> dbcList = null) { return(new Parser(mainWindow, dbcList)); }