Oakrey.LDF.Values
2.0.1
dotnet add package Oakrey.LDF.Values --version 2.0.1
NuGet\Install-Package Oakrey.LDF.Values -Version 2.0.1
<PackageReference Include="Oakrey.LDF.Values" Version="2.0.1" />
<PackageVersion Include="Oakrey.LDF.Values" Version="2.0.1" />
<PackageReference Include="Oakrey.LDF.Values" />
paket add Oakrey.LDF.Values --version 2.0.1
#r "nuget: Oakrey.LDF.Values, 2.0.1"
#:package Oakrey.LDF.Values@2.0.1
#addin nuget:?package=Oakrey.LDF.Values&version=2.0.1
#tool nuget:?package=Oakrey.LDF.Values&version=2.0.1
Oakrey.LDF.Values
Overview
Oakrey.LDF.Values is a .NET 10 class library that adds a runtime value layer on top of
Oakrey.LDF.
It provides LdfSignalValue for reading and writing individual LIN signal values with physical
unit decoding (offset + scale), and LdfTaskFrame for composing and parsing complete raw LIN
message byte arrays across all positioned signals in a frame.
Both types are designed for use in data-driven and MVVM applications.
Main Features
LdfSignalValue
- Wraps a
Signaltemplate fromOakrey.LDFat a specific bit position inside a parent frame. - Exposes three representations of the value simultaneously:
Value(physicaldouble),RawValue(byte[]), andSignalContent(NumericBitArray). - Physical value decoding uses the
SignalEncodingType.OffsetandSignalEncodingType.Scalefrom the bound encoding; falls back to raw integer if no encoding is set. - Implements
INotifyPropertyChanged� writing any of the three value properties raises change notifications for all three, making direct WPF/MVVM binding straightforward. - Three constructors: from a
Signal+ initial value, from aSignalwith a specifieddoublevalue, and a copy constructor.
LdfTaskFrame
- Wraps a
Frametemplate and builds anObservableCollection<LdfSignalValue>directly from the frame's positioned signals. LinMessagecomposes the current signal contents into a rawbyte[]of the frame's response length.SetValues(byte[]slices the incoming byte array to the correct response length (pads or truncates as needed) and pushes each slice into the correct signal via bit position.- Copy constructor preserves the same template, signal collection, and bit content.
Architecture
classDiagram
class LdfTaskFrame {
+long Id
+string Name
+byte[] LinMessage
+int SignalCount
+ObservableCollection~LdfSignalValue~ Signals
+Frame Template
+SetValues(byte[])
}
class LdfSignalValue {
+string Name
+int Position
+long ParentId
+int Size
+double Value
+byte[] RawValue
+NumericBitArray SignalContent
+Signal Template
+NotifyPropertyChanged(string?)
}
class INotifyPropertyChanged {
<<interface>>
+PropertyChanged
}
LdfTaskFrame --> LdfSignalValue : Signals
LdfSignalValue ..|> INotifyPropertyChanged
LdfTaskFrame --> Frame : Template
LdfSignalValue --> Signal : Template
Signal --> SignalEncodingType : Encoding
Requirements
- .NET 10 or higher
Oakrey.LDF>= 3.2.0 (project reference or NuGet)Oakrey.BitArray>= 3.0.0
Installation
.NET CLI
dotnet add package Oakrey.LDF.Values
Package Manager Console
Install-Package Oakrey.LDF.Values
NuGet Package Manager
Search for Oakrey.LDF.Values under Tools > NuGet Package Manager > Manage NuGet Packages for Solution.
Build
dotnet build
dotnet pack --configuration Release
Example Usage
Construct a task frame from a parsed LDF
LdfMatrix matrix = await LdfMatrix.CreateAsync(new FileInfo("vehicle.ldf"), CancellationToken.None);
Frame frame = matrix.Frames.Single(f => f.Name == "BodyFrame");
LdfTaskFrame taskFrame = new LdfTaskFrame(frame);
Read physical signal values
foreach (LdfSignalValue signal in taskFrame.Signals)
{
Console.WriteLine($"{signal.Name} @ bit {signal.Position}: value={signal.Value} raw={BitConverter.ToString(signal.RawValue)}");
}
Write a physical value
LdfSignalValue speedSignal = taskFrame.Signals.Single(s => s.Name == "VehicleSpeed");
speedSignal.Value = 120.0;
// Compose the updated frame as raw bytes ready to transmit
byte[] linMessage = taskFrame.LinMessage;
Parse received raw bytes into signals
byte[] receivedBytes = [0x00, 0x7B, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00];
taskFrame.SetValues(receivedBytes);
foreach (LdfSignalValue signal in taskFrame.Signals)
{
Console.WriteLine($"{signal.Name} = {signal.Value}");
}
WPF / MVVM binding
LdfSignalValue implements INotifyPropertyChanged. Bind directly to Value, RawValue,
or SignalContent in a DataGrid or custom control � updates propagate automatically when
any representation is written.
<DataGrid ItemsSource="{Binding TaskFrame.Signals}" AutoGenerateColumns="False">
<DataGrid.Columns>
<DataGridTextColumn Header="Signal" Binding="{Binding Name}" />
<DataGridTextColumn Header="Value" Binding="{Binding Value, Mode=TwoWay}" />
</DataGrid.Columns>
</DataGrid>
Development Notes
LdfSignalValue.Valuegetter returns0when noSignalEncodingTypeis bound to the signal. If you expect a raw integer value in that case, readSignalContentdirectly instead.LdfTaskFrame.SetValuespads with zero bytes when the provided array is shorter thanFrame.ResponseLength, and silently truncates when it is longer.LdfTaskFrame.LinMessagerebuilds the byte array on every access from the currentframeContent� it is not cached.NotifyPropertyChangedonLdfSignalValueispublic, enabling external components to trigger UI refresh after bulk updates without going through the property setters.
Project Information
- Author: Oakrey
- License: MIT
- Repository: Azure DevOps
- Package page: oakrey.cz
License
This project is licensed under the MIT License.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Oakrey.BitArray (>= 3.0.0)
- Oakrey.LDF (>= 3.2.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.