Skip to content

Commit

Permalink
support also for weird XML ODIS formats
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Žďárský committed Oct 29, 2023
1 parent 5a8b8a6 commit f01d314
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
2 changes: 1 addition & 1 deletion DatasetParser/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
<RadioButton Name="wordlenghtselector8" GroupName="wordlenght" IsChecked="True">8</RadioButton>
</StackPanel>
<StackPanel Grid.Row="2" Orientation="Vertical">
<diffplex:DiffViewer x:Name="DiffView" ScrollViewer.VerticalScrollBarVisibility="Auto" ScrollViewer.HorizontalScrollBarVisibility="Auto" Width="Auto" MaxHeight="5000"/>
<diffplex:DiffViewer x:Name="DiffView" ScrollViewer.VerticalScrollBarVisibility="Auto" ScrollViewer.HorizontalScrollBarVisibility="Auto" Width="Auto" MinHeight="280" MaxHeight="280"/>
</StackPanel>

</StackPanel>
Expand Down
31 changes: 27 additions & 4 deletions DatasetParser/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@ private void loadFileButton_Click(object sender, RoutedEventArgs e)
if(response?.RESULT != null)
{
// Display the binary data in the TextBox
binaryDataTextBox.Text = response?.RESULT.RESPONSE.DATA.PARAMETER_DATA.Text.Replace("0x", "").Replace(",", " ").Replace(" ", " ").ToUpperInvariant();
binaryDataTextBox.Text = response?.RESULT.RESPONSE.DATA.PARAMETER_DATA.Text.Replace("\n","").Replace("0x", "").Replace(",", " ").ToUpperInvariant();
binaryDataTextBox.Text = Regex.Replace(binaryDataTextBox.Text, @"\s+", " ");
if (binaryDataTextBox.Text.Substring(0, 1) == " ")
binaryDataTextBox.Text = binaryDataTextBox.Text.Remove(0, 1);

start_address.Text = response?.RESULT.RESPONSE.DATA.PARAMETER_DATA.START_ADDRESS;
diagnostics_address.Text = response?.RESULT.RESPONSE.DATA.PARAMETER_DATA.DIAGNOSTIC_ADDRESS;
sw_name.Text = response?.RESULT.RESPONSE.DATA.PARAMETER_DATA.ZDC_NAME;
Expand All @@ -61,8 +65,15 @@ private void loadFileButton_Click(object sender, RoutedEventArgs e)
sw_name.Text = germanResponse?.DATENBEREICHE.DATENBEREICH.DATENNAME;
sw_version.Text = germanResponse?.IDENT.CNTVERSIONINHALT;
}
string[] hexValuesSplit = binaryDataTextBox.Text
.Replace("\\n", "")
.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
.Select(s => s.Trim())
.Where(s => !string.IsNullOrWhiteSpace(s))
.ToArray();



string[] hexValuesSplit = binaryDataTextBox.Text.Split(' ');
datasetBytes = new byte[hexValuesSplit.Length];


Expand Down Expand Up @@ -201,7 +212,11 @@ private void loadFileButton2_Click(object sender, RoutedEventArgs e)
if (response?.RESULT != null)
{
// Display the binary data in the TextBox
binaryDataTextBox2.Text = response?.RESULT.RESPONSE.DATA.PARAMETER_DATA.Text.Replace("0x", "").Replace(",", " ").Replace(" ", " ").ToUpperInvariant();
// Display the binary data in the TextBox
binaryDataTextBox2.Text = response?.RESULT.RESPONSE.DATA.PARAMETER_DATA.Text.Replace("\n", "").Replace("0x", "").Replace(",", " ").ToUpperInvariant();
binaryDataTextBox2.Text = Regex.Replace(binaryDataTextBox2.Text, @"\s+", " ");
if (binaryDataTextBox2.Text.Substring(0, 1) == " ")
binaryDataTextBox2.Text = binaryDataTextBox2.Text.Remove(0, 1);


}
Expand All @@ -212,7 +227,12 @@ private void loadFileButton2_Click(object sender, RoutedEventArgs e)
}


string[] hexValuesSplit = binaryDataTextBox2?.Text?.Split(' ');
string[] hexValuesSplit = binaryDataTextBox2.Text
.Replace("\\n", "")
.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
.Select(s => s.Trim())
.Where(s => !string.IsNullOrWhiteSpace(s))
.ToArray();
datasetBytes = new byte[hexValuesSplit.Length];


Expand Down Expand Up @@ -354,6 +374,9 @@ private string GetResult(short shortValue)
case 16945:
vehicle_type.Text = "VW Golf Sportsvan";
break;
case 12853:
vehicle_type.Text = "Audi TT";
break;
default:
vehicle_type.Text = "NO IDEA";
break;
Expand Down

0 comments on commit f01d314

Please sign in to comment.