Oakrey.Vector.Base
4.0.4
dotnet add package Oakrey.Vector.Base --version 4.0.4
NuGet\Install-Package Oakrey.Vector.Base -Version 4.0.4
<PackageReference Include="Oakrey.Vector.Base" Version="4.0.4" />
<PackageVersion Include="Oakrey.Vector.Base" Version="4.0.4" />
<PackageReference Include="Oakrey.Vector.Base" />
paket add Oakrey.Vector.Base --version 4.0.4
#r "nuget: Oakrey.Vector.Base, 4.0.4"
#:package Oakrey.Vector.Base@4.0.4
#addin nuget:?package=Oakrey.Vector.Base&version=4.0.4
#tool nuget:?package=Oakrey.Vector.Base&version=4.0.4
Oakrey.Vector.Base
Foundation package for building Vector hardware clients. Provides VectorClientBase and VectorChannelBase
abstract types with IObservable message streams (Rx.NET) for CAN and LIN channel implementations built on
top of Oakrey.Vector.Wrapper.
Main features
- Client abstraction -
VectorClientBase<TVectorChannel, TArgs>discovers all compatible hardware channels for a given serial number and bus type at construction time. Exposes a mergedIObservable<TArgs>stream that aggregates messages from every channel. - Channel abstraction -
VectorChannelBase<TArgs>owns the port lifecycle (open, activate, flush, deactivate, close) and publishes received frames via aSubject<TArgs>exposed asIObservable<TArgs>. - Rx.NET streams - every channel and client exposes
ReceivedDataas a cold-merged observable. Consumers subscribe using standard Rx operators and dispose the subscription to stop receiving. - Enable / Disable lifecycle - channels support explicit
Enable()/Disable()calls so hardware resources are acquired only when needed. - Correct disposal - both client and channel implement
IDisposable; disposing the client disables all channels, closes theVectorHandle, and disposes all Rx subscriptions. - Typed message generics -
TArgsis constrained toReceivedMessage(fromOakrey.Vector.Wrapper), allowing CAN and LIN implementations to carry their own strongly-typed payloads without casting.
Architecture
classDiagram
direction TB
class IVectorClientBase~TArgs~ {
<<interface>>
+IObservable~TArgs~ ReceivedData
+uint SerialNumber
+EnableChannel(byte)
+DisableChannel(byte)
}
class IVectorChannelBase~TArgs~ {
<<interface>>
+IObservable~TArgs~ ReceivedData
+byte ChannelNumber
+uint SerialNumber
+Enable()
+Disable()
+Dispose()
}
class VectorClientBase~TVectorChannel_TArgs~ {
<<abstract>>
#BusType BusType
#VectorHandle driver
#Dictionary channels
+AvailableDevices(BusType) List
#FindChannel(byte) TVectorChannel
#GetCompatibleChannels(uint) IEnumerable
}
class VectorChannelBase~TArgs~ {
<<abstract>>
#BusType BusType
#uint RxQueueSize
#OpenPort()
#StartReading()
#StopReading()
#PrepareEnable(ActivateAction)
#OnNewMessage(TArgs)
}
IVectorClientBase~TArgs~ <|.. VectorClientBase~TVectorChannel_TArgs~
IVectorChannelBase~TArgs~ <|.. VectorChannelBase~TArgs~
VectorClientBase~TVectorChannel_TArgs~ o-- VectorChannelBase~TArgs~
Concrete implementations (e.g. VectorCanChannel, VectorLinChannel) live in the VectorCan and
VectorLin projects that reference this package.
Requirements
- .NET 10 or higher
- Vector hardware driver installed on the host machine (XL Driver Library)
Oakrey.Vector.Wrapper(pulled automatically as a project/package dependency)System.Reactive6.1.0 or higher
Build instructions
dotnet build VectorBase/VectorBase.csproj
To produce a NuGet package:
dotnet pack VectorBase/VectorBase.csproj -c Release
Installation
.NET CLI
dotnet add package Oakrey.Vector.Base
Package Manager Console
Install-Package Oakrey.Vector.Base
NuGet Package Manager
Search for Oakrey.Vector.Base in the Visual Studio NuGet Package Manager UI.
Example usage
// Assuming a concrete VectorCanClient : VectorClientBase<VectorCanChannel, CanMessage>
using VectorCanClient client = new VectorCanClient(serialNumber: 12345, appName: "MyApp");
// Subscribe to all incoming CAN messages from any channel
using IDisposable subscription = client.ReceivedData
.Subscribe(msg => Console.WriteLine($"CAN id=0x{msg.Id:X} data={BitConverter.ToString(msg.Data)}"));
// Enable a specific channel before traffic can flow
client.EnableChannel(channelNumber: 1);
Console.ReadLine();
client.DisableChannel(channelNumber: 1);
// subscription.Dispose() stops receiving; client.Dispose() shuts down hardware
Per-channel subscription is also possible:
IVectorChannelBase<CanMessage> ch = /* obtained from client internals or DI */;
ch.ReceivedData
.Where(m => m.Id == 0x123)
.Subscribe(m => HandleFrame(m));
Development notes
- Implement
VectorChannelBase<TArgs>by overridingOpenPort(),StartReading(), andBusType. CallOnNewMessage(args)inside the read loop to push frames into the observable stream. PrepareEnable(ActivateAction)handles channel activation and queue flushing; call it fromEnable().StopReading()cancels theCancellationTokenSourceused by the read loop; override if additional cleanup is needed.VectorClientBaseusesActivator.CreateInstanceto instantiate channel types via their constructor signature(ChannelConfiguration, VectorHandle, string). Concrete channel types must expose this constructor.AvailableDevices(BusType)is a static helper that can be called before constructing a client to enumerate connected hardware.
License
MIT - Copyright (c) Oakrey 2016-present. See the LICENSE file for details.
- Author: Oakrey
- Repository: https://dev.azure.com/oakrey/OpenPackages/_git/Drivers
- Package URL: https://www.oakrey.cz/opkg_drivers_vector
| 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.Vector.Wrapper (>= 3.0.3)
- System.Reactive (>= 6.1.0)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Oakrey.Vector.Base:
| Package | Downloads |
|---|---|
|
Oakrey.Vector.Can
CAN and CAN FD client for Vector hardware (XL Driver Library). Provides VectorCanClient and VectorCanChannel with IObservable message streams (Rx.NET), per-channel Init/InitFd/SendData lifecycle, and FD capability detection. Built on Oakrey.Vector.Base and Oakrey.Vector.Wrapper. |
|
|
Oakrey.Vector.Lin
LIN master and slave client for Vector hardware (XL Driver Library). Provides VectorLinClient and VectorLinChannel with IObservable message streams (Rx.NET), slave answer table management, LIN scheduler, master request sending, and per-channel LinConfig. Built on Oakrey.Vector.Base and Oakrey.Vector.Wrapper. |
GitHub repositories
This package is not used by any popular GitHub repositories.