Oakrey.DBC.Converters
1.0.0
dotnet add package Oakrey.DBC.Converters --version 1.0.0
NuGet\Install-Package Oakrey.DBC.Converters -Version 1.0.0
<PackageReference Include="Oakrey.DBC.Converters" Version="1.0.0" />
<PackageVersion Include="Oakrey.DBC.Converters" Version="1.0.0" />
<PackageReference Include="Oakrey.DBC.Converters" />
paket add Oakrey.DBC.Converters --version 1.0.0
#r "nuget: Oakrey.DBC.Converters, 1.0.0"
#:package Oakrey.DBC.Converters@1.0.0
#addin nuget:?package=Oakrey.DBC.Converters&version=1.0.0
#tool nuget:?package=Oakrey.DBC.Converters&version=1.0.0
Oakrey.DBC.Converters
WPF binding converters for CAN signals from Oakrey.DBC and Oakrey.DBC.Values.
Targets net10.0-windows and requires the .NET 10 Windows Desktop runtime.
Install
dotnet add package Oakrey.DBC.Converters
Use a Windows WPF project with <UseWPF>true</UseWPF>.
Converters
| Converter | Input | Output |
|---|---|---|
| AttributeTypeToStringConverter | IAttribute | Hex, String, Float, Int or Enum; otherwise empty text |
| EndianStringConverter | SignalEndian | 1 · Little Endian or 0 · Big Endian |
| SignedStringConverter | SignalSigned | - · Signed or + · Unsigned |
| SignalSizeToVisibilityConverter | int | Visible for one bit; otherwise Collapsed |
| SignalLogicalValuesConverter | Signal | Dictionary mapping scaled enum values to descriptions |
| SignalValueEnumToStringConverter | IEnumerable<EnumValue> | Lines of value -> description, without a trailing newline |
| SignalValueConverter | MultiBinding: physical double, enum collection, double scale, double offset | First matching description, or null |
| ScaleOffsetSliderValueConverter | MultiBinding: raw double, double scale, double offset | Scaled value formatted as N2 with the binding culture |
| SliderMinValueConverter / SliderMaxValueConverter | SignalValue | Ordered physical slider endpoints as double |
WPF example
The DataContext below is an Oakrey.DBC.Values.SignalValue.
<StackPanel xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:dbc="clr-namespace:Oakrey.DBC.Converters;assembly=Oakrey.DBC.Converters">
<StackPanel.Resources>
<dbc:SignalValueConverter x:Key="Label" />
<dbc:SliderMinValueConverter x:Key="Minimum" />
<dbc:SliderMaxValueConverter x:Key="Maximum" />
</StackPanel.Resources>
<Slider Minimum="{Binding Converter={StaticResource Minimum}, Mode=OneWay}"
Maximum="{Binding Converter={StaticResource Maximum}, Mode=OneWay}"
Value="{Binding Value, Mode=TwoWay}" />
<TextBlock>
<TextBlock.Text>
<MultiBinding Converter="{StaticResource Label}" Mode="OneWay">
<Binding Path="Value" />
<Binding Path="Template.Values" />
<Binding Path="Template.Scale" />
<Binding Path="Template.Offset" />
</MultiBinding>
</TextBlock.Text>
</TextBlock>
</StackPanel>
Behavior and limits
- Null, wrong-type, short and unresolved multi-bindings do not throw. Label lookup returns null; numeric formatting returns
DependencyProperty.UnsetValue, allowing WPFFallbackValue. - Enum converters accept model lists, observable collections, arrays and other generic enumerables. Empty/invalid enum formatting returns null.
- Logical dictionaries ignore null entries and non-finite scaled keys. Duplicate keys (including collisions from zero scale or double rounding) keep the first description, consistently with label lookup.
- Label matching uses exact double equality with
raw * scale + offset. No tolerance or inverse rounding is applied. - Integer slider bounds use the complete signed/unsigned raw range for 1–64 bits, transformed by scale and offset. Negative scale reverses endpoints; zero scale yields the offset for both. DBC MinValue/MaxValue do not constrain integer sliders.
- Float/double templates use their declared physical MinValue/MaxValue and require 32/64 bits respectively. Unsupported types, invalid sizes and non-finite bounds return 0d. Bounds are UI metadata and do not implement floating-point payload encoding.
- Double cannot represent every integer above 2^53; slider endpoints and dictionary keys have that precision limit.
- Endian and signedness converters support ConvertBack for their exact display strings; unknown text returns
Binding.DoNothing. All other converters are one-way and retainNotSupportedExceptionfor ConvertBack.
Performance and binding updates
Enum formatting is O(n), with no repeated IndexOf searches or per-line intermediate strings. Lookups scan once without capturing LINQ predicates. Dictionaries reserve the source count and bounds do not allocate payload buffers. Converters do not cache mutable signal templates or collections: each invocation reads current data. The binding source must notify WPF or explicitly refresh the binding after model changes; concurrent collection mutation is not supported.
Validation
From the repository root on Windows:
dotnet run --project Converters.Tests/Converters.Tests.csproj
dotnet pack DBC.Converters/DBC.Converters.csproj -c Release
The test project uses the xUnit v3 executable runner. README and package icon are included in the NuGet package.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0-windows7.0 is compatible. |
-
net10.0-windows7.0
- Oakrey.DBC.Values (>= 6.1.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0 | 83 | 9/21/2026 |